impure.nix: Add extendModules to hosts.*

With this something like `hosts.servo.extendModules { networking.hostname = "shel-is-awesome"; }` works as expected. Mirrors the functionality of extendModules on the result of evalConfig
This commit is contained in:
Shelvacu
2025-03-04 12:23:20 -08:00
committed by Shelvacu on fw
parent 4f4c06f753
commit a405850cf8

View File

@@ -24,19 +24,20 @@ let
pkgs.sops-nix.nixosModules.sops pkgs.sops-nix.nixosModules.sops
]; ];
mkFlavoredHost = args: let mkFlavoredHost = args: let
host = evalHost args; plainHost = evalHost args;
# expose the toplevel nixos system as the toplevel attribute itself, # expose the toplevel nixos system as the toplevel attribute itself,
# with nested aliases for other common build targets # with nested aliases for other common build targets
in host.config.system.build.toplevel.overrideAttrs (base: { addPassthru = host: host.config.system.build.toplevel.overrideAttrs (base: {
passthru = (base.passthru or {}) // { passthru = (base.passthru or {}) // {
config = host.config; inherit (host) config;
fs = host.config.sane.fs; inherit (host.config.sane) fs;
img = host.config.system.build.img; inherit (host.config.system.build) imgs pkgs;
pkgs = host.config.system.build.pkgs;
programs = builtins.mapAttrs (_: p: p.package) host.config.sane.programs; programs = builtins.mapAttrs (_: p: p.package) host.config.sane.programs;
toplevel = host.config.system.build.toplevel; #< self toplevel = host.config.system.build.toplevel; #< self
extendModules = arg: addPassthru (host.extendModules arg);
}; };
}); });
in addPassthru plainHost;
mkHost = args: { mkHost = args: {
# TODO: swap order: $host-{next,staging}-{min,light}: # TODO: swap order: $host-{next,staging}-{min,light}:
# then lexicographically-adjacent targets would also have the minimal difference in closure, # then lexicographically-adjacent targets would also have the minimal difference in closure,