summary refs log tree commit diff stats
path: root/flake.nix
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-12-25 18:25:51 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-12-25 18:25:51 +0100
commitd9ab6c7ea59d29af3ae8c29c7367fe0e8808f5db (patch)
tree4076dca44feeb7fccf90af3f9c9cc6e73b845c6f /flake.nix
parentfix(treewide): Add constant uids and gids to each user and group (diff)
downloadnixos-server-d9ab6c7ea59d29af3ae8c29c7367fe0e8808f5db.tar.gz
nixos-server-d9ab6c7ea59d29af3ae8c29c7367fe0e8808f5db.zip
refactor(hosts): Use a `by-name` structure and construct all host depended values
This allows us to outsource the host-handling from the `flake.nix` file.
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix53
1 files changed, 37 insertions, 16 deletions
diff --git a/flake.nix b/flake.nix
index 9378a15..df8d6c4 100644
--- a/flake.nix
+++ b/flake.nix
@@ -13,6 +13,14 @@
         nixpkgs.follows = "nixpkgs";
       };
     };
+    deploy-rs = {
+      url = "github:serokell/deploy-rs";
+      inputs = {
+        flake-compat.follows = "flake-compat";
+        nixpkgs.follows = "nixpkgs";
+        utils.follows = "flake-utils";
+      };
+    };
 
     # inputs for following
     systems = {
@@ -84,6 +92,7 @@
     nixpkgs-unstable,
     library,
     treefmt-nix,
+    deploy-rs,
     # modules
     simple-nixos-mailserver,
     impermanence,
@@ -94,9 +103,23 @@
     ...
   } @ attrs: let
     system = "x86_64-linux";
-    pkgs = nixpkgs.legacyPackages.${system};
     nixos-lib = import (nixpkgs + "/nixos/lib") {};
+    pkgs = nixpkgs.legacyPackages.${system};
     pkgsUnstable = nixpkgs-unstable.legacyPackages.${system};
+    deployPackage =
+      (import nixpkgs {
+        inherit system;
+        overlays = [
+          deploy-rs.overlays.default
+          (self: super: {
+            deploy-rs = {
+              inherit (pkgs) deploy-rs;
+              inherit (super.deploy-rs) lib;
+            };
+          })
+        ];
+      })
+      .deploy-rs;
 
     specialArgs =
       attrs
@@ -114,24 +137,18 @@
     tests = import ./tests {inherit pkgs specialArgs nixLib;};
     vhackPackages = import ./pkgs {inherit pkgs nixLib;};
 
+    hosts = import ./hosts {inherit pkgs nixLib nixpkgs specialArgs extraModules deployPackage;};
+
     inherit (library) nixLib;
     treefmtEval = import ./treefmt.nix {inherit treefmt-nix pkgs;};
   in {
-    nixosConfigurations."server1" = nixpkgs.lib.nixosSystem {
-      system = "x86_64-linux";
-      inherit specialArgs;
-      modules =
-        extraModules
-        ++ [
-          ./modules
-          ./hosts/server1/configuration.nix
-        ];
-    };
-
-    checks."${system}" = nixLib.warnMerge tests {
-      formatting =
-        treefmtEval.config.build.check self;
-    } "the flake checks";
+    checks."${system}" =
+      nixLib.warnMerge (nixLib.warnMerge tests {
+        formatting =
+          treefmtEval.config.build.check self;
+      } "the flake checks and formatting")
+      (deployPackage.lib.deployChecks self.deploy)
+      "the flake checks and deploy-rs";
 
     packages."${system}" = vhackPackages;
     formatter."${system}" = treefmtEval.config.build.wrapper;
@@ -142,6 +159,8 @@
           # used for certificate generation in the taskserver setup
           gnutls
 
+          pkgs.deploy-rs
+
           git-bug
 
           cocogitto
@@ -149,5 +168,7 @@
         ];
       };
     };
+
+    inherit (hosts) nixosConfigurations deploy;
   };
 }