diff options
Diffstat (limited to '')
| -rw-r--r-- | hosts/by-name/server2/host.toml | 1 | ||||
| -rw-r--r-- | hosts/by-name/server3/host.toml | 1 | ||||
| -rw-r--r-- | hosts/default.nix | 32 |
3 files changed, 20 insertions, 14 deletions
diff --git a/hosts/by-name/server2/host.toml b/hosts/by-name/server2/host.toml index ca8423a..16e2764 100644 --- a/hosts/by-name/server2/host.toml +++ b/hosts/by-name/server2/host.toml @@ -1,2 +1,3 @@ hostname = "server2.vhack.eu" nixpkgs = "stable" +deployment = "deploy-rs" diff --git a/hosts/by-name/server3/host.toml b/hosts/by-name/server3/host.toml index 8a885ae..0f0cb59 100644 --- a/hosts/by-name/server3/host.toml +++ b/hosts/by-name/server3/host.toml @@ -1,2 +1,3 @@ hostname = "server3.vhack.eu" nixpkgs = "stable" +deployment = "deploy-rs" diff --git a/hosts/default.nix b/hosts/default.nix index 40f2bd8..8a85ad5 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -1,5 +1,6 @@ { self, + lib, extra_lib, module_args, special_args, @@ -12,12 +13,14 @@ useShards = false; baseDirectory = ./by-name; fileName = "configuration.nix"; + finalizeFunction = host_name: path: let + definition = builtins.fromTOML (builtins.readFile (path + "/../host.toml")); + in {inherit path definition;}; }; - mkNixosConfiguration = name: path: let - host_file = builtins.fromTOML (builtins.readFile (path + "/../host.toml")); + mkNixosConfiguration = name: host: let nixpkgs = - if host_file.nixpkgs == "stable" + if host.definition.nixpkgs == "stable" then nixpkgs-stable else nixpkgs-unstable; in @@ -27,24 +30,25 @@ { _module.args = module_args; } - path + host.path ../modules # ../modules/common ]; }; - mkDeployHost = name: path: let - host_file = builtins.fromTOML (builtins.readFile (path + "/../host.toml")); - in { - inherit (host_file) hostname; - profiles.system = { - user = "root"; - path = deploy-rs.lib."${system}".activate.nixos self.nixosConfigurations."${name}"; - }; - }; + mkDeployHost = name: host: + if (host.definition.deployment == "deploy-rs") + then { + inherit (host.definition) hostname; + profiles.system = { + user = "root"; + path = deploy-rs.lib."${system}".activate.nixos self.nixosConfigurations."${name}"; + }; + } + else null; nixosConfigurations = builtins.mapAttrs mkNixosConfiguration hosts; - nodes = builtins.mapAttrs mkDeployHost hosts; + nodes = lib.filterAttrs (_: value: value != null) (builtins.mapAttrs mkDeployHost hosts); in { inherit nixosConfigurations nodes; } |
