diff --git a/flake-parts/hosts.nix b/flake-parts/hosts.nix index c950cba..3101dfc 100644 --- a/flake-parts/hosts.nix +++ b/flake-parts/hosts.nix @@ -8,7 +8,10 @@ let mkHost = hostDir: inputs.nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs self; }; + specialArgs = { + inherit inputs self; + inherit (self) allHosts; + }; modules = (lib.singleton { networking.hostName = hostDir |> lib.baseNameOf |> lib.unsafeDiscardStringContext; diff --git a/modules/system/networking/default.nix b/modules/system/networking/default.nix index 5b790a4..24f8ac3 100644 --- a/modules/system/networking/default.nix +++ b/modules/system/networking/default.nix @@ -1,7 +1,7 @@ { config, - self, lib, + allHosts, ... }: let @@ -18,7 +18,7 @@ in nodes = lib.mkOption { type = lib.types.anything; default = - self.allHosts + allHosts |> lib.attrValues |> lib.map (host: host.config.custom.networking) |> lib.map ( diff --git a/modules/system/networking/overlay.nix b/modules/system/networking/overlay.nix index 910f3aa..fd140eb 100644 --- a/modules/system/networking/overlay.nix +++ b/modules/system/networking/overlay.nix @@ -1,7 +1,7 @@ { config, - self, lib, + allHosts, ... }: let @@ -57,7 +57,7 @@ in dnsServers = lib.mkOption { type = lib.types.anything; default = - self.allHosts + allHosts |> lib.attrValues |> lib.filter (host: host.config.custom.services.dns.enable) |> lib.map (host: host.config.custom.networking.overlay.address); diff --git a/modules/system/services/dns.nix b/modules/system/services/dns.nix index f4c204f..72e7e64 100644 --- a/modules/system/services/dns.nix +++ b/modules/system/services/dns.nix @@ -2,6 +2,7 @@ config, self, lib, + allHosts, ... }: let @@ -27,7 +28,7 @@ in netCfg.nodes |> lib.map (node: "\"${node.hostName}.${node.overlay.domain}. A ${node.overlay.address}\""); serviceRecords = - self.allHosts + allHosts |> lib.attrValues |> lib.concatMap ( host: diff --git a/modules/system/services/sshd.nix b/modules/system/services/sshd.nix index 14f35c7..ca32281 100644 --- a/modules/system/services/sshd.nix +++ b/modules/system/services/sshd.nix @@ -1,7 +1,7 @@ { config, - self, lib, + allHosts, ... }: let @@ -41,7 +41,7 @@ in }; users.users.seb.openssh.authorizedKeys.keyFiles = - self.allHosts + allHosts |> lib.attrValues |> lib.filter (host: host.config.networking.hostName != netCfg.hostName) |> lib.filter (host: host.config |> lib.hasAttr "home-manager") diff --git a/modules/system/services/syncthing.nix b/modules/system/services/syncthing.nix index bdccc4c..72355c5 100644 --- a/modules/system/services/syncthing.nix +++ b/modules/system/services/syncthing.nix @@ -2,6 +2,7 @@ config, self, lib, + allHosts, ... }: let @@ -87,7 +88,7 @@ in settings = let hosts = - self.allHosts + allHosts |> lib.filterAttrs (_: host: host.config.networking.hostName != config.networking.hostName) |> lib.filterAttrs (_: host: host.config.custom.services.syncthing.enable); in diff --git a/modules/system/web-services/gatus.nix b/modules/system/web-services/gatus.nix index aa8d3f4..c47da79 100644 --- a/modules/system/web-services/gatus.nix +++ b/modules/system/web-services/gatus.nix @@ -1,7 +1,7 @@ { config, - self, lib, + allHosts, ... }: let @@ -173,7 +173,7 @@ in web-services.gatus.endpoints = let defaultEndpoints = - self.allHosts + allHosts |> lib.mapAttrs ( _: host: host.config.custom.services.caddy.virtualHosts |> lib.attrValues |> lib.map (vHost: vHost.domain)