ctucx.git: nixfiles

ctucx' nixfiles

commit 8fe84450b8325bc43be2a64b520d35ca1150ee55
parent bd99586f44145bfcdec989a053bca1146c2f9c1e
Author: Katja (ctucx) <git@ctu.cx>
Date: Fri, 28 Feb 2025 00:49:43 +0100

machines/hector: use systemd-networkd
1 file changed, 34 insertions(+), 22 deletions(-)
M
machines/hector/default.nix
|
56
++++++++++++++++++++++++++++++++++----------------------
diff --git a/machines/hector/default.nix b/machines/hector/default.nix
@@ -54,11 +54,13 @@
 
       postCommands = ''
         ip link set dev ens3 up
+
         ip addr add ${config.networking.primaryIP}/128 dev ens3
         ip route add default via fe80::1 dev ens3 onlink
 
         ip addr add ${config.networking.primaryIP4}/22 dev ens3
-        ip route add default via ${config.networking.defaultGateway.address} dev ens3 onlink
+        ip route add default via 194.59.204.1 dev ens3 onlink
+
         echo 'cryptsetup-askpass' >> /root/.profile
       '';
     };

@@ -68,32 +70,42 @@
     primaryIP    = "2a03:4000:34:23e::1";
     primaryIP4   = "194.59.205.194";
 
-    resolvconf.enable = false;
-    nameservers       = [ "8.8.8.8" "1.1.1.1" ];
+    useNetworkd  = true;
+    useDHCP      = false;
 
-    defaultGateway  = {
-      interface = "ens3";
-      address    = "194.59.204.1";
-    };
-    defaultGateway6 = {
-      interface = "ens3";
-      address   = "fe80::1";
-    };
+    firewall.enable = true;
+    nftables.enable = true;
+  };
 
-    interfaces.ens3 = {
-      ipv4.addresses = [{
-        address = config.networking.primaryIP4;
-        prefixLength = 22;
-      }];
-      ipv6.addresses = [{
-        address      = config.networking.primaryIP;
-        prefixLength = 64;
-      }];
+  systemd.network = {
+    enable             = true;
+    wait-online.enable = false;
+
+    networks = {
+      "10-ens3" = {
+        matchConfig.Name = "ens3";
+
+        address = [ "${config.networking.primaryIP4}/22" "${config.networking.primaryIP}/64" ];
+
+        networkConfig = {
+          DNS = [ "8.8.8.8" "1.1.1.1" ];
+        };
+
+        routes = [
+          {
+            Gateway       = "fe80::1";
+            GatewayOnLink = true;
+          }
+          {
+            Gateway       = "194.59.204.1";
+            GatewayOnLink = true;
+          }
+        ];
+      };
     };
-
-    nftables.enable = true;
   };
 
+
   services.email-notify.enable = true;
 
   system.stateVersion = "24.11";