Refactor host entrypoints again

This commit is contained in:
SebastianStork 2024-08-17 23:38:53 +02:00
parent 09f0de731a
commit 1bdbed129e

View file

@ -1,30 +1,36 @@
{ inputs, self, ... }: {
inputs,
self,
lib,
...
}:
let let
specialArgs = { unstable = inputs.nixpkgs;
inherit inputs self; stable = inputs.nixpkgs-stable;
mkHost = hostname: nixpkgs: {
${hostname} = nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs self;
};
modules =
[
{ networking.hostName = hostname; }
"${self}/hosts/${hostname}"
]
++ builtins.filter (path: builtins.pathExists path) (
map (user: "${self}/users/${user}/@${hostname}") (
builtins.attrNames (lib.filterAttrs (_: v: v == "directory") (builtins.readDir "${self}/users"))
)
);
};
}; };
modulesOf = hostname: [
{ networking.hostName = hostname; }
"${self}/hosts/${hostname}"
"${self}/users/seb/@${hostname}"
];
in in
{ {
flake.nixosConfigurations = { flake.nixosConfigurations = lib.mkMerge [
north = inputs.nixpkgs.lib.nixosSystem { (mkHost "north" unstable)
inherit specialArgs; (mkHost "inspiron" unstable)
modules = modulesOf "north"; (mkHost "installer" stable)
}; ];
inspiron = inputs.nixpkgs.lib.nixosSystem {
inherit specialArgs;
modules = modulesOf "inspiron";
};
installer = inputs.nixpkgs-stable.lib.nixosSystem {
inherit specialArgs;
modules = [
{ networking.hostName = "installer"; }
"${self}/hosts/installer"
];
};
};
} }