infra/nix/os/devices/sj-vps-htz0/system.nix

112 lines
2.7 KiB
Nix
Raw Normal View History

2024-01-18 14:59:17 +00:00
{
2024-02-08 20:53:22 +01:00
pkgs,
lib,
config,
repoFlake,
nodeName,
...
2024-11-15 10:17:56 +01:00
}:
let
2024-02-08 20:53:22 +01:00
wireguardPort = 51820;
2024-11-15 10:17:56 +01:00
in
{
imports = [ ../../snippets/systemd-resolved.nix ];
networking.firewall.enable = true;
networking.nftables.enable = true;
networking.firewall.allowedTCPPorts = [
# iperf3
5201
];
2024-11-15 10:17:56 +01:00
networking.firewall.allowedUDPPorts = [ wireguardPort ];
2023-08-22 10:20:16 +02:00
networking.firewall.logRefusedConnections = false;
networking.usePredictableInterfaceNames = false;
networking.dhcpcd.enable = false;
networking.interfaces.eth0 = {
mtu = 1400;
2024-01-18 14:59:17 +00:00
useDHCP = true;
2023-02-07 18:24:28 +01:00
ipv4.addresses = [
{
"address" = "167.233.1.14";
"prefixLength" = 29;
}
];
2024-11-15 10:17:56 +01:00
ipv6.addresses = [ ];
};
networking.defaultGateway = {
address = "167.233.1.9";
interface = "eth0";
};
networking.defaultGateway6 = {
address = "fe80::1";
interface = "eth0";
};
networking.nat = {
enable = true;
2024-11-15 10:17:56 +01:00
internalInterfaces = [
"ve-*"
"wg*"
];
externalInterface = "eth0";
};
networking.firewall.filterForward = true;
networking.firewall.extraForwardRules = ''
meta nfproto ipv4 tcp flags syn tcp option maxseg size set 1360;
meta nfproto ipv6 tcp flags syn tcp option maxseg size set 1340;
'';
2023-08-22 10:20:16 +02:00
sops.secrets.wg0-private.sopsFile = ../../../../secrets/${nodeName}/secrets.yaml;
sops.secrets.wg0-psk-steveej-psk.sopsFile = ../../../../secrets/${nodeName}/secrets.yaml;
networking.wireguard.enable = true;
networking.wireguard.interfaces.wg0 = {
# eth0 MTU (1400) - 80
mtu = 1320;
2024-11-15 10:17:56 +01:00
ips = [ "192.168.99.1/31" ];
listenPort = wireguardPort;
2023-08-22 10:20:16 +02:00
privateKeyFile = config.sops.secrets.wg0-private.path;
peers = [
{
2024-11-15 10:17:56 +01:00
allowedIPs = [ "192.168.99.2/32" ];
2023-08-22 10:20:16 +02:00
publicKey = "O3k4jEdX6jkV1fHP/J8KSH5tvi+n1VvnBTD5na6Naw0=";
presharedKeyFile = config.sops.secrets.wg0-psk-steveej-psk.path;
}
];
};
# virtualization
2024-11-15 10:17:56 +01:00
virtualisation = {
docker.enable = false;
};
services.spice-vdagentd.enable = true;
services.qemuGuest.enable = true;
2024-11-15 10:17:56 +01:00
nix.gc = {
automatic = true;
};
2024-11-15 10:17:56 +01:00
containers = { };
home-manager.users.steveej = import ../../../home-manager/configuration/text-minimal.nix {
inherit pkgs;
};
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. Its perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "22.11"; # Did you read the comment?
}