{"id":18522436,"url":"https://github.com/astro/nix-openwrt-imagebuilder","last_synced_at":"2025-04-04T22:07:03.962Z","repository":{"id":37398224,"uuid":"486343816","full_name":"astro/nix-openwrt-imagebuilder","owner":"astro","description":"Build OpenWRT images in Nix derivations","archived":false,"fork":false,"pushed_at":"2024-10-29T08:55:45.000Z","size":32757,"stargazers_count":140,"open_issues_count":2,"forks_count":17,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-10-29T10:03:40.022Z","etag":null,"topics":["nix","nix-flake","nixos","openwrt"],"latest_commit_sha":null,"homepage":"","language":"Nix","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/astro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-27T20:38:30.000Z","updated_at":"2024-10-29T08:55:49.000Z","dependencies_parsed_at":"2023-09-23T03:23:57.859Z","dependency_job_id":"bb39c3bd-c8cb-4d41-8fff-9b5d948b09af","html_url":"https://github.com/astro/nix-openwrt-imagebuilder","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astro%2Fnix-openwrt-imagebuilder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astro%2Fnix-openwrt-imagebuilder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astro%2Fnix-openwrt-imagebuilder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astro%2Fnix-openwrt-imagebuilder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/astro","download_url":"https://codeload.github.com/astro/nix-openwrt-imagebuilder/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247256112,"owners_count":20909240,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nix","nix-flake","nixos","openwrt"],"created_at":"2024-11-06T17:30:56.256Z","updated_at":"2025-04-04T22:07:03.940Z","avatar_url":"https://github.com/astro.png","language":"Nix","funding_links":[],"categories":["Installation Media","Nix"],"sub_categories":[],"readme":"# nix-openwrt-imagebuilder\n\nGenerate OpenWRT images from Nix derivations using the official\nImageBuilders that are provided upstream.\n\nFor OpenWRT releases since 19.07 there is profile helper functionality\nthat helps you find the proper image specification (target, variant)\naccording to your hardware's profile name.\n\n## Background\n\nIn an ideal world, OpenWRT would be built from source in many\nfine-grained Nix derivations. Until someone implements that (please\ndo!), this project exists to reuse the binary ImageBuilders that are\nincluded in every OpenWRT release. They are only available for\nx86_64-linux hosts.\n\nThe ImageBuilder can generate new *sysupgrade* images with a\ncustomized set of packages and included files.\n\n## Usage with vanilla Nix\n\n```nix\nlet\n  pkgs = import \u003cnixpkgs\u003e {};\n\n  # use fetchurl, Hydra inputs, or something else to refer to this project\n  openwrt-imagebuilder = ../nix-openwrt-imagebuilder;\n\n  profiles = import (openwrt-imagebuilder + \"/profiles.nix\") { inherit pkgs; };\n\n  # example: find target/variant for an old Fritzbox\n  config = profiles.identifyProfile \"avm_fritz7412\" // {\n    # add package to include in the image, ie. packages that you don't\n    # want to install manually later\n    packages = [ \"tcpdump\" ];\n\n    disabledServices = [ \"dnsmasq\" ];\n\n    # include files in the images.\n    # to set UCI configuration, create a uci-defauts scripts as per\n    # official OpenWRT ImageBuilder recommendation.\n    files = pkgs.runCommand \"image-files\" {} ''\n      mkdir -p $out/etc/uci-defaults\n      cat \u003e $out/etc/uci-defaults/99-custom \u003c\u003cEOF\n      uci -q batch \u003c\u003c EOI\n      set system.@system[0].hostname='testap'\n      commit\n      EOI\n      EOF\n    '';\n  };\n\nin\n  # actually build the image\n  import (openwrt-imagebuilder + \"/builder.nix\") config\n```\n\n## Usage with Nix Flakes\n\n```nix\n{\n  inputs = {\n    openwrt-imagebuilder.url = \"github:astro/nix-openwrt-imagebuilder\";\n  };\n  outputs = { self, nixpkgs, openwrt-imagebuilder }: {\n    packages.x86_64-linux.my-router =\n      let\n        pkgs = nixpkgs.legacyPackages.x86_64-linux;\n\n        profiles = openwrt-imagebuilder.lib.profiles { inherit pkgs; };\n\n        config = profiles.identifyProfile \"avm_fritz7412\" // {\n          # add package to include in the image, ie. packages that you don't\n          # want to install manually later\n          packages = [ \"tcpdump\" ];\n\n          disabledServices = [ \"dnsmasq\" ];\n\n          # include files in the images.\n          # to set UCI configuration, create a uci-defauts scripts as per\n          # official OpenWRT ImageBuilder recommendation.\n          files = pkgs.runCommand \"image-files\" {} ''\n            mkdir -p $out/etc/uci-defaults\n            cat \u003e $out/etc/uci-defaults/99-custom \u003c\u003cEOF\n            uci -q batch \u003c\u003c EOI\n            set system.@system[0].hostname='testap'\n            commit\n            EOI\n            EOF\n          '';\n        };\n\n      in\n        openwrt-imagebuilder.lib.build config;\n  };\n}\n```\n\n## Refreshing hashes\n\n**downloads.openwrt.org** appears to be never at rest. That's why we\nupdate the [hashes subdirectory](./hashes/) daily with [a Github\naction.](https://github.com/astro/nix-openwrt-imagebuilder/actions/workflows/update-hashes.yml)\n\nIf you still encounter `hash mismatch in fixed-output derivation` in\nbetween these updates, update them yourself:\n\n```bash\nnix run .#generate-hashes $(sed -e 's/\"//g' latest-release.nix)\n```\n\nIf your `flake.nix` has this project in its `inputs`, then you can\nbuild with your local working copy using\n`nix build --override-input openwrt-imagebuilder git+file:///... .#...`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastro%2Fnix-openwrt-imagebuilder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fastro%2Fnix-openwrt-imagebuilder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastro%2Fnix-openwrt-imagebuilder/lists"}