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,
|
2023-02-26 05:44:54 +00:00
|
|
|
flake-inputs,
|
2022-10-10 13:03:08 +01:00
|
|
|
...
|
|
|
|
}: {
|
2021-04-19 00:39:33 +01:00
|
|
|
imports = [
|
2023-02-26 05:44:54 +00:00
|
|
|
flake-inputs.sops-nix.nixosModules.sops
|
|
|
|
flake-inputs.tlaternet-webserver.nixosModules.default
|
|
|
|
|
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
|
2023-04-23 15:46:38 +01:00
|
|
|
./services/foundryvtt.nix
|
2021-04-19 00:39:33 +01:00
|
|
|
./services/gitea.nix
|
|
|
|
./services/nextcloud.nix
|
|
|
|
./services/webserver.nix
|
2023-04-23 15:46:38 +01:00
|
|
|
./services/wireguard.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
|
|
|
};
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
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
|
2023-01-11 02:00:33 +00:00
|
|
|
settings.trusted-users = ["@wheel"];
|
2021-04-12 01:35:24 +01:00
|
|
|
};
|
|
|
|
|
2022-04-23 04:08:45 +01:00
|
|
|
nixpkgs.config.allowUnfreePredicate = pkg:
|
2023-01-11 02:00:33 +00:00
|
|
|
builtins.elem (lib.getName pkg) ["steam-original" "steam-runtime" "steam-run" "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;
|
|
|
|
|
2022-10-29 00:13:44 +01:00
|
|
|
firewall = {
|
|
|
|
allowedTCPPorts = [
|
|
|
|
# http
|
|
|
|
80
|
|
|
|
443
|
|
|
|
# ssh
|
|
|
|
2222
|
|
|
|
# matrix
|
|
|
|
8448
|
|
|
|
# starbound
|
|
|
|
21025
|
2023-01-11 02:00:13 +00:00
|
|
|
# Minecraft
|
|
|
|
25565
|
2022-10-29 00:13:44 +01:00
|
|
|
|
|
|
|
config.services.coturn.listening-port
|
|
|
|
config.services.coturn.tls-listening-port
|
2022-11-05 22:26:52 +00:00
|
|
|
config.services.coturn.alt-listening-port
|
|
|
|
config.services.coturn.alt-tls-listening-port
|
2022-10-29 00:13:44 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
allowedUDPPorts = [
|
2023-01-11 02:00:13 +00:00
|
|
|
# More minecraft
|
|
|
|
25565
|
|
|
|
|
2022-10-29 00:13:44 +01:00
|
|
|
config.services.coturn.listening-port
|
|
|
|
config.services.coturn.tls-listening-port
|
2022-11-05 22:26:52 +00:00
|
|
|
config.services.coturn.alt-listening-port
|
|
|
|
config.services.coturn.alt-tls-listening-port
|
2022-10-29 00:13:44 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
allowedUDPPortRanges = [
|
|
|
|
{
|
|
|
|
from = config.services.coturn.min-port;
|
|
|
|
to = config.services.coturn.max-port;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2021-04-12 01:35:24 +01:00
|
|
|
};
|
|
|
|
|
2023-04-23 15:46:38 +01:00
|
|
|
systemd.network.enable = true;
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2022-11-05 17:59:27 +00:00
|
|
|
security = {
|
|
|
|
sudo.execWheelOnly = true;
|
|
|
|
|
|
|
|
pam = {
|
|
|
|
enableSSHAgentAuth = true;
|
|
|
|
services.sudo.sshAgentAuth = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
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";
|
|
|
|
}
|