Add rebuild-nexus: rebuild the hypervisor from DEPLOY_FLAKE #61
No reviewers
Labels
No labels
blocked
bug
decision
duplicate
enhancement
help wanted
invalid
landed?
question
ready-to-merge
stale
wontfix
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
allod/nexus!61
Loading…
Reference in a new issue
No description provided.
Delete branch "agent/rebuild-nexus"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A running host gains one command,
rebuild-nexus [switch|boot|test], which rebuilds the hypervisor from the flake named byDEPLOY_FLAKEand nothing else. It refuses to run whenDEPLOY_FLAKEis unset instead of falling back to a checkout, and it prints the flake path, the attribute and the evaluated toplevel store path before it switches, so the operator can see what is about to land. Nothing existing changes: the VM scripts, their fallbacks and the option that rendersDEPLOY_FLAKEbehave as before; the only edits outside the new files are list entries and doc sentences. The proof is the new test suite intests/rebuild-nexus.sh(run by theprovisioning-contractflake check) plus one cold cross-family review of the diff. If it is wrong, revert this PR; the hand-runsudo nixos-rebuildpath is untouched and keeps working.The issue named the script
rebuild-host; the owner asked for it to berebuild-nexus, and every file, test and doc mention uses that name.What changes
scripts/rebuild-nexus: new host-side script. Mode defaults toswitch;bootandtestpass through unchanged; anything else is a usage error. WithDEPLOY_FLAKEunset or empty it dies with a message namingnexus.provisioning.deployFlakeand invokes neithernixnornixos-rebuild. It evaluatesnixosConfigurations.<hostname>.config.system.build.toplevel.outPathwithnix eval --raw, prints flake, attribute and path, then runsnixos-rebuild <mode> --flake $DEPLOY_FLAKE#<hostname> --sudo.--sudois one deliberate addition to the issue's command line: the operator runs the script as themselves soDEPLOY_FLAKEfrom the login session is honoured, andnixos-rebuild --sudoelevates only the activation step. Running the whole script undersudowould drop the variable, which is the failure the issue exists to stop.rebuild-vm-from-hostuses the same flag.tests/rebuild-nexus.sh: eight tests withhostname,nixandnixos-rebuildstubs: recorder arguments for all three modes, usage errors, unset and emptyDEPLOY_FLAKErefusing before any tool runs, printed toplevel equal to the stub'snix evalanswer, and a failing eval refusing before the recorder.flake.nix,nix/provisioning-scripts.nix: the script and test join theprovisioning-contractcheck (syntax, shellcheck, test run, packagedtest -x).nix/configuration.nix,docs/provisioning-scripts.md: thedeployFlakeoption and the provisioning-pointers doc namerebuild-nexusand its lack of a fallback; a short "Rebuilding the host" section tells operators to use it instead of the hand-run command.README.mdhas no host-rebuild sentence, so it is unchanged.Risk
R2. The worst credible failure after validation is a local
nixos-rebuild --sudobehaving differently on a real host than the recorder shows; that leaves the host on its current generation (a failed build or refused sudo) or activates exactly the toplevel the script printed. The authoritative source, the deploy flake, is never written. Rollback is a revert of this PR. The fixtures cannot exercise a real switch; the issue's on-host check (a lock bump moving one input,readlinkof the new generation equal to the printed path,nix store diff-closuresshowing only that input) is a human step on a deployment host and was not run here.Validation
Run by the integrator in the PR worktree at
050789f(the head after the fix round):The check runs
bash -nandshellcheck -xover the new files andtest -xon the packagedrebuild-nexus.Cold cross-family review:
gpt-5.6-solviacodex exec, reasoning efforthigh, read the diff atbbff982(Claude-family worker authored it). Four should-fix findings, all verified against the source and fixed in050789f: the printed attribute dropped the quotes the evaluation uses, so a hostname such as123hostcould not be pasted into the comparison command; the recorder stub flattened arguments with$*, so a script passing one joined argument would have passed; the test did not pin that the preview prints before the switch, now asserted by a stdout marker from the recorder; and three sentences in the provisioning-pointers doc still promised a fallback thatrebuild-nexusrefuses, now limited to the VM scripts. No blockers. Per the pass budget, no second reading follows the fix round; the fixes are settled by the test suite and the flake check above.Closes allod/nexus#59