system/wireguard: fix caramel and client config

This commit is contained in:
LavaDesu 2022-02-13 15:33:16 +07:00
parent f774334203
commit c4e2846818
Signed by: cilly
GPG key ID: 6500251E087653C9
2 changed files with 5 additions and 3 deletions

View file

@ -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

View file

@ -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;