diff --git a/deploy/iso.nix b/deploy/iso.nix index 8064b8d..3be1457 100644 --- a/deploy/iso.nix +++ b/deploy/iso.nix @@ -131,7 +131,7 @@ in ''; }); - # Smaller: no firmware (a VM needs none, 800M+), docs, git, RAID or memtest. + # Smaller: no firmware (a VM needs none, 800M+), docs, RAID or memtest. hardware.enableRedistributableFirmware = lib.mkForce false; documentation = { enable = lib.mkForce false; @@ -140,7 +140,6 @@ in info.enable = lib.mkForce false; nixos.enable = lib.mkForce false; }; - programs.git.enable = lib.mkForce false; environment.defaultPackages = lib.mkForce [ ]; boot.swraid.enable = lib.mkForce false; boot.loader.grub.memtest86.enable = lib.mkForce false; @@ -163,6 +162,9 @@ in # Lets the VPS panel see the installer's address. services.qemuGuest.enable = true; + # No channel here (channel.nix is off): without this NIX_PATH still names root's + # channels, and every lookup warns that they do not exist. is the flake's. + nix.channel.enable = false; nix.settings.experimental-features = [ "nix-command" "flakes" @@ -179,6 +181,7 @@ in programs.fish.enable = true; users.defaultUserShell = pkgs.fish; programs.vim.enable = true; + programs.git.enable = true; environment.systemPackages = [ installer (pkgs.callPackage ./net-rescue.nix { }) diff --git a/deploy/server-module.nix b/deploy/server-module.nix index 48d7de5..807061c 100644 --- a/deploy/server-module.nix +++ b/deploy/server-module.nix @@ -82,7 +82,8 @@ in default = true; description = '' Admin comforts: fish as the login shell, vim next to nano (still the default - editor), and htop, tmux, jq, mtr, iftop, dig and ncdu. + editor), and git, htop, tmux, jq, mtr, iftop, dig, ncdu, iperf3, tcpdump, + bandwhich, nload, lsof and nvd. ''; }; @@ -282,6 +283,27 @@ in "flakes" ]; + # A small disk left alone for months: old generations, store duplicates and logs are + # cleaned up, not collected until it is full. + nix.gc = { + automatic = lib.mkDefault true; + dates = lib.mkDefault "weekly"; + options = lib.mkDefault "--delete-older-than 14d"; + }; + nix.optimise.automatic = lib.mkDefault true; + boot.loader.grub.configurationLimit = lib.mkDefault 10; + services.journald.settings.Journal.SystemMaxUse = lib.mkDefault "200M"; + + # Password logins on a public address: repeated failures get the address banned + # (the sshd jail follows sshPort), for longer each time it comes back. + services.fail2ban = { + enable = lib.mkDefault true; + bantime-increment.enable = lib.mkDefault true; + }; + + # Traffic per day and month, against the plan's quota: vnstat -m. + services.vnstat.enable = lib.mkDefault true; + security.acme = { acceptTerms = true; defaults.email = cfg.acmeEmail; @@ -376,14 +398,22 @@ in pkgs.iftop pkgs.dig pkgs.ncdu + pkgs.iperf3 + pkgs.tcpdump + pkgs.nload + pkgs.lsof + pkgs.nvd ]; programs = lib.mkIf cfg.tools.enable { fish.enable = true; # Next to nano, which stays the default editor. vim.enable = true; + git.enable = true; tmux.enable = true; mtr.enable = true; + # Bandwidth per process and connection, without sudo (a capability wrapper). + bandwhich.enable = true; }; users.defaultUserShell = lib.mkIf cfg.tools.enable pkgs.fish; diff --git a/docs/usage/server.md b/docs/usage/server.md index 1cc5c2c..89567c7 100644 --- a/docs/usage/server.md +++ b/docs/usage/server.md @@ -16,8 +16,11 @@ the VPS from it. The console installer asks for the public IP, users, an optiona domain, whether to run the QEMU guest agent (so the VPS panel sees the server's state) and the disk to erase, then installs NixOS with `nixosModules.server`: VLESS REALITY, TLS and WS listeners, ACME certificates and SSH, with fish as the login shell -and vim (nano stays the default editor), htop, tmux, jq, mtr, iftop, dig and ncdu -(`services.proxy-suite-server.tools`). +and vim (nano stays the default editor), git, htop, tmux, jq, mtr, iftop, dig, ncdu, +iperf3, tcpdump, bandwhich, nload, lsof and nvd (`services.proxy-suite-server.tools`). +It also collects Nix garbage weekly (generations older than 14 days, 10 boot entries at +most), caps the journal at 200M, bans addresses that keep failing SSH logins (fail2ban), +and counts traffic per day and month (`vnstat -m`); each is a NixOS default to override. It installs the proxy-suite source the ISO carries: `/etc/nixos` follows this repository on GitHub when the ISO's commit is there, and holds a copy otherwise. The disk is laid out by disko (`services.proxy-suite-server.disko`): btrfs with `compress=zstd:3`, subvolumes `@` on `/`, diff --git a/nix/checks/server-module.nix b/nix/checks/server-module.nix index 5754170..749e525 100644 --- a/nix/checks/server-module.nix +++ b/nix/checks/server-module.nix @@ -182,6 +182,16 @@ in (ok (ipServer.config.users.defaultUserShell.pname == "fish")) (ok (ipServer.config.users.users.admin.shell.pname == "fish")) (ok (ipServer.config.programs.vim.enable && ipServer.config.programs.nano.enable)) + (ok (ipServer.config.programs.git.enable && !plainServer.config.programs.git.enable)) + # Upkeep: garbage collection, a journal cap, fail2ban on the SSH port, vnstat. + (ok (ipServer.config.nix.gc.automatic && ipServer.config.nix.optimise.automatic)) + (ok (ipServer.config.boot.loader.grub.configurationLimit == 10)) + (ok (ipServer.config.services.journald.settings.Journal.SystemMaxUse == "200M")) + (ok ( + ipServer.config.services.fail2ban.enable + && (mkServer { sshPort = 2222; }).config.services.fail2ban.jails.sshd.settings.port == "2222" + )) + (ok ipServer.config.services.vnstat.enable) (ok (ipServer.config.environment.variables.EDITOR == "nano")) (ok (!plainServer.config.programs.fish.enable && !plainServer.config.programs.vim.enable)) # The console banner names the server and the admin account, interpolated: an escaped