2018-11-12 11:26:22 +01:00
|
|
|
|
{ pkgs
|
|
|
|
|
, lib
|
2018-11-12 20:27:30 +01:00
|
|
|
|
, config
|
2018-11-12 11:26:22 +01:00
|
|
|
|
, ... }:
|
|
|
|
|
|
2018-11-12 20:27:30 +01:00
|
|
|
|
let
|
|
|
|
|
keys = import ../../../variables/keys.nix;
|
|
|
|
|
|
|
|
|
|
in {
|
2018-11-12 11:26:22 +01:00
|
|
|
|
# TASK: new device
|
2019-02-03 11:55:43 +01:00
|
|
|
|
networking.hostName = "vmd32387"; # Define your hostname.
|
|
|
|
|
networking.domain = "contaboserver.net";
|
2018-11-12 11:26:22 +01:00
|
|
|
|
|
2018-11-13 00:54:04 +01:00
|
|
|
|
networking.firewall.enable = true;
|
2018-11-18 14:44:58 +01:00
|
|
|
|
networking.firewall.allowedTCPPorts = [
|
|
|
|
|
# iperf3
|
|
|
|
|
5201
|
|
|
|
|
];
|
2019-02-03 01:46:04 +01:00
|
|
|
|
networking.firewall.logRefusedConnections = false;
|
2018-11-19 02:03:22 +01:00
|
|
|
|
|
|
|
|
|
networking.usePredictableInterfaceNames = false;
|
2019-02-03 01:46:04 +01:00
|
|
|
|
networking.dhcpcd = {
|
|
|
|
|
enable = true;
|
|
|
|
|
persistent = true;
|
|
|
|
|
};
|
|
|
|
|
|
2018-11-18 14:44:38 +01:00
|
|
|
|
networking.interfaces.eth0 = {
|
2019-02-03 01:46:04 +01:00
|
|
|
|
useDHCP = true;
|
2018-11-19 02:03:22 +01:00
|
|
|
|
ipv6.addresses = [
|
|
|
|
|
{ address = "2a02:c207:3003:2387::1"; prefixLength = 64; }
|
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
networking.defaultGateway6 = {
|
|
|
|
|
address = "fe80::1";
|
|
|
|
|
interface = "eth0";
|
2018-11-18 14:44:38 +01:00
|
|
|
|
};
|
2018-11-12 11:26:22 +01:00
|
|
|
|
|
2019-01-28 15:50:31 +01:00
|
|
|
|
networking.nat = {
|
|
|
|
|
enable = true;
|
|
|
|
|
internalInterfaces = [ "ve-+" ];
|
|
|
|
|
externalInterface = "eth0";
|
|
|
|
|
};
|
|
|
|
|
|
2018-11-12 11:26:22 +01:00
|
|
|
|
# Kubernetes
|
|
|
|
|
# services.kubernetes.roles = ["master" "node"];
|
|
|
|
|
|
|
|
|
|
# virtualization
|
|
|
|
|
virtualisation = {
|
|
|
|
|
docker.enable = true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
services.spice-vdagentd.enable = true;
|
|
|
|
|
services.qemuGuest.enable = true;
|
2019-02-11 11:31:46 +01:00
|
|
|
|
|
|
|
|
|
systemd.services."sshd-status" = {
|
|
|
|
|
enable = true;
|
|
|
|
|
description = "sshd-status service";
|
|
|
|
|
path = [ pkgs.systemd ];
|
|
|
|
|
script = ''
|
|
|
|
|
systemctl status sshd | grep -i tasks
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2019-03-10 10:38:30 +01:00
|
|
|
|
systemd.services.sshd.serviceConfig = {
|
|
|
|
|
TasksMax = 32;
|
|
|
|
|
};
|
|
|
|
|
|
2019-02-11 11:31:46 +01:00
|
|
|
|
systemd.timers."sshd-status" = {
|
|
|
|
|
description = "Timer to trigger sshd-status periodically";
|
|
|
|
|
enable = true;
|
|
|
|
|
wantedBy = [ "timer.target" "multi-user.target" ];
|
|
|
|
|
timerConfig = {
|
|
|
|
|
OnActiveSec="5s";
|
|
|
|
|
OnUnitActiveSec="5s";
|
|
|
|
|
AccuracySec="1s";
|
|
|
|
|
Unit = "sshd-status.service";
|
|
|
|
|
};
|
|
|
|
|
};
|
2018-11-12 20:27:30 +01:00
|
|
|
|
|
2020-10-17 00:13:34 +02:00
|
|
|
|
nix.gc = {
|
|
|
|
|
automatic = true;
|
|
|
|
|
};
|
|
|
|
|
|
2018-11-12 20:27:30 +01:00
|
|
|
|
boot.initrd.network = {
|
|
|
|
|
enable = true;
|
|
|
|
|
udhcpc.extraArgs = [ "-x hostname:${config.networking.hostName}" ];
|
|
|
|
|
|
|
|
|
|
ssh = {
|
|
|
|
|
enable = true;
|
|
|
|
|
authorizedKeys = keys.users.steveej.openssh;
|
2020-10-18 20:14:11 +02:00
|
|
|
|
hostKeys = [
|
|
|
|
|
"/etc/secrets/initrd/ssh_host_rsa_key"
|
|
|
|
|
"/etc/secrets/initrd/ssh_host_ed25519_key"
|
|
|
|
|
];
|
2018-11-12 20:27:30 +01:00
|
|
|
|
};
|
|
|
|
|
};
|
2018-11-19 02:03:22 +01:00
|
|
|
|
|
|
|
|
|
boot.initrd.postMountCommands = ''
|
|
|
|
|
for iface in $(cd /sys/class/net && ls); do
|
|
|
|
|
echo "Bringing down $iface..."
|
|
|
|
|
ip address flush dev $iface
|
|
|
|
|
ip link set $iface down
|
|
|
|
|
done
|
|
|
|
|
'';
|
2019-01-28 15:50:31 +01:00
|
|
|
|
|
2020-03-16 22:24:46 +01:00
|
|
|
|
networking.useHostResolvConf = true;
|
|
|
|
|
|
2019-01-28 15:50:31 +01:00
|
|
|
|
containers = {
|
|
|
|
|
mailserver = import ../../containers/mailserver.nix {
|
|
|
|
|
hostAddress = "192.168.100.10";
|
|
|
|
|
localAddress = "192.168.100.11";
|
2020-09-15 17:21:28 +02:00
|
|
|
|
|
2020-09-14 19:38:36 +02:00
|
|
|
|
imapsPort = 993;
|
|
|
|
|
sievePort = 4190;
|
2019-01-28 15:50:31 +01:00
|
|
|
|
};
|
2019-01-28 15:50:31 +01:00
|
|
|
|
|
|
|
|
|
webserver = import ../../containers/webserver.nix {
|
|
|
|
|
hostAddress = "192.168.100.12";
|
|
|
|
|
localAddress = "192.168.100.13";
|
2020-09-15 17:21:28 +02:00
|
|
|
|
|
2020-09-14 19:38:36 +02:00
|
|
|
|
httpsPort = 443;
|
2019-01-28 15:50:31 +01:00
|
|
|
|
};
|
2019-02-08 23:52:22 +01:00
|
|
|
|
|
|
|
|
|
syncthing = import ../../containers/syncthing.nix {
|
|
|
|
|
hostAddress = "192.168.100.14";
|
|
|
|
|
localAddress = "192.168.100.15";
|
2020-09-15 17:21:28 +02:00
|
|
|
|
|
2020-09-14 19:38:36 +02:00
|
|
|
|
syncthingPort = 22000;
|
2019-02-08 23:52:22 +01:00
|
|
|
|
};
|
2019-02-10 13:51:21 +01:00
|
|
|
|
|
|
|
|
|
backup = import ../../containers/backup.nix {
|
|
|
|
|
inherit config;
|
|
|
|
|
hostAddress = "192.168.100.16";
|
|
|
|
|
localAddress = "192.168.100.17";
|
|
|
|
|
};
|
2019-01-28 15:50:31 +01:00
|
|
|
|
};
|
2020-07-16 10:59:42 +02: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 = "20.03"; # Did you read the comment?
|
2018-11-12 11:26:22 +01:00
|
|
|
|
}
|