tlaternet-server/configuration/default.nix

148 lines
3 KiB
Nix
Raw Normal View History

{
2022-10-29 00:13:44 +01:00
config,
pkgs,
lib,
modulesPath,
...
}: {
imports = [
"${modulesPath}/profiles/headless.nix"
2022-10-30 17:43:52 +00:00
"${modulesPath}/profiles/minimal.nix"
(import ../modules)
2022-10-21 20:48:14 +01:00
./services/conduit.nix
./services/gitea.nix
./services/nextcloud.nix
./services/webserver.nix
2022-04-23 04:08:45 +01:00
./services/starbound.nix
./services/postgres.nix
./sops.nix
];
nixpkgs.overlays = [
(final: prev: {
local = import ../pkgs {
pkgs = prev;
2022-10-17 11:00:02 +01:00
lib = prev.lib;
};
# Mitigate
# https://mta.openssl.org/pipermail/openssl-announce/2022-October/000238.html
nginxStable = prev.nginxStable.override {openssl = prev.openssl_1_1;};
})
];
nix = {
package = pkgs.nixFlakes;
extraOptions = ''
experimental-features = nix-command flakes
'';
# Enable remote builds from tlater
trustedUsers = ["@wheel"];
};
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
# Optimization for minecraft servers, see:
# https://bugs.mojang.com/browse/MC-183518
boot.kernelParams = ["highres=off" "nohz=off"];
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;
}
];
};
};
time.timeZone = "Europe/London";
users.users.tlater = {
isNormalUser = true;
extraGroups = ["wheel"];
openssh.authorizedKeys.keyFiles = [../keys/tlater.pub];
};
services.openssh = {
enable = true;
allowSFTP = false;
passwordAuthentication = false;
permitRootLogin = "no";
ports = [2222];
startWhenNeeded = true;
gatewayPorts = "yes";
};
services.nginx = {
enable = true;
recommendedTlsSettings = true;
recommendedOptimisation = true;
recommendedGzipSettings = true;
recommendedProxySettings = true;
clientMaxBodySize = "10G";
domain = "tlater.net";
};
security.acme = {
defaults.email = "tm@tlater.net";
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 = [];
system.stateVersion = "20.09";
}