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

@@ -80,7 +80,9 @@
in in
{ {
# Every host under hosts/ is discovered and built. # Every host under hosts/ is discovered and built.
nixosConfigurations = flake.mkHosts (self + "/hosts"); nixosConfigurations = flake.mkHosts {
root = self + "/hosts";
};
# A project shell for agent-local resources that should travel with this # A project shell for agent-local resources that should travel with this
# checkout rather than the operator's global profile. # checkout rather than the operator's global profile.

View File

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

View File

@@ -1,46 +1,51 @@
{ {
inputs, inputs,
lib, lib,
self,
specialArgs, specialArgs,
repositoryModules, repositoryModules,
# TODO refactor guests
guestFiles, guestFiles,
# TODO refactor registry
registryAssembly, registryAssembly,
}: }:
let let
mkHost = mkHost =
{ {
hostName, root,
system ? "x86_64-linux", name,
}: }:
inputs.nixpkgs.lib.nixosSystem { lib.nixosSystem {
inherit system specialArgs; inherit specialArgs;
modules = modules =
[ guestFiles
repositoryModules
]
++ guestFiles
++ [ ++ [
inputs.chaotic.nixosModules.default inputs.chaotic.nixosModules.default
inputs.disko.nixosModules.disko inputs.disko.nixosModules.disko
inputs.sops-nix.nixosModules.sops inputs.sops-nix.nixosModules.sops
inputs.stylix.nixosModules.stylix 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; 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 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; }
);
} }