Skip to content

test(nix): smoke-test the in-container nix/direnv runtime - #679

Merged
c-vigo merged 1 commit into
feature/625-nix-claude-migrationfrom
test/675-nix-incontainer-smoke
Jun 24, 2026
Merged

c-vigo merged 1 commit into
feature/625-nix-claude-migrationfrom
test/675-nix-incontainer-smoke

Conversation

@c-vigo

@c-vigo c-vigo commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

What

Adds an in-container Nix runtime smoke test so a regression that leaves
nix/direnv on PATH but broken can no longer pass CI.

The Nix-built image bakes the Nix toolchain live into the closure (nix,
direnv, nix-direnv — flake.nix imageTools, #634). The portable testinfra
suite (tests/test_image.py, #635) only asserts tool presence, not that the
runtime functions — so a broken evaluator/direnv would slip through.

Changes

  • scripts/nix_runtime_smoke.sh (new, executable, shellcheck-clean) — runs
    INSIDE the image and checks, all network-free:
    • nix --version
    • direnv version
    • nix eval --extra-experimental-features 'nix-command flakes' --expr '1 + 1'
      (asserts == 2) — exercises the evaluator + experimental features, not just
      the binary's --version
    • direnv allow + direnv exec . true round-trip against a trivial .envrc
      — proves direnv's own allow/hook/exec runtime
  • .github/workflows/nix-image.yml — a new gating step in build-and-test
    (both arches), right after the testinfra run, executes the script in the image
    the test-image action already loaded into podman (${REGISTRY}:nix-image),
    bind-mounting scripts/ read-only:
    podman run --rm -v "${PWD}/scripts":/smoke:ro "${REGISTRY}:nix-image" \
      bash /smoke/nix_runtime_smoke.sh
    
  • CHANGELOG.md (+ hook-synced assets/workspace/.devcontainer/CHANGELOG.md)
    — one ### Added bullet.

Design notes

  • podman, not docker: the test-image composite action loads the image into
    podman as ${REGISTRY}:nix-image; reusing that loaded image avoids a
    second docker load of the heavy tarball.
  • Network-free by design: nix develop against the scaffolded workspace flake
    (/root/assets/workspace) would fetch github:vig-os/devcontainer + nixpkgs
    (slow, flaky, can produce false failures). Instead the script uses nix eval
    (evaluator path) + a direnv allow/exec round-trip (the acceptance-listed
    direnv substitute), which are deterministic and still fail iff the runtime is
    broken.
  • Confined to nix-image.yml; ci.yml untouched (sibling PR owns it).

Validation

Per the TDD note, the full image was not built locally (heavy/minutes). The
script logic was validated on the host (nix --version, direnv version,
nix eval, direnv allow/exec all green) and shellcheck/yamllint are clean.
Full in-image execution is deferred to the scoped nix-image.yml CI run.

Closes #675

The portable testinfra suite only asserts that nix/direnv/nix-direnv are
present in the Nix-built image, not that the baked runtime functions. Add a
self-contained, network-free smoke script run inside the loaded image that
checks `nix --version`, `direnv version`, a real `nix eval` (evaluator +
nix-command/flakes), and a direnv allow/exec round-trip, and gate the
nix-image build/test job on it so a broken in-container nix/direnv fails CI.

Refs: #675
@c-vigo
c-vigo force-pushed the test/675-nix-incontainer-smoke branch from 449f57b to f14687d Compare June 24, 2026 11:42
@c-vigo
c-vigo merged commit c0d1fdb into feature/625-nix-claude-migration Jun 24, 2026
2 checks passed
@c-vigo
c-vigo deleted the test/675-nix-incontainer-smoke branch June 24, 2026 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant