feat(engine): Engine::bootstrap wires LiveNixInstaller + writes /etc/nix/nix.conf#56
Merged
Merged
Conversation
…nix/nix.conf
Implements ADR-0012 + ADR-0013 on the engine side. The CLI surface
(`pearlite bootstrap` subcommand + script-fetch path) lands in the
next chunk; this PR wires the engine method that subcommand will
dispatch to.
- New `crates/pearlite-engine/src/bootstrap.rs`:
- `BootstrapOutcome { install: InstallOutcome, nix_conf_written: bool }`.
- `Engine::bootstrap(host_file, installer, script_path, nix_conf_path)`
loads the host via the existing Nickel adapter, requires a
declared `[nix.installer]` block, calls `installer.install_if_missing`
with the operator-supplied SHA pin, then writes
`/etc/nix/nix.conf` idempotently per ADR-0013.
- `BootstrapError` enum in `errors.rs`: Nickel / NixNotDeclared /
Installer / Fs / Io variants. `From` impls for the wrapped errors.
- `Engine::nickel()` accessor (pub(crate)) so bootstrap.rs can
reuse the same evaluator without duplicating the field.
- nix moved from dev-dep to regular dep so we can resolve current
uid/gid for the temp-dir-injected nix.conf write in tests; the
production write uses the same pearlite-fs::write_etc_atomic
pipeline as ConfigWrite, no new I/O surface.
- Five tests with MockNixInstaller covering: declared-SHA pass-through,
fresh nix.conf write, idempotent skip when line already present,
NixNotDeclared error, and short-circuit when nix is already
installed.
Tests: 312 passing (+5). Clippy clean. fmt clean. audit clean.
Bootstrap intentionally does not run schema validation — that's
plan's job; bootstrap is a one-shot side-effect with its own narrower
precondition.
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
Implements the engine half of ADR-0012 (
pearlite bootstrap) and ADR-0013 (system-wide nix.conf). The CLI surface —pearlite bootstrapsubcommand + installer-script-fetch path — lands in the next chunk; this PR is the engine method the subcommand will dispatch to.crates/pearlite-engine/src/bootstrap.rs:BootstrapOutcome { install: InstallOutcome, nix_conf_written: bool }.Engine::bootstrap(host_file, installer, script_path, nix_conf_path)loads the host via the existing Nickel adapter, requires a declared[nix.installer]block, callsinstaller.install_if_missingwith the operator-supplied SHA pin, then writes/etc/nix/nix.confidempotently withexperimental-features = nix-command flakesper ADR-0013.BootstrapErrorenum inerrors.rs: Nickel / NixNotDeclared / Installer / Fs / Io variants withFromimpls.Engine::nickel()accessor (pub(crate)) so bootstrap.rs can reuse the same evaluator.nixmoved from dev-dep to regular dep so we can resolve current uid/gid for the temp-dir-injected nix.conf write in tests; production uses the samepearlite-fs::write_etc_atomicpipeline asConfigWrite.Five new tests with
MockNixInstallercovering: declared-SHA pass-through, fresh nix.conf write, idempotent skip when the experimental-features line is already present (operator preamble preserved),NixNotDeclarederror, and the already-installed short-circuit.Bootstrap intentionally does not run schema validation — that's
plan's job; bootstrap is a one-shot side-effect with its own narrower precondition (NixNotDeclared).Test plan
cargo test --workspace --all-features— 312 passing (+5 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