nixfiles/hosts/hetzner-vm/profiles/wireguard.nix

36 lines
1.1 KiB
Nix
Raw Normal View History

{config, ...}: let
secrets = config.services.secrets.secrets;
2023-08-09 20:53:22 +01:00
data = import ../../../data/chaos_wireguard_internal.nix {};
2022-11-11 20:53:17 +00:00
in {
networking.wg-quick.interfaces = {
wg0 = {
2023-08-09 20:53:22 +01:00
address = ["${data.hosts.hetzner-vm.ip}/32"];
2022-11-11 20:53:17 +00:00
listenPort = 51820;
privateKeyFile = "${secrets.wg_privkey.path}";
2022-11-11 20:53:17 +00:00
peers = [
# vault
{
2023-08-09 20:53:22 +01:00
publicKey = "${data.hosts.vault.public}";
presharedKeyFile = "${secrets.wg_preshared_vault.path}";
2023-08-09 20:53:22 +01:00
endpoint = "${data.hosts.vault.endpoint}";
allowedIPs = ["${data.hosts.vault.ip}/32"];
2022-11-11 20:53:17 +00:00
}
# iphone8
{
2023-08-09 20:53:22 +01:00
publicKey = "${data.hosts.iphone8.public}";
presharedKeyFile = "${secrets.wg_preshared_iphone8.path}";
2023-08-09 20:53:22 +01:00
allowedIPs = ["${data.hosts.iphone8.ip}/32"];
}
# lappy-t495
{
publicKey = "${data.hosts.lappy-t495.public}";
presharedKeyFile = "${secrets.wg_preshared_lappy-t495.path}";
allowedIPs = ["${data.hosts.lappy-t495.ip}/32"];
}
2022-11-11 20:53:17 +00:00
];
};
};
networking.firewall.allowedUDPPorts = [51820];
2022-11-11 20:53:17 +00:00
}