base/export/nixosConfigurations.nix
Jonas Rabenstein a5dc014e65 make home-manager optional
As the home-manager depends on the actual used nixpkgs version
and is not always used, remove it from the base dependencies but
use still use it implictely if a home-manager input exists.
2025-11-26 03:01:08 +01:00

23 lines
1.1 KiB
Nix

{ nixosUsers ? {}, nixosGroups ? {}, nixosModules, hmModules ? { default = {}; }, ...}@flake: { ... }@inputs: { host, ... }@imports: let
host' = name: snippets: let
system = { namespace?"fbs42", nixpkgs?"nixpkgs" }: inputs.${nixpkgs}.lib.nixosSystem {
specialArgs = { inherit inputs flake namespace; };
modules = builtins.concatLists (map (base: builtins.attrValues (flake.lib.scan { base = "${base}/host/${name}"; })) flake.lib.schema.base)
++ [ { config.networking.hostName = name; } ]
++ [ nixosModules.default ]
++ inputs.${nixpkgs}.lib.optional (inputs ? home-manager) {
imports = [ inputs.home-manager.nixosModules.default ];
config.home-manager = {
sharedModules = [ hmModules.default ];
extraSpecialArgs = { inherit flake namespace; };
};
}
++ builtins.attrValues nixosUsers
++ builtins.attrValues nixosGroups
;
};
cfg = assert builtins.length snippets == 1; builtins.head snippets;
in system cfg;
in builtins.mapAttrs host' host