Skip to content

Commit e80ccab

Browse files
committed
fmt
1 parent 303fcbc commit e80ccab

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

wireguard-wrapper.nix

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,27 @@ with lib.types; {
5656
config = mkIf cfg.enable ({
5757
networking.firewall.allowedUDPPorts = mkIf cfg.openPort [ cfg.port ];
5858

59-
networking."${cfg.kind}".interfaces = {
60-
"wg0" = {
61-
ips = [ (builtins.head cfg.nodes."${hostname}".ips) ];
62-
mtu = cfg.mtu;
63-
privateKeyFile = cfg.privateKeyFile;
64-
listenPort = cfg.port;
65-
peers = (builtins.map (l:
66-
let
67-
other = (lib.head (lib.remove hostname l));
68-
other_node = cfg.nodes."${other}";
69-
in ({
70-
name = other;
71-
publicKey = ((cfg.publicKey) other);
72-
allowedIPs = (other_node.ips);
73-
persistentKeepalive = 25;
74-
endpoint = other_node.endpoint;
75-
})) our_connections);
59+
networking."${cfg.kind}".interfaces =
60+
let ips_name = if cfg.kind == "wireguard" then "ips" else "address";
61+
in {
62+
"wg0" = {
63+
${ips_name} = [ (builtins.head cfg.nodes."${hostname}".ips) ];
64+
mtu = cfg.mtu;
65+
privateKeyFile = cfg.privateKeyFile;
66+
listenPort = cfg.port;
67+
peers = (builtins.map (l:
68+
let
69+
other = (lib.head (lib.remove hostname l));
70+
other_node = cfg.nodes."${other}";
71+
in ({
72+
publicKey = ((cfg.publicKey) other);
73+
allowedIPs = (other_node.ips);
74+
persistentKeepalive = 25;
75+
endpoint = other_node.endpoint;
76+
} // (if cfg.kind == "wireguard" then { name = other; } else { })))
77+
our_connections);
78+
};
7679
};
77-
};
7880

7981
});
8082
}

0 commit comments

Comments
 (0)