From d88ee49aaf0fb2f6aea1625c845ef24eccfb9946 Mon Sep 17 00:00:00 2001 From: alexion Date: Sat, 29 Aug 2026 17:05:43 -0400 Subject: [PATCH] refactor(host): simplify host assembly --- flake.nix | 4 +++- flake/default.nix | 1 - flake/host.nix | 45 +++++++++++++++++++++++++-------------------- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/flake.nix b/flake.nix index 11ed1f0..b31ddba 100644 --- a/flake.nix +++ b/flake.nix @@ -80,7 +80,9 @@ in { # 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 # checkout rather than the operator's global profile. diff --git a/flake/default.nix b/flake/default.nix index 359dab8..231e602 100644 --- a/flake/default.nix +++ b/flake/default.nix @@ -51,7 +51,6 @@ let inherit inputs lib - self specialArgs guestFiles registryAssembly diff --git a/flake/host.nix b/flake/host.nix index 0b7c889..2627cc2 100644 --- a/flake/host.nix +++ b/flake/host.nix @@ -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; } + ); }