2024-11-12 01:49:31 +01:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
cfg,
|
|
|
|
...
|
2024-11-12 03:46:56 +01:00
|
|
|
}: let
|
|
|
|
# helper vars to prettify
|
|
|
|
currentHost = lyn.network.hosts.${networking.hostName};
|
|
|
|
wireguardPort = currentHost.wg.port;
|
|
|
|
in {
|
2024-11-12 01:49:31 +01:00
|
|
|
opt.useIPv6 = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
description = "Whether to use IPv6. Defaults to true";
|
|
|
|
default = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
networking.wireguard.interfaces.wg0 = {
|
|
|
|
ips = ["${lyn.network.IPv4.wg_subnet}"];
|
|
|
|
listenPort = cfg.wireguardPort;
|
|
|
|
privateKeyFile = "/var/lib/wireguard-keys/private";
|
|
|
|
mtu = 1420;
|
|
|
|
};
|
|
|
|
services.wgautomesh = {
|
|
|
|
enable = true;
|
|
|
|
services.wgautomesh.settings = {
|
|
|
|
interface = "wg0";
|
|
|
|
peers =
|
2024-11-12 01:52:07 +01:00
|
|
|
if cfg.useIPv6
|
2024-11-12 01:49:31 +01:00
|
|
|
then lyn.network.IPv6.peerlist
|
|
|
|
else lyn.network.IPv4.peerlist;
|
|
|
|
upnp_forward_external_port = wireguardPort;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|