infra/nix/os/devices/sj-srv1/system.nix

197 lines
4.3 KiB
Nix
Raw Normal View History

2024-01-18 21:06:45 +00:00
{
2024-02-08 20:53:22 +01:00
pkgs,
lib,
config,
repoFlake,
2024-06-01 21:46:09 +02:00
nodeFlake,
2024-02-08 20:53:22 +01:00
nodeName,
...
}: let
hostBridgeAddress = "192.168.101.1";
in {
2024-01-18 21:06:45 +00:00
imports = [
../../snippets/systemd-resolved.nix
];
networking.firewall.enable = true;
networking.nftables.enable = true;
networking.nftables.flushRuleset = true;
2024-01-18 21:06:45 +00:00
networking.firewall.allowedTCPPorts = [
# iperf3
5201
];
networking.firewall.logRefusedConnections = false;
networking.usePredictableInterfaceNames = false;
networking.useNetworkd = true;
networking.useDHCP = false;
2024-01-18 21:06:45 +00:00
networking.nat = {
enable = true;
internalInterfaces = ["br0"];
externalInterface = "dmz0";
2024-01-18 21:06:45 +00:00
};
networking.bridges = {
br0 = {
interfaces = [];
};
};
networking.interfaces = {
br0 = {
ipv4.addresses = [
{
address = hostBridgeAddress;
prefixLength = 24;
}
];
};
};
systemd.network.netdevs."10-dmz0" = {
enable = true;
netdevConfig = {
Name = "dmz0";
Kind = "macvlan";
MACAddress = "1c:69:7a:07:08:6f";
};
macvlanConfig = {
Mode = "bridge";
};
};
systemd.network.networks."20-eth0" = {
enable = true;
matchConfig.Name = "eth0";
linkConfig.RequiredForOnline = "carrier";
networkConfig.LinkLocalAddressing = "no";
# TODO: i'm not sure if and if so why this is required
macvlan = [
"dmz0"
];
DHCP = "no";
};
systemd.network.networks."30-dmz0" = {
enable = true;
matchConfig.Name = "dmz0";
DHCP = "yes";
};
boot.kernel.sysctl = {
"net.ipv4.ip_forward" = 1;
"net.ipv6.ip_forward" = 1;
};
2024-01-18 21:06:45 +00:00
# virtualization
2024-02-08 20:53:22 +01:00
virtualisation = {docker.enable = false;};
2024-01-18 21:06:45 +00:00
2024-02-08 20:53:22 +01:00
nix.gc = {automatic = true;};
2024-01-18 21:06:45 +00:00
sops.secrets.restic-password.sopsFile = ../../../../secrets/${nodeName}/secrets.yaml;
# adapted from https://github.com/lilyinstarlight/foosteros/blob/5c75ded111878970fd4f600c7adc013f971d5e71/config/restic.nix
2024-02-08 20:53:22 +01:00
services.restic.backups.${nodeName} = let
btrfs = "${pkgs.btrfs-progs}/bin/btrfs";
in {
initialize = true;
repository = "sftp://u217879-sub3@u217879-sub3.your-storagebox.de:23/restic/${nodeName}";
paths = [
"/backup"
];
pruneOpts = [
"--keep-daily 7"
"--keep-weekly 5"
"--keep-monthly 12"
"--keep-yearly 2"
];
timerConfig = {
OnCalendar = lib.mkDefault "daily";
Persistent = true;
};
2024-01-18 21:06:45 +00:00
2024-02-08 20:53:22 +01:00
passwordFile = config.sops.secrets.restic-password.path;
2024-01-18 21:06:45 +00:00
2024-02-08 20:53:22 +01:00
backupPrepareCommand = ''
${btrfs} su snapshot -r /var/lib/container-volumes /backup/container-volumes
'';
backupCleanupCommand = ''
${btrfs} su delete /backup/container-volumes
'';
};
2024-01-18 21:06:45 +00:00
containers = {
mailserver = import ../../containers/mailserver.nix {
2024-06-01 21:46:09 +02:00
specialArgs = {
inherit repoFlake nodeFlake;
};
2024-01-18 21:06:45 +00:00
autoStart = true;
hostBridge = "br0";
hostAddress = hostBridgeAddress;
localAddress = "192.168.101.10/24";
2024-01-18 21:06:45 +00:00
imapsPort = 993;
sievePort = 4190;
};
webserver =
2024-01-18 21:06:45 +00:00
import ../../containers/webserver.nix
2024-02-08 20:53:22 +01:00
{
2024-06-01 21:46:09 +02:00
specialArgs = {
inherit repoFlake nodeFlake;
};
2024-01-18 21:06:45 +00:00
2024-02-08 20:53:22 +01:00
autoStart = true;
2024-01-18 21:06:45 +00:00
hostBridge = "br0";
hostAddress = hostBridgeAddress;
localAddress = "192.168.101.11/24";
2024-01-18 21:06:45 +00:00
2024-02-08 20:53:22 +01:00
httpPort = 80;
httpsPort = 443;
2024-06-12 22:22:46 +02:00
forgejoSshPort = 2222;
2024-02-08 20:53:22 +01:00
};
2024-01-18 21:06:45 +00:00
syncthing = import ../../containers/syncthing.nix {
2024-06-01 21:46:09 +02:00
specialArgs = {
inherit repoFlake nodeFlake;
};
2024-01-18 21:06:45 +00:00
autoStart = true;
hostBridge = "br0";
hostAddress = hostBridgeAddress;
localAddress = "192.168.101.12/24";
2024-01-18 21:06:45 +00:00
syncthingPort = 22000;
};
};
virtualisation.libvirtd = {
enable = true;
onShutdown = "shutdown";
parallelShutdown = 3;
};
fileSystems."/mnt/8078-532D".device = "/dev/disk/by-uuid/8078-532D";
2024-01-18 21:06:45 +00:00
# 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?
}