2021-04-12 01:35:24 +01:00
|
|
|
{
|
2022-10-29 00:13:44 +01:00
|
|
|
config,
|
2022-10-10 13:03:08 +01:00
|
|
|
pkgs,
|
|
|
|
lib,
|
2022-10-13 00:03:32 +01:00
|
|
|
modulesPath,
|
2022-10-10 13:03:08 +01:00
|
|
|
...
|
|
|
|
}: {
|
2021-04-19 00:39:33 +01:00
|
|
|
imports = [
|
2022-10-13 00:03:32 +01:00
|
|
|
"${modulesPath}/profiles/headless.nix"
|
2022-10-30 17:43:52 +00:00
|
|
|
"${modulesPath}/profiles/minimal.nix"
|
2022-10-13 00:03:32 +01:00
|
|
|
(import ../modules)
|
|
|
|
|
2022-10-21 20:48:14 +01:00
|
|
|
./services/conduit.nix
|
2021-04-19 00:39:33 +01:00
|
|
|
./services/gitea.nix
|
|
|
|
./services/nextcloud.nix
|
|
|
|
./services/webserver.nix
|
2022-04-23 04:08:45 +01:00
|
|
|
./services/starbound.nix
|
2022-10-12 18:04:06 +01:00
|
|
|
./services/postgres.nix
|
2022-10-12 02:03:22 +01:00
|
|
|
./sops.nix
|
2021-04-19 00:39:33 +01:00
|
|
|
];
|
2021-04-12 01:35:24 +01:00
|
|
|
|
2022-10-13 00:03:32 +01:00
|
|
|
nixpkgs.overlays = [
|
|
|
|
(final: prev: {
|
|
|
|
local = import ../pkgs {
|
|
|
|
pkgs = prev;
|
2022-10-17 11:00:02 +01:00
|
|
|
lib = prev.lib;
|
2022-10-13 00:03:32 +01:00
|
|
|
};
|
2022-10-31 16:07:41 +00:00
|
|
|
|
|
|
|
# Mitigate
|
|
|
|
# https://mta.openssl.org/pipermail/openssl-announce/2022-October/000238.html
|
|
|
|
nginxStable = prev.nginxStable.override {openssl = prev.openssl_1_1;};
|
2022-10-13 00:03:32 +01:00
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2021-04-12 01:35:24 +01:00
|
|
|
nix = {
|
|
|
|
package = pkgs.nixFlakes;
|
|
|
|
extraOptions = ''
|
|
|
|
experimental-features = nix-command flakes
|
|
|
|
'';
|
2021-04-28 00:22:21 +01:00
|
|
|
|
|
|
|
# Enable remote builds from tlater
|
2022-10-10 13:03:08 +01:00
|
|
|
trustedUsers = ["@wheel"];
|
2021-04-12 01:35:24 +01:00
|
|
|
};
|
|
|
|
|
2022-04-23 04:08:45 +01:00
|
|
|
nixpkgs.config.allowUnfreePredicate = pkg:
|
2022-10-13 00:30:07 +01:00
|
|
|
builtins.elem (lib.getName pkg) ["steam-original" "steam-runtime" "steamcmd"];
|
2022-04-23 04:08:45 +01:00
|
|
|
|
2022-10-12 01:24:54 +01:00
|
|
|
# Optimization for minecraft servers, see:
|
|
|
|
# https://bugs.mojang.com/browse/MC-183518
|
2022-10-10 13:03:08 +01:00
|
|
|
boot.kernelParams = ["highres=off" "nohz=off"];
|
2021-08-25 19:45:15 +01:00
|
|
|
|
2021-04-12 01:35:24 +01:00
|
|
|
networking = {
|
|
|
|
hostName = "tlaternet";
|
|
|
|
|
|
|
|
usePredictableInterfaceNames = false;
|
|
|
|
useDHCP = false;
|
|
|
|
interfaces.eth0.useDHCP = true;
|
|
|
|
|
2022-10-29 00:13:44 +01:00
|
|
|
firewall = {
|
|
|
|
allowedTCPPorts = [
|
|
|
|
# http
|
|
|
|
80
|
|
|
|
443
|
|
|
|
# ssh
|
|
|
|
2222
|
|
|
|
# matrix
|
|
|
|
8448
|
|
|
|
# starbound
|
|
|
|
21025
|
|
|
|
|
|
|
|
config.services.coturn.listening-port
|
|
|
|
config.services.coturn.tls-listening-port
|
|
|
|
];
|
|
|
|
|
|
|
|
allowedUDPPorts = [
|
|
|
|
config.services.coturn.listening-port
|
|
|
|
config.services.coturn.tls-listening-port
|
|
|
|
];
|
|
|
|
|
|
|
|
allowedUDPPortRanges = [
|
|
|
|
{
|
|
|
|
from = config.services.coturn.min-port;
|
|
|
|
to = config.services.coturn.max-port;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2021-04-12 01:35:24 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
time.timeZone = "Europe/London";
|
|
|
|
|
|
|
|
users.users.tlater = {
|
|
|
|
isNormalUser = true;
|
2022-10-10 13:03:08 +01:00
|
|
|
extraGroups = ["wheel"];
|
|
|
|
openssh.authorizedKeys.keyFiles = [../keys/tlater.pub];
|
2021-04-12 01:35:24 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
services.openssh = {
|
|
|
|
enable = true;
|
|
|
|
allowSFTP = false;
|
|
|
|
passwordAuthentication = false;
|
|
|
|
permitRootLogin = "no";
|
2022-10-10 13:03:08 +01:00
|
|
|
ports = [2222];
|
2021-04-12 01:35:24 +01:00
|
|
|
startWhenNeeded = true;
|
2022-10-10 13:01:26 +01:00
|
|
|
gatewayPorts = "yes";
|
2021-04-12 01:35:24 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
services.nginx = {
|
|
|
|
enable = true;
|
|
|
|
recommendedTlsSettings = true;
|
|
|
|
recommendedOptimisation = true;
|
|
|
|
recommendedGzipSettings = true;
|
|
|
|
recommendedProxySettings = true;
|
|
|
|
clientMaxBodySize = "10G";
|
2021-05-17 00:00:34 +01:00
|
|
|
domain = "tlater.net";
|
2021-04-12 01:35:24 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
security.acme = {
|
2022-10-12 19:58:09 +01:00
|
|
|
defaults.email = "tm@tlater.net";
|
2021-04-12 01:35:24 +01:00
|
|
|
acceptTerms = true;
|
|
|
|
};
|
|
|
|
|
2022-10-14 01:11:15 +01:00
|
|
|
services.fail2ban = {
|
|
|
|
enable = true;
|
|
|
|
extraPackages = [pkgs.ipset];
|
|
|
|
banaction = "iptables-ipset-proto6-allports";
|
|
|
|
bantime-increment.enable = true;
|
|
|
|
|
|
|
|
jails = {
|
|
|
|
nginx-botsearch = ''
|
|
|
|
enabled = true
|
|
|
|
logpath = /var/log/nginx/access.log
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
ignoreIP = [
|
|
|
|
"127.0.0.0/8"
|
|
|
|
"10.0.0.0/8"
|
|
|
|
"172.16.0.0/12"
|
|
|
|
"192.168.0.0/16"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2022-10-30 17:43:52 +00:00
|
|
|
# Remove some unneeded packages
|
|
|
|
environment.defaultPackages = [];
|
|
|
|
|
2021-04-12 01:35:24 +01:00
|
|
|
system.stateVersion = "20.09";
|
|
|
|
}
|