diff options
| author | 2026-09-17 11:05:45 +0200 | |
|---|---|---|
| committer | 2026-09-17 11:05:45 +0200 | |
| commit | f793f76e26b461c3228c69926d82bf950aaac671 (patch) | |
| tree | affac98593ff0de3bb24fcd8aa64f6ef8ed9dc19 /flake.nix | |
| parent | ae3fa667bda75f11881c9209dc67226f98bcfd95 (diff) | |
| download | desktop-flake-f793f76e26b461c3228c69926d82bf950aaac671.tar.gz desktop-flake-f793f76e26b461c3228c69926d82bf950aaac671.tar.bz2 desktop-flake-f793f76e26b461c3228c69926d82bf950aaac671.zip | |
Add scripted host bootstrapping with directory-driven discovery
nixosConfigurations now auto-discovers hosts/<name>/ directories instead
of a hand-maintained attrset, and scripts/bootstrap-host.sh (exposed as
`nix run .#bootstrap-host`) scaffolds a new host from the template. The
script always requires an explicit --root for hardware-configuration.nix
so a live-installer run can never read the live ISO's own /etc/nixos by
accident. Also records the belated task-11.1 checkbox update for the
prior change's already-committed state.
Diffstat (limited to 'flake.nix')
| -rw-r--r-- | flake.nix | 36 |
1 files changed, 33 insertions, 3 deletions
| @@ -20,11 +20,26 @@ | |||
| 20 | "x86_64-darwin" | 20 | "x86_64-darwin" |
| 21 | "aarch64-darwin" | 21 | "aarch64-darwin" |
| 22 | ]; | 22 | ]; |
| 23 | |||
| 24 | # Any directory under hosts/ other than hosts/template that contains a | ||
| 25 | # `system` file becomes a real nixosConfigurations.<name> output — | ||
| 26 | # adding a host means dropping in a directory, not editing this file. | ||
| 27 | # hosts/template is excluded by name so it is never built, even though | ||
| 28 | # it also carries a system file (kept only so it stays a complete, | ||
| 29 | # consistent copy-source for the bootstrap script). | ||
| 30 | hostNames = builtins.attrNames | ||
| 31 | (nixpkgs.lib.filterAttrs | ||
| 32 | (name: type: type == "directory" && name != "template") | ||
| 33 | (builtins.readDir ./hosts)); | ||
| 34 | |||
| 35 | mkHostConfig = hostname: | ||
| 36 | lib.mkNixos { | ||
| 37 | inherit hostname; | ||
| 38 | system = builtins.readFile (./hosts + "/${hostname}/system"); | ||
| 39 | }; | ||
| 23 | in | 40 | in |
| 24 | { | 41 | { |
| 25 | # No real NixOS host exists yet. hosts/template/ is copy-source only and | 42 | nixosConfigurations = nixpkgs.lib.genAttrs hostNames mkHostConfig; |
| 26 | # is deliberately not wired in here — see hosts/template/ and README.md. | ||
| 27 | nixosConfigurations = { }; | ||
| 28 | 43 | ||
| 29 | homeConfigurations = { | 44 | homeConfigurations = { |
| 30 | "tom@linux" = lib.mkHome { | 45 | "tom@linux" = lib.mkHome { |
| @@ -44,5 +59,20 @@ | |||
| 44 | packages = [ pkgs.statix pkgs.deadnix pkgs.nixfmt-rfc-style ]; | 59 | packages = [ pkgs.statix pkgs.deadnix pkgs.nixfmt-rfc-style ]; |
| 45 | }; | 60 | }; |
| 46 | }); | 61 | }); |
| 62 | |||
| 63 | apps = forAllSystems (system: | ||
| 64 | let | ||
| 65 | pkgs = nixpkgs.legacyPackages.${system}; | ||
| 66 | in | ||
| 67 | { | ||
| 68 | bootstrap-host = { | ||
| 69 | type = "app"; | ||
| 70 | program = "${pkgs.writeShellApplication { | ||
| 71 | name = "bootstrap-host"; | ||
| 72 | runtimeInputs = [ pkgs.coreutils pkgs.gnused ]; | ||
| 73 | text = builtins.readFile ./scripts/bootstrap-host.sh; | ||
| 74 | }}/bin/bootstrap-host"; | ||
| 75 | }; | ||
| 76 | }); | ||
| 47 | }; | 77 | }; |
| 48 | } | 78 | } |
