From ff8caa51926d2a34d6f437586d7672c97f71df14 Mon Sep 17 00:00:00 2001
From: willifan <willifan@pm.me>
Date: Sat, 4 Jan 2025 13:56:22 +0100
Subject: [PATCH] add Puenktchen builder

---
 hosts/Anton/default.nix                       | 19 +++++++++------
 hosts/Puenktchen/default.nix                  | 13 +++++++----
 .../default/common/{server => }/builder.nix   |  2 +-
 modules/default/common/default.nix            |  1 +
 .../default/common/desktop/remoteBuilder.nix  | 23 +++++++++++++++----
 modules/default/common/options.nix            | 10 ++++++++
 modules/default/common/server/default.nix     |  1 -
 7 files changed, 52 insertions(+), 17 deletions(-)
 rename modules/default/common/{server => }/builder.nix (96%)

diff --git a/hosts/Anton/default.nix b/hosts/Anton/default.nix
index 34387f8..eeebd82 100644
--- a/hosts/Anton/default.nix
+++ b/hosts/Anton/default.nix
@@ -21,13 +21,18 @@
 
   server.enable = true;
 
-  common.syncthing = {
-    enable = true;
-    basePath = "/mnt/data/services/syncthing/data";
-    devices = {
-      Lenni = { id = "NDERY5Q-N7L6CPD-RMIFA65-OC3HP6T-ONZOB7Y-7FLS4VR-UWBKBZV-XJJVGQG"; };
-      Puenktchen = { id = "REVJKI3-3QYKRZN-QDKQ24V-UNZQ4L2-R7XHQCE-N4H3FSY-IARCHM3-PMWBJQP"; };
-      Damin = { id = "HAGKFGG-EMCPKHG-Y7V2ACJ-DJVAIIA-A6TNGTQ-VWPB3F5-PES673W-W2YBJAD"; };
+  common = {
+
+    builder.enable = true;
+
+    syncthing = {
+      enable = true;
+      basePath = "/mnt/data/services/syncthing/data";
+      devices = {
+        Lenni = { id = "NDERY5Q-N7L6CPD-RMIFA65-OC3HP6T-ONZOB7Y-7FLS4VR-UWBKBZV-XJJVGQG"; };
+        Puenktchen = { id = "REVJKI3-3QYKRZN-QDKQ24V-UNZQ4L2-R7XHQCE-N4H3FSY-IARCHM3-PMWBJQP"; };
+        Damin = { id = "HAGKFGG-EMCPKHG-Y7V2ACJ-DJVAIIA-A6TNGTQ-VWPB3F5-PES673W-W2YBJAD"; };
+      };
     };
   };
 
diff --git a/hosts/Puenktchen/default.nix b/hosts/Puenktchen/default.nix
index be6471e..410335e 100644
--- a/hosts/Puenktchen/default.nix
+++ b/hosts/Puenktchen/default.nix
@@ -20,10 +20,15 @@
     };
   };
 
-  common.syncthing = {
-    enable = true;
-    devices = {
-      Anton = { id = "SIMFE5V-UHVQLHM-3ES7TAM-XIGP6TL-WCC37VY-B5ET6LJ-LPC2QIL-MYG4OQR"; };
+  common = {
+
+    builder.enable = true;
+
+    syncthing = {
+      enable = true;
+      devices = {
+        Anton = { id = "SIMFE5V-UHVQLHM-3ES7TAM-XIGP6TL-WCC37VY-B5ET6LJ-LPC2QIL-MYG4OQR"; };
+      };
     };
   };
 
diff --git a/modules/default/common/server/builder.nix b/modules/default/common/builder.nix
similarity index 96%
rename from modules/default/common/server/builder.nix
rename to modules/default/common/builder.nix
index fc80914..20c0344 100644
--- a/modules/default/common/server/builder.nix
+++ b/modules/default/common/builder.nix
@@ -1,5 +1,5 @@
 { lib, config, ... }:
-lib.mkIf config.server.enable {
+lib.mkIf config.common.builder.enable {
   users.users.builder = {
     group = "builder";
     isNormalUser = true;
diff --git a/modules/default/common/default.nix b/modules/default/common/default.nix
index bd5a650..6b04eb3 100644
--- a/modules/default/common/default.nix
+++ b/modules/default/common/default.nix
@@ -10,6 +10,7 @@
 
     ./autoupdate.nix
     ./boot.nix
+    ./builder.nix
     ./envvar.nix
     ./garbage-collect.nix
     ./keyd.nix
diff --git a/modules/default/common/desktop/remoteBuilder.nix b/modules/default/common/desktop/remoteBuilder.nix
index c1323ee..e04adca 100644
--- a/modules/default/common/desktop/remoteBuilder.nix
+++ b/modules/default/common/desktop/remoteBuilder.nix
@@ -1,18 +1,33 @@
 { lib, config, ... }:
 lib.mkIf config.desktop.enable {
-	nix.buildMachines = [ {
+	nix.buildMachines = [
+  {
 	  hostName = "Anton";
     sshUser = "builder";
 	  systems = [ "x86_64-linux" "aarch64-linux" ];
-    protocol = "ssh";
+    protocol = "ssh-ng";
 	  # if the builder supports building for multiple architectures, 
 	  # replace the previous line by, e.g.
 	  # systems = ["x86_64-linux" "aarch64-linux"];
-	  maxJobs = 1;
+	  maxJobs = 4;
 	  speedFactor = 2;
 	  supportedFeatures = [ "nixos-test" "benchmark" "big-parallel" "kvm" ];
 	  mandatoryFeatures = [ ];
-	}];
+	}
+  {
+	  hostName = "Puenktchen";
+    sshUser = "builder";
+	  systems = [ "x86_64-linux" "aarch64-linux" ];
+    protocol = "ssh-ng";
+	  # if the builder supports building for multiple architectures, 
+	  # replace the previous line by, e.g.
+	  # systems = ["x86_64-linux" "aarch64-linux"];
+	  maxJobs = 8;
+	  speedFactor = 4;
+	  supportedFeatures = [ "nixos-test" "benchmark" "big-parallel" "kvm" ];
+	  mandatoryFeatures = [ ];
+  }
+  ];
 	nix.distributedBuilds = true;
 	# optional, useful when the builder has a faster internet connection than yours
 	nix.extraOptions = ''
diff --git a/modules/default/common/options.nix b/modules/default/common/options.nix
index a5d33a6..92a6fbd 100644
--- a/modules/default/common/options.nix
+++ b/modules/default/common/options.nix
@@ -1,6 +1,16 @@
 { lib, ... }:
 {
   options = {
+
+    common = {
+
+      builder.enable = lib.mkOption {
+        default = false;
+        type = lib.types.bool;
+      };
+
+    };
+
     desktop = {
 
       enable = lib.mkOption {
diff --git a/modules/default/common/server/default.nix b/modules/default/common/server/default.nix
index 0271d0e..904ea30 100644
--- a/modules/default/common/server/default.nix
+++ b/modules/default/common/server/default.nix
@@ -2,7 +2,6 @@
 {
 
   imports = [
-    ./builder.nix
     ./ssh-server.nix
   ];
 }