Repair stale new-host and SOPS registration helpers #224

Open
opened 2026-09-12 17:15:15 +01:00 by nimmo · 2 comments
Owner

Problem

Phase 4 wiki verification found that the public new-host helpers no longer match the current repository architecture and secret-scope policy.

  • just add-host HOSTNAME correctly creates and stages hosts/HOSTNAME/default.nix, but its printed flake registration example still expands the old inline nixpkgs.lib.nixosSystem form. Current hosts use the shared makeNixosSystem { configName = "HOSTNAME"; } builder.
  • just add-secret and just add-secret-remote tell the operator to use a nonexistent migrate-host-key recipe when a host is already registered.
  • Both secret helpers insert the new host reference after only the last recipient reference in .sops.yaml. In the current scoped layout, host access must be selected per explicit consumer rule; appending to one syntactic location is not a reliable expression of required access.
  • The helpers then run sops updatekeys across tracked secret files, which can give a false impression that every required host/service rule was deliberately reviewed.

Scope

  • Update host scaffolding output to the current makeNixosSystem registration pattern and current host/profile boundaries.
  • Replace or implement the nonexistent host-key migration guidance.
  • Make recipient registration explicit and safe for the scoped SOPS layout. It should not silently grant broad access or imply that one recipient-group insertion is sufficient.
  • Add regression coverage for generated guidance and recipient-rule handling.
  • Update README/wiki commands if the supported interface changes.

Acceptance criteria

  • Generated host registration instructions match current flake.nix.
  • New-host recipient access is chosen from real consumer requirements and represented in explicit creation rules.
  • Duplicate/existing host handling points to a real supported rotation procedure.
  • Tests cover current multi-rule .sops.yaml behavior.
  • Host provisioning runbook can use the helpers without a transitional warning.

Discovered while executing wiki rebuild issue #222 against source commit 556df88494.

## Problem Phase 4 wiki verification found that the public new-host helpers no longer match the current repository architecture and secret-scope policy. - `just add-host HOSTNAME` correctly creates and stages `hosts/HOSTNAME/default.nix`, but its printed flake registration example still expands the old inline `nixpkgs.lib.nixosSystem` form. Current hosts use the shared `makeNixosSystem { configName = "HOSTNAME"; }` builder. - `just add-secret` and `just add-secret-remote` tell the operator to use a nonexistent `migrate-host-key` recipe when a host is already registered. - Both secret helpers insert the new host reference after only the last recipient reference in `.sops.yaml`. In the current scoped layout, host access must be selected per explicit consumer rule; appending to one syntactic location is not a reliable expression of required access. - The helpers then run `sops updatekeys` across tracked secret files, which can give a false impression that every required host/service rule was deliberately reviewed. ## Scope - Update host scaffolding output to the current `makeNixosSystem` registration pattern and current host/profile boundaries. - Replace or implement the nonexistent host-key migration guidance. - Make recipient registration explicit and safe for the scoped SOPS layout. It should not silently grant broad access or imply that one recipient-group insertion is sufficient. - Add regression coverage for generated guidance and recipient-rule handling. - Update README/wiki commands if the supported interface changes. ## Acceptance criteria - [ ] Generated host registration instructions match current `flake.nix`. - [ ] New-host recipient access is chosen from real consumer requirements and represented in explicit creation rules. - [ ] Duplicate/existing host handling points to a real supported rotation procedure. - [ ] Tests cover current multi-rule `.sops.yaml` behavior. - [ ] Host provisioning runbook can use the helpers without a transitional warning. Discovered while executing wiki rebuild issue #222 against source commit 556df88494686003b1c4f20c8e0b99b5afc16a6e.
Author
Owner

Additional verified defect: after nixos-anywhere completes, the provision recipe prints ssh root@TARGET 'rm /root/.config/sops/age/keys.txt'. Managed hosts that enable SSH set PermitRootLogin = "no", so this cleanup path is normally unavailable after first boot. The supported guidance should use the configured administrative account with sudo (and a TTY where required), after permanent host-key decryption has been proven. The current wiki runbook documents that safe sequence.

Additional verified defect: after nixos-anywhere completes, the provision recipe prints `ssh root@TARGET 'rm /root/.config/sops/age/keys.txt'`. Managed hosts that enable SSH set `PermitRootLogin = "no"`, so this cleanup path is normally unavailable after first boot. The supported guidance should use the configured administrative account with sudo (and a TTY where required), after permanent host-key decryption has been proven. The current wiki runbook documents that safe sequence.
Author
Owner

Additional Phase 4 finding: secrets/README.md still instructs just migrate-host-key HOSTNAME, but just --list and justfiles/secrets.just confirm that recipe does not exist. The new wiki runbook uses a staged manual recipient-rotation procedure until this issue repairs the helper and README guidance. The current remove-secret-key helper also bulk-runs updatekeys using the invoking host SSH identity, which may not be authorised for every scoped file; avoid presenting it as a complete rotation procedure without per-file checks.

Additional Phase 4 finding: secrets/README.md still instructs just migrate-host-key HOSTNAME, but just --list and justfiles/secrets.just confirm that recipe does not exist. The new wiki runbook uses a staged manual recipient-rotation procedure until this issue repairs the helper and README guidance. The current remove-secret-key helper also bulk-runs updatekeys using the invoking host SSH identity, which may not be authorised for every scoped file; avoid presenting it as a complete rotation procedure without per-file checks.
Sign in to join this conversation.
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
nimmo/nixos-config#224
No description provided.