35 lines
800 B
Nix
35 lines
800 B
Nix
|
{
|
||
|
config,
|
||
|
pkgs,
|
||
|
lib,
|
||
|
cfg,
|
||
|
...
|
||
|
}: {
|
||
|
opt.useIPv6 = lib.mkOption {
|
||
|
type = lib.types.bool;
|
||
|
description = "Whether to use IPv6. Defaults to true";
|
||
|
default = true;
|
||
|
};
|
||
|
# helper vars to prettify
|
||
|
currentHost = lyn.network.hosts.${networking.hostName};
|
||
|
wireguardPort = currentHost.wg.port;
|
||
|
|
||
|
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 =
|
||
|
if opt.useIPv6
|
||
|
then lyn.network.IPv6.peerlist
|
||
|
else lyn.network.IPv4.peerlist;
|
||
|
upnp_forward_external_port = wireguardPort;
|
||
|
};
|
||
|
};
|
||
|
}
|