From df46627173cf7c9262c8f6736ad00cccd79b4b81 Mon Sep 17 00:00:00 2001 From: Ari Sosnovsky Date: Sun, 20 Sep 2026 20:55:17 -0400 Subject: [PATCH] some security patches + buzz updates --- hosts/hl-bigbox2.nix | 2 +- hosts/hl-fwdesk.nix | 2 +- hosts/hl-minipc1.nix | 8 ++++++-- hosts/hl-terra1.nix | 2 +- modules/core/default.nix | 6 ++---- modules/nixos/common/ABOUTME.md | 17 ++++++++++------- .../containers/container-services/ABOUTME.md | 4 ++++ .../containers/container-services/default.nix | 8 +++++--- .../containers/container-services/files.nix | 2 ++ .../containers/container-services/options.nix | 6 ++++++ .../containers/container-services/systemd.nix | 9 ++++++--- modules/nixos/common/core.nix | 1 + modules/nixos/common/networking.nix | 4 ++-- modules/nixos/common/ssh-notify.nix | 8 ++++++-- modules/nixos/common/ssh-server.nix | 16 +++++++--------- modules/nixos/desktop/ABOUTME.md | 2 ++ modules/nixos/desktop/default.nix | 1 - 17 files changed, 62 insertions(+), 36 deletions(-) diff --git a/hosts/hl-bigbox2.nix b/hosts/hl-bigbox2.nix index 94996cc..a71dbc1 100644 --- a/hosts/hl-bigbox2.nix +++ b/hosts/hl-bigbox2.nix @@ -36,8 +36,8 @@ in skyg.nixos.common.cachePush.enable = false; # firmware updater services.fwupd.enable = true; + skyg.nixos.common.networking.nfsServer.enable = true; services.nfs.server = { - enable = true; lockdPort = ports.lockdPort; mountdPort = ports.mountdPort; statdPort = ports.statdPort; diff --git a/hosts/hl-fwdesk.nix b/hosts/hl-fwdesk.nix index cb8fa82..a97353e 100644 --- a/hosts/hl-fwdesk.nix +++ b/hosts/hl-fwdesk.nix @@ -45,6 +45,7 @@ in core.qemu.enable = true; nixos = { common.ssh-server.enable = true; + common.cachePush.enable = true; common.hardware = { pipewire.enable = true; amdgpu.enable = true; @@ -118,7 +119,6 @@ in }; users.users.ari.extraGroups = [ "input" - "disk" "wheel" "tty" "dialout" diff --git a/hosts/hl-minipc1.nix b/hosts/hl-minipc1.nix index 6b389cf..7c53539 100644 --- a/hosts/hl-minipc1.nix +++ b/hosts/hl-minipc1.nix @@ -33,11 +33,13 @@ let bucket = "buzz-media"; }; # NFS-backed volume on tnas1 (repo pattern: compose volume with nfs driver_opts). + # The server must be in `device` (the local driver uses it as the mount source); + # `o = addr=...` alone is not honoured here. nfsVolume = subpath: { driver_opts = { type = "nfs"; - o = "addr=tnas1.lab.internal,rw,nfsvers=4.0,nolock,hard,noatime"; - device = ":/mnt/SmallG/buzz/${subpath}"; + o = "rw,nfsvers=4.0,nolock,hard,noatime"; + device = "tnas1.lab.internal:/mnt/SmallG/buzz/${subpath}"; }; }; in @@ -231,6 +233,8 @@ in skyg.nixos.common.container-services.buzz = { enable = true; autoUpdate.enable = true; + # Image pulls on first start / after a tag moves can exceed the 120s default. + timeoutStartSec = 600; networks = { internal = { driver = "bridge"; }; diff --git a/hosts/hl-terra1.nix b/hosts/hl-terra1.nix index c8def57..3f0bf38 100644 --- a/hosts/hl-terra1.nix +++ b/hosts/hl-terra1.nix @@ -38,8 +38,8 @@ in networking.firewall.allowedUDPPorts = openPorts; networking.firewall.allowedTCPPorts = openPorts; # NFS + skyg.nixos.common.networking.nfsServer.enable = true; services.nfs.server = { - enable = true; lockdPort = 4001; mountdPort = 4002; statdPort = 4000; diff --git a/modules/core/default.nix b/modules/core/default.nix index 6050a6c..7388656 100644 --- a/modules/core/default.nix +++ b/modules/core/default.nix @@ -73,9 +73,7 @@ } ]; nix.distributedBuilds = true; - # optional, useful when the builder has a faster internet connection than yours - nix.extraOptions = '' - builders-use-substitutes = true - ''; + # useful when the builder has a faster internet connection than yours + nix.settings.builders-use-substitutes = true; }; } diff --git a/modules/nixos/common/ABOUTME.md b/modules/nixos/common/ABOUTME.md index b4b87e6..1db2023 100644 --- a/modules/nixos/common/ABOUTME.md +++ b/modules/nixos/common/ABOUTME.md @@ -11,11 +11,11 @@ Most leaf modules expose a `skyg.nixos.common.*` enable flag and stay inert unti common/ ├── default.nix # Imports everything below + always-on env defaults ├── core.nix # System packages, nh (clean + gc), nix-ld, timezone (Toronto), locale; skyg.nixos.common.minimal -├── networking.nix # skyg.core.hostName, NetworkManager, NFS server (skyg.nixos.common.networking.nfsServer) +├── networking.nix # skyg.core.hostName, NetworkManager, NFS server opt-in (skyg.nixos.common.networking.nfsServer, default false) ├── user.nix # skyg.user.createSystemUser — creates the system user/groups + zsh shell ├── fonts.nix # System font packages + fontconfig defaults (Fira Code, Noto, …); skyg.nixos.common.fonts.minimal -├── ssh-server.nix # skyg.nixos.common.ssh-server — hardened sshd + master pubkey -├── ssh-notify.nix # skyg.nixos.common.ssh-notify — forward notify-send from SSH sessions to a desktop client +├── ssh-server.nix # skyg.nixos.common.ssh-server — hardened sshd + master public keys (list) +├── ssh-notify.nix # skyg.nixos.common.ssh-notify — forward notify-send from SSH sessions to a desktop client (RemoteForward scoped to *.lab.internal) ├── qemu.nix # skyg.core.qemu — QEMU/quickemu + SPICE guest tooling ├── binary-cache.nix # skyg.nixos.common.cachePush — push finished builds to the bigbox2 cache ├── containers/ # Docker vs Podman runtime selection + host-created container networks @@ -29,11 +29,14 @@ common/ `programs.nh` with auto-clean (`--keep-since 7d --keep 5`, overridable per host via `programs.nh.clean.extraArgs`) as the single GC mechanism — no separate cron jobs or `nix.gc.automatic`. `skyg.nixos.common.nh.flake` sets the flake path per host. -- **`networking.nix`** defines `skyg.core.hostName`, enables NetworkManager + the NFS server, - and disables the flaky `NetworkManager-wait-online` unit. +- **`networking.nix`** defines `skyg.core.hostName`, enables NetworkManager, and disables the + flaky `NetworkManager-wait-online` unit. The NFS server is **off by default** + (`skyg.nixos.common.networking.nfsServer.enable = false`); only hosts that export shares + opt in. - **`user.nix`** creates the actual system user (in `wheel` + `networkmanager`) with zsh as the login shell; gated by `skyg.user.createSystemUser` (default `true`). -- **`ssh-server.nix`** ships the master public key and a hardened sshd config +- **`ssh-server.nix`** ships the master public keys (`masterPubKeys`, a list so a key can be + rotated by adding the new one before dropping the old) and a hardened sshd config (key-only auth, long keepalives). Disabled by default. ## Option Namespace @@ -48,7 +51,7 @@ skyg.nixos.common.cachePush.* → binary-cache.nix skyg.nixos.common.minimal → core.nix (skip heavy always-on system packages) skyg.nixos.common.nh.flake → core.nix (flake path for 'nh os' commands, set per host) skyg.nixos.common.fonts.minimal → fonts.nix (install only a minimal font set) -skyg.nixos.common.networking.nfsServer → networking.nix (enable/disable the NFS server) +skyg.nixos.common.networking.nfsServer → networking.nix (enable/disable the NFS server, default false) skyg.nixos.common.containers.* → containers/ skyg.nixos.common.hardware.* → hardware/ skyg.nixos.common.pritunl.* → pritunl/ diff --git a/modules/nixos/common/containers/container-services/ABOUTME.md b/modules/nixos/common/containers/container-services/ABOUTME.md index f9b8883..1a117c5 100644 --- a/modules/nixos/common/containers/container-services/ABOUTME.md +++ b/modules/nixos/common/containers/container-services/ABOUTME.md @@ -44,6 +44,10 @@ If adding a new per-service option: - Each group gets **one** systemd unit (`container-services-.service`) that manages the whole stack - Group units are ordered after `container-networks.target`, so any network declared in `skyg.nixos.common.containers.networks` exists before a stack starts +- Each unit puts the runtime CLI (`pkgs.podman`/`pkgs.docker`) and `coreutils` on `PATH`: + `podman-compose` shells out to a bare `podman`, and NixOS systemd services do not inherit + `/run/current-system/sw/bin` (Docker worked without this only because `docker-compose` v2 + talks to the socket directly) - Custom files are collected and written by a separate unit (`container-services--files.service`) - Env file changes trigger a path unit that restarts the stack (`container-services--env-reload.*`) - Compose files are rendered to the store and staged to `/var/lib/container-services//compose.yml` diff --git a/modules/nixos/common/containers/container-services/default.nix b/modules/nixos/common/containers/container-services/default.nix index b07bb36..dd91db1 100644 --- a/modules/nixos/common/containers/container-services/default.nix +++ b/modules/nixos/common/containers/container-services/default.nix @@ -13,6 +13,8 @@ let composeBin = containerLib.composeBin containersCfg.runtime; runtimeService = containerLib.runtimeService isDocker; runtimeBin = containerLib.runtimeBin isDocker; + # Put the runtime CLI on each unit's PATH (podman-compose shells out to `podman`). + runtimePkg = if isDocker then pkgs.docker else pkgs.podman; enabledGroups = lib.filterAttrs (_: g: g.enable) cfg; autoUpdateGroups = lib.filterAttrs (_: g: g.autoUpdate.enable) enabledGroups; @@ -82,7 +84,7 @@ in in lib.nameValuePair "container-services-${groupName}" - (systemdLib.mkSystemdService groupName grpCfg effectiveComposeFile overridesFile composeBin runtimeService hasFiles)) + (systemdLib.mkSystemdService groupName grpCfg effectiveComposeFile overridesFile composeBin runtimeService runtimePkg hasFiles)) enabledGroups // lib.foldAttrs lib.recursiveUpdate { } ( lib.mapAttrsToList @@ -102,7 +104,7 @@ in ) // lib.mapAttrs' (groupName: grpCfg: - let units = systemdLib.mkUpdateUnits groupName grpCfg (mkOverridesFileFor groupName grpCfg) composeBin runtimeBin; + let units = systemdLib.mkUpdateUnits groupName grpCfg (mkOverridesFileFor groupName grpCfg) composeBin runtimeBin runtimePkg; in lib.nameValuePair "container-services-${groupName}-update" units.services."container-services-${groupName}-update") autoUpdateGroups; @@ -119,7 +121,7 @@ in systemd.timers = lib.mapAttrs' (groupName: grpCfg: - let units = systemdLib.mkUpdateUnits groupName grpCfg (mkOverridesFileFor groupName grpCfg) composeBin runtimeBin; + let units = systemdLib.mkUpdateUnits groupName grpCfg (mkOverridesFileFor groupName grpCfg) composeBin runtimeBin runtimePkg; in lib.nameValuePair "container-services-${groupName}-update" units.timers."container-services-${groupName}-update") autoUpdateGroups; }; diff --git a/modules/nixos/common/containers/container-services/files.nix b/modules/nixos/common/containers/container-services/files.nix index 0bd8660..fe11410 100644 --- a/modules/nixos/common/containers/container-services/files.nix +++ b/modules/nixos/common/containers/container-services/files.nix @@ -74,6 +74,8 @@ rec { "container-services-${groupName}-files" = { description = "Write custom files for container service group '${groupName}'"; before = [ "container-services-${groupName}.service" ]; + # The script uses bare mkdir/cat/chmod/dirname, so coreutils must be on PATH. + path = [ pkgs.coreutils ]; serviceConfig = { Type = "oneshot"; ExecStart = scriptFile; diff --git a/modules/nixos/common/containers/container-services/options.nix b/modules/nixos/common/containers/container-services/options.nix index c34da96..d5fc7ac 100644 --- a/modules/nixos/common/containers/container-services/options.nix +++ b/modules/nixos/common/containers/container-services/options.nix @@ -30,6 +30,12 @@ description = "Seconds to wait for 'compose down' before forcibly killing containers."; }; + timeoutStartSec = lib.mkOption { + type = lib.types.int; + default = 120; + description = "Seconds to wait for 'compose up -d' (image pulls included) before the unit is considered failed."; + }; + composeFile = lib.mkOption { type = lib.types.nullOr lib.types.str; default = null; diff --git a/modules/nixos/common/containers/container-services/systemd.nix b/modules/nixos/common/containers/container-services/systemd.nix index 48b7b9c..b7aa0d3 100644 --- a/modules/nixos/common/containers/container-services/systemd.nix +++ b/modules/nixos/common/containers/container-services/systemd.nix @@ -2,7 +2,8 @@ { # Create a systemd oneshot service that manages the compose stack. - mkSystemdService = groupName: grpCfg: composeFile: overridesFile: composeBin: runtimeService: hasFiles: + # `runtimePkg` is put on PATH because podman-compose shells out to `podman`. + mkSystemdService = groupName: grpCfg: composeFile: overridesFile: composeBin: runtimeService: runtimePkg: hasFiles: let stateDir = grpCfg.stateDir; fileServiceDep = if hasFiles then "container-services-${groupName}-files.service" else null; @@ -25,12 +26,13 @@ ++ lib.optional hasFiles fileServiceDep; requires = [ runtimeService ] ++ lib.optional hasFiles fileServiceDep; + path = [ runtimePkg pkgs.coreutils ]; startLimitIntervalSec = 300; # 5 minutes window startLimitBurst = 6; # allow 6 failures before giving up serviceConfig = { Restart = "on-failure"; RestartSec = "15s"; - TimeoutStartSec = "120s"; + TimeoutStartSec = grpCfg.timeoutStartSec; Type = "oneshot"; RemainAfterExit = true; TimeoutStopSec = grpCfg.timeoutStopSec; @@ -44,7 +46,7 @@ }; # Create the update service + timer for a group's autoUpdate config. - mkUpdateUnits = groupName: grpCfg: overridesFile: composeBin: runtimeBin: + mkUpdateUnits = groupName: grpCfg: overridesFile: composeBin: runtimeBin: runtimePkg: let auCfg = grpCfg.autoUpdate; stateDir = grpCfg.stateDir; @@ -60,6 +62,7 @@ description = "Pull latest images and recreate container service group '${groupName}'"; after = [ "container-services-${groupName}.service" ]; requires = [ "container-services-${groupName}.service" ]; + path = [ runtimePkg pkgs.coreutils ]; serviceConfig = { Type = "oneshot"; ExecStart = diff --git a/modules/nixos/common/core.nix b/modules/nixos/common/core.nix index fb8042f..a6aeaa7 100644 --- a/modules/nixos/common/core.nix +++ b/modules/nixos/common/core.nix @@ -21,6 +21,7 @@ nixpkgs.config.allowUnfree = true; nix = { optimise.automatic = true; + optimise.dates = [ "weekly" ]; settings.experimental-features = [ "nix-command" "flakes" ]; }; programs.nh = { diff --git a/modules/nixos/common/networking.nix b/modules/nixos/common/networking.nix index 25795b9..a56f5fa 100644 --- a/modules/nixos/common/networking.nix +++ b/modules/nixos/common/networking.nix @@ -12,9 +12,9 @@ in }; skyg.nixos.common.networking = { nfsServer.enable = lib.mkOption { - description = "Enable the NFS server (services.nfs.server)."; + description = "Enable the NFS server (services.nfs.server). Off by default; opt in on hosts that export shares."; type = lib.types.bool; - default = true; + default = false; }; }; }; diff --git a/modules/nixos/common/ssh-notify.nix b/modules/nixos/common/ssh-notify.nix index ab11166..950963e 100644 --- a/modules/nixos/common/ssh-notify.nix +++ b/modules/nixos/common/ssh-notify.nix @@ -55,9 +55,13 @@ in # to the shared local listener, and tell the server-side wrapper (via # SetEnv, expanded here with the same %C the RemoteForward bind uses) # which socket to connect to. + # Scoped to lab hosts: without the Match, every outbound ssh (GitHub, + # work bastions, …) tries the forward, logs failures, and may leave a + # socket behind on hosts that accept it. programs.ssh.extraConfig = lib.mkIf isClient '' - RemoteForward ${remoteSocketPath} ${localSocketPath} - SetEnv SSH_NOTIFY_SOCK=${remoteSocketPath} + Match host *.lab.internal + RemoteForward ${remoteSocketPath} ${localSocketPath} + SetEnv SSH_NOTIFY_SOCK=${remoteSocketPath} ''; # Server: accept the SSH_NOTIFY_SOCK env var forwarded by the client diff --git a/modules/nixos/common/ssh-server.nix b/modules/nixos/common/ssh-server.nix index 8b42065..f11a56c 100644 --- a/modules/nixos/common/ssh-server.nix +++ b/modules/nixos/common/ssh-server.nix @@ -7,9 +7,11 @@ in skyg.nixos.common.ssh-server = { enable = lib.mkEnableOption "enable ssh server"; - masterPubKey = lib.mkOption { - type = lib.types.str; - default = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCuatskL9qXvgvS3E8zRwosFnpcN0f8PkKl8syAvpn297V2iPk6mi8yK3EE7xPpxaKKlwUuBHDj3BNUCoLgdRFKUgroRDzr3BMm+gZTHy6CuEZBY9zBRTmH+aOV6FZ96QPW4zba0BW5YPkPNy/FhYibjpXyZ3nX4/LWSbPKQJ7wTnUJZgq4VFmevBOttvhzUJUgTziMFsGXn6I38fAi6LI8qwI+zOOdsNjtKgr/TIlO/7VqcH7GYnQEwlthl577sDd1V6+XWz649qoiBYyq0Ahm09dwYx2iGQwLo8IYFbSy4aJRK/PI0+ytnPBoF5QCl+ILb5E8uV3e6Wb9WpXl9Hv2iLx91/9iq5hykHPnfVtkq3MK0C2vqkvX1qFOIkKM7vmxvXGbaDZDGK3G+/zkQ7GUw8ydbl9wGwE9cKbm9miqs4w2Ry/+3IZasE6G2TI97bSzSYInQd2RwoglqBOaJojbUqgI9wvNdKxGhADNFbZah2+s6SSe1ByQRN3b9wtmqu0= ari@shared"; + masterPubKeys = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCuatskL9qXvgvS3E8zRwosFnpcN0f8PkKl8syAvpn297V2iPk6mi8yK3EE7xPpxaKKlwUuBHDj3BNUCoLgdRFKUgroRDzr3BMm+gZTHy6CuEZBY9zBRTmH+aOV6FZ96QPW4zba0BW5YPkPNy/FhYibjpXyZ3nX4/LWSbPKQJ7wTnUJZgq4VFmevBOttvhzUJUgTziMFsGXn6I38fAi6LI8qwI+zOOdsNjtKgr/TIlO/7VqcH7GYnQEwlthl577sDd1V6+XWz649qoiBYyq0Ahm09dwYx2iGQwLo8IYFbSy4aJRK/PI0+ytnPBoF5QCl+ILb5E8uV3e6Wb9WpXl9Hv2iLx91/9iq5hykHPnfVtkq3MK0C2vqkvX1qFOIkKM7vmxvXGbaDZDGK3G+/zkQ7GUw8ydbl9wGwE9cKbm9miqs4w2Ry/+3IZasE6G2TI97bSzSYInQd2RwoglqBOaJojbUqgI9wvNdKxGhADNFbZah2+s6SSe1ByQRN3b9wtmqu0= ari@shared" + ]; }; }; }; @@ -30,11 +32,7 @@ in settings.MaxSessions = 64; settings.MaxStartups = "64:30:128"; }; - users.users.${config.skyg.user.name}.openssh.authorizedKeys.keys = [ - cfg.masterPubKey - ]; - users.users.root.openssh.authorizedKeys.keys = [ - cfg.masterPubKey - ]; + users.users.${config.skyg.user.name}.openssh.authorizedKeys.keys = cfg.masterPubKeys; + users.users.root.openssh.authorizedKeys.keys = cfg.masterPubKeys; }; } diff --git a/modules/nixos/desktop/ABOUTME.md b/modules/nixos/desktop/ABOUTME.md index 59765ea..20a0372 100644 --- a/modules/nixos/desktop/ABOUTME.md +++ b/modules/nixos/desktop/ABOUTME.md @@ -50,6 +50,8 @@ skyg.nixos.desktop.fixes.* → fixes/ ## Notes +- The desktop user's `extraGroups` deliberately **excludes `disk`**: raw block-device access + is equivalent to root and nothing here needs it. Do not re-add it. - The old `packages.nix`, `wayland.nix`, and `x11/` modules were folded into `default.nix`: the desktop apps and Xorg/XWayland now install only in full (non-slim) mode. - Tiler app groups (`control`, `gnome`, `media`) and Hyprland shell `tools` are opt-in — see diff --git a/modules/nixos/desktop/default.nix b/modules/nixos/desktop/default.nix index c5eda21..7d75144 100644 --- a/modules/nixos/desktop/default.nix +++ b/modules/nixos/desktop/default.nix @@ -10,7 +10,6 @@ let environment.sessionVariables.NIXOS_OZONE_WL = "1"; users.users.${skygUser.name}.extraGroups = [ "input" - "disk" "wheel" "tty" "dialout"