feat(cli): pearlite bootstrap subcommand wires Engine::bootstrap#57
Merged
Conversation
Surfaces ADR-0012's bootstrap entry point to operators. Verifies the
operator-supplied Determinate installer script against the host's
declared SHA-256 pin, runs the installer if nix is missing, and writes
/etc/nix/nix.conf with the experimental-features minimum (ADR-0013).
- New `Command::Bootstrap { host_file, installer_script, nix_conf }`
in args.rs. `installer_script` is required (operator pre-downloads;
URL-fetch is a follow-up). `nix_conf` defaults to /etc/nix/nix.conf.
- `dispatch_bootstrap` calls Engine::bootstrap with the per-host
declared sha and renders BootstrapOutcome as the envelope `data`.
- `bootstrap_error_payload` maps every BootstrapError variant to a
typed error code with a runnable hint:
- NIX_NOT_DECLARED — host has no [nix.installer] block
- NIX_INSTALLER_SHA256_MISMATCH — declared vs. observed sha (ADR-004)
- NIX_INSTALLER_FAILED — script exec, missing shell, or non-zero exit
- BOOTSTRAP_NIX_CONF_WRITE_FAILED / BOOTSTRAP_NIX_CONF_READ_FAILED
- BOOTSTRAP_NICKEL_FAILED
All are class=preflight, exit=2 — bootstrap halts before mutating
state, so even installer failures are recoverable from the operator's
perspective.
- RunContext gains `nix_installer: Box<dyn NixInstaller>`. main.rs
wires LiveNixInstaller; the six dispatch test sites wire
MockNixInstaller. Two new dispatch tests cover the happy path and
the NIX_NOT_DECLARED error.
Tests: 314 passing (+2). Clippy clean. fmt clean. audit clean.
The next chunk lands the apply-side preflight check (NIX_NOT_INSTALLED
when home_manager.enabled = true and `nix --version` fails).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Surfaces ADR-0012's bootstrap entry point to operators. Verifies the operator-supplied Determinate installer script against the host's declared SHA-256 pin, runs the installer if nix is missing, and writes
/etc/nix/nix.confwith the experimental-features minimum (ADR-0013).New
Command::Bootstrap { host_file, installer_script, nix_conf }inargs.rs.installer_scriptis required (operator pre-downloads — URL-fetch is a follow-up).nix_confdefaults to/etc/nix/nix.conf.dispatch_bootstrapcallsEngine::bootstrapwith the per-host declared SHA and rendersBootstrapOutcomein the envelopedata.bootstrap_error_payloadmaps everyBootstrapErrorvariant to a typed error code with a runnable hint:NIX_NOT_DECLARED— host has no[nix.installer]blockNIX_INSTALLER_SHA256_MISMATCH— declared vs. observed SHA (ADR-004)NIX_INSTALLER_FAILED— script exec, missing shell, or non-zero exitBOOTSTRAP_NIX_CONF_WRITE_FAILED/BOOTSTRAP_NIX_CONF_READ_FAILEDBOOTSTRAP_NICKEL_FAILEDAll are class=preflight, exit=2 — bootstrap halts before mutating state, so even installer failures are recoverable from the operator's perspective.
RunContextgainsnix_installer: Box<dyn NixInstaller>.main.rswiresLiveNixInstaller; the six dispatch test sites wireMockNixInstaller. Two new dispatch tests cover the happy path and theNIX_NOT_DECLAREDerror.The next chunk lands the apply-side preflight check (
NIX_NOT_INSTALLEDwhenhome_manager.enabled = trueandnix --versionfails — per ADR-0012 decision 3).Test plan
cargo test --workspace --all-features— 314 passing (+2 new)cargo clippy --workspace --all-targets --all-features -- -D warnings— cleancargo fmt --all -- --check— cleanscripts/ci/check-spdx.sh— cleanpearlite-audit check .— 1 check, 0 violations🤖 Generated with Claude Code