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,
|
|
|
|
|
...
|
2024-08-24 01:02:59 +02:00
|
|
|
|
}: let
|
|
|
|
|
hostBridgeAddress = "192.168.101.1";
|
|
|
|
|
in {
|
2024-01-18 21:06:45 +00:00
|
|
|
|
imports = [
|
|
|
|
|
../../snippets/systemd-resolved.nix
|
2024-10-16 23:01:57 +02:00
|
|
|
|
{
|
|
|
|
|
# make sure it uses the DNS that comes in via DHCP
|
|
|
|
|
networking.nameservers = lib.mkForce [];
|
|
|
|
|
services.resolved.enable = true;
|
|
|
|
|
|
|
|
|
|
# provide DNS to the containers
|
|
|
|
|
services.resolved.extraConfig = ''
|
|
|
|
|
DNSStubListenerExtra=${hostBridgeAddress}
|
|
|
|
|
'';
|
|
|
|
|
networking.firewall.interfaces.br0.allowedTCPPorts = [53];
|
|
|
|
|
networking.firewall.interfaces.br0.allowedUDPPorts = [53];
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
programs.wireshark.enable = true;
|
|
|
|
|
environment.systemPackages = [
|
|
|
|
|
pkgs.dnsutils
|
2024-01-18 21:06:45 +00:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
networking.firewall.enable = true;
|
|
|
|
|
networking.nftables.enable = true;
|
2024-07-26 18:02:15 +02:00
|
|
|
|
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;
|
2024-08-24 00:18:17 +02:00
|
|
|
|
networking.useDHCP = false;
|
2024-01-18 21:06:45 +00:00
|
|
|
|
|
|
|
|
|
networking.nat = {
|
|
|
|
|
enable = true;
|
2024-08-24 00:16:29 +02:00
|
|
|
|
internalInterfaces = ["br0"];
|
2024-08-24 00:18:17 +02:00
|
|
|
|
externalInterface = "dmz0";
|
2024-01-18 21:06:45 +00:00
|
|
|
|
};
|
2024-08-24 00:16:29 +02:00
|
|
|
|
|
|
|
|
|
networking.bridges = {
|
|
|
|
|
br0 = {
|
|
|
|
|
interfaces = [];
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
networking.interfaces = {
|
|
|
|
|
br0 = {
|
|
|
|
|
ipv4.addresses = [
|
|
|
|
|
{
|
2024-08-24 01:02:59 +02:00
|
|
|
|
address = hostBridgeAddress;
|
2024-08-24 00:16:29 +02:00
|
|
|
|
prefixLength = 24;
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2024-08-24 00:18:17 +02:00
|
|
|
|
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";
|
|
|
|
|
|
2024-08-24 01:02:59 +02:00
|
|
|
|
linkConfig.RequiredForOnline = "carrier";
|
|
|
|
|
networkConfig.LinkLocalAddressing = "no";
|
|
|
|
|
|
2024-08-24 00:18:17 +02:00
|
|
|
|
# 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";
|
2024-10-16 23:01:57 +02:00
|
|
|
|
|
|
|
|
|
dhcpV4Config.UseDNS = true;
|
|
|
|
|
dhcpV6Config.UseDNS = true;
|
2024-08-24 00:18:17 +02:00
|
|
|
|
};
|
|
|
|
|
|
2024-07-26 18:02:15 +02:00
|
|
|
|
boot.kernel.sysctl = {
|
|
|
|
|
"net.ipv4.ip_forward" = 1;
|
2024-08-24 00:18:17 +02:00
|
|
|
|
"net.ipv6.ip_forward" = 1;
|
2024-07-26 18:02:15 +02:00
|
|
|
|
};
|
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-10-16 23:01:57 +02:00
|
|
|
|
hostAddress = hostBridgeAddress;
|
2024-06-01 21:46:09 +02:00
|
|
|
|
};
|
2024-01-18 21:06:45 +00:00
|
|
|
|
|
|
|
|
|
autoStart = true;
|
|
|
|
|
|
2024-08-24 00:16:29 +02:00
|
|
|
|
hostBridge = "br0";
|
2024-08-24 01:02:59 +02:00
|
|
|
|
hostAddress = hostBridgeAddress;
|
2024-08-24 00:16:29 +02:00
|
|
|
|
localAddress = "192.168.101.10/24";
|
2024-01-18 21:06:45 +00:00
|
|
|
|
|
|
|
|
|
imapsPort = 993;
|
|
|
|
|
sievePort = 4190;
|
|
|
|
|
};
|
|
|
|
|
|
2024-08-24 00:16:29 +02:00
|
|
|
|
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-10-16 23:01:57 +02:00
|
|
|
|
hostAddress = hostBridgeAddress;
|
2024-06-01 21:46:09 +02:00
|
|
|
|
};
|
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
|
|
|
|
|
2024-08-24 00:16:29 +02:00
|
|
|
|
hostBridge = "br0";
|
2024-08-24 01:02:59 +02:00
|
|
|
|
hostAddress = hostBridgeAddress;
|
2024-08-24 00:16:29 +02:00
|
|
|
|
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-10-16 23:01:57 +02:00
|
|
|
|
hostAddress = hostBridgeAddress;
|
2024-06-01 21:46:09 +02:00
|
|
|
|
};
|
2024-01-18 21:06:45 +00:00
|
|
|
|
autoStart = true;
|
|
|
|
|
|
2024-08-24 00:16:29 +02:00
|
|
|
|
hostBridge = "br0";
|
2024-08-24 01:02:59 +02:00
|
|
|
|
hostAddress = hostBridgeAddress;
|
2024-08-24 00:16:29 +02:00
|
|
|
|
localAddress = "192.168.101.12/24";
|
2024-01-18 21:06:45 +00:00
|
|
|
|
|
|
|
|
|
syncthingPort = 22000;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2024-08-22 14:33:39 +02:00
|
|
|
|
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. It‘s 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?
|
|
|
|
|
}
|