From c4e28468187dcd0c50619dabb99998a6f2936e0c Mon Sep 17 00:00:00 2001 From: LavaDesu Date: Sun, 13 Feb 2022 15:33:16 +0700 Subject: [PATCH] system/wireguard: fix caramel and client config --- hosts/caramel/default.nix | 1 + modules/system/wireguard.nix | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hosts/caramel/default.nix b/hosts/caramel/default.nix index b4d4ca8..03f02cf 100644 --- a/hosts/caramel/default.nix +++ b/hosts/caramel/default.nix @@ -6,6 +6,7 @@ age.secrets = { passwd.file = ../../secrets/passwd.age; wpa_conf.file = ../../secrets/wpa_conf.age; + wg_caramel.file = ../../secrets/wg_caramel.age; }; imports = with modules.system; [ inputs.home-manager-porcupine.nixosModule diff --git a/modules/system/wireguard.nix b/modules/system/wireguard.nix index 2d2d02e..b28a4dd 100644 --- a/modules/system/wireguard.nix +++ b/modules/system/wireguard.nix @@ -74,9 +74,10 @@ let clientConfig = { wireguard.interfaces.wg0 = let - client = routeBypass."${config.networking.hostName}"; - mappedAdd = lib.concatMapStringsSep "\n" (r: "${pkgs.iproute2}/bin/ip route add ${r} via ${client.gateway} dev ${client.interface}") client.routes; - mappedDel = lib.concatMapStringsSep "\n" (r: "${pkgs.iproute2}/bin/ip route del ${r} via ${client.gateway} dev ${client.interface}") client.routes; + client = clients."${config.networking.hostName}"; + routes = routeBypass."${config.networking.hostName}"; + mappedAdd = lib.concatMapStringsSep "\n" (r: "${pkgs.iproute2}/bin/ip route add ${r} via ${routes.gateway} dev ${routes.interface}") routes.routes; + mappedDel = lib.concatMapStringsSep "\n" (r: "${pkgs.iproute2}/bin/ip route del ${r} via ${routes.gateway} dev ${routes.interface}") routes.routes; in { ips = client.allowedIPs; listenPort = port;