summary refs log tree commit diff stats
path: root/hosts/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'hosts/default.nix')
-rw-r--r--hosts/default.nix42
1 files changed, 29 insertions, 13 deletions
diff --git a/hosts/default.nix b/hosts/default.nix
index f7df5d3..f53ee35 100644
--- a/hosts/default.nix
+++ b/hosts/default.nix
@@ -4,22 +4,38 @@
   nixpkgs,
   specialArgs,
   extraModules,
+  deployPackage,
 }: let
+  hostnames = builtins.fromTOML (builtins.readFile ./host-names.toml);
+
   hosts = nixLib.mkByName {
     useShards = false;
     baseDirectory = ./by-name;
     fileName = "configuration.nix";
-    finalizeFunction = name: value:
-      nixpkgs.lib.nixosSystem {
-        system = "x86_64-linux";
-        inherit specialArgs;
-        modules =
-          extraModules
-          ++ [
-            ../modules
-            value
-          ];
-      };
+    finalizeFunction = name: value: value;
   };
-in
-  hosts
+
+  mkNixosConfiguration = _: value:
+    nixpkgs.lib.nixosSystem {
+      system = "x86_64-linux";
+      inherit specialArgs;
+      modules =
+        extraModules
+        ++ [
+          ../modules
+          value
+        ];
+    };
+  nixosConfigurations = builtins.mapAttrs mkNixosConfiguration hosts;
+
+  mkDeploy = name: _: {
+    hostname = hostnames."${name}";
+    profiles.system = {
+      user = "root";
+      path = deployPackage.lib.activate.nixos nixosConfigurations."${name}";
+    };
+  };
+  deploy = {nodes = builtins.mapAttrs mkDeploy hosts;};
+in {
+  inherit nixosConfigurations deploy;
+}