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
unstable = inputs.nixpkgs;
stable = inputs.nixpkgs-stable;
mkHost = hostname: nixpkgs: {
${hostname} = nixpkgs.lib.nixosSystem {
specialArgs = { specialArgs = {
inherit inputs self; inherit inputs self;
}; };
modulesOf = hostname: [ modules =
[
{ networking.hostName = hostname; } { networking.hostName = hostname; }
"${self}/hosts/${hostname}" "${self}/hosts/${hostname}"
"${self}/users/seb/@${hostname}" ]
]; ++ builtins.filter (path: builtins.pathExists path) (
map (user: "${self}/users/${user}/@${hostname}") (
builtins.attrNames (lib.filterAttrs (_: v: v == "directory") (builtins.readDir "${self}/users"))
)
);
};
};
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"
]; ];
};
};
} }