Skip to content

fix(image): bake template .venv into Nix image - #745

Merged
c-vigo merged 2 commits into
feature/625-nix-claude-migrationfrom
bugfix/735-bake-venv
Jun 29, 2026
Merged

c-vigo merged 2 commits into
feature/625-nix-claude-migrationfrom
bugfix/735-bake-venv

Conversation

@c-vigo

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

Copy link
Copy Markdown
Contributor

Summary

The Nix-built image sets UV_PROJECT_ENVIRONMENT/VIRTUAL_ENV to /root/assets/workspace/.venv but never created that venv (the old Debian image did). The published 0.3.x consumer post-create.sh runs sed -i .../.venv/bin/activate as its first venv step and aborts under set -euo pipefail (exit 2) when the file is missing — so git setup, gh auth, pre-commit install, and just sync never run. Reproduced on 4/4 non-TypeScript consumers.

Change

  • flake.nix: the bootstrap layer (which already creates /opt/pre-commit-cache, /workspace, /usr/local/bin, /tmp) now pre-creates the project virtualenv from the baked CPython:
    • ${python}/bin/python3 -m venv "$out/root/assets/workspace/.venv" — hermetic, network-free, no packages (the consumer's just sync/uv populates it).
    • Rewrites the build-time $out prefix baked into activate/pyvenv.cfg so VIRTUAL_ENV resolves to the runtime path /root/assets/workspace/.venv inside the container. The advertised env vars are unchanged (the path is already writable — assets is cp -r'd, not a store symlink).
  • tests/test_image.py: new TestFileStructure::test_template_venv_baked asserts /root/assets/workspace/.venv/bin/activate exists (runs in the CI image suite).
  • CHANGELOG.md ## Unreleased → ### Fixed entry [#735], mirrored into assets/workspace/.devcontainer/CHANGELOG.md via sync_manifest.py.

Verification

  • Offline-safe: nix eval --raw .#devcontainerImage.drvPath --accept-flake-config → /nix/store/k5vkv59hx1ln62lvbcwivhyh3pqbg4gy-devcontainer.tar.gz.drv (flake evaluates).
  • Full build + in-container assertion run in the dispatched CI image suite (no local build — sandbox has no network).

Closes #735

c-vigo added 2 commits June 29, 2026 12:51
The image advertises UV_PROJECT_ENVIRONMENT/VIRTUAL_ENV at
/root/assets/workspace/.venv but never created it, so consumer
post-create.sh aborted under set -e on the first .venv/bin/activate
step. Pre-create the venv from the baked CPython in the bootstrap
layer (hermetic, no deps).

Refs: #735
@c-vigo
c-vigo merged commit cff9e69 into feature/625-nix-claude-migration Jun 29, 2026
10 checks passed
@c-vigo
c-vigo deleted the bugfix/735-bake-venv branch June 29, 2026 11:35
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