Skip to content

perf(image): bake the build-time placeholder manifest into the Nix image - #802

Merged
c-vigo merged 3 commits into
devfrom
feature/718-bake-placeholder-manifest
Jul 3, 2026
Merged

c-vigo merged 3 commits into
devfrom
feature/718-bake-placeholder-manifest

Conversation

@c-vigo

@c-vigo c-vigo commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

assets/init-workspace.sh reads a build-time manifest at
$SCRIPT_DIR/.placeholder-manifest.txt (/root/assets/.placeholder-manifest.txt
in the image) to take a fast substitution path, falling back to a slow runtime
find+grep over the whole scaffold when it is absent (logging "Manifest not found, searching at runtime (slower)"). The Nix image never generated this
manifest, so workspace init always took the slow path. The old Debian
Containerfile produced it via grep -rl over the workspace assets.

This bakes the manifest at image build time so the fast path fires. Output is
unchanged — the runtime fallback already produced correct results; this is a
startup-time optimization only.

Changes

  • flake.nix — the bootstrap layer now generates
    /root/assets/.placeholder-manifest.txt by grep -rl-listing every workspace
    asset carrying a {{SHORT_NAME}} / {{ORG_NAME}} / {{GITHUB_REPOSITORY}}
    token, rewritten to the in-image runtime path (/root/assets/workspace/...)
    and LC_ALL=C sorted for bit-reproducibility. Token set mirrors the runtime
    fallback in init-workspace.sh; matches how the Debian Containerfile built
    it. Excludes .git / .venv / .pre-commit-cache.
  • tests/test_image.py — new TestFileStructure::test_placeholder_manifest_baked
    asserting the baked image ships the manifest: present, non-empty, every line an
    in-image workspace path, and a known placeholder-bearing file
    (pyproject.toml) listed.
  • CHANGELOG.md — ### Changed entry under ## Unreleased.

Verification

  • nix eval .#packages.x86_64-linux.devcontainerImage.drvPath — flake evaluates
    clean.
  • nix fmt flake.nix — 0 changes (formatting gate satisfied).
  • Reproduced the exact grep -rl … | sort output over the real assets locally
    (18 placeholder-bearing files); the only build-specific step is stripping the
    $out store prefix via sed.
  • pytest --collect-only confirms the new test collects.

Caveat: I did not run a full nix build .#devcontainerImage / the image-content
test here (needs a full image build + a running podman container). The new
test_placeholder_manifest_baked gate runs against the built image in CI.

Refs: #718

c-vigo added 3 commits July 3, 2026 08:43
Add a TestFileStructure case asserting the Nix image ships
/root/assets/.placeholder-manifest.txt (non-empty, in-image workspace
paths, listing a known placeholder-bearing file) so init-workspace.sh
can take its fast substitution path. RED cannot be observed locally
without a full image build; the gate runs in CI against the built image.

Refs: #718
The Nix bootstrap layer now generates
/root/assets/.placeholder-manifest.txt (the file init-workspace.sh reads
beside itself) by grep-listing every workspace asset carrying a
{{SHORT_NAME}}/{{ORG_NAME}}/{{GITHUB_REPOSITORY}} token, at its in-image
runtime path and LC_ALL=C sorted for bit-reproducibility. Previously the
image shipped without the manifest, so workspace init always fell back to
a slow runtime find+grep; the fast substitution path now fires. Output is
unchanged (the fallback already produced correct results).

Refs: #718
Fixes the CI failures on the #718 branch: ruff-format reflows the new
test assertions, and the sync-manifest mirror of CHANGELOG.md into
assets/workspace/.devcontainer/ was stale (which also tripped the
pre-existing test_manifest_files image checksum gate).

Refs: #718
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