about summary refs log tree commit diff
path: root/modules/wireguard.nix
diff options
context:
space:
mode:
authorazahi <azat@bahawi.net>2024-10-21 15:39:18 +0300
committerazahi <azat@bahawi.net>2024-10-21 15:39:18 +0300
commit2c03460ad97ed1d10415918e9ec53744e4f920dc (patch)
tree7f7f7438096b2981a39cc3f236e02f6258314624 /modules/wireguard.nix
parent2024-10-21 (diff)
2024-10-21
Diffstat (limited to '')
-rw-r--r--modules/wireguard.nix19
1 files changed, 11 insertions, 8 deletions
diff --git a/modules/wireguard.nix b/modules/wireguard.nix
index 8547f70..8ea360b 100644
--- a/modules/wireguard.nix
+++ b/modules/wireguard.nix
@@ -9,6 +9,15 @@
 with lib;
 let
   cfg = config.nixfiles.modules.wireguard;
+
+  DNSSetup =
+    let
+      resolvectl = "${config.systemd.package}/bin/resolvectl";
+    in
+    ''
+      ${resolvectl} dns ${cfg.interface} ${cfg.server.ipv6.address} ${cfg.server.ipv4.address}
+      ${resolvectl} domain ${cfg.interface} ${my.domain.shire}
+    '';
 in
 {
   disabledModules = [
@@ -166,14 +175,7 @@ in
               ipv6.address
               ipv4.address
             ];
-            postUp =
-              let
-                resolvectl = "${config.systemd.package}/bin/resolvectl";
-              in
-              ''
-                ${resolvectl} dns ${cfg.interface} ${ipv6.address} ${ipv4.address}
-                ${resolvectl} domain ${cfg.interface} ${concatStringsSep " " (mapAttrsToList (_: v: v) my.domain)}
-              '';
+            postUp = DNSSetup;
           })
         ];
 
@@ -216,6 +218,7 @@ in
               ];
               listenPort = port;
               inherit peers;
+              postSetup = DNSSetup;
               allowedIPsAsRoutes = false;
             };
           };

Consider giving Nix/NixOS a try! <3