2024-12-19 17:22:19 +00:00
|
|
|
# Wireguard VPN client configuration
|
2024-12-27 08:16:49 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
2024-12-19 17:22:19 +00:00
|
|
|
|
|
|
|
let
|
2024-12-27 08:16:49 +00:00
|
|
|
inherit (lib) mkOption;
|
2024-12-19 17:22:19 +00:00
|
|
|
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
nixin.wg.client = {
|
2024-12-19 17:34:25 +00:00
|
|
|
ipv4 = mkOption { type = lib.types.str; };
|
|
|
|
ipv6 = mkOption { type = lib.types.str; };
|
2024-12-25 17:24:33 +00:00
|
|
|
allowedIPs = mkOption { type = lib.types.listOf lib.types.str; };
|
|
|
|
endpoint = mkOption { type = lib.types.str; };
|
|
|
|
endpointKey = mkOption { type = lib.types.str; };
|
2024-12-19 17:22:19 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
networking = {
|
|
|
|
wg-quick.interfaces = {
|
|
|
|
wg0 = {
|
2024-12-27 08:16:49 +00:00
|
|
|
address = [
|
|
|
|
"${config.nixin.wg.client.ipv4}/32"
|
|
|
|
"${config.nixin.wg.client.ipv6}/128"
|
|
|
|
];
|
|
|
|
dns = [
|
|
|
|
"80.67.169.12"
|
|
|
|
"80.67.169.40"
|
|
|
|
"2001:910:800::12"
|
|
|
|
"2001:910:800::40"
|
|
|
|
];
|
2024-12-19 17:22:19 +00:00
|
|
|
privateKeyFile = "/var/src/secrets/wg-private.key";
|
|
|
|
|
|
|
|
peers = [
|
|
|
|
{
|
2024-12-25 17:24:33 +00:00
|
|
|
publicKey = config.nixin.wg.client.endpointKey;
|
|
|
|
allowedIPs = config.nixin.wg.client.allowedIPs;
|
|
|
|
endpoint = config.nixin.wg.client.endpoint;
|
2024-12-19 17:22:19 +00:00
|
|
|
persistentKeepalive = 15;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|