Allow to specify a list of classes in the host/<hostname>.nix (by default the class <hostname> is used) that will automatically load specified outputs of inputs.
49 lines
1.3 KiB
Nix
49 lines
1.3 KiB
Nix
{
|
|
nixosUsers ? { },
|
|
nixosGroups ? { },
|
|
nixosModules,
|
|
hmModules ? {
|
|
default = { };
|
|
},
|
|
...
|
|
}@flake:
|
|
{ ... }@inputs:
|
|
{ host, ... }@imports:
|
|
let
|
|
system =
|
|
hostname:
|
|
{
|
|
namespace ? "fbs42",
|
|
nixpkgs ? "nixpkgs",
|
|
classes ? [ hostname ],
|
|
}:
|
|
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 (class: {
|
|
imports = map (input: input.${namespace}.${class} or { }) (builtins.attrValues inputs);
|
|
}) classes
|
|
++ [ { 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
|