From 3deb7383e17a63225f1c35f60ddace4c7a43eac9 Mon Sep 17 00:00:00 2001
From: clerie <git@clerie.de>
Date: Sun, 16 Mar 2025 18:44:55 +0100
Subject: [PATCH] hosts/storage-2: Migrate to systemd-network

---
 hosts/storage-2/configuration.nix | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/hosts/storage-2/configuration.nix b/hosts/storage-2/configuration.nix
index b664f44..403171f 100644
--- a/hosts/storage-2/configuration.nix
+++ b/hosts/storage-2/configuration.nix
@@ -16,10 +16,28 @@
   boot.loader.grub.device = "/dev/vda";
 
   networking.useDHCP = false;
-  networking.interfaces.ens19.ipv4.addresses = [ { address = "192.168.10.35"; prefixLength = 24; } ];
-  networking.interfaces.ens18.ipv6.addresses = [ { address = "2001:638:904:ffc0::4"; prefixLength = 64; } ];
-  networking.defaultGateway = { address = "192.168.10.1"; interface = "ens19"; };
-  networking.defaultGateway6 = { address = "2001:638:904:ffc0::1"; interface = "ens18"; };
+  systemd.network.enable = true;
+
+  systemd.network.networks."10-wan" = {
+    matchConfig.Name = "ens18";
+    address = [
+      "2001:638:904:ffc0::4/64"
+    ];
+    routes = [
+      { Gateway = "2001:638:904:ffc0::1"; }
+    ];
+    linkConfig.RequiredForOnline = "routable";
+  };
+  systemd.network.networks."10-nat-netz-mercury" = {
+    matchConfig.Name = "ens19";
+    address = [
+      "192.168.10.35/24"
+    ];
+    routes = [
+      { Gateway = "192.168.10.1"; }
+    ];
+    linkConfig.RequiredForOnline = "routable";
+  };
 
   services.nginx.enable = true;