{ config, pkgs, ... }: { imports = [ # Include the results of the hardware scan. ./hardware.nix ]; 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)} ''; }; networking = { hostName = "nix-cache"; domain = "gmem.ca"; firewall = { trustedInterfaces = ["tailscale0"]; checkReversePath = "loose"; allowedTCPPorts = [ 80 443 ]; allowedUDPPortRanges = [ { from = 4000; to = 4007; } { from = 8000; to = 8010; } ]; allowedUDPPorts = [ 41641 ]; enable = true; }; nftables.enable = true; nameservers = [ "1.1.1.1" "1.0.0.1" ]; }; time.timeZone = "Europe/London"; users.users.root.openssh.authorizedKeys.keys = let authorizedKeys = pkgs.fetchurl { url = "https://gmem.ca/ssh"; sha256 = "0iwrm80hsadr0midy0h3da4x0sbci76a92g8f9wnz5pj38gimdi9"; }; in pkgs.lib.splitString "\n" (builtins.readFile authorizedKeys); 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; nix-serve = { enable = true; secretKeyFile = "/var/cache-priv-key.pem"; }; nginx = { enable = true; recommendedProxySettings = true; recommendedGzipSettings = true; recommendedBrotliSettings = true; recommendedZstdSettings = true; recommendedOptimisation = true; recommendedTlsSettings = true; virtualHosts = { "nix-cache.gmem.ca" = { enableACME = true; forceSSL = true; locations."/".proxyPass = "http://${config.services.nix-serve.bindAddress}:${toString config.services.nix-serve.port}"; }; "git.gmem.ca" = { enableACME = true; forceSSL = true; locations."/" = { proxyPass = "http://100.116.48.47"; extraConfig = '' client_max_body_size 100M; ''; }; }; }; }; }; security.acme = { acceptTerms = true; email = "acme@gmem.ca"; }; system.copySystemConfiguration = true; system.stateVersion = "23.11"; # dId YoU rEaD tHe CoMmEnT? }