Compare commits

...
14 Commits
Author SHA1 Message Date
Ryan Yin 9fbed400dc docs(agents): note dsh patch-row name matching and missing service tier
Assisted-by: DeepSeek Harness (deepseek-flash)
2026-11-21 13:55:51 +08:00
Ryan Yin 7576a30c87 fix(youko): probe transmission over TCP to avoid its brute-force lockout
Assisted-by: DeepSeek Harness (claude-opus-5-5)
2026-11-21 13:54:24 +08:00
ryan4yin | 二花 8cb31f449e docs(aquamarine): llama-swap runs as a systemd user unit (#537)
Assisted-by: DeepSeek Harness (claude-opus-5-5)
2026-11-20 14:18:11 +08:00
ryan4yin | 二花 1bc8d252a6 feat(aquamarine): join the friends' tailnet (#536)
Assisted-by: DeepSeek Harness (claude-opus-5-5)
2026-11-20 14:06:00 +08:00
ryan4yin | 二花 a9d38491f0 feat(git): sign commits with the CanoKey OpenPGP key, reuse SSH 30 s (#535)
* feat(ssh): reuse every connection for 30 s to save touches

Assisted-by: DeepSeek Harness (claude-opus-5-5)

* feat(git): sign commits with the OpenPGP key on the CanoKeys

Assisted-by: DeepSeek Harness (claude-opus-5-5)
Assisted-by: DeepSeek Harness (claude-fable-5-2)

* flake.lock: Update

Flake lock file updates:

• Updated input 'mysecrets':
    'git+ssh://git@github.com/ryan4yin/nix-secrets.git?ref=refs/heads/main&rev=6ab2a713e5938e1bb8ef2d33acab632ba0bd5331&shallow=1' (2026-11-11)
  → 'git+ssh://git@github.com/ryan4yin/nix-secrets.git?ref=refs/heads/main&rev=eba74369427e98b0246f6f0f35e80ddcc6808995&shallow=1' (2026-11-19)
2026-11-19 22:56:41 +08:00
Ryan Yin 2c3db10bf0 fix(youko): enlarge the nix cache proxy upstream keepalive pool
Assisted-by: DeepSeek Harness (claude-opus-5-5)
2026-11-17 23:57:25 +08:00
Ryan Yin ac3f775efa chore(nix): drop the nixVersions.latest override
Assisted-by: DeepSeek Harness (claude-opus-5-5)
2026-11-17 23:39:58 +08:00
Ryan Yin 480c486ea2 fix(youko): reuse upstream TLS connections in the nix cache proxy
Assisted-by: DeepSeek Harness (claude-opus-5-5)
2026-11-17 23:25:56 +08:00
Ryan Yin 6ca74dcd86 chore(niri): drop the xdg-desktop-portal-wlr 0.8.2 pin
Assisted-by: DeepSeek Harness (claude-opus-5-5)
2026-11-17 23:20:08 +08:00
ryan4yin | 二花 7e28766a37 chore(flake): pin microvm and nixos-apple-silicon, update home-manager (#534)
* chore(flake): pin microvm and nixos-apple-silicon to reviewed commits

Assisted-by: DeepSeek Harness (claude-opus-5-5)

* flake.lock: Update

Flake lock file updates:

• Updated input 'home-manager':
    'github:nix-community/home-manager/095fef2f265c3c0da4fe315efba8f8a04495ab34?narHash=sha256-X6xa6sGA7RnJQuZGbFMC%2BK%2BKToWAlBDCCjJXfTwEPsw%3D' (2026-10-28)
  → 'github:nix-community/home-manager/5b76c5b8eec25fdbce4f43309b3ee10584374a26?narHash=sha256-hMI9Xg%2BlxS8kbnxIxL/jPQn688dstoxQAcMEbCb1ax0%3D' (2026-11-17)
2026-11-17 23:09:24 +08:00
Ryan Yin 6bd97ddf98 fix(monitoring): require exporter sockets from their services
Assisted-by: DeepSeek Harness (claude-opus-5-5)
2026-11-17 22:43:59 +08:00
ryan4yin | 二花 f02b06563e chore(aquamarine): drop nixos-unstable-small for the NPU stack (#533)
* flake.lock: Update
* chore(aquamarine): drop nixos-unstable-small for the NPU stack
* docs(workarounds): drop removed rows

Assisted-by: DeepSeek Harness (claude-opus-5-5)
2026-11-17 22:39:59 +08:00
ryan4yin | 二花 6b425fe036 feat(monitoring): close host and service monitoring gaps (#530)
Assisted-by: DeepSeek Harness (claude-opus-5-5)
2026-11-17 21:08:02 +08:00
ryan4yin | 二花 667fd76cac feat(nixos): Nix store hygiene, PostgreSQL dumps, OOM and backup quotas (#532)
Assisted-by: DeepSeek Harness (claude-opus-5-5)
2026-11-17 21:07:39 +08:00
46 changed files with 851 additions and 208 deletions

No files matched your search

+5
View File
@@ -72,4 +72,9 @@ extend-ignore-re = [
# "for"/"far"/"fps".
"fpr",
"FPR",
# PCIe Advanced Error Reporting (rasdaemon's `aer` collector and metrics); the
# dictionary wants "are".
"aer",
"AER",
]
+22 -9
View File
@@ -25,7 +25,11 @@ How this fleet is backed up, where the data lives, and how to restore it.
automatic retention it needs. A compromised desktop can still `forget --prune` its own repository
through the REST API, so youko also snapshots `/data/backups` hourly into a read-only btrfs
subvolume the desktop cannot reach (see
`hosts/12kingdoms-youko/homelab-services/restic-server-snapshots.nix`).
`hosts/12kingdoms-youko/homelab-services/restic-server-snapshots.nix`). The REST store has one
512 GiB quota (`--max-size`) shared by all repositories, so a runaway client cannot fill the HDD
pool it shares with `/data/apps` and `/data/fileshare`; at the quota, uploads fail with HTTP 507
and the client's backup-failure alert fires. youko's own repository (`/data/backups/restic`) is
written directly, outside the quota.
3. **cloud copy** (planned). youko will copy the homelab repositories with `restic copy` (it holds
that password). Desktops copy their own: youko does not hold the desktop password. This layer is
what protects history against a compromised host, so the target should be immutable or versioned
@@ -60,15 +64,17 @@ Consequences worth remembering:
Slots are assigned per host; the random delay only smooths load and must not be relied on to prevent
collisions.
| Time | Job |
| ---------------- | ----------------------------------- |
| 01:30 + 15m | desktops push to youko |
| 02:30 + 15m | youko backs itself up |
| hourly | youko snapshots the REST store |
| 03:45:20 Tue/Sat | btrbk local snapshots |
| 06:00 (planned) | youko copies homelab repos to cloud |
| Time | Job |
| ---------------- | -------------------------------------------- |
| 01:30 + 15m | desktops push to youko |
| 02:30 + 15m | youko dumps PostgreSQL, then backs itself up |
| hourly | youko snapshots the REST store |
| 03:45:20 Tue/Sat | btrbk local snapshots |
| 04:00-05:00, 1st | btrfs scrub on the physical servers |
| 06:00 (planned) | youko copies homelab repos to cloud |
Set per host via `modules.restic-backup.onCalendar` and `randomizedDelaySec`.
Set per host via `modules.restic-backup.onCalendar` and `randomizedDelaySec`. The scrub row is a
start window: reading youko's HDDs (about 2.7 TiB used) takes hours, past the 06:00 slot.
## What is never backed up
@@ -129,6 +135,12 @@ Restoring a btrbk snapshot (offline; stop writers first):
- Units: `systemctl status restic-backups-homelab`, `systemctl list-timers 'restic-backups*'`.
- Repository integrity (where the password is): `restic check`, which runs after every backup via
`modules.restic-backup.checkOpts` (a 5% data read, `1/20`, by default).
- PostgreSQL on youko: `postgresqlBackup.service` runs before every `restic-backups-homelab` run and
writes `pg_dumpall` output to `/var/lib/postgresql-backup/all.sql.zstd` (the previous dump is kept
as `all.prev.sql.zstd`). Restore into an empty cluster with
`zstd -dc all.sql.zstd | sudo -u postgres psql -X postgres`. A failed dump does not block the
backup; it shows up as a failed unit.
- REST store quota: `restic-rest-server` logs `Quota initialized, currently using N GiB` at start.
- Server side, ciphertext only: repository directories under `/data/backups/rest-server/<user>/`,
with no leftover files in `locks/` and no stale `.tmp` files.
- `restic-rest-server`'s log must not print `Invalid htpasswd entry`: that means the client's REST
@@ -158,6 +170,7 @@ Restoring a btrbk snapshot (offline; stop writers first):
| [`modules/nixos/base/btrbk.nix`](../modules/nixos/base/btrbk.nix) | local btrfs snapshots |
| `hosts/12kingdoms-youko/default.nix` | the REST server and youko's own backup |
| `hosts/12kingdoms-youko/homelab-services/restic-server-snapshots.nix` | hourly read-only snapshots of the REST store |
| `hosts/12kingdoms-youko/homelab-services/postgresql.nix` | the PostgreSQL dump taken before youko's backup |
| `hosts/12kingdoms-youko/homelab-services/caddy.nix` | the `restic.writefor.fun` vhost |
| `secrets/nixos.nix` | which secret is defined on which host |
| `hosts/idols-ai/restic.nix`, `hosts/12kingdoms-youko/default.nix` | per-host backup configuration |
+15 -4
View File
@@ -36,16 +36,16 @@ small, reversible controls and narrow exceptions; benchmark before adopting expe
| Boundary | Current design | Limitation |
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Administration | Key-based SSH; root key login retained for Colmena/MicroVM deployment; only keys declared in Nix are honoured, and no password or keyboard-interactive login; remote-builder host keys only reach `nix-daemon` | Deployment credentials are root-equivalent file keys, usable by any same-user process through the desktop SSH agent; one stolen key reaches every host |
| Host network | Shared nftables firewall trusts the home LAN, tailnet interface and local Podman bridge; IPv6 link-local is accepted | These are broad trust zones, not service-level least privilege; router exposure and tailnet ACLs require separate verification |
| Host network | Shared nftables firewall trusts the home LAN, tailnet interface and local Podman bridge; IPv6 link-local is accepted | These are broad trust zones, not service-level least privilege; router exposure and tailnet ACLs require separate verification; aquamarine also joins a tailnet shared with friends, which reaches its wildcard-bound sockets (see its README) |
| Monitoring | node/smartctl exporters bind the host LAN IPv4 (9100/9633); firewall rules restrict exporter ports 9100, 9835 and 9633 to the monitoring host over IPv4. RAPL counters are exposed only on x86 server hosts, to `node-exporter` through the `rapl` group. | nvidia_gpu_exporter (9835) still binds wildcard; the IPv6 denial for those three ports is in the shared firewall; current running hosts require separate verification. The node_exporter account can measure package energy for local side channels; interactive users, desktops, and guests keep the kernel-default root-only permission. |
| VM hosts | shoryu, shushou and youko run guests behind `br0`; ruby/kana are libvirt guests | A bridge is not network isolation; host compromise affects its guests |
| k3s | Three control-plane and three worker MicroVMs; Cilium, API VIP and NFS CSI | Cluster-admin, privileged/host-mounted pods and writable NFS data are powerful trust boundaries |
| MicroVM storage | Host store shared read-only through virtiofs; guest `/etc`, `/var` and `/home` persisted in separate images | Read-only store does not isolate the host-side virtiofs implementation or protect writable guest state |
| Desktop apps | Selected apps use nixpak/bubblewrap; Podman is rootless | Rules and shared directories vary per app; user namespaces are needed for these sandboxes |
| Security keys | idols-ai/shoukei use a CanoKey for touch-based sudo (pam_u2f, password fallback; servers via pam_rssh and the forwarded agent), a resident `ed25519-sk` SSH key per CanoKey as the only user SSH keys for GitHub and all hosts, FIDO2 LUKS unlock on shoukei and on-card OpenPGP subkeys; key management happens only in the phone app ([setup](./security-keys.md)) | Touch-only sudo can be triggered by any same-user process, and on a server by root through the forwarded agent; losing both CanoKeys leaves only root logins with the `romantic` recovery key |
| Security keys | idols-ai/shoukei use a CanoKey for touch-based sudo (pam_u2f, password fallback; servers via pam_rssh and the forwarded agent), a resident `ed25519-sk` SSH key per CanoKey as the only user SSH keys for GitHub and all hosts, FIDO2 LUKS unlock on shoukei and on-card OpenPGP subkeys; key management happens only in the phone app ([setup](./security-keys.md)) | Touch-only sudo can be triggered by any same-user process, and on a server by root through the forwarded agent; losing both CanoKeys leaves only root logins with the `romantic` recovery key; an OpenPGP touch and an SSH connection each stay usable by same-user processes for 30 s |
| Secrets | agenix declarations here, encrypted data in the private nix-secrets repository | Recipients and plaintext file permissions must be reviewed; root on a recipient can read its decrypted secrets |
| Supply chain | Locked flake inputs; explicit binary-cache trust keys on NixOS; normal user is not a Nix trusted-user | A trusted cache or imported Nix module can supply code executed as root; a lock file is not a security audit |
| Recovery | NixOS generations, btrbk/restic, hourly read-only snapshots of the REST store, and documented backup procedures | A rollback does not undo compromised data or secrets; backup configuration alone does not prove restore works; the offsite immutable copy is still planned |
| Recovery | NixOS generations with automatic boot fallback on the physical servers, btrbk/restic, hourly read-only snapshots of the REST store, and documented backup procedures | A rollback does not undo compromised data or secrets; backup configuration alone does not prove restore works; the offsite immutable copy is still planned |
Sources: [host layout](../hosts/README.md), [k3s deployment](../hosts/k8s/README.md),
[firewall](../modules/nixos/base/networking/firewall.nix), [SSH](../modules/nixos/base/ssh.nix),
@@ -102,6 +102,12 @@ an advisory and affected kernel versions before adding CVE claims; search snippe
key enrollment and actual Secure Boot state with `sbctl status`; do not assume all hosts have it.
- Secure Boot, signed boot images, kernel lockdown and module signature enforcement are distinct
controls. Test custom kernels and NVIDIA/out-of-tree modules before extending enforcement.
- A failed initrd on the physical servers opens a root shell after the root password
(`boot.initrd.systemd.emergencyAccess`, the public hash in [vars](../vars/default.nix)). It adds
no protection on shoryu, shushou and youko: Secure Boot is off, the systemd-boot editor is on and
TPM2 unlocks LUKS on PCRs 0+7 alone, so console access already grants root through a kernel
command-line edit. aquamarine's Lanzaboote stub ignores command-line edits while Secure Boot is
on.
- AppArmor is enabled, but the only explicit policy, sudo's, is in complain mode. Complain mode logs
rather than blocks. Existing FHS-oriented abstractions need Nix store path review; this is not
broad enforced application confinement.
@@ -400,6 +406,11 @@ compatibility, and a generation change that only affects the initrd, modules or
kernel path unchanged. Guest profiles and a runner staged only on a MicroVM's physical host require
separate verification.
Physical hosts run this comparison for the kernel, initrd and kernel modules every 15 minutes and
export the result as `node_reboot_required`
([monitoring.nix](../modules/nixos/base/monitoring.nix)); `HostRequiresReboot` warns when a reboot
has been pending for a day.
## Remaining prioritized TODOs
| Priority | Work | Acceptance / constraints |
@@ -410,7 +421,7 @@ separate verification.
| P1 | Review router mappings and tailnet ACLs; narrow service exposure where warranted | Audit was limited to sampled host listeners; test intended and denied access without locking out deployment |
| P1 | Review NFS client scope and root identity requirements | Restrict to required VM hosts/CSI nodes where practical; test provisioning, permissions and existing PVCs before changing squash semantics |
| P1 | Narrow operator/secret access where justified; finish permission checks | Selected effective probes and ai/youko modes audited; validate broad secret-reader needs, remaining hosts and recipient scope; Darwin per-file ownership is now explicit and needs a runtime check |
| P1 | Adopt the documented cadence and verify the booted kernel after rollouts | Routine documented; compare booted and selected kernel paths and recheck API/workloads after reboot; no automated metric is deployed |
| P1 | Adopt the documented cadence and verify the booted kernel after rollouts | Routine documented; physical hosts export `node_reboot_required` to `HostRequiresReboot`; guests still need the manual check; recheck API/workloads after reboot |
| P1 | Exercise backup restore and credential rotation | Use an approved isolated restore target and recovery access; never overwrite live data for a drill |
| P2 | Promote selected AppArmor profiles to enforce; harden exposed systemd services | Per-app positive/negative tests, store-path coverage, reviewed capabilities and reversible rollout |
| P2 | Maintain ai boot integrity and assess other host roles | Review sbctl configuration migration, recovery boot and signed custom/NVIDIA modules; ai Secure Boot state already verified |
+29 -31
View File
@@ -16,42 +16,40 @@ obsolete workarounds get rolled back instead of lingering.
A version or revision pinned for a reason that can go away.
| ID | What & where | Why | Removal condition | Added | Revisit | Status |
| ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | ---------- | ------------------------------------- | ------ |
| WA-004 | `catppuccin` on `main` — `flake.nix` | `main` carries the nodejs→nodejs-slim deprecation fix, which is not in a release | Switch to a release tag once it includes the fix | 2026-09-25 | on catppuccin release | active |
| WA-006 | `nixpkgs-blender` — `flake.nix` | Blender 5.2 LTS + CUDA/OptiX pin; keeps `just up` from triggering a full source rebuild | Bump deliberately when needed; drop the pin if the current nixpkgs build is acceptable | 2026-07-24 | deliberate | active |
| WA-020 | `fcitx5-vinput` pinned to release tag `v2.4.2` — `flake.nix`; consumer `home/linux/gui/base/vinput/default.nix` | Tracks a release tag instead of a branch, so `just up` stays on that release | Bump to a newer release tag when its changes are wanted | 2026-10-04 | on vinput release | active |
| WA-021 | `nix-x86-on-aarch64` input — our fork of rowanG077's patched FEX + muvm runtime — `flake.nix`; `hosts/12kingdoms-shoukei/game/` | FEX does not support 16K pages, so x86/x86_64 apps and games on shoukei need this pinned flake's 4K-page microVM runtime; our fork lets upstream changes be reviewed before use | Drop once FEX supports 16K pages directly, or nixpkgs/nixos-apple-silicon ships an equivalent runtime | 2026-10-07 | on FEX/nixpkgs/muvm update | active |
| WA-023 | `nix.package = pkgs.nixVersions.latest` — `modules/nixos/base/nix.nix` | NixOS is opted into Nix 2.35 (2.35.3), which nixpkgs ships as `nixVersions.latest`, while `nixVersions.stable` is still 2.34 (2.34.9) | Drop the override and fall back to the default `pkgs.nix` once `nixVersions.stable` is 2.35 or newer | 2026-10-07 | eval warning | active |
| WA-037 | `nixpkgs-small` input on `nixos-unstable-small`, which carries [NixOS/nixpkgs#570230](https://github.com/NixOS/nixpkgs/pull/570230) — `flake.nix`; consumer `pkgs-small` in `outputs/default.nix`, the `intel-npu-driver` overlay in `hosts/idols-aquamarine/hardware-intel-cpu.nix`, and the Python env in `hosts/idols-aquamarine/asr/default.nix` | The Intel NPU compiler, and the driver change that loads it, are not in `nixos-unstable` yet; `openvino-genai` 2026.4.0.0 failed to build there | Drop the overlay once #570230 reaches `nixos-unstable`; drop the input once `openvino-genai` also builds there | 2026-10-17 | when #570230 reaches `nixos-unstable` | active |
| ID | What & where | Why | Removal condition | Added | Revisit | Status |
| ------ | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ---------- | -------------------------- | ------ |
| WA-004 | `catppuccin` on `main` — `flake.nix` | `main` carries the nodejs→nodejs-slim deprecation fix, which is not in a release | Switch to a release tag once it includes the fix | 2026-09-25 | on catppuccin release | active |
| WA-006 | `nixpkgs-blender` — `flake.nix` | Blender 5.2 LTS + CUDA/OptiX pin; keeps `just up` from triggering a full source rebuild | Bump deliberately when needed; drop the pin if the current nixpkgs build is acceptable | 2026-07-24 | deliberate | active |
| WA-020 | `fcitx5-vinput` pinned to release tag `v2.4.2` — `flake.nix`; consumer `home/linux/gui/base/vinput/default.nix` | Tracks a release tag instead of a branch, so `just up` stays on that release | Bump to a newer release tag when its changes are wanted | 2026-10-04 | on vinput release | active |
| WA-021 | `nix-x86-on-aarch64` input — our fork of rowanG077's patched FEX + muvm runtime — `flake.nix`; `hosts/12kingdoms-shoukei/game/` | FEX does not support 16K pages, so x86/x86_64 apps and games on shoukei need this pinned flake's 4K-page microVM runtime; our fork lets upstream changes be reviewed before use | Drop once FEX supports 16K pages directly, or nixpkgs/nixos-apple-silicon ships an equivalent runtime | 2026-10-07 | on FEX/nixpkgs/muvm update | active |
## Workarounds
A setting that works around a bug or a hardware quirk.
| ID | What & where | Why | Removal condition | Added | Revisit | Status |
| ------ | --------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | --------------------------------------------------------------------------------------------------- | ------- |
| WA-009 | USB-SATA bridge mitigations (`usbcore.autosuspend=-1`, `usb-storage.delay_use=10`) — `hosts/12kingdoms-youko/default.nix` | flaky JMicron JMS567 resets with UDMA-CRC and I/O errors | Drop once the bridge/controller is replaced; the signal is smartctl CRC/media errors | 2026-09-21 | on hardware change or CRC errors | active |
| WA-010 | Insta360 Link reset-resume quirk (`usbcore.quirks=2e1a:4c01:b`) — `hosts/idols-ai/default.nix` | the camera stays enumerated with a stalled UVC endpoint after resume | Drop after the Insta360 firmware or the kernel `uvcvideo` fixes it | 2026-08-01 | on kernel or firmware change | active |
| WA-011 | Kernel module blacklist (`esp4`, `esp6`, `rxrpc`) — `hardening/kernel-hardening.nix` | attack surface for the Dirty Frag LPE (CVE-2026-43284 / CVE-2026-43500) | Kept as defence in depth; drop only if something needs those modules | 2026-10-03 | rarely | active |
| WA-018 | user-owned `~/.ssh/config` + disabled systemd ssh-proxy include — `home/base/tui/ssh.nix`, `modules/nixos/base/ssh.nix` | bwrap exposes root-owned store files as `nobody` | Drop once sandboxes preserve store ownership | 2026-10-06 | when sandbox layout changes | active |
| WA-019 | DW-Proton for Steam and umu — `hardening/nixpaks/modules/gaming-policy.nix`, `hardening/nixpaks/umu.nix`, `modules/nixos/desktop/gaming.nix` | ACE games fail on GE/mainline Proton, work with DW-Proton | Drop once mainline or GE-Proton runs these games (GE-Proton#433) | 2026-10-07 | on Proton/GE bump | active |
| WA-024 | Wi-Fi power saving disabled (`networking.networkmanager.wifi.powersave = false`) — `hosts/12kingdoms-shoukei/apple-silicon.nix` | On this BCM4378/brcmfmac laptop, powersave is a common source of intermittent ASSOC-REJECT / authentication-timeout failures; NetworkManager then mistakes the failure for a bad key, re-prompts, and the client (Noctalia, nmtui, nmcli) saves the answer as a duplicate `<SSID> 1` profile | Drop once the kernel carries the brcmfmac `port_authorized` fix (WA-025) and no association failures remain | 2026-10-07 | watch `journalctl -u wpa_supplicant` for ASSOC-REJECT / authentication timeout | active |
| WA-026 | guest deploys run `installOnHost` then `systemctl restart microvm@<guest>` on the physical host — `Justfile`, `lib/genMicrovmGuestModule.nix` | this is the fallback that microvm.nix's own `microvm.deploy.rebuild` uses when it cannot switch in place (`doc/src/ssh-deploy.md`), so only the in-place switch is lost: its sshSwitch step runs `nix-store --load-db` against the guest's read-only virtiofs `/nix/store` and dies on `cannot remount "/nix/store" writable` (nix 2.35) | Switch guests in place with sshSwitch once microvm.nix or nix handles a read-only store. Until then, note that a host activation re-links `/var/lib/microvms/<guest>/current` to the runner baked into the host's system, so switch the host after installing a guest from a newer tree | 2026-10-09 | on microvm.nix or nix bump | active |
| WA-028 | GitHub SSH pinned to IPv4 (`AddressFamily = "inet"`) — `home/base/tui/ssh.nix` | a v6 fake AAAA for `ssh.github.com` from the `2001:2::/64` pool (WA-029) is not proven on the 443 SSH tunnel yet | Drop once the v6 fake-ip pool is proven for GitHub SSH | 2026-10-10 | on a mihomo bump or a v6 pool change | active |
| WA-029 | mihomo `fake-ip-range6` is `2001:2::/64`, not the shipped ULA default — `modules/nixos/desktop/networking/mihomo/generate.nu` | the default `fdfe:dcba:9876::/64` sits in `fc00::/7`, which Local Network Access calls local, so a public page loaded over the v4 fake pool and pulling a dual-stack subresource prompts for local-network access (Chrome 154, Firefox). The same range also stalled ssh: a session to a fake AAAA authenticated and then never closed, on both `gvisor` and `mips`. `2001:2::/48` is RFC 5180 benchmarking -- the v6 twin of the `198.18.0.0/15` v4 default, absent from that table -- and both symptoms went with the move | Go back to the upstream default once mihomo ships a pool outside the LNA non-public table; the ULA default brings the ssh stall back | 2026-10-09 | on a browser or mihomo bump -- that table already grew to cover `2001:db8::/32` and `198.18.0.0/15` | active |
| WA-030 | mihomo unit sets `SKIP_SYSTEM_IPV6_CHECK=1` — `modules/nixos/desktop/networking/mihomo/default.nix` | mihomo checks at startup whether another NIC already holds an IPv6 address and, finding none, skips the TUN's v6 half -- but `strict-route` still installs its v6 blackhole (`ip -6 rule add priority 9000 unreachable`). On a cold boot that rule lands before networkd's Router Solicitation is answered, so the host can never send RS/NS, never gets a GUA, and mihomo never re-checks: self-locking until the core restarts. The env var forces the TUN v6 address up, which installs mihomo's normal v6 rules whose `lookup main suppress_prefixlength 0` keeps on-link neighbor discovery and the RA default route off the TUN | Drop once mihomo either re-runs the IPv6 check or skips the v6 strict-route blackhole when the v6 TUN is disabled | 2026-10-10 | on a mihomo bump | active |
| WA-031 | `iommu=pt` kernel parameter — `hosts/idols-aquamarine/hardware-amd-gpu.nix` | ROCm's system requirements warn that multi-GPU systems may need IOMMU passthrough to prevent application hangs, and this host has two Radeon AI PRO R9700 cards. Added before the first inference run; not yet observed on gfx1201. | Drop once a ROCm release states that the default IOMMU mode is safe for multi-GPU gfx1201, or when the host runs a single GPU | 2026-10-13 | on a ROCm bump, or on the first hang report | active |
| WA-032 | `amdgpu.runpm=0` kernel parameter — `hosts/idols-aquamarine/hardware-amd-gpu.nix` | this board's DSDT advertises ATPX power control (`\_SB.PC00.GFX0.ATPX`) but never defines the `PEG0.PEGP._OFF`/`_ON` symbols its body calls, so the first idle resume of the headless R9700 leaves it in `runtime_status = error` (`resume of IP block <smu> failed -62`) until reboot, and amdgpu discards the ACPI error. Root cause, kernel-source trail and the measured field comparison: `hosts/idols-aquamarine/ROCM.md`. | Drop once a BIOS update defines those ACPI methods (upstream releases 1023/1066 exist for this board; a flash changes PCR7, so re-enroll TPM2), or a kernel release stops trusting ATPX when its power methods are missing | 2026-10-14 | on a BIOS update or kernel bump | active |
| WA-036 | catppuccin eval-time ports kept in the home closure (`home.extraDependencies`) — `home/base/core/theme.nix` | catppuccin/nix reads some ports at eval time (`lib.importTOML "${sources.starship}/<flavor>.toml"`) and inlines the result, so the built port, catppuccin's build/install hooks and the fetched port source stay unreachable: every gc deletes them, and the deploy after it rebuilds them (build logs: 2026-10-16). `home.extraDependencies` records the port in the generation, which is a gc root. Also read at eval time upstream: `bottom`, `element` (option `element-desktop`), `firefox`, `rio`, `palette` (options `skim`, `tty`), `spotify-player`. | Drop once catppuccin/nix stops reading port files at eval time, or those ports come from a binary cache | 2026-10-16 | on a catppuccin bump | active |
| WA-039 | niri's NVIDIA free-buffer pool bounded (`GLVidHeapReuseRatio` 0) — `hosts/idols-ai/hardware-nvidia.nix` | the driver does not return freed vidmem buffers to its free pool, so niri's VRAM grows to ~1.1 GiB instead of the ~100 MiB its NVIDIA notes expect (measured 1137 MiB after 24 h uptime; [NVIDIA/egl-wayland#126](https://github.com/NVIDIA/egl-wayland/issues/126)) | Drop once a driver stops growing niri's VRAM without the profile, or niri ships its own default | 2026-10-19 | on an nvidia driver bump | active |
| WA-041 | Monitor OSD "no-signal auto power-off" disabled — no code in this repo (the P32A2V OSD setting) | during a DPMS-off idle the panel drops and re-adds HPD every ~13 s, and after wake niri keeps scanning out while the panel stays dark until the monitor is power cycled; the panel's own auto power-off drives that state, so it is now disabled. Pinning the mode to 120 Hz did not change the symptom | Drop once a driver retrains the DP link after a DPMS wake, the monitor firmware stops cycling HPD, or this monitor is replaced | 2026-10-21 | confirm on the next full idle cycle, then on an nvidia or monitor firmware update | active |
| WA-042 | Colmena nodes set `system.nixos.versionSuffix` and `revision` from the flake's lib — `outputs/default.nix` (`rawColmenaHive`) | Colmena evaluates each node with nixpkgs' `eval-config.nix` and plain lib, which reports `26.11pre-git`, so without the override a Colmena deploy differs from the `nixosConfigurations` toplevel; the `colmena-parity` eval test guards the match | Drop once Colmena evaluates nodes with the flake's lib or accepts `nixosConfigurations` directly, keeping `colmena-parity` green | 2026-10-21 | on a colmena bump | active |
| WA-046 | xdg-desktop-portal-wlr pinned to 0.8.2 — `modules/nixos/desktop/xdg.nix` | niri's GNOME ScreenCast path exposes only DMA-BUF with modifiers, which Zoom 7.2.1 rejects; xdg-desktop-portal-wlr 0.8.2 provides the working SHM path, while 0.8.4 regresses Zoom's SelectSources. | Drop once niri's ScreenCast path works with Zoom or xdg-desktop-portal-wlr 0.8.4+ is fixed. | 2026-10-31 | eval assertion, or on a Zoom update | active |
| WA-048 | Nixpak GUI fontconfig comes from the host — `hardening/nixpaks/modules/desktop-base.nix` | Nixpak normally generates a standalone `/etc/fonts` and font package list for each sandbox; that bypasses the host `defaultFonts` and made browser chrome, Telegram, QQ and other sandboxed apps choose a different CJK fallback from the host. The wrapper now disables Nixpak fonts and bind-mounts `/etc/static/fonts` at `/etc/fonts`, so sandboxed GUI apps reuse the host font packages and family preferences through the already-mounted `/nix/store`. | Drop once Nixpak can directly reuse the host fontconfig or no longer overrides `/etc/fonts`, then remove the bind and restore the library-supported configuration path | 2026-11-01 | on a nixpak update | active |
| WA-049 | none — superseded by pointing `npmRegistryOverrides` at a mirror whose path avoids the join (`outputs/default.nix`) | nixpkgs joins an `npmRegistryOverrides` mirror's path (`/` for a bare host) with the request path, so `fetchNpmDeps` requests `https://registry.npmmirror.com//<pkg>`, which npmmirror answers with 404 (npmjs tolerates `//`); every npm-deps fetch that misses the binary caches fails. Only `fetchNpmDeps` (fixed-output) gets the patched copy: `npmConfigHook` is a build input of every npm package, so patching the shared `prefetch-npm-deps` would change all their output paths | Drop once nixpkgs' `prefetch-npm-deps/src/util.rs` joins the paths without doubling the slash | 2026-11-03 | on a nixpkgs bump | removed |
| WA-050 | polkit agent-helper sandbox opened for pam_u2f — `modules/nixos/desktop/canokey.nix` | nixpkgs relaxes `polkit-agent-helper@`'s `PrivateDevices`/`ProtectHome` for pam_u2f only when the global `security.pam.u2f.enable` is set; this repo enables U2F per service (sudo, polkit-1) so other PAM services keep the password, and without the override pam_u2f cannot reach `/dev/hidraw*` and polkit silently falls back to the password | Drop once nixpkgs' `polkit.nix` also checks per-service `u2f.enable` | 2026-11-09 | on a nixpkgs bump | active |
| WA-051 | Steam on the raw session bus, nixpak's D-Bus proxy off — `hardening/nixpaks/steam.nix` | Steam's SteamRT3 client starts pressure-vessel, which wraps any bus path other than `$XDG_RUNTIME_DIR/bus` in a second D-Bus proxy; the launcher-service RPC (`steam-runtime-launch-client --alongside-steam -- lspci`) never crosses that nesting, so the client hangs before its window with no error. On the standard path pressure-vessel binds the bus directly and Steam starts; the cost is that Steam can reach every name on the session bus | Drop once nixpak can expose its proxy at `$XDG_RUNTIME_DIR/bus` (or pressure-vessel stops nesting proxies), so the filtered bus comes back | 2026-11-14 | on a nixpak or Steam client update | active |
| ID | What & where | Why | Removal condition | Added | Revisit | Status |
| ------ | --------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | --------------------------------------------------------------------------------------------------- | ------ |
| WA-009 | USB-SATA bridge mitigations (`usbcore.autosuspend=-1`, `usb-storage.delay_use=10`) — `hosts/12kingdoms-youko/default.nix` | flaky JMicron JMS567 resets with UDMA-CRC and I/O errors | Drop once the bridge/controller is replaced; the signal is smartctl CRC/media errors | 2026-09-21 | on hardware change or CRC errors | active |
| WA-010 | Insta360 Link reset-resume quirk (`usbcore.quirks=2e1a:4c01:b`) — `hosts/idols-ai/default.nix` | the camera stays enumerated with a stalled UVC endpoint after resume | Drop after the Insta360 firmware or the kernel `uvcvideo` fixes it | 2026-08-01 | on kernel or firmware change | active |
| WA-011 | Kernel module blacklist (`esp4`, `esp6`, `rxrpc`) — `hardening/kernel-hardening.nix` | attack surface for the Dirty Frag LPE (CVE-2026-43284 / CVE-2026-43500) | Kept as defence in depth; drop only if something needs those modules | 2026-10-03 | rarely | active |
| WA-018 | user-owned `~/.ssh/config` + disabled systemd ssh-proxy include — `home/base/tui/ssh.nix`, `modules/nixos/base/ssh.nix` | bwrap exposes root-owned store files as `nobody` | Drop once sandboxes preserve store ownership | 2026-10-06 | when sandbox layout changes | active |
| WA-019 | DW-Proton for Steam and umu — `hardening/nixpaks/modules/gaming-policy.nix`, `hardening/nixpaks/umu.nix`, `modules/nixos/desktop/gaming.nix` | ACE games fail on GE/mainline Proton, work with DW-Proton | Drop once mainline or GE-Proton runs these games (GE-Proton#433) | 2026-10-07 | on Proton/GE bump | active |
| WA-024 | Wi-Fi power saving disabled (`networking.networkmanager.wifi.powersave = false`) — `hosts/12kingdoms-shoukei/apple-silicon.nix` | On this BCM4378/brcmfmac laptop, powersave is a common source of intermittent ASSOC-REJECT / authentication-timeout failures; NetworkManager then mistakes the failure for a bad key, re-prompts, and the client (Noctalia, nmtui, nmcli) saves the answer as a duplicate `<SSID> 1` profile | Drop once the kernel carries the brcmfmac `port_authorized` fix (WA-025) and no association failures remain | 2026-10-07 | watch `journalctl -u wpa_supplicant` for ASSOC-REJECT / authentication timeout | active |
| WA-026 | guest deploys run `installOnHost` then `systemctl restart microvm@<guest>` on the physical host — `Justfile`, `lib/genMicrovmGuestModule.nix` | this is the fallback that microvm.nix's own `microvm.deploy.rebuild` uses when it cannot switch in place (`doc/src/ssh-deploy.md`), so only the in-place switch is lost: its sshSwitch step runs `nix-store --load-db` against the guest's read-only virtiofs `/nix/store` and dies on `cannot remount "/nix/store" writable` (nix 2.35) | Switch guests in place with sshSwitch once microvm.nix or nix handles a read-only store. Until then, note that a host activation re-links `/var/lib/microvms/<guest>/current` to the runner baked into the host's system, so switch the host after installing a guest from a newer tree | 2026-10-09 | on microvm.nix or nix bump | active |
| WA-028 | GitHub SSH pinned to IPv4 (`AddressFamily = "inet"`) — `home/base/tui/ssh.nix` | a v6 fake AAAA for `ssh.github.com` from the `2001:2::/64` pool (WA-029) is not proven on the 443 SSH tunnel yet | Drop once the v6 fake-ip pool is proven for GitHub SSH | 2026-10-10 | on a mihomo bump or a v6 pool change | active |
| WA-029 | mihomo `fake-ip-range6` is `2001:2::/64`, not the shipped ULA default — `modules/nixos/desktop/networking/mihomo/generate.nu` | the default `fdfe:dcba:9876::/64` sits in `fc00::/7`, which Local Network Access calls local, so a public page loaded over the v4 fake pool and pulling a dual-stack subresource prompts for local-network access (Chrome 154, Firefox). The same range also stalled ssh: a session to a fake AAAA authenticated and then never closed, on both `gvisor` and `mips`. `2001:2::/48` is RFC 5180 benchmarking -- the v6 twin of the `198.18.0.0/15` v4 default, absent from that table -- and both symptoms went with the move | Go back to the upstream default once mihomo ships a pool outside the LNA non-public table; the ULA default brings the ssh stall back | 2026-10-09 | on a browser or mihomo bump -- that table already grew to cover `2001:db8::/32` and `198.18.0.0/15` | active |
| WA-030 | mihomo unit sets `SKIP_SYSTEM_IPV6_CHECK=1` — `modules/nixos/desktop/networking/mihomo/default.nix` | mihomo checks at startup whether another NIC already holds an IPv6 address and, finding none, skips the TUN's v6 half -- but `strict-route` still installs its v6 blackhole (`ip -6 rule add priority 9000 unreachable`). On a cold boot that rule lands before networkd's Router Solicitation is answered, so the host can never send RS/NS, never gets a GUA, and mihomo never re-checks: self-locking until the core restarts. The env var forces the TUN v6 address up, which installs mihomo's normal v6 rules whose `lookup main suppress_prefixlength 0` keeps on-link neighbor discovery and the RA default route off the TUN | Drop once mihomo either re-runs the IPv6 check or skips the v6 strict-route blackhole when the v6 TUN is disabled | 2026-10-10 | on a mihomo bump | active |
| WA-031 | `iommu=pt` kernel parameter — `hosts/idols-aquamarine/hardware-amd-gpu.nix` | ROCm's system requirements warn that multi-GPU systems may need IOMMU passthrough to prevent application hangs, and this host has two Radeon AI PRO R9700 cards. Added before the first inference run; not yet observed on gfx1201. | Drop once a ROCm release states that the default IOMMU mode is safe for multi-GPU gfx1201, or when the host runs a single GPU | 2026-10-13 | on a ROCm bump, or on the first hang report | active |
| WA-032 | `amdgpu.runpm=0` kernel parameter — `hosts/idols-aquamarine/hardware-amd-gpu.nix` | this board's DSDT advertises ATPX power control (`\_SB.PC00.GFX0.ATPX`) but never defines the `PEG0.PEGP._OFF`/`_ON` symbols its body calls, so the first idle resume of the headless R9700 leaves it in `runtime_status = error` (`resume of IP block <smu> failed -62`) until reboot, and amdgpu discards the ACPI error. Root cause, kernel-source trail and the measured field comparison: `hosts/idols-aquamarine/ROCM.md`. | Drop once a BIOS update defines those ACPI methods (upstream releases 1023/1066 exist for this board; a flash changes PCR7, so re-enroll TPM2), or a kernel release stops trusting ATPX when its power methods are missing | 2026-10-14 | on a BIOS update or kernel bump | active |
| WA-036 | catppuccin eval-time ports kept in the home closure (`home.extraDependencies`) — `home/base/core/theme.nix` | catppuccin/nix reads some ports at eval time (`lib.importTOML "${sources.starship}/<flavor>.toml"`) and inlines the result, so the built port, catppuccin's build/install hooks and the fetched port source stay unreachable: every gc deletes them, and the deploy after it rebuilds them (build logs: 2026-10-16). `home.extraDependencies` records the port in the generation, which is a gc root. Also read at eval time upstream: `bottom`, `element` (option `element-desktop`), `firefox`, `rio`, `palette` (options `skim`, `tty`), `spotify-player`. | Drop once catppuccin/nix stops reading port files at eval time, or those ports come from a binary cache | 2026-10-16 | on a catppuccin bump | active |
| WA-039 | niri's NVIDIA free-buffer pool bounded (`GLVidHeapReuseRatio` 0) — `hosts/idols-ai/hardware-nvidia.nix` | the driver does not return freed vidmem buffers to its free pool, so niri's VRAM grows to ~1.1 GiB instead of the ~100 MiB its NVIDIA notes expect (measured 1137 MiB after 24 h uptime; [NVIDIA/egl-wayland#126](https://github.com/NVIDIA/egl-wayland/issues/126)) | Drop once a driver stops growing niri's VRAM without the profile, or niri ships its own default | 2026-10-19 | on an nvidia driver bump | active |
| WA-041 | Monitor OSD "no-signal auto power-off" disabled — no code in this repo (the P32A2V OSD setting) | during a DPMS-off idle the panel drops and re-adds HPD every ~13 s, and after wake niri keeps scanning out while the panel stays dark until the monitor is power cycled; the panel's own auto power-off drives that state, so it is now disabled. Pinning the mode to 120 Hz did not change the symptom | Drop once a driver retrains the DP link after a DPMS wake, the monitor firmware stops cycling HPD, or this monitor is replaced | 2026-10-21 | confirm on the next full idle cycle, then on an nvidia or monitor firmware update | active |
| WA-042 | Colmena nodes set `system.nixos.versionSuffix` and `revision` from the flake's lib — `outputs/default.nix` (`rawColmenaHive`) | Colmena evaluates each node with nixpkgs' `eval-config.nix` and plain lib, which reports `26.11pre-git`, so without the override a Colmena deploy differs from the `nixosConfigurations` toplevel; the `colmena-parity` eval test guards the match | Drop once Colmena evaluates nodes with the flake's lib or accepts `nixosConfigurations` directly, keeping `colmena-parity` green | 2026-10-21 | on a colmena bump | active |
| WA-046 | niri's ScreenCast routed to xdg-desktop-portal-wlr — `modules/nixos/desktop/xdg.nix` | niri's GNOME ScreenCast path exposes only DMA-BUF with modifiers, which Zoom 7.2.1 rejects; xdg-desktop-portal-wlr provides an SHM path | Drop once niri's ScreenCast path works with Zoom | 2026-10-31 | on a niri or Zoom update | active |
| WA-048 | Nixpak GUI fontconfig comes from the host — `hardening/nixpaks/modules/desktop-base.nix` | Nixpak normally generates a standalone `/etc/fonts` and font package list for each sandbox; that bypasses the host `defaultFonts` and made browser chrome, Telegram, QQ and other sandboxed apps choose a different CJK fallback from the host. The wrapper now disables Nixpak fonts and bind-mounts `/etc/static/fonts` at `/etc/fonts`, so sandboxed GUI apps reuse the host font packages and family preferences through the already-mounted `/nix/store`. | Drop once Nixpak can directly reuse the host fontconfig or no longer overrides `/etc/fonts`, then remove the bind and restore the library-supported configuration path | 2026-11-01 | on a nixpak update | active |
| WA-050 | polkit agent-helper sandbox opened for pam_u2f — `modules/nixos/desktop/canokey.nix` | nixpkgs relaxes `polkit-agent-helper@`'s `PrivateDevices`/`ProtectHome` for pam_u2f only when the global `security.pam.u2f.enable` is set; this repo enables U2F per service (sudo, polkit-1) so other PAM services keep the password, and without the override pam_u2f cannot reach `/dev/hidraw*` and polkit silently falls back to the password | Drop once nixpkgs' `polkit.nix` also checks per-service `u2f.enable` | 2026-11-09 | on a nixpkgs bump | active |
| WA-051 | Steam on the raw session bus, nixpak's D-Bus proxy off — `hardening/nixpaks/steam.nix` | Steam's SteamRT3 client starts pressure-vessel, which wraps any bus path other than `$XDG_RUNTIME_DIR/bus` in a second D-Bus proxy; the launcher-service RPC (`steam-runtime-launch-client --alongside-steam -- lspci`) never crosses that nesting, so the client hangs before its window with no error. On the standard path pressure-vessel binds the bus directly and Steam starts; the cost is that Steam can reach every name on the session bus | Drop once nixpak can expose its proxy at `$XDG_RUNTIME_DIR/bus` (or pressure-vessel stops nesting proxies), so the filtered bus comes back | 2026-11-14 | on a nixpak or Steam client update | active |
| WA-053 | rasdaemon exporter with `enabledCollectors = [ ]` — `modules/nixos/base/monitoring.nix` | nixpkgs' exporter module passes `--collector-<name>` for each listed collector, but the exporter declares its default-on `aer`, `mce` and `mc` collectors with argparse `store_false`, so the module default (all three) turns them off and nothing is exported. Passing no flags keeps them on | Drop once nixpkgs passes no flag for a default-on collector, or the exporter makes the flags enable collectors | 2026-11-17 | on the next nixpkgs bump | active |
If the KINGBANK KP260 NVMe freezes on `ai` recur (formerly WA-008, now back at the kernel's APST
defaults), restore the parameters commented out in `hosts/idols-ai/hardware-configuration.nix` —
+4 -4
View File
@@ -222,9 +222,9 @@ cannot go to a public cache.
**Current:** static `nix.buildMachines` (`modules/nixos/base/remote-builders.nix`); the plain user
is deliberately not a trusted user on the clients, though the builder host trusts its builder login;
Nix 2.35 via `nixVersions.latest` (WA-023). `auto-allocate-uids` (with `cgroups`) is already enabled
in `modules/nixos/base/nix.nix` for nixpkgs' nspawn-based tests, and the locked nixpkgs has no
`nix-servd` module or package.
Nix 2.35 from nixpkgs' default `nixVersions.stable`. `auto-allocate-uids` (with `cgroups`) is
already enabled in `modules/nixos/base/nix.nix` for nixpkgs' nspawn-based tests, and the locked
nixpkgs has no `nix-servd` module or package.
**Proposed:** `nix-servd` for scheduling, plus the `local-overlay-store` experimental feature
(`auto-allocate-uids` is already on, see Current).
@@ -548,6 +548,6 @@ header) should then be trimmed to **adopt** items only.
`services/monitoring/prometheus/exporters.nix`.
- NixOS 26.05 release notes; Nix manual, Experimental Features.
- Repo context: `docs/SECURITY.md` (trust zones and control limits), `docs/WORKAROUNDS.md` (WA-001,
WA-008, WA-009, WA-023), `modules/nixos/base/networking/mdns.nix`,
WA-008, WA-009), `modules/nixos/base/networking/mdns.nix`,
`hosts/12kingdoms-youko/homelab-services/caddy.nix`,
`hosts/12kingdoms-youko/homelab-services/README.md`.
+96 -38
View File
@@ -3,17 +3,20 @@
How the CanoKey (or a YubiKey) is set up and used on the desktops: initial setup, adding a backup
key, and recovery. Commands here are the single source; the Nix files only point to this page.
Scope: **idols-ai** and **shoukei** (`modules.desktop.canokey.enable`). frieren only shares the
GnuPG `scdaemon` setting. Servers never see a key; they only ask the forwarded agent for sudo.
Scope: **idols-ai** and **shoukei** (`modules.desktop.canokey.enable`). The macOS hosts share only
the GnuPG `scdaemon` setting and commit signing. Servers never see a key; they only ask the
forwarded agent for sudo.
## Principle
Management and use happen on different devices.
- **PCs only use the key:** WebAuthn/passkeys, sudo, SSH, LUKS unlock and OpenPGP (pass).
- **PCs only use the key:** WebAuthn/passkeys, sudo, SSH, LUKS unlock and OpenPGP (pass, commit
signing).
- **Management happens only in the phone app** (CanoKey Console on iOS/Android): every PIN change,
touch policies, application and factory reset, device settings. The CanoKey Admin PIN is never
typed on a PC; the OpenPGP Admin PIN is typed once, for `keytocard`.
typed on a PC; the OpenPGP Admin PIN only while loading a card (`keytocard` and its public key
URL).
- Sandboxed browsers see only the FIDO HID interface, never raw USB or CCID, so the WebUSB console
is unreachable from them ([hardening](../hardening/README.md)). Unsandboxed software is trusted;
if it is malicious, the PC is compromised regardless.
@@ -24,6 +27,7 @@ Management and use happen on different devices.
| sudo, polkit | [canokey.nix](../modules/nixos/desktop/canokey.nix), registrations in [vars](../vars/default.nix) `canokeyU2fKeys` | password |
| sudo via SSH | [ssh-agent-sudo.nix](../modules/nixos/server/ssh-agent-sudo.nix), keys in [vars](../vars/default.nix) `canokeySshKeys` | password |
| SSH | [ssh.nix](../home/base/tui/ssh.nix), public keys in [vars](../vars/default.nix) `mainSshAuthorizedKeys` | the other CanoKey; root also accepts the `romantic` recovery key |
| Git signing | [git-signing.nix](../home/base/gui/git-signing.nix) | the other CanoKey; `git commit --no-gpg-sign` |
| shoukei LUKS | [hardware-configuration.nix](../hosts/12kingdoms-shoukei/hardware-configuration.nix) `crypttabExtraOpts` | passphrase (prompted after 10 s) |
| pass / GPG | [gpg](../home/base/tui/gpg/default.nix) `scdaemonSettings.disable-ccid` | the age-encrypted key backup |
@@ -43,37 +47,38 @@ Who decides differs by application:
Touch is enforced only over USB; over NFC nothing asks for one (section 1.2). Once section 2 is
done:
| Operation | PIN | Touch | Decided by |
| ---------------------------------------- | -------------------------------------------------------------- | -------------------- | ----------------------------------------------------------------------------- |
| WebAuthn in browsers | FIDO2 PIN, unless the site discourages user verification | every operation | request: the site's `userVerification`; "preferred" asks for the PIN once set |
| sudo, polkit (pam-u2f) | none | every prompt | request: registration `+presence`, no `pinverification` |
| sudo on a server (pam_rssh) | none | every sudo | request: same as SSH |
| SSH login, git over SSH | none; FIDO2 PIN only for `ssh-keygen` creation and `-K` export | every new connection | request: key created without `-O verify-required`; details in [SSH](#ssh) |
| shoukei LUKS | FIDO2 PIN | every boot | request: `systemd-cryptenroll` default |
| OpenPGP decrypt (pass, browserpass) | OpenPGP PIN, once per plug-in | every decryption | key: DEC touch, cache time |
| OpenPGP sign (`pass init`, `gpg --sign`) | OpenPGP PIN, **every signature** | every signature | key: signature PIN, SIG touch, cache time |
| OpenPGP authenticate | OpenPGP PIN, once per plug-in | every use | key: AUT touch, cache time; unused, SSH uses the FIDO2 key |
| Operation | PIN | Touch | Decided by |
| ----------------------------------- | -------------------------------------------------------------- | -------------------- | ----------------------------------------------------------------------------- |
| WebAuthn in browsers | FIDO2 PIN, unless the site discourages user verification | every operation | request: the site's `userVerification`; "preferred" asks for the PIN once set |
| sudo, polkit (pam-u2f) | none | every prompt | request: registration `+presence`, no `pinverification` |
| sudo on a server (pam_rssh) | none | every sudo | request: same as SSH |
| SSH login, git over SSH | none; FIDO2 PIN only for `ssh-keygen` creation and `-K` export | every new connection | request: key created without `-O verify-required`; details in [SSH](#ssh) |
| shoukei LUKS | FIDO2 PIN | every boot | request: `systemd-cryptenroll` default |
| OpenPGP decrypt (pass, browserpass) | OpenPGP PIN, once per plug-in | cached 30 s | key: DEC touch, cache time |
| OpenPGP sign (git commit, email) | OpenPGP PIN, once per plug-in | cached 30 s | key: signature PIN, SIG touch, cache time |
| OpenPGP authenticate | OpenPGP PIN, once per plug-in | cached 30 s | key: AUT touch, cache time; unused, SSH uses the FIDO2 key |
Little here signs: git commit signing is off, and pass signs only `.gpg-id` on `pass init` (checking
that signature uses the public key, not the card).
The OpenPGP `[S]` subkey signs Git commits ([Commit signing](#commit-signing)), email and `.gpg-id`
on `pass init` (checking that signature uses the public key, not the card).
#### OpenPGP settings on the key
Stored on the CanoKey, so they follow it to every machine and survive a gpg reinstall; an OpenPGP
application reset returns them to the defaults.
| Setting | CanoKey default | Set to | Effect | Change with |
| --------------------- | ---------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| Signature PIN | forced | forced | forced: PIN for every signature. Not forced: PIN for the first signature after plug-in | `gpg --card-edit` → `admin` → `forcesig` (toggles) |
| Touch for SIG/DEC/AUT | off | on | a touch for every operation with that key, unless cached | `gpg --card-edit` → `admin` → `uif 1 on` (`2` DEC, `3` AUT) |
| Touch cache time | 0 s (no cache) | 0 s | one value for all three keys, 0–255 s: after a touch, operations within that many seconds need none. 0: every operation needs a touch | phone app; gpg has no command for it |
| PIN retries | 3 (PIN, Admin PIN, RC) | 3 | see [1.1](#11-replace-every-default-secret-first) | firmware 3.1.0+ only (1–15), and it resets the PIN and Admin PIN |
| PIN state | — | — | after one PIN entry, decrypt and authenticate need none until the key is unplugged | not configurable |
| Setting | CanoKey default | Set to | Effect | Change with |
| --------------------- | ---------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| Signature PIN | forced | not forced | forced: PIN for every signature. Not forced: PIN for the first signature after plug-in | phone app, or `gpg --card-edit` → `admin` → `forcesig` (toggles) |
| Touch for SIG/DEC/AUT | off | on | a touch for every operation with that key, unless cached | `gpg --card-edit` → `admin` → `uif 1 on` (`2` DEC, `3` AUT) |
| Touch cache time | 0 s (no cache) | 30 s | one value for all three keys, 0–255 s: after a touch, operations within that many seconds need none. 0: every operation needs a touch | phone app; gpg has no command for it |
| PIN retries | 3 (PIN, Admin PIN, RC) | 3 | see [1.1](#11-replace-every-default-secret-first) | firmware 3.1.0+ only (1–15), and it resets the PIN and Admin PIN |
| PIN state | — | — | after one PIN entry, every operation needs none until the key is unplugged (signing only when the signature PIN is not forced) | not configurable |
- Use `uif N on`, never `permanent`: a permanent touch policy cannot be turned off again, only
cleared by resetting the OpenPGP application.
- A non-zero cache time lets anything holding the gpg-agent socket (browserpass included) decrypt
silently for that window after each touch; 0 keeps one touch per decryption.
- The 30 s cache lets anything holding the gpg-agent socket (browserpass included) sign or decrypt
silently for 30 s after each touch. It buys one touch for a rebase or a burst of pass lookups; the
touch outside that window is what still stops silent use.
- Check the key: `gpg --card-status` shows `Signature PIN` and `UIF setting`, but not the cache
time.
@@ -235,9 +240,10 @@ How it works, and what the prompts mean:
- **FIDO2 PIN:** asked only when creating the credential and when exporting it with `-K`, not for
each login. Adding `-O verify-required` at creation would require the PIN for every login too.
- **Touch:** required for every new connection, including each `git push`/`fetch`. Existing sessions
and reused connections need none: LAN hosts multiplex for 30 minutes (`ControlMaster` in
[ssh.nix](../home/base/tui/ssh.nix)). A deploy that opens one connection per host needs one touch
per host.
and reused connections need none: every host and GitHub multiplex for 30 s after the last session
closes, LAN hosts for 30 minutes (`ControlMaster` in [ssh.nix](../home/base/tui/ssh.nix)). Within
that window any process running as you can open a session over the master without a touch. A
deploy that opens one connection per host needs one touch per host.
- **File passphrase:** leave it empty. Reading the file already takes your user session, and
software running as you is trusted (see [Principle](#principle)); it could also capture the
passphrase the next time you type it. A passphrase would cost one prompt per login, not per
@@ -277,18 +283,20 @@ its own GPG passphrase too: it stays protected in the tmpfs keyrings whenever a
and age's scrypt covers gpg's weaker S2K against offline guessing.
[gpg_canokey.py](../scripts/gpg_canokey.py) does each step in throwaway keyrings on tmpfs.
A new key replaces the old one outright: the old key decrypts the store once, during the switch, and
is then retired.
The key has no scheduled rotation: the subkeys cannot leave the cards, so a new key is made only
when a card is lost or the key may be compromised. A new key replaces the old one outright: the old
key decrypts the store once, during the switch, and is then retired.
**Prepare.** Nothing changes for pass yet.
1. Turn on signature and decryption touch on every CanoKey in the phone app; `card` refuses a key
without them. Decryption touch matters most: browserpass gives browsers the GPG agent socket, and
without touch a compromised browser could decrypt the whole store silently after the first PIN.
1. On every CanoKey in the phone app, turn on signature and decryption touch, set the touch cache to
30 s and the signature PIN to not forced; `card` refuses a key without both touches. Decryption
touch matters most: browserpass gives browsers the GPG agent socket, and without touch a
compromised browser could decrypt the whole store silently after the first PIN.
2. Create the key, with two backup drives mounted:
```bash
python3 scripts/gpg_canokey.py generate --uid '<name> (pass) <address>' \
python3 scripts/gpg_canokey.py generate --uid '<name> <address>' \
--dest /run/media/$USER/<drive-1> --dest /run/media/$USER/<drive-2> \
--public-key ~/codes/nix-secrets/public/<name>.pub
```
@@ -302,12 +310,14 @@ is then retired.
3. Load each CanoKey, with only that key plugged in:
`python3 scripts/gpg_canokey.py card --backup <drive>/gpg-<fingerprint>.tar.age`. It prints the
`gpg --edit-key` commands to type, then signs and decrypts once through the card. `keytocard` is
the only step that types the OpenPGP Admin PIN on a PC; change it again in the phone app
afterwards.
`gpg --edit-key` commands to type, then signs and decrypts once through the card. In the same
sitting, set the public key URL: `gpg --card-edit` → `admin` → `url` →
`https://github.com/ryan4yin.gpg`. These are the only steps that type the OpenPGP Admin PIN on a
PC; change it again in the phone app afterwards.
4. Prepare, but do not deploy, the configuration change: add the public key to
`programs.gpg.publicKeys` in [gpg](../home/base/tui/gpg/default.nix), set `PASSWORD_STORE_KEY` to
the `[E]` fingerprint and `PASSWORD_STORE_SIGNING_KEY` to the primary fingerprint (pass checks
the `[E]` fingerprint, and `PASSWORD_STORE_SIGNING_KEY` and `signing.key` in
[git-signing.nix](../home/base/gui/git-signing.nix) to the primary fingerprint (pass checks
signatures only against full 40-digit fingerprints).
**Switch**, in one sitting:
@@ -336,6 +346,54 @@ Until the old key is retired, rolling back is `git -C <store> reset --hard <comm
To revoke the current key: `age --decrypt <backup> | tar -xOf - revocation.asc | gpg --import`, then
publish the public key.
#### Publish the public key
The key also signs and encrypts email, so its public key is published. Published user IDs carry no
comment: add one per mail address and revoke any that has one, with the primary key in a keyring on
tmpfs (gpg asks for the GPG passphrase):
```bash
export GNUPGHOME=$(mktemp -d -p "$XDG_RUNTIME_DIR")
age --decrypt <backup> | tar -xOf - secret.asc | gpg --import
gpg --import ~/codes/nix-secrets/public/<public-key-file> # user IDs added since the backup
gpg --quick-add-uid <primary-fingerprint> '<name> <address>'
gpg --quick-revoke-uid <primary-fingerprint> '<name> (<comment>) <address>'
gpg --armor --export <primary-fingerprint> > ~/codes/nix-secrets/public/<public-key-file>
gpgconf --kill all && rm -rf "$GNUPGHOME" && unset GNUPGHOME
```
The backups keep the original user IDs; the public key in nix-secrets is the copy that has the
changes. Push nix-secrets, then run `just upp mysecrets` here. Then publish it:
1. GitHub: `gh auth refresh -h github.com -s write:gpg_key`, then
`gh gpg-key add ~/codes/nix-secrets/public/<public-key-file>`.
2. keys.openpgp.org: upload the file at <https://keys.openpgp.org/upload> and confirm every address
from its email. Until then it serves the key without user IDs, which gpg refuses to import.
A card loaded before its URL was set gets one at its next `card`. A new key repeats these steps;
remove the retired key from GitHub, since the card URL serves every key listed there. Commits it
signed stay Verified: GitHub records verification at push time.
#### Commit signing
[git-signing.nix](../home/base/gui/git-signing.nix) signs every commit on the desktops with the
`[S]` subkey, so either CanoKey signs; tags are signed only with `git tag -s`. A rebase or a burst
of commits within 30 s takes one touch. Repositories under `~/work` are not signed: the key carries
no work address. Servers have no card, so commits there stay unsigned.
GitHub marks a commit Verified once the public key is on the account and has a user ID with the
commit email, verified on the account.
#### Android (OpenKeychain)
OpenKeychain imports the public key and keeps stubs that send each operation to the CanoKey over NFC
or USB, like the stubs in `~/.gnupg`:
1. Manage my keys → Use Security Token, then hold the CanoKey to the phone or plug it in.
2. OpenKeychain fetches the public key from the card's URL. Without one, choose to import the
exported public key file.
3. Each operation asks for the OpenPGP PIN; over NFC no touch is needed (section 1.2).
## 3. Add a backup key
A second CanoKey or a YubiKey works the same way; the module name is CanoKey-specific but nothing in
Generated
+17 -32
View File
@@ -343,11 +343,11 @@
]
},
"locked": {
"lastModified": 1793193205,
"narHash": "sha256-X6xa6sGA7RnJQuZGbFMC+K+KToWAlBDCCjJXfTwEPsw=",
"lastModified": 1794897420,
"narHash": "sha256-hMI9Xg+lxS8kbnxIxL/jPQn688dstoxQAcMEbCb1ax0=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "095fef2f265c3c0da4fe315efba8f8a04495ab34",
"rev": "5b76c5b8eec25fdbce4f43309b3ee10584374a26",
"type": "github"
},
"original": {
@@ -460,16 +460,17 @@
"spectrum": "spectrum"
},
"locked": {
"lastModified": 1793225170,
"narHash": "sha256-G/iL0mroLP5etLwYs55uyOyffMS4t+gpyXF06haba4w=",
"lastModified": 1794529892,
"narHash": "sha256-m5iXk3ILiCuRpCgqYWNiGVFmu8YLh2FNxxaZj/Auc10=",
"owner": "microvm-nix",
"repo": "microvm.nix",
"rev": "c37d37a876a3c4bd7ff78fcc716b2e4fac770360",
"rev": "194a254693f49af939a2b53d04982bd4b276fdb3",
"type": "github"
},
"original": {
"owner": "microvm-nix",
"repo": "microvm.nix",
"rev": "194a254693f49af939a2b53d04982bd4b276fdb3",
"type": "github"
}
},
@@ -493,10 +494,10 @@
"mysecrets": {
"flake": false,
"locked": {
"lastModified": 1794376126,
"narHash": "sha256-lDoa+rGdXjwd4czCYy26ye094LMv0eXY4pIpeDcWK7k=",
"lastModified": 1795099807,
"narHash": "sha256-uIQNROEKtFbZGNYPto7Wcv0H+YmcsEisN/gUGUsOikA=",
"ref": "refs/heads/main",
"rev": "6ab2a713e5938e1bb8ef2d33acab632ba0bd5331",
"rev": "eba74369427e98b0246f6f0f35e80ddcc6808995",
"shallow": true,
"type": "git",
"url": "ssh://git@github.com/ryan4yin/nix-secrets.git"
@@ -577,16 +578,17 @@
]
},
"locked": {
"lastModified": 1793626980,
"narHash": "sha256-U98lLEsMqZUE9cp0gQTVlZdWSUBi+59OmwS7aB5txdo=",
"lastModified": 1794910092,
"narHash": "sha256-acu4eioYHfOOUAhWL9765/h/2f2/PGmVmZmiZ7YPKZQ=",
"owner": "nix-community",
"repo": "nixos-apple-silicon",
"rev": "481cf53add16849ecd02c4419a1794ce70bfc0eb",
"rev": "ce7d0925860cf29d686b24ea5798f3a02676b4f7",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixos-apple-silicon",
"rev": "ce7d0925860cf29d686b24ea5798f3a02676b4f7",
"type": "github"
}
},
@@ -692,22 +694,6 @@
"type": "github"
}
},
"nixpkgs-small": {
"locked": {
"lastModified": 1794378162,
"narHash": "sha256-gJGP/BWdmF1pbjAzbuICPSeGkMncAiDt9PRe7L13664=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "c24da8b1d51f447e8faedcb5cb823b3f84346a60",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable-small",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1793183032,
@@ -726,11 +712,11 @@
},
"nixpkgs_2": {
"locked": {
"lastModified": 1793225069,
"narHash": "sha256-sx1f99WGrDfJ83KKuQrqGPmot0rnDgmpLJDzpU2oHQQ=",
"lastModified": 1794705614,
"narHash": "sha256-DZ5eNWHA6heAHwkMt1SBtF1p8Lfgi4ivqdqmgxUZkLs=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e62746b0b472753ef019baceab6f1e2e52014980",
"rev": "1c872b8c508bbbfebc1b0b74777ff391ce0a574c",
"type": "github"
},
"original": {
@@ -897,7 +883,6 @@
"nixpkgs-darwin": "nixpkgs-darwin",
"nixpkgs-master": "nixpkgs-master",
"nixpkgs-patched": "nixpkgs-patched",
"nixpkgs-small": "nixpkgs-small",
"nixpkgs-stable": "nixpkgs-stable",
"nu_scripts": "nu_scripts",
"nur-ryan4yin": "nur-ryan4yin",
+4 -5
View File
@@ -32,12 +32,10 @@
nixpkgs-patched.url = "github:ryan4yin/nixpkgs/nixos-unstable-patched";
# get some latest packages from the master branch
nixpkgs-master.url = "github:nixos/nixpkgs/master";
# Ahead of nixos-unstable for aquamarine's NPU stack, through `pkgs-small`;
# removal condition in docs/WORKAROUNDS.md WA-037.
nixpkgs-small.url = "github:nixos/nixpkgs/nixos-unstable-small";
# NixOS MicroVMs -- run the VMs directly on the hosts, replacing the former KubeVirt
# Pinned to a reviewed commit: the newest tag (v0.5.0, 2024) is far behind main.
microvm = {
url = "github:microvm-nix/microvm.nix";
url = "github:microvm-nix/microvm.nix/194a254693f49af939a2b53d04982bd4b276fdb3";
inputs.nixpkgs.follows = "nixpkgs";
};
@@ -126,8 +124,9 @@
# Blender/CUDA source rebuild; bump the rev deliberately when needed.
nixpkgs-blender.url = "github:nixos/nixpkgs/4b8338e3113dc41bcf7695f56dc372107b7ff4c9";
# Pinned to a reviewed commit: release tags lag main by months.
nixos-apple-silicon = {
url = "github:nix-community/nixos-apple-silicon";
url = "github:nix-community/nixos-apple-silicon/ce7d0925860cf29d686b24ea5798f3a02676b4f7";
inputs.nixpkgs.follows = "nixpkgs";
};
+1
View File
@@ -25,6 +25,7 @@ systems.
- **gui/**: Cross-platform GUI applications and configurations
- **dev-tools.nix**: Misc development and network tools (mitmproxy, wireshark)
- **git-signing.nix**: Git commit signing with the OpenPGP key on the CanoKeys
- **media.nix**: Media players and utilities
- **zed-editor.nix**: Zed editor configuration (primary GUI editor)
- **rime/**: Rime (flypy) customisation shared by fcitx5-rime (Linux) and Squirrel (macOS)
+17
View File
@@ -0,0 +1,17 @@
{
# Sign commits with the OpenPGP [S] subkey that both CanoKeys hold; the card's
# touch cache covers a burst of commits. Desktop layer only, where the cards
# are used; setup: docs/security-keys.md#commit-signing.
programs.git = {
signing.key = "BB8DFBAC2E9BE8F15649E3AA1F2440D500288E48"; # primary; gpg picks its [S] subkey
# Not signByDefault: its tag.gpgSign turns every lightweight `git tag` into an annotated one.
settings.commit.gpgSign = true;
# The personal key carries no work address, so work commits stay unsigned.
includes = [
{
condition = "gitdir:~/work/";
contents.commit.gpgSign = false;
}
];
};
}
+12 -1
View File
@@ -16,7 +16,7 @@ profile patches remain machine-local runtime state, the place for private endpoi
staging gateways) too. Nix installs plain `dsh` from `nur-ryan4yin`, with no package wrapper and no
`--patch` overlay.
Three behaviours that are easy to get wrong:
Five behaviours that are easy to get wrong:
- A patch row's `config` **replaces** the row's config object instead of deep-merging into it.
Repeat every key you mean to keep; the shipped `agent-loop` row repeats `agents: []` for this
@@ -26,6 +26,17 @@ Three behaviours that are easy to get wrong:
`contextWindow` and `maxTokens` instead.
- `dsh-llm-pi-ai` registers its providers once, so mount only one instance: a second one fails with
`provider "..." is already declared`.
- A patch row matches its bundle row by `id` and must repeat that row's exact `name`. Pointing the
row at a local plugin file instead makes dsh skip the whole row with
`patch: name mismatch for "..."`, which silently drops everything the row configured: an
`llm-pi-ai` row lost this way takes every custom provider route out of the picker, leaving only
the `dsh-base` default model. To run a patched adapter, set `disabled: true` on the bundle row and
`insert` the replacement under a different id.
- A provider route has no service-tier knob: `dsh-llm-pi-ai` through 0.2.2-rc.3 accepts no
`serviceTier` and offers no payload hook, even though the pi-ai it bundles sends `service_tier`.
Only a patched adapter can set it, and the `openai` / `openai-re` gateways then answer
`service_tier: priority` with `service_tier: default` while rejecting unknown values
(`Unsupported service_tier: flex`), so the tier is not something these routes can select.
To see what your own patches actually change:
+6 -3
View File
@@ -30,7 +30,8 @@ tool that is simple enough, functional enough, and widely adopted.
Currently I use both age & GnuPG:
1. Age for secrets encryption, it's simple and easy to use.
2. GnuPG for password-store, because pass, browserpass and Android Password Store all speak OpenPGP.
2. GnuPG for password-store, because pass, browserpass and Android Password Store all speak OpenPGP,
and for Git commit signing and signed or encrypted email.
SSH no longer goes through GnuPG: each CanoKey holds a FIDO2 SSH key instead (no `[A]` subkey).
@@ -44,7 +45,8 @@ SSH no longer goes through GnuPG: each CanoKey holds a FIDO2 SSH key instead (no
backup is opened, and age's scrypt covers gpg's weak S2K (see section 0) against offline guessing.
- [`scripts/gpg_canokey.py`](../../../../scripts/gpg_canokey.py) generates the key, switches the
password store to it and loads the cards, all in throwaway keyrings on tmpfs. The procedure is in
[hardware security keys](../../../../docs/security-keys.md#pass-openpgp).
[hardware security keys](../../../../docs/security-keys.md#pass-openpgp), with publishing the
public key and using the cards from OpenKeychain on Android.
The sections below explain the GnuPG concepts behind that setup.
@@ -290,7 +292,8 @@ But in OpenPGP:
embarrassing.
- Anyone can upload a key to the key server, and claim that it is the key of a certain
person(such as Linus), which is very insecure.
- **key server** is not recommend to use.
- **key server** is not recommend to use. keys.openpgp.org is the exception: it publishes a user
ID only after mailing that address, and lets the owner remove it.
- GnuPG will generate revocation certificate when generating
keypair(`~/.gnupg/openpgp-revocs.d/<fingerprint>.rev`), anyone can import this certificate to
revoke the keypair. But OpenPGP standard **DO NOT provide a way to distribute this certificate to
+4 -3
View File
@@ -9,9 +9,10 @@
## Changing the GPG key
Change the key every two or three years. `python3 scripts/gpg_canokey.py pass` switches the store:
it decrypts every entry with the old key before changing anything, runs `pass init`, then checks
that each entry opens with the new key alone and kept its content. The whole procedure, from
Change the key only when a CanoKey is lost or the key may be compromised; its subkeys never leave
the cards, so there is no scheduled rotation. `python3 scripts/gpg_canokey.py pass` switches the
store: it decrypts every entry with the old key before changing anything, runs `pass init`, then
checks that each entry opens with the new key alone and kept its content. The whole procedure, from
generating the key to retiring the old one, is in
[hardware security keys](../../../../docs/security-keys.md#pass-openpgp).
+5 -4
View File
@@ -27,8 +27,8 @@ in
home.file.".ssh/romantic.pub".source = "${mysecrets}/public/romantic.pub";
# Each CanoKey holds a resident FIDO2 SSH key for GitHub and every host, its
# handle exported on each desktop to ~/.ssh/canokey-<name>; every use needs a
# touch, and ssh skips the handle of an unplugged key. Setup:
# handle exported on each desktop to ~/.ssh/canokey-<name>; every new
# connection needs a touch, and ssh skips the handle of an unplugged key. Setup:
# docs/security-keys.md.
programs.ssh = {
enable = true;
@@ -53,9 +53,10 @@ in
ServerAliveCountMax = 3;
HashKnownHosts = false;
UserKnownHostsFile = "~/.ssh/known_hosts";
ControlMaster = "no";
# A connection reused within 30 s needs no new touch.
ControlMaster = "auto";
ControlPath = "~/.ssh/master-%r@%n:%p";
ControlPersist = "no";
ControlPersist = "30s";
};
"github.com" = {
+7 -1
View File
@@ -94,7 +94,13 @@ in
# expose /metrics for victoriametrics; unauthenticated is fine because the
# server only listens on loopback
prometheus = true;
extraFlags = [ "--prometheus-no-auth" ];
extraFlags = [
"--prometheus-no-auth"
# One quota for the whole store, all repositories together, so a runaway
# client cannot fill the HDD pool shared with /data/apps and /data/fileshare.
"--max-size"
(toString (512 * 1024 * 1024 * 1024)) # 512 GiB
];
};
# repositories live on the HDD, which has to be mounted first
@@ -63,14 +63,15 @@ document is the agreed design and the rationale.
## Backup and disaster recovery
- **Database**: already covered by the existing youko restic backup, which snapshots
`/btr_pool/@persistent` (Postgres data lives there).
- **Database**: covered by the youko restic backup, which snapshots `/btr_pool/@persistent`. Each
run first writes a `pg_dumpall` dump to `/var/lib/postgresql-backup` (see
[BACKUP.md](../../../../docs/BACKUP.md#verifying)); restore from that dump, since the raw data
directory in the snapshot is only crash-consistent.
- **Media and existing photos**: both live on the HDD already. A local HDD->HDD backup adds no
protection, so none is added here. This is deferred to the planned cloud copy, which will cover
the photo library.
- **Note for the cloud-copy work**: a raw btrfs snapshot of a running Postgres is only
crash-consistent; prefer a `pg_dump` into the cloud set for a clean restore. That set should
include `mediaLocation` and the external-library source.
- **Note for the cloud-copy work**: that set should include `mediaLocation` and the external-library
source.
- **One-time disruption**: adding the extensions and `shared_preload_libraries` restarts PostgreSQL
(affects the `playground` DB only).
@@ -13,6 +13,19 @@
node_exporter's textfile collector after a successful run. `alert_rules/restic-backup.yml` alerts
when it is older than two days (the schedule is daily) or absent entirely.
## HTTPS Probes
`blackbox.nix` probes every named caddy vhost on youko over HTTPS; `alert_rules/blackbox.yml` alerts
on a failing probe and on a certificate that expires within 14 days.
## Deploy State
Physical hosts also publish, from `modules/nixos/base/monitoring.nix`:
- `node_reboot_required`, for `HostRequiresReboot` in `alert_rules/node-exporter.yml`.
- `flake_input_last_modified{input,rev}` of the running generation, for
`alert_rules/flake-inputs.yml`: nixpkgs older than 30 days, or a week behind the newest host.
## TODO
- **Dead-man switch**: `Watchdog` in `alert_rules/general.yml` always fires (`vector(1)`) but is
@@ -1,4 +1,27 @@
{ config, mylib, ... }:
{
config,
lib,
pkgs,
mylib,
...
}:
let
ruleGlobs = [
"alert_rules/*.yml"
"alert_rules/*.yaml"
"recording_rules/*.yml"
"recording_rules/*.yaml"
];
# A rule vmalert cannot parse fails this build instead of the running service.
checkedRules =
pkgs.runCommand "vmalert-homelab-rules" { nativeBuildInputs = [ config.services.vmalert.package ]; }
''
mkdir $out
cp -r ${./alert_rules} $out/alert_rules
cp -r ${./recording_rules} $out/recording_rules
vmalert -dryRun ${lib.concatMapStringsSep " " (glob: ''-rule="$out/${glob}"'') ruleGlobs}
'';
in
{
# https://docs.victoriametrics.com/victoriametrics/vmalert/
services.vmalert.instances."homelab" = {
@@ -18,12 +41,7 @@
# from URLs in log messages or UI and exported metrics.
"datasource.showURL" = false;
# Path to the files with alerting and/or recording rules.
rule = [
"${./alert_rules}/*.yml"
"${./alert_rules}/*.yaml"
"${./recording_rules}/*.yml"
"${./recording_rules}/*.yaml"
];
rule = map (glob: "${checkedRules}/${glob}") ruleGlobs;
# https://docs.victoriametrics.com/victoriametrics/vmalert/#link-to-alert-source
# Set this two args to generate the correct `.GeneratorURL`
"external.url" = "https://grafana.writefor.fun";
@@ -0,0 +1,27 @@
groups:
- name: blackbox.rules
rules:
# Probes of every caddy vhost on youko (monitoring/blackbox.nix): the Let's
# Encrypt wildcard that security.acme renews, and the private ecc-ca server
# certificate that is rotated by hand.
- alert: CertificateExpiry
expr: probe_ssl_earliest_cert_expiry - time() < 14 * 86400
for: 15m
labels:
severity: warning
annotations:
summary: Certificate for {{ $labels.instance }} expires in {{ $value | humanizeDuration }}
description:
"Check `systemctl status acme-writefor.fun.service` on youko for the public wildcard, or
rotate certs/ecc-server.crt for the private one."
- alert: HttpsEndpointDown
expr: probe_success{job="blackbox-https"} == 0
for: 15m
labels:
severity: warning
annotations:
summary: "{{ $labels.instance }} is unreachable"
description:
"The HTTPS probe from youko fails (TLS, DNS or an unexpected status). Check caddy and
the backend service there."
@@ -0,0 +1,30 @@
groups:
- name: flake-inputs.rules
rules:
# modules/nixos/base/monitoring.nix publishes the commit time and revision
# of the running generation's nixpkgs (physical hosts only).
- alert: NixpkgsOutOfDate
expr: (time() - flake_input_last_modified{input="nixpkgs"}) / 86400 > 30
for: 1h
labels:
severity: warning
annotations:
summary: nixpkgs on {{ $labels.host }} is {{ $value | humanize }} days old
description:
"{{ $labels.host }} runs nixpkgs {{ $labels.rev }}. Update the flake lock and deploy it
to pick up security fixes."
# A host that the last deploys skipped.
- alert: NixpkgsBehindFleet
expr:
(scalar(max(flake_input_last_modified{input="nixpkgs"})) -
flake_input_last_modified{input="nixpkgs"}) / 86400 > 7
for: 1d
labels:
severity: warning
annotations:
summary:
nixpkgs on {{ $labels.host }} is {{ $value | humanize }} days behind the newest host
description:
"{{ $labels.host }} runs nixpkgs {{ $labels.rev }}, older than the newest nixpkgs
deployed to another host. Deploy it."
@@ -93,18 +93,22 @@ groups:
"Disk is probably writing too much data (> 50 MB/s)\n VALUE = {{ $value }}\n LABELS =
{{ $labels }}"
# The absolute floor keeps multi-TB disks from alerting with hundreds of GiB
# left; a fast fill is HostDiskWillFillIn24Hours' job.
- alert: HostOutOfDiskSpace
expr:
'((node_filesystem_avail_bytes * 100) / node_filesystem_size_bytes < 10 and ON (instance,
device, mountpoint) node_filesystem_readonly == 0) * on(instance) group_left (nodename)
device, mountpoint) node_filesystem_avail_bytes < 100 * 1024^3 and ON (instance, device,
mountpoint) node_filesystem_readonly == 0) * on(instance) group_left (nodename)
node_uname_info{nodename=~".+"}'
for: 2m
for: 30m
labels:
severity: warning
annotations:
summary: Host out of disk space (instance {{ $labels.instance }})
description:
"Disk is almost full (< 10% left)\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
"Disk is almost full (< 10% and < 100 GiB left)\n VALUE = {{ $value }}\n LABELS = {{
$labels }}"
- alert: HostDiskWillFillIn24Hours
expr:
@@ -288,7 +292,8 @@ groups:
expr:
'(node_systemd_unit_state{state="failed"} == 1) * on(instance) group_left (nodename)
node_uname_info{nodename=~".+"}'
for: 0m
# Skip failures that clear on their own (a retry, the next timer run).
for: 15m
labels:
severity: warning
annotations:
@@ -544,15 +549,33 @@ groups:
"Clock not synchronising. Ensure NTP is configured on this host.\n VALUE = {{ $value
}}\n LABELS = {{ $labels }}"
# Watchdog and panic reboots (modules/nixos/watchdog.nix) recover a host
# without anyone noticing; warning, because info never notifies. Headless
# servers only: desktops boot daily and MicroVM guests restart on deploys.
- alert: HostRebooted
expr:
'(time() - node_boot_time_seconds{host=~"aquamarine|shoryu|shushou|youko"} < 600) *
on(instance) group_left (nodename) node_uname_info{nodename=~".+"}'
labels:
severity: warning
annotations:
summary: Host rebooted (instance {{ $labels.instance }})
description:
"{{ $labels.instance }} booted {{ $value | humanizeDuration }} ago. If nobody rebooted
it, check `journalctl -b -1` there for a panic or watchdog reset.\n LABELS = {{ $labels
}}"
# node_reboot_required comes from modules/nixos/base/monitoring.nix
# (physical hosts only). A day leaves room for a planned `boot` deploy.
- alert: HostRequiresReboot
expr:
'(node_reboot_required > 0) * on(instance) group_left (nodename)
node_uname_info{nodename=~".+"}'
for: 4h
for: 1d
labels:
severity: info
severity: warning
annotations:
summary: Host requires reboot (instance {{ $labels.instance }})
description:
"{{ $labels.instance }} requires a reboot.\n VALUE = {{ $value }}\n LABELS = {{
$labels }}"
"{{ $labels.instance }} has a system profile whose kernel, initrd or kernel modules
differ from the booted ones; reboot it to run them.\n LABELS = {{ $labels }}"
@@ -0,0 +1,27 @@
groups:
- name: rasdaemon.rules
rules:
# Counts per message from rasdaemon's database on the physical servers.
# Corrected errors need no action; uncorrected and deferred ones point at
# failing CPU, memory or PCIe hardware.
- alert: MachineCheckError
expr: increase(rasdaemon_mce_records_total{mce_msg!~"Corrected.*"}[1h]) > 0
labels:
severity: critical
annotations:
summary: Machine check error on {{ $labels.host }}
description:
"{{ $labels.mce_msg }}. Inspect `ras-mc-ctl --errors` and `journalctl -k` on {{
$labels.host }}."
- alert: PcieUncorrectedError
expr: increase(rasdaemon_aer_events_total{aer_err_type!="Corrected"}[1h]) > 0
labels:
severity: critical
annotations:
summary:
"{{ $labels.aer_err_type }} PCIe error on {{ $labels.host }} device {{
$labels.aer_dev_name }}"
description:
"{{ $labels.aer_err_msg }}. Inspect `ras-mc-ctl --errors` and `journalctl -k` on {{
$labels.host }}."
@@ -105,3 +105,19 @@ groups:
summary:
SATA SSD {{ $labels.device }} on {{ $labels.host }} wear indicator is low ({{ $value }})
description: "Wear_Leveling_Count normalized value below 20 (100 = new)."
# btrfs keeps these per-device counters on disk across reboots; scrubs
# (services.btrfs.autoScrub) and normal I/O both raise them. The alert
# holds until the counters are reset after the cause is dealt with.
- alert: BtrfsDeviceErrors
expr: node_btrfs_device_errors_total > 0
for: 5m
labels:
severity: critical
annotations:
summary:
btrfs on {{ $labels.host }} device {{ $labels.device }} has {{ $value }} {{ $labels.type
}} errors
description:
"Run `btrfs device stats` and check `journalctl -k` and the drive's SMART data on {{
$labels.host }}; after the cause is fixed, reset with `btrfs device stats --reset`."
@@ -0,0 +1,103 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.prometheus.exporters.blackbox;
# Unauthenticated probes count as failed logins and trip transmission's
# anti-brute-force lockout, so its RPC port is probed over TCP instead.
httpsExcluded = [ "transmission.writefor.fun" ];
# Every named caddy vhost on this host; the `*.writefor.fun` catch-all only
# answers 404.
httpsTargets = map (name: "https://${name}/") (
lib.filter (name: !lib.hasPrefix "*." name && !lib.elem name httpsExcluded) (
lib.attrNames config.services.caddy.virtualHosts
)
);
relabelToExporter = [
{
source_labels = [ "__address__" ];
target_label = "__param_target";
}
{
source_labels = [ "__param_target" ];
target_label = "instance";
}
{
target_label = "__address__";
replacement = "127.0.0.1:${toString cfg.port}";
}
];
in
{
# https://github.com/prometheus/blackbox_exporter/blob/master/CONFIGURATION.md
services.prometheus.exporters.blackbox = {
enable = true;
listenAddress = "127.0.0.1";
configFile = (pkgs.formats.yaml { }).generate "blackbox.yml" {
modules.https_up = {
prober = "http";
timeout = "10s";
http = {
# The services resolve to this host's LAN IPv4.
preferred_ip_protocol = "ip4";
ip_protocol_fallback = false;
fail_if_not_ssl = true;
# 401/403 come from the backend's own auth (restic, s3, webdav),
# so caddy and the service are both up.
valid_status_codes = [
200
401
403
];
};
};
modules.tcp_up = {
prober = "tcp";
timeout = "10s";
};
};
};
services.victoriametrics.prometheusConfig.scrape_configs = [
{
job_name = "blackbox-https";
scrape_interval = "60s";
metrics_path = "/probe";
params.module = [ "https_up" ];
static_configs = [
{
targets = httpsTargets;
labels.type = "probe";
labels.app = "caddy";
labels.host = "youko";
labels.env = "homelab";
labels.cluster = "homelab";
}
];
relabel_configs = relabelToExporter;
}
{
job_name = "blackbox-tcp";
scrape_interval = "60s";
metrics_path = "/probe";
params.module = [ "tcp_up" ];
static_configs = [
{
targets = [ "192.168.5.118:9091" ];
labels.type = "probe";
labels.app = "transmission";
labels.host = "youko";
labels.env = "homelab";
labels.cluster = "homelab";
}
];
relabel_configs = relabelToExporter;
}
];
}
@@ -3,5 +3,6 @@
imports = [
./victoriametrics.nix
./alert.nix
./blackbox.nix
];
}
@@ -27,6 +27,10 @@ let
"shushou"
"youko"
];
# Physical servers run rasdaemon and its exporter on :10029 (hardware.rasdaemon
# in lib/genVmHostModule.nix and hosts/idols-aquamarine/default.nix).
rasdaemonHosts = lib.remove "ai" physicalHosts;
in
{
# https://victoriametrics.io/docs/victoriametrics/latest/configuration/configuration/
@@ -263,7 +267,33 @@ in
];
}
]
) [ ] (lib.attrsets.filterAttrs (n: _: builtins.elem n physicalHosts) myvars.networking.hostsAddr));
) [ ] (lib.attrsets.filterAttrs (n: _: builtins.elem n physicalHosts) myvars.networking.hostsAddr))
# --- MCE / PCIe AER / memory errors (physical servers only) --- #
++ (lib.attrsets.foldlAttrs
(
acc: hostname: addr:
acc
++ [
{
job_name = "rasdaemon-${hostname}";
scrape_interval = "60s";
metrics_path = "/metrics";
static_configs = [
{
targets = [ "${addr.ipv4}:10029" ];
labels.type = "rasdaemon";
labels.app = "rasdaemon";
labels.host = hostname;
labels.env = "homelab";
labels.cluster = "homelab";
}
];
}
]
)
[ ]
(lib.attrsets.filterAttrs (n: _: builtins.elem n rasdaemonHosts) myvars.networking.hostsAddr)
);
};
};
}
@@ -1,4 +1,4 @@
{ myvars, ... }:
{ lib, myvars, ... }:
let
cacheDir = "/data/apps/nix-cache-proxy";
inherit (myvars.ports) youkoNixCacheProxy;
@@ -25,10 +25,23 @@ let
add_header X-Cache-Status $upstream_cache_status always;
'';
upstreamHosts = [
"cache.nixos.org"
"cache.numtide.com"
"ryan4yin.cachix.org"
"mirrors.ustc.edu.cn"
];
upstreamName = host: builtins.replaceStrings [ "." ] [ "_" ] host;
# Reuse upstream TLS connections: Nix fetches hundreds of narinfos at once,
# and a fresh handshake per request gets reset under that burst.
cacheLocation = upstream: subPath: {
proxyPass = "https://${upstream}${subPath}/";
proxyPass = "https://${upstreamName upstream}${subPath}/";
extraConfig = ''
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Host ${upstream};
proxy_ssl_name ${upstream};
${cacheConfig}
'';
};
@@ -46,6 +59,20 @@ in
use_temp_path=off;
'';
upstreams = lib.genAttrs' upstreamHosts (
host:
lib.nameValuePair (upstreamName host) {
servers."${host}:443" = { };
# Several Nix clients open up to 25 connections each; keep them idle
# between bursts instead of handshaking again.
extraConfig = ''
keepalive 128;
keepalive_requests 2000;
keepalive_timeout 120s;
'';
}
);
virtualHosts."nix-cache-proxy" = {
# Caddy owns the public listener and terminates HTTPS; nginx is internal.
listen = [
@@ -57,7 +57,12 @@ in
# logging
log_connections = true;
log_statement = "all";
# Log slow statements instead of every statement; also lock waits longer
# than deadlock_timeout, every temp file, and slow autovacuum runs.
log_min_duration_statement = 1000; # ms
log_lock_waits = true;
log_temp_files = 0;
log_autovacuum_min_duration = 1000; # ms
logging_collector = true;
log_disconnections = true;
log_destination = lib.mkForce "syslog";
@@ -119,6 +124,21 @@ in
# '';
};
# Logical dump of all databases and roles. The restic snapshot of the data
# directory is only crash-consistent; the dump restores cleanly. /var/lib is
# persisted, so the dump lands in the @persistent tree that restic backs up.
services.postgresqlBackup = {
enable = true;
location = "/var/lib/postgresql-backup";
compression = "zstd";
# no timer of its own: each restic run takes a fresh dump first
startAt = [ ];
};
systemd.services.restic-backups-homelab = {
wants = [ "postgresqlBackup.service" ];
after = [ "postgresqlBackup.service" ];
};
services.prometheus.exporters.postgres = {
enable = true;
# loopback only: scraped by VictoriaMetrics on the same host
+16
View File
@@ -180,8 +180,24 @@ qemu-kvm path; there are none right now.
settings). Deploy serially (`-p 1`) and re-check VM reachability afterwards.
- Use `boot` + a serial reboot for anything that can drop the network mid-flight — `systemd.network`
/ `br0` changes, nixpkgs updates, or any broad rebuild.
- `switch` enforces this through `system.switch.inhibitors` in
[genVmHostModule.nix](../lib/genVmHostModule.nix): when the kernel, its parameters or modules, the
initrd, systemd, `networkd.conf`, or the `br0` / uplink units change, `switch-to-configuration`
prints `There are changes to critical components of the system` and exits before installing the
boot loader, and Colmena reports the activation as failed. Colmena has already pointed the system
profile at the new generation, so rerun with `just <host> boot` and reboot, or switch anyway on
the host with `NIXOS_NO_CHECK=1 /nix/var/nix/profiles/system/bin/switch-to-configuration switch`.
- If a host loses VM networking, check `br0` and the VM taps, or reboot the host.
## Boot Recovery on Physical Servers
`shoryu`, `shushou`, `youko` (systemd-boot) and `aquamarine` (Lanzaboote) write each new generation
with a boot counter. After 3 boots that never reach `boot-complete.target` (ordered after
`sysinit.target`), the entry is marked bad and the boot loader starts the newest good one. The root
LUKS volume unlocks through TPM2 alone, so retries need no console. Failures later in boot, such as
a broken `br0`, do not count, and a hung boot retries only after a reboot or power cycle.
`bootctl list` shows each entry's remaining tries.
## Common Build Commands
Use the Just recipes for host configuration checks and builds:
+11
View File
@@ -279,6 +279,17 @@ The builder's login user is `root`, which the daemon trusts by default, so this
host key, which is passphrase-free and root-readable; `hosts/idols-aquamarine/default.nix`
authorizes those keys for root.
## Friends' tailnet
Aquamarine joins a tailnet shared with friends so they can use llama-swap/Strata. Log in once with
`sudo tailscale login`; the node state stays in the persisted `/var/lib/tailscale`.
The shared firewall accepts everything on `tailscale0`, so what that tailnet reaches is decided by
bind addresses: sockets on the LAN IPv4 (ASR, MagPie, the exporters) are unreachable from it, while
wildcard sockets (SSH, LLMNR/mDNS) are reachable. llama-swap's systemd user unit, which lives
outside this repository, therefore listens on `0.0.0.0:63081`. Friends cannot wake the host from
idle suspend; Wake-on-LAN works only on the LAN.
## Deploy
```bash
+4 -8
View File
@@ -3,7 +3,6 @@
mylib,
myvars,
pkgs,
pkgs-small,
...
}:
let
@@ -12,9 +11,9 @@ let
port = aquamarineAsr;
# OpenVINO publishes static IRs for Whisper only, and the NPU compiler accepts
# nothing less: any other ASR family keeps a dynamic time axis and aborts it
# (docs/WORKAROUNDS.md WA-037). Pinned by content because the NPU caches the
# compiled graph; a version bump should be deliberate.
# nothing less: any other ASR family keeps a dynamic time axis and aborts it.
# Pinned by content because the NPU caches the compiled graph; a version bump
# should be deliberate.
modelFiles = {
"added_tokens.json" = "sha256-PFH2bEwh+eEmlwB48RrnenjHSu6N9gbunauobkZxCOA=";
"config.json" = "sha256-v9ksCXVHqxLLQquugAi+WlmpH9xas5rM4kSJ64o+ioY=";
@@ -51,10 +50,7 @@ let
)}
'';
# openvino-genai 2026.4.0.0 fails to compile against the OpenVINO headers in
# nixos-unstable (no matching constructor in continuous_batching); the
# service takes it from the same nixpkgs as the NPU stack.
pythonEnv = pkgs-small.python3.withPackages (ps: [
pythonEnv = pkgs.python3.withPackages (ps: [
ps.fastapi
ps.numpy
ps.openvino-genai
+1 -1
View File
@@ -4,7 +4,7 @@ vinput records raw PCM (S16_LE, mono, 16 kHz), wraps it in a WAV container and
POSTs it to /v1/audio/transcriptions; this service is that endpoint. Whisper is
the only ASR family OpenVINO publishes fully static IRs for, and a static graph
is what the NPU compiler accepts -- every other family keeps a dynamic time axis
and aborts the compiler, see docs/WORKAROUNDS.md WA-037.
and aborts the compiler.
"""
import io
+5
View File
@@ -19,6 +19,7 @@ in
{
imports = [
disko.nixosModules.default
../../modules/nixos/hardware-health.nix
../../modules/nixos/headless-recovery.nix
../../modules/nixos/power.nix
../../modules/nixos/watchdog.nix
@@ -37,8 +38,12 @@ in
# services
./asr
./idle-suspend.nix
./tailscale.nix
];
# A failed initrd drops to a root shell behind the root password (docs/SECURITY.md).
boot.initrd.systemd.emergencyAccess = myvars.initialHashedPassword;
# Bind the board's NCT6798D SuperIO, otherwise fan RPM and board temperatures
# are missing.
boot.kernelModules = [ "nct6775" ];
@@ -1,13 +1,10 @@
{
pkgs,
pkgs-small,
...
}:
{
# The NPU serves ./asr; the driver's compiler lookup is fixed by
# NixOS/nixpkgs#570230, which reached nixos-unstable-small first (WA-037).
# The NPU serves ./asr.
hardware.cpu.intel.npu.enable = true;
nixpkgs.overlays = [ (_: _: { inherit (pkgs-small) intel-npu-driver; }) ];
# Ad-hoc CPU idle-power diagnostics: package power, C-state residency and
# wakeup attribution. Long-term RAPL export lives in the shared
+2
View File
@@ -26,5 +26,7 @@
boot.lanzaboote = {
enable = true;
pkiBundle = "/etc/secureboot";
# Retries need no console: root LUKS unlocks through TPM2 alone (hosts/README.md).
bootCounting.initialTries = 3;
};
}
+20
View File
@@ -0,0 +1,20 @@
# Joins the tailnet shared with friends: ./README.md#friends-tailnet.
{
# `services.tailscale` already puts the CLI in `environment.systemPackages`.
services.tailscale = {
enable = true;
port = 41641;
interfaceName = "tailscale0";
# No-op here: the shared firewall opens 41641 in `extraInputRules` and
# forces `allowedUDPPorts` empty.
openFirewall = true;
extraSetFlags = [
# Friends' devices share this tailnet: their routes must not shadow the
# home LAN, and its DNS settings must not replace the proxy gateway.
"--accept-routes=false"
"--accept-dns=false"
];
};
}
+41 -1
View File
@@ -9,9 +9,16 @@ let
inherit (networking.hostsAddr.${hostName}) iface ipv4;
ipv4WithMask = "${ipv4}/24";
in
{
config,
lib,
myvars,
...
}:
{
# CPU policy belongs to physical hosts; guests do not control hardware frequency.
imports = [
../modules/nixos/hardware-health.nix
../modules/nixos/headless-recovery.nix
../modules/nixos/power.nix
../modules/nixos/watchdog.nix
@@ -30,6 +37,12 @@ in
"nfs"
];
# Retries need no console: root LUKS unlocks through TPM2 alone (hosts/README.md).
boot.loader.systemd-boot.bootCounting.enable = true;
# A failed initrd drops to a root shell behind the root password (docs/SECURITY.md).
boot.initrd.systemd.emergencyAccess = myvars.initialHashedPassword;
# KVM for the microVMs and the libvirt domains. AMD-specific: an Intel VM host
# would need kvm-intel instead (see hosts/idols-ai/hardware-intel.nix).
boot.kernelModules = [ "kvm-amd" ];
@@ -62,7 +75,18 @@ in
# zram itself is provided by modules/nixos/base/zram.nix (enabled by default).
# Kill the greediest process before the host starts thrashing / gets OOM-killed.
services.earlyoom.enable = true;
services.earlyoom = {
enable = true;
# The MicroVMs' qemu and virtiofsd are the largest processes and would be
# killed first. Prefixes of /proc/PID/comm, which is cut to 15 characters
# (wrapped binaries start with a dot).
extraArgs = [
"--avoid"
"^(\\.qemu-system-x8|virtiofsd|\\.postgres-wrap|victoria-metric)"
];
};
# Builds inherit the daemon's oom_score_adj, so earlyoom and the kernel kill them first.
systemd.services.nix-daemon.serviceConfig.OOMScoreAdjust = 500;
environment.systemPackages = with pkgs; [
# Validate Hardware Virtualization Support via:
@@ -139,6 +163,22 @@ in
};
};
# `switch` refuses changes that only a reboot applies or that can drop br0 mid-flight; deploy
# those with `boot` (hosts/README.md). Guest tap units are left out so a new guest still switches.
system.switch.inhibitors = {
kernel = toString config.system.build.kernel;
kernel-params = toString config.boot.kernelParams;
kernel-modules = toString config.system.modulesTree;
initrd = toString config.system.build.initialRamdisk;
systemd = toString config.systemd.package;
}
// lib.genAttrs [
"systemd/networkd.conf"
"systemd/network/10-br0.netdev"
"systemd/network/10-br0.network"
"systemd/network/20-${iface}.network"
] (name: toString config.environment.etc.${name}.source);
# systemd-journal - cap disk usage, but keep plenty of history on the big
# persistent disk (/var/log is preserved to /persistent).
# https://www.freedesktop.org/software/systemd/man/latest/journald.conf.html
+77 -3
View File
@@ -1,6 +1,9 @@
{
config,
lib,
pkgs,
inputs,
mylib,
myvars,
...
}:
@@ -21,6 +24,18 @@ let
lanExporters = lib.filterAttrs (_: cfg: cfg.enable) {
inherit (config.services.prometheus.exporters) node smartctl nvidia-gpu;
};
# Deploy-state metrics are published by physical hosts only (hardwareTools is
# off on VM guests).
publishDeployState =
config.services.prometheus.exporters.node.enable && config.modules.hardwareTools.enable;
# nixpkgs only: any other input would rebuild every host whenever it moves.
flakeInputsProm = pkgs.writeText "flake-inputs.prom" ''
# HELP flake_input_last_modified Commit time of a flake input of the running generation.
# TYPE flake_input_last_modified gauge
flake_input_last_modified{input="nixpkgs",rev="${inputs.nixpkgs.rev}"} ${toString inputs.nixpkgs.lastModified}
'';
in
{
# node_exporter on every host that has a static LAN IPv4 (see `lanAddr` above)
@@ -67,9 +82,43 @@ in
# Created here so the textfile collector has somewhere to read from before
# the first successful backup writes its metric.
systemd.tmpfiles.rules = lib.mkIf (lanAddr != null) [
"d ${textfileDir} 0755 root root - -"
];
systemd.tmpfiles.rules = lib.mkIf (lanAddr != null) (
[ "d ${textfileDir} 0755 root root - -" ]
++ lib.optional publishDeployState "L+ ${textfileDir}/flake-inputs.prom - - - - ${flakeInputsProm}"
);
# node_reboot_required for the HostRequiresReboot alert. Compare against the
# system profile, not /run/current-system: a `boot` deploy only moves the
# profile. Same comparison as nixpkgs' system.autoUpgrade.allowReboot.
systemd.services.node-reboot-required = lib.mkIf publishDeployState {
description = "Report whether the next boot changes the kernel, initrd or modules";
serviceConfig = mylib.systemdHardening.mkDefaults mylib.systemdHardening.service // {
Type = "oneshot";
ReadWritePaths = [ textfileDir ];
};
path = [ pkgs.coreutils ];
script = ''
booted="$(readlink /run/booted-system/{initrd,kernel,kernel-modules})"
built="$(readlink /nix/var/nix/profiles/system/{initrd,kernel,kernel-modules})"
required=0
if [ "$booted" != "$built" ]; then
required=1
fi
{
echo '# HELP node_reboot_required 1 if the system profile boots another kernel, initrd or kernel modules.'
echo '# TYPE node_reboot_required gauge'
echo "node_reboot_required $required"
} > ${textfileDir}/reboot-required.prom.tmp
mv -f ${textfileDir}/reboot-required.prom.tmp ${textfileDir}/reboot-required.prom
'';
};
systemd.timers.node-reboot-required = lib.mkIf publishDeployState {
wantedBy = [ "timers.target" ];
timerConfig = {
OnBootSec = "1min";
OnUnitActiveSec = "15min";
};
};
# Drive SMART health (wear, spare, media errors, temperature, bytes written)
# on physical hosts. node_exporter's nvme collector only exposes
@@ -86,12 +135,37 @@ in
extraFlags = [ "--web.systemd-socket" ];
};
# MCE, AER and memory-controller error counts from rasdaemon's database, on
# hosts that run rasdaemon.
services.prometheus.exporters.rasdaemon =
lib.mkIf (lanAddr != null && config.hardware.rasdaemon.enable)
{
enable = true;
listenAddress = lanAddr;
port = 10029;
# No flags: each flag turns off one of the default aer/mce/mc collectors
# (WA-053 in docs/WORKAROUNDS.md).
enabledCollectors = [ ];
};
# This Python exporter cannot take a systemd socket, so it binds the LAN
# address itself and retries until the address exists and rasdaemon has
# created its database.
systemd.services.prometheus-rasdaemon-exporter =
lib.mkIf config.services.prometheus.exporters.rasdaemon.enable
{
after = [ "rasdaemon.service" ];
serviceConfig.RestartSec = "5s";
};
# Socket activation with FreeBind: the LAN address may not exist yet at boot.
systemd.sockets = lib.mkIf (lanAddr != null) (
lib.mapAttrs' (
name: cfg:
lib.nameValuePair "prometheus-${name}-exporter" {
wantedBy = [ "sockets.target" ];
# nixpkgs also starts the service from multi-user.target; requiring the
# socket (which systemd orders first) keeps a switch from starting it bare.
requiredBy = [ "prometheus-${name}-exporter.service" ];
listenStreams = [ "${cfg.listenAddress}:${toString cfg.port}" ];
socketConfig.FreeBind = true;
}
+15 -1
View File
@@ -1,8 +1,14 @@
{ lib, myvars, ... }:
{
config,
lib,
myvars,
...
}:
let
inherit (myvars.networking) lanCidr;
# The host that scrapes the exporters (VictoriaMetrics runs on youko).
monitoringHost = myvars.networking.hostsAddr.youko.ipv4;
rasdaemonExporter = config.services.prometheus.exporters.rasdaemon;
in
{
# Hosts bring their own firewall as defence in depth behind the router's
@@ -32,6 +38,14 @@ in
# smartctl_exporter (drive/SSD SMART health) is scraped only by the
# monitoring host.
ip saddr != ${monitoringHost} tcp dport 9633 drop
''
+ lib.optionalString rasdaemonExporter.enable ''
# rasdaemon's exporter (physical servers), likewise; it also drops IPv6.
ip saddr != ${monitoringHost} tcp dport ${toString rasdaemonExporter.port} drop
meta nfproto ipv6 tcp dport ${toString rasdaemonExporter.port} drop
''
+ ''
# Monitoring uses the stable IPv4 address above. Deny IPv6 exporter
# connections before broad LAN/tailnet/container trust can accept them;
+23 -7
View File
@@ -1,16 +1,17 @@
{
config,
lib,
pkgs,
nixpkgsConfig,
...
}:
let
# Store hygiene below applies to physical hosts only: VM guests build nothing
# locally (Colmena pushes their closures) and MicroVM guests share the host's
# read-only store. `hardwareTools` is off on every guest.
isPhysical = config.modules.hardwareTools.enable;
GiB = 1024 * 1024 * 1024;
in
{
# Nix 2.35 is newer than nixpkgs' nixVersions.stable (still 2.34), so opt into
# the latest released version until stable catches up.
# https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/tools/package-management/nix/default.nix
nix.package = pkgs.nixVersions.latest;
warnings = lib.optional (lib.versionAtLeast pkgs.nixVersions.stable.version "2.35") "nixVersions.stable is 2.35+: drop the nixVersions.latest override (WA-023)";
# https://lix.systems/add-to-config/
# nix.package = pkgs.lix;
@@ -25,11 +26,26 @@
options = lib.mkDefault "--delete-older-than 7d";
};
# A run can fail while a store path is still in use; retry instead of waiting a week.
systemd.services.nix-gc.serviceConfig.Restart = lib.mkIf isPhysical "on-failure";
# Builds cut off by a crash or power loss stay in the build dir (/nix/var/nix/builds,
# Nix's default `build-dir`) on the persistent pool. Clear it at boot, before
# nix-daemon runs; the line is boot-only, so Nix's own 7-day tmpfiles rule still
# ages the directory at runtime.
systemd.tmpfiles.rules = lib.mkIf isPhysical [ "D! /nix/var/nix/builds 0755 root root -" ];
# Manual optimise storage: nix-store --optimise
# https://nixos.org/manual/nix/stable/command-ref/conf-file.html#conf-auto-optimise-store
nix.settings = {
auto-optimise-store = true;
# When a build leaves less than 20 GiB free, GC until 50 GiB is free. The
# store shares its btrfs pool with /persistent (databases, VM images), which
# must keep room to write.
min-free = lib.mkIf isPhysical (20 * GiB);
max-free = lib.mkIf isPhysical (50 * GiB);
# Required to run nixpkgs' systemd-nspawn based NixOS tests locally (used
# by the nixpkgs-review workflow). These are daemon-wide settings, so every
# local build pays the small uid/cgroup allocation overhead; drop them if
+3 -14
View File
@@ -1,9 +1,4 @@
{
lib,
pkgs,
pkgs-stable,
...
}:
{ lib, pkgs, ... }:
{
xdg.terminal-exec = {
enable = true;
@@ -44,6 +39,7 @@
"gnome"
];
};
# niri's own ScreenCast offers only DMA-BUF, which Zoom rejects; wlr has SHM (WA-046).
niri."org.freedesktop.impl.portal.ScreenCast" = "wlr";
};
@@ -58,16 +54,9 @@
extraPortals = with pkgs; [
xdg-desktop-portal-gtk # file picker and OpenURI
xdg-desktop-portal-gnome # screenshot and remaining GNOME services
# xdg-desktop-portal-wlr 0.8.4 regresses Zoom; 0.8.2 works with niri.
pkgs-stable.xdg-desktop-portal-wlr
xdg-desktop-portal-wlr # ScreenCast on niri
];
};
assertions = [
{
assertion = pkgs.xdg-desktop-portal-wlr.version == "0.8.4";
message = "nixpkgs moved xdg-desktop-portal-wlr past 0.8.4: retest Zoom with it and drop the 0.8.2 pin (WA-046)";
}
];
# The xdg-autostart-generator starts every autostart app (including nixpak
# sandboxes like firefox/telegram) right at graphical-session.target, while
+15
View File
@@ -0,0 +1,15 @@
{ lib, ... }:
{
# Monthly scrub of every btrfs filesystem; errors show up in node_btrfs_device_errors_total.
# Start between 04:00 and 05:00, after the 01:30-03:45 backup window (docs/BACKUP.md):
# nixpkgs' AccuracySec of 1d could otherwise place it anywhere in the day.
services.btrfs.autoScrub = {
enable = true;
interval = "*-*-01 04:00:00";
};
systemd.timers."btrfs-scrub@".timerConfig.AccuracySec = lib.mkForce "1h";
# Record machine-check, PCIe AER and memory errors; exported to VictoriaMetrics by
# modules/nixos/base/monitoring.nix. Its database lives in the preserved /var/lib.
hardware.rasdaemon.enable = true;
}
+1 -5
View File
@@ -15,7 +15,7 @@ let
nixpkgsConfig = {
allowUnfree = true;
# Only Huawei works here: npmmirror 404s on prefetch-npm-deps' doubled
# slash, and Tencent answers 567 to its concurrent fetches (WA-049).
# slash, and Tencent answers 567 to its concurrent fetches.
npmRegistryOverrides = {
"registry.npmjs.org" = "https://mirrors.huaweicloud.com/repository/npm";
};
@@ -61,10 +61,6 @@ let
# to use chrome, we need to allow the installation of non-free software
config.allowUnfree = true;
};
pkgs-small = import inputs.nixpkgs-small {
inherit system;
config.allowUnfree = true;
};
pkgs-blender = import inputs.nixpkgs-blender {
inherit system;
config = lib.optionalAttrs (system == "x86_64-linux") {
@@ -8,8 +8,14 @@
cachixProxyConfigured = true;
directFallbacks = true;
cacheLivesOnDataVolume = true;
nixosUpstream = "https://cache.nixos.org/";
numtideUpstream = "https://cache.numtide.com/";
cachixUpstream = "https://ryan4yin.cachix.org/";
ustcUpstream = "https://mirrors.ustc.edu.cn/nix-channels/store/";
nixosUpstream = "https://cache_nixos_org/";
numtideUpstream = "https://cache_numtide_com/";
cachixUpstream = "https://ryan4yin_cachix_org/";
ustcUpstream = "https://mirrors_ustc_edu_cn/nix-channels/store/";
upstreamServers = {
cache_nixos_org = [ "cache.nixos.org:443" ];
cache_numtide_com = [ "cache.numtide.com:443" ];
mirrors_ustc_edu_cn = [ "mirrors.ustc.edu.cn:443" ];
ryan4yin_cachix_org = [ "ryan4yin.cachix.org:443" ];
};
}
@@ -26,4 +26,5 @@ in
cachixUpstream = nginx.virtualHosts."nix-cache-proxy".locations."/ryan4yin.cachix.org/".proxyPass;
ustcUpstream =
nginx.virtualHosts."nix-cache-proxy".locations."/mirrors.ustc.edu.cn/nix-channels/store/".proxyPass;
upstreamServers = lib.mapAttrs (_: upstream: builtins.attrNames upstream.servers) nginx.upstreams;
}
+1 -1
View File
@@ -554,7 +554,7 @@ def build_parser() -> argparse.ArgumentParser:
return command
generate = add("generate", cmd_generate, "create the key and its backup")
generate.add_argument("--uid", required=True, help="such as 'Name (pass) <address>'")
generate.add_argument("--uid", required=True, help="such as 'Name <address>'")
generate.add_argument(
"--dest", action="append", required=True, help="directory for one backup copy; repeat it"
)