mirror of
https://gitlab.com/upRootNutrition/dotfiles.git
synced 2025-08-09 05:14:41 -05:00
65 lines
1.3 KiB
Nix
65 lines
1.3 KiB
Nix
{ config, flake, ... }:
|
|
let
|
|
inherit (flake.config.services.instances) wireGuard web;
|
|
inherit (flake.config.machines.devices) mars;
|
|
service = wireGuard;
|
|
in
|
|
{
|
|
networking = {
|
|
firewall = {
|
|
allowedUDPPorts = [
|
|
53
|
|
service.ports.port0
|
|
];
|
|
interfaces.wg0.allowedTCPPorts = [
|
|
80
|
|
443
|
|
8080
|
|
];
|
|
};
|
|
|
|
nat = {
|
|
enable = true;
|
|
enableIPv6 = true;
|
|
externalInterface = "eth0";
|
|
internalInterfaces = [ "wg0" ];
|
|
};
|
|
|
|
wireguard.interfaces = {
|
|
wg0 = {
|
|
ips = [ "${web.wireguard.interface0}/24" ];
|
|
listenPort = service.ports.port0;
|
|
privateKeyFile = config.sops.secrets."${service.name}-private".path;
|
|
peers = [
|
|
{
|
|
publicKey = "9zfRPxkxTLHM9tABC8lIaDMrzdjcF2l1mtG82uqGKUQ=";
|
|
allowedIPs = [ "${mars.wireguard.ip0}/32" ];
|
|
}
|
|
];
|
|
};
|
|
};
|
|
};
|
|
|
|
sops.secrets =
|
|
let
|
|
sopsPath = secret: {
|
|
path = "${service.sops.path0}/${service.name}-${secret}";
|
|
owner = "root";
|
|
mode = "600";
|
|
};
|
|
in
|
|
(map
|
|
(secret: {
|
|
name = "${service.name}-${secret}";
|
|
value = sopsPath secret;
|
|
})
|
|
[
|
|
"private"
|
|
"public"
|
|
]
|
|
);
|
|
|
|
boot.kernel.sysctl = {
|
|
"net.ipv4.ip_forward" = 1;
|
|
};
|
|
}
|