ctucx.git: nixfiles

ctucx' nixfiles

commit f7f620e58e1720811b6845c897ec64f30260e778
parent d33c5f944c87f6e5c15a88d0272f418a0de0321f
Author: Leah (ctucx) <git@ctu.cx>
Date: Fri, 12 May 2023 13:53:21 +0200

machines/wanderduene: use `networking.primaryIP` and `networking.primaryIP4` options
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/machines/wanderduene/configuration.nix b/machines/wanderduene/configuration.nix
@@ -19,7 +19,10 @@
 
   age.secrets.wireguard-privkey.file = ../../secrets/wanderduene/wireguard-privkey.age;
 
-  dns.zones."ctu.cx".subdomains."${config.networking.hostName}" = (pkgs.dns.lib.combinators.host "46.38.253.139" "2a03:4000:1:45d::1");
+  networking.primaryIP    = "2a03:4000:1:45d::1";
+  networking.primaryIP4   = "46.38.253.139";
+
+  dns.zones."ctu.cx".subdomains."${config.networking.hostName}" = (pkgs.dns.lib.combinators.host config.networking.primaryIP4 config.networking.primaryIP);
 
   boot = {
     loader.grub = {

@@ -39,10 +42,10 @@
 
       postCommands = ''
         ip link set dev ens3 up
-        ip addr add 2a03:4000:1:45d::1/128 dev ens3
+        ip addr add ${config.networking.primaryIP}/128 dev ens3
         ip route add default via fe80::1 dev ens3 onlink
 
-        ip addr add 46.38.253.139/22 dev ens3
+        ip addr add ${config.networking.primaryIP4}/22 dev ens3
         ip route add default via 46.38.253.1 dev ens3 onlink
         echo 'cryptsetup-askpass' >> /root/.profile
       '';

@@ -61,12 +64,12 @@
 
     interfaces.ens3 = {
       ipv4.addresses = [{
-        address = "46.38.253.139";
+        address = config.networking.primaryIP4;
         prefixLength = 24;
       }];
 
       ipv6.addresses = [{
-        address      = "2a03:4000:1:45d::1";
+        address      = config.networking.primaryIP;
         prefixLength = 64;
       }];
     };