2023-08-05 12:04:12 +01:00
|
|
|
{
|
2024-02-05 13:13:44 +00:00
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: {
|
|
|
|
imports = [
|
|
|
|
# Include the results of the hardware scan.
|
|
|
|
./hardware.nix
|
|
|
|
];
|
|
|
|
|
2023-08-05 12:04:12 +01:00
|
|
|
boot = {
|
|
|
|
tmp.cleanOnBoot = true;
|
|
|
|
};
|
|
|
|
zramSwap.enable = true;
|
|
|
|
|
|
|
|
nix = {
|
|
|
|
settings = {
|
|
|
|
auto-optimise-store = true;
|
|
|
|
experimental-features = ["nix-command" "flakes"];
|
|
|
|
};
|
|
|
|
gc = {
|
|
|
|
automatic = true;
|
|
|
|
dates = "weekly";
|
|
|
|
options = "--delete-older-than 30d";
|
|
|
|
};
|
|
|
|
# Free up to 1GiB whenever there is less than 100MiB left.
|
|
|
|
extraOptions = ''
|
|
|
|
min-free = ${toString (100 * 1024 * 1024)}
|
|
|
|
max-free = ${toString (1024 * 1024 * 1024)}
|
2024-02-05 13:13:44 +00:00
|
|
|
'';
|
2023-08-05 12:04:12 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
networking = {
|
2024-01-10 19:06:54 +00:00
|
|
|
hostName = "stream";
|
2023-08-05 12:04:12 +01:00
|
|
|
domain = "gmem.ca";
|
|
|
|
firewall = {
|
|
|
|
trustedInterfaces = ["tailscale0"];
|
|
|
|
checkReversePath = "loose";
|
2024-02-05 13:13:44 +00:00
|
|
|
allowedTCPPorts = [80 443 1935];
|
2023-08-05 12:04:12 +01:00
|
|
|
allowedUDPPortRanges = [
|
2024-02-05 13:13:44 +00:00
|
|
|
{
|
|
|
|
from = 4000;
|
|
|
|
to = 4007;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
from = 8000;
|
2024-06-07 14:51:18 +01:00
|
|
|
to = 8900;
|
2024-02-05 13:13:44 +00:00
|
|
|
}
|
2023-08-05 12:04:12 +01:00
|
|
|
];
|
2024-02-05 13:13:44 +00:00
|
|
|
allowedUDPPorts = [41641 1935];
|
2023-08-05 12:04:12 +01:00
|
|
|
enable = true;
|
|
|
|
};
|
|
|
|
nftables.enable = true;
|
2024-02-05 13:13:44 +00:00
|
|
|
nameservers = ["1.1.1.1" "1.0.0.1"];
|
2023-08-05 12:04:12 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
time.timeZone = "Europe/London";
|
|
|
|
|
|
|
|
users.users.root.openssh.authorizedKeys.keys = let
|
|
|
|
authorizedKeys = pkgs.fetchurl {
|
|
|
|
url = "https://gmem.ca/ssh";
|
2023-09-05 17:10:55 +01:00
|
|
|
sha256 = "0vm0q5fzx55mmgw7md430c20rvywmknmpvnkffx9szlm0l74bypc";
|
2023-08-05 12:04:12 +01:00
|
|
|
};
|
2024-02-05 13:13:44 +00:00
|
|
|
in
|
|
|
|
pkgs.lib.splitString "\n" (builtins.readFile
|
|
|
|
authorizedKeys);
|
2023-08-05 12:04:12 +01:00
|
|
|
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
vim
|
|
|
|
wget
|
|
|
|
htop
|
|
|
|
git
|
|
|
|
screen
|
|
|
|
nix-output-monitor
|
|
|
|
tailscale
|
|
|
|
nfs-utils
|
|
|
|
];
|
|
|
|
|
|
|
|
services = {
|
|
|
|
rpcbind.enable = true;
|
|
|
|
openssh.enable = true;
|
|
|
|
tailscale.enable = true;
|
2024-01-10 19:06:54 +00:00
|
|
|
owncast = {
|
2024-06-07 14:51:18 +01:00
|
|
|
enable = false;
|
2024-01-10 19:06:54 +00:00
|
|
|
port = 8080;
|
|
|
|
openFirewall = false;
|
|
|
|
};
|
2024-06-07 14:51:18 +01:00
|
|
|
mediamtx = {
|
|
|
|
enable = true;
|
|
|
|
settings = {
|
|
|
|
rtmp = false;
|
|
|
|
pathDefaults.srtPublishPassphrase = "thisisntforyoutouse";
|
|
|
|
paths = {
|
|
|
|
eufuria = {
|
|
|
|
srtPublishPassphrase = "beckiiscute";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-08-05 12:04:12 +01:00
|
|
|
nginx = {
|
|
|
|
enable = true;
|
|
|
|
recommendedProxySettings = true;
|
|
|
|
recommendedGzipSettings = true;
|
|
|
|
recommendedBrotliSettings = true;
|
|
|
|
recommendedZstdSettings = true;
|
|
|
|
recommendedOptimisation = true;
|
|
|
|
recommendedTlsSettings = true;
|
|
|
|
virtualHosts = {
|
2024-01-10 19:06:54 +00:00
|
|
|
"stream.gmem.ca" = {
|
2023-08-05 12:04:12 +01:00
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
|
|
|
locations."/" = {
|
2024-01-10 19:06:54 +00:00
|
|
|
proxyPass = "http://127.0.0.1:8080";
|
|
|
|
proxyWebsockets = true;
|
2024-02-05 13:13:44 +00:00
|
|
|
|
|
|
|
extraConfig = ''
|
2023-08-15 09:11:46 +01:00
|
|
|
client_max_body_size 100M;
|
2024-01-10 19:06:54 +00:00
|
|
|
proxy_pass_header Authorization;
|
2024-02-05 13:13:44 +00:00
|
|
|
'';
|
2023-08-05 12:04:12 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
security.acme = {
|
|
|
|
acceptTerms = true;
|
2023-09-05 17:10:55 +01:00
|
|
|
defaults = {
|
|
|
|
email = "acme@gmem.ca";
|
|
|
|
};
|
2023-08-05 12:04:12 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
system.stateVersion = "23.11"; # dId YoU rEaD tHe CoMmEnT?
|
|
|
|
}
|