diff --git a/plan/phase-5-consolidator/ws-f-nixos-docs.md b/plan/phase-5-consolidator/ws-f-nixos-docs.md index 321a3bf..abb13f5 100644 --- a/plan/phase-5-consolidator/ws-f-nixos-docs.md +++ b/plan/phase-5-consolidator/ws-f-nixos-docs.md @@ -4,7 +4,7 @@ Part of [Phase 5: Consolidator](README.md). Contracts: [contracts.md](contracts. | Field | Value | |---|---| -| Status | Not started | +| Status | In progress (F1 done; F2 to F4 pending) | | Owner | | | Depends on | C, D, E (original plan). F1 (module) and F4 (docs drafts) can begin once A1 settles the config keys, since they depend only on contracts sections 6 and 9; F2/F3 need the other streams | | Blocks | phase exit | @@ -47,3 +47,13 @@ Shippable, documented, verified. ## Log - 2026-10-19: Split from the single phase plan 2026-10-19. `tests/peers.rs` ownership moved here from WS-T; `docs/consolidator.md` shares one `## Testing` section with WS-T. +- 2026-10-19: **F1 done** (commit `F: F1 NixOS peers options with LoadCredential token delivery`). + - Options under `services.skyg-linux-tracker.peers`: `enable` (off by default), `settings` (freeform `[peers]` tuning, snake_case, no secrets) and `peers. = { url; tokenFile; caFile ? null; enable ? true; allowPlainHttp ? false; }`. + - Rendering: one `[[peers.peer]]` per peer with `enable = true`, with `name`, `url`, `allow_plain_http`, `ca_file` (only when set) and `token_file = /run/credentials/skyg-linux-tracker.service/peer-`. Peers with `enable = false` are left out of both the TOML and `LoadCredential`. A peer-less config gains no `[peers]` section, so existing deployments keep the same generated file. + - Credentials: `LoadCredential=peer-:` per enabled peer, merged with the TLS `cert`/`key` entries; `RefreshOnReload=credentials` now applies when TLS **or** peers are on; `ExecReload` stays SIGHUP. + - Reload vs restart: with peers enabled the config file moves from `restartTriggers` to `reloadTriggers`, so a peer edit is applied with SIGHUP (and the credential copy is refreshed). This is deliberate instead of `reloadIfChanged`: that flag would also reload on unrelated unit changes such as a package upgrade, keeping the old binary running. Changes SIGHUP cannot apply (bind, port, auth database) need a manual `systemctl restart`; the module description of the trigger notes it. With peers off the unit still restarts on config change, byte-identical to before. + - Assertions: declaring `peers.` requires `peers.enable`; `peers.enable` requires at least one declared peer (or the legacy freeform list); names match `^[a-z0-9][a-z0-9_-]{0,31}$` (uniqueness is by attribute name); `tokenFile` is absolute and outside the store (an interpolated `"${./secret}"` would otherwise put the token in the store); `caFile` is absolute when set; first-class peers and `settings.peers.peer` cannot be mixed. The pre-F1 freeform style stays valid, so `nix/tests/peers.nix` evaluates unchanged (verified: alpha keeps its two peers, gamma none). + - Tests: `nix/tests/module-peers.nix` (new file, eval only, no builds) renders the config and the unit and checks 25 cases: peer-less default, TLS-only unchanged, TLS+peers credential list, rendering of enabled/disabled peers, token path never in the config, reload/restart triggers, freeform compatibility and every assertion. Not wired into `flake.nix` (F2 owns that file); run it with: + `nix eval --impure --json --expr 'let f = builtins.getFlake (toString ./.); in import ./nix/tests/module-peers.nix { pkgs = f.inputs.nixpkgs.legacyPackages.x86_64-linux; module = f.nixosModules.default; }'` + - Not run (no nix builds in this worktree): `nix build .#checks.x86_64-linux.vm -L`, `nix build .#tests.x86_64-linux.peers -L`, `nix flake check`. The orchestrator should run those; `vm` covers the unchanged peer-less/TLS path, `peers` covers the legacy freeform path F2 will migrate to the new options. + - Handoff: F1 is complete; F2 can switch `nix/tests/peers.nix` to `peers.enable`/`peers.peers..tokenFile` (the TOML it produced is identical), move the test into `checks.vm-peers` and add the three-machine variant. F4 still owes the README peers section, `docs/consolidator.md` and the DEC-14 note (a consolidator token reaches every peer's data). `systemd/skyg-linux-tracker.service` is unchanged: the example is a manual install without peers.