Files
Chickadee/hosts/vps/default.nix
T

66 lines
1.5 KiB
Nix
Raw Normal View History

2026-07-11 14:56:13 -04:00
{ config, lib, pkgs, ... }:
{
imports = [
2026-07-11 16:28:11 -04:00
./hardware-configuration.nix
../../modules/ssh.nix
2026-09-21 10:58:46 -04:00
../../lilac.nix
2026-07-11 14:56:13 -04:00
];
networking.hostName = "vps";
2026-08-03 13:22:28 -04:00
# forwarding inbound network traffic over wireguard
networking = {
firewall = {
2026-09-12 20:33:30 -04:00
enable = true;
allowedTCPPorts = [ 80 443 ];
allowedUDPPorts = [ 51820 ];
trustedInterfaces = [ "wg0" ];
};
wireguard.interfaces."wg0" = {
2026-08-03 13:22:28 -04:00
ips = [ "10.0.0.3/24" ];
2026-09-12 20:33:30 -04:00
listenPort = 51820;
generatePrivateKeyFile = true;
privateKeyFile = "/var/lib/wireguard/wg0.key";
peers = [
{
allowedIPs = [ "10.0.0.1/32" ];
2026-09-12 17:11:21 -04:00
publicKey = "guKFJGQW946HXWjca/biMYH1nJKw0fguLjzGXKZ7Bxw=";
2026-09-12 20:33:30 -04:00
}
{
2026-08-03 13:22:28 -04:00
allowedIPs = [ "10.0.0.2/32" ];
2026-09-12 20:33:30 -04:00
publicKey = "7BcwtszpzS4ABDwKwMaiJ7F35sJRa89fBbuh80Sk8Uk=";
}
{
allowedIPs = [ "10.0.0.4/32" ];
publicKey = "XjuV3wzkP03UUjYSJfY3OG3WWLRtoQBN7GokDEWhdhQ=";
}
2026-08-03 13:22:28 -04:00
];
2026-09-12 20:33:30 -04:00
};
nftables = {
enable = true;
tables.nat = {
family = "ip";
content = ''
2026-08-03 13:22:28 -04:00
chain prerouting {
type nat hook prerouting priority dstnat; policy accept;
iifname "enp1s0" tcp dport { 80, 443 } dnat to 10.0.0.2
}
2026-09-12 20:33:30 -04:00
chain postrouting {
2026-08-03 13:22:28 -04:00
type nat hook postrouting priority srcnat; policy accept;
oifname "wg0" masquerade
}
'';
};
2026-09-12 20:33:30 -04:00
};
2026-08-03 13:22:28 -04:00
};
boot.kernel.sysctl = {
"net.ipv4.ip_forward" = 1;
};
2026-07-11 16:28:11 -04:00
nix.settings.experimental-features = [ "nix-command" "flakes" ];
2026-07-11 14:56:13 -04:00
system.stateVersion = "26.05";
}