refactor(host): simplify host assembly

This commit is contained in:
2026-08-29 17:05:43 -04:00
parent 647b20b934
commit d88ee49aaf
3 changed files with 28 additions and 22 deletions

View File

@@ -51,7 +51,6 @@ let
inherit
inputs
lib
self
specialArgs
guestFiles
registryAssembly

View File

@@ -1,46 +1,51 @@
{
inputs,
lib,
self,
specialArgs,
repositoryModules,
# TODO refactor guests
guestFiles,
# TODO refactor registry
registryAssembly,
}:
let
mkHost =
{
hostName,
system ? "x86_64-linux",
root,
name,
}:
inputs.nixpkgs.lib.nixosSystem {
inherit system specialArgs;
lib.nixosSystem {
inherit specialArgs;
modules =
[
repositoryModules
]
++ guestFiles
guestFiles
++ [
inputs.chaotic.nixosModules.default
inputs.disko.nixosModules.disko
inputs.sops-nix.nixosModules.sops
inputs.stylix.nixosModules.stylix
registryAssembly.module
(self + "/hosts/${hostName}")
repositoryModules
# TODO: refactor
registryAssembly.module (root + "/${name}")
{
networking.hostName = hostName;
networking.hostName = name;
modules.host.enable = true;
}
];
};
mkHosts =
hostsDir:
let
hostNames = lib.attrNames (lib.filterAttrs (_name: type: type == "directory") (builtins.readDir hostsDir));
in
lib.genAttrs hostNames (hostName: mkHost { inherit hostName; });
in
{
inherit mkHosts;
mkHosts =
{ root }:
let
directories = lib.filterAttrs (_name: type: type == "directory") (builtins.readDir root);
names = lib.attrNames directories;
in
lib.genAttrs names (
name:
mkHost { inherit root name; }
);
}