base/export/nixosConfigurations.nix

46 lines
1.2 KiB
Nix

{
nixosUsers ? { },
nixosGroups ? { },
nixosModules,
hmModules ? {
default = { };
},
...
}@flake:
{ ... }@inputs:
{ host, ... }@imports:
let
system =
hostname:
{
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/${hostname}"; })
) flake.lib.schema.base
)
++ map (input: input.${namespace}.${name} or { }) inputs
++ [ { config.networking.hostName = hostname; } ]
++ [ 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;
};
in
builtins.mapAttrs (
name: value:
assert builtins.length value == 1;
system name (builtins.head value)
) host