From 276e7a02a67c7245141f0937871837a96f4eb138 Mon Sep 17 00:00:00 2001 From: alexion Date: Fri, 28 Aug 2026 18:25:03 -0400 Subject: [PATCH] refactor(host): derive host paths from root --- flake.nix | 4 +++- flake/default.nix | 1 - flake/host.nix | 36 +++++++++++++++++++----------------- 3 files changed, 22 insertions(+), 19 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..9711464 100644 --- a/flake/host.nix +++ b/flake/host.nix @@ -1,46 +1,48 @@ { inputs, lib, - self, specialArgs, repositoryModules, + + # TODO refactor guests guestFiles, + # TODO refactor registry registryAssembly, }: let mkHost = { + root, hostName, - system ? "x86_64-linux", }: - 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 + + repositoryModules + + # TODO: refactor registryAssembly.module - (self + "/hosts/${hostName}") + (root + "/${hostName}") + { networking.hostName = hostName; 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 + hostNames = lib.attrNames (lib.filterAttrs (_name: type: type == "directory") (builtins.readDir root)); + in + lib.genAttrs hostNames (hostName: mkHost { inherit root hostName; }); }