Skip to content

feat(nix): migrate the devcontainer to a Nix toolchain + Claude-native setup (#625) - #670

Merged
c-vigo merged 251 commits into
devfrom
feature/625-nix-claude-migration
Jun 30, 2026
Merged

c-vigo merged 251 commits into
devfrom
feature/625-nix-claude-migration

Conversation

@c-vigo

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

Copy link
Copy Markdown
Contributor

Migrate the devcontainer to a Nix toolchain

This epic replaces the Debian-based devcontainer (a Containerfile on
python:3.14-slim, provisioned with apt + ad-hoc installers) with a Nix
flake that is the single source of truth for one toolchain
, delivered two
ways. It is a large change; this description is the reviewer's map of the new
paradigm. Per-change detail is in the ## Unreleased section of CHANGELOG.md;
onboarding/architecture is in docs/NIX.md; the consumer-facing contract is in
docs/MIGRATION.md (also shipped in the image).

The paradigm

  • One toolchain SSoT. flake.nix's devTools list defines the toolchain
    once. A parity test (tests/test_flake_devshell.py) guarantees the dev-shell
    and the image never drift. The old per-OS requirements.yaml dual-manifest is
    gone.
  • Two delivery modes, same toolchain.
    • Container image — assembled by dockerTools.buildLayeredImage (no base
      distro, no Dockerfile FROM), bit-reproducible, built natively for
      amd64 + arm64
      (no QEMU). Published as ghcr.io/vig-os/devcontainer.
    • Bare-nix dev-shell — the same toolchain via nix develop / direnv,
      consumed as a flake input (vigos.lib.mkProjectShell). install.sh --mode devcontainer|direnv|both scaffolds either.
  • Reproducibility & updates. flake.lock is the controlling version
    document; nixpkgs is pinned (nixos-26.05) with a thin nixpkgs-unstable
    overlay for fast-movers (uv, gh, claude). Renovate's nix manager bumps
    the lock through the normal PR/CI gate.
  • On-demand, not bloated. The image stays minimal (build automation, git/gh,
    uv/Python 3.14, Node, shell tooling, linters, agent toolkit). Extra language
    toolchains (Rust/Go/cc) are sourced on-demand via a project flake's
    extraPackages or ad-hoc nix shell, never baked into every consumer.
  • Security. Debian/Trivy-OS scanning is replaced by vulnix (nixpkgs-native
    CVE scanner) + a CycloneDX SBOM; "advance the pinned nixpkgs rev" is the
    primary CVE lever. A nightly vulnix-gate is the publish go/no-go signal.

What reviewers should focus on

  • flake.nix — devTools, mkProjectShell, and the buildLayeredImage
    assembly (the bootstrap layer that restores the FHS conveniences a pure-Nix
    userland lacks: /usr/bin/env, an arch-aware manylinux loader + LD_LIBRARY_PATH,
    a writable npm prefix, the baked project .venv, /etc/nix/nix.conf, and a
    docker → podman shim).
  • CI: setup-env provisions flake tooling from the dev-shell (the SSoT) for
    every job that actually consumes it — the image build/test jobs and the vulnix
    CVE gate — while jobs that only run uv-managed project tools or GitHub-native
    actions use the lighter ad-hoc setup; the Nix Image (discovery) workflow
    builds + tests the image on both arches and runs an in-container Nix runtime
    smoke test.
  • The dev-shell ⇄ image parity model and the NixOS-vs-FHS handling of the C++
    runtime on LD_LIBRARY_PATH (gated to avoid leaking into FHS host binaries).

Consumer-facing contract (see docs/MIGRATION.md)

No apt; #!/usr/bin/env works; npm -g resolves; docker maps to podman
(DooD via mounted socket); Python is uv-managed CPython 3.14 (pin
requires-python as a range, not an exact patch); manylinux wheels run;
pre-commit ruff/typos come from the flake.

Cross-stack validation (final image)

The finished image + bare-nix dev-shell were exercised live against one real
consumer per stack, in both delivery modes (container :dev and
nix develop against the flake input):

Repo Stack What was tested Result
vig-os/sync-issues-action TypeScript post-create (node/act/tsx/local-action), npm ci && build && test; bare-nix python3+pre-commit ✅ 95/95
exoma-ch/brother-printer Python baked .venv + post-create, uv sync, in-image pre-commit incl. pymarkdown, just test, DooD ✅ 321 pass
exo-pet/playground-carlos Python/web post-create, numpy/scipy/pandas + pymarkdown/ruff/typos in-image, just test ✅ 69 pass
vig-os/devcontainer-smoke-test Shell + DooD docker→podman DooD (sibling container spawn), on-demand nix ✅ (see note)
vig-os/scitadel Rust image stays Rust-minimal; on-demand toolchain via project-flake extraPackages / nix shell ✅

What a consumer must adapt for the new environment (the image is a pure-Nix
userland, not Debian):

  • Drop apt-based post-create steps — there is no apt. Get tools from the
    baked toolchain, uv/npm, or Nix. (e.g. the old node-via-apt pattern and
    brother-printer's apt install libusb step now no-op; the latter only affects
    opt-in hardware tests.)
  • Pin requires-python as a range, not an exact patch — an ==3.14.x pin can
    be unsatisfiable against the image interpreter. (The smoke-test repo still
    carries a stale ==3.14.6; it heals from the template at the next release
    dispatch — the ⚠️ "note" above.)
  • Compiled toolchains (Rust/Go/cc) come from the consumer's project flake
    (extraPackages) or an ad-hoc nix shell, never the base image.
  • DooD needs both CONTAINER_HOST and DOCKER_HOST pointed at the mounted
    socket (the scaffolded docker-compose.yml does this); literal docker calls
    resolve through the podman shim.

Scope / sequencing

This PR is validated end-to-end (CI green on both arches; a cross-stack live
sweep across TypeScript/Python/Rust/shell consumers in both modes). The
versioned/:latest publish-cutover is intentionally gated and remains a
separate, deliberate step after this merges.

c-vigo and others added 30 commits June 23, 2026 09:23
Add a guard that fails until agent rules/skills migrate from .cursor/ to
.claude/ and the root .cursor/ directory is deleted. Archival snapshots
(docs/issues, docs/pull-requests, docs/plans) and the downstream workspace
template (assets/workspace/, #629) are excluded.

Refs: #626
Replace the cursor-agent invocations in the worktree recipes with the
claude CLI. worktree-start/worktree-attach now launch
'claude --dangerously-skip-permissions' in the tmux session, mapping
'agent chat --yolo --approve-mcps' (autonomous, auto-approve shell and
MCP prompts) onto claude's permission-bypass flag. The cursor-specific
directory-trust helper and the 'tmux send-keys a' approval trigger are no
longer needed and are removed. Prerequisite, auth (claude auth
status/login, ANTHROPIC_API_KEY), requirements.yaml, and the generated
docs now reference the claude CLI.

Refs: #627
Replace Debian/FHS-specific assertions in tests/test_image.py with
path-agnostic equivalents so the suite is valid against both the current
Debian image and the future Nix image:

- convert dpkg host.package(...).is_installed checks (git, curl,
  openssh-client, nano, tmux, rsync) to --version/-V runs
- resolve gh, just, hadolint, taplo and cargo-installed tools via PATH
  (command -v) instead of hardcoded /usr/local/bin, /root/.cargo/bin and
  /root/.local/bin locations
- drop the DEBIAN_FRONTEND env assertion and apt-sourced version-prefix
  checks (git, curl, tmux, rsync) from EXPECTED_VERSIONS

Refs: #635
Move agent rules and skills from .cursor/ to .claude/ and delete the root
.cursor/ directory:

- Move the 30 skills to .claude/skills/ and rewrite the 29 .claude/commands/*.md
  wrappers to point at the new paths and .claude-located rules.
- Split the 7 .cursor/rules/*.mdc: static principles (coding-principles,
  commit-messages, changelog, single-source-of-truth) are consolidated into
  CLAUDE.md; workflow rules (branch-naming, tdd, subagent-delegation) become
  on-demand .claude/skills/.
- Port agent-models.toml and worktrees.json to .claude/.
- Update path consumers: docs/generate.py scan path, the check-skill-names and
  generate-docs pre-commit hooks, the check-skill-names and derive-branch-summary
  shell entrypoints, scripts/manifest.toml, docs/SKILL_PIPELINE.md(.j2),
  docs/RELEASE_CYCLE.md, CLAUDE.md command table, CODEOWNERS, label-taxonomy.toml,
  and the vig-utils README/tests.

The downstream assets/workspace/.cursor/ template is left for #629.

Refs: #626
## Summary

Implements C1 (#626): make `.claude/` the single source of truth for
agent rules and skills, removing the `.cursor/` indirection.

- **Skills:** moved the 30 `.cursor/skills/*/SKILL.md` (and the
`inception_explore/README.md` sibling) to `.claude/skills/`; rewrote the
29 `.claude/commands/*.md` wrappers to point at `.claude/skills/...` and
`.claude/`-located rules.
- **Rules split** (7 `.mdc`): static principles (`coding-principles`,
`commit-messages`, `changelog`, `single-source-of-truth`) consolidated
into `CLAUDE.md`; workflow rules (`branch-naming`, `tdd`,
`subagent-delegation`) became on-demand `.claude/skills/` with
`disable-model-invocation: true`.
- **Config:** ported `agent-models.toml` and `worktrees.json` to
`.claude/`.
- **Path consumers updated:** `docs/generate.py` scan path + docstrings;
`.pre-commit-config.yaml` (`check-skill-names` entry/`files`,
`generate-docs` `files` now also fires on `.claude/skills/**/SKILL.md` —
folds in #144); `check-skill-names.sh` and `derive-branch-summary.sh`
defaults; `scripts/manifest.toml`; `docs/SKILL_PIPELINE.md(.j2)`;
`docs/RELEASE_CYCLE.md`; `CLAUDE.md` command table + rule pointers;
`.github/CODEOWNERS`; `.github/label-taxonomy.toml`; vig-utils
`README.md` and tests.
- **Deleted** the root `.cursor/`.

## TDD

- `packages/vig-utils/tests/test_claude_ssot.py` asserts no tracked file
(outside `assets/workspace/`, archival
`docs/issues|pull-requests|plans/`, and append-only `CHANGELOG.md`)
references `.cursor/skills/`, and that root `.cursor/` is gone.
Committed failing first (RED), then implementation (GREEN).

## Verification

- All 492 vig-utils tests pass.
- `pre-commit run --all-files` green.
- `just docs` regenerates cleanly; command table intact (33 rows); the 3
new workflow skills do not leak into the table.
- Every command wrapper resolves to an existing
`.claude/skills/.../SKILL.md`; no `.cursor/` path in any wrapper; root
`.cursor/` deleted.

## Coordination notes

- The downstream `assets/workspace/.cursor/` template is **#629 (C4)'s**
scope and is intentionally left in place. The mandatory `sync-manifest`
pre-commit hook now also propagates `.claude/skills/` +
`.claude/worktrees.json` into `assets/workspace/.claude/`; the stale
`assets/workspace/.cursor/` tree is for #629 to remove.
- `justfile.worktree` recipe bodies were not edited (C2/W2). The
`~/.cursor/cli-config.json` reference in `SKILL_PIPELINE.md` is the
cursor-agent CLI runtime (#627) and was left untouched.
- #144 is effectively resolved by the updated `generate-docs` hook
filter.

Refs: #626
…' into feature/627-worktree-claude-cli

# Conflicts:
#	CHANGELOG.md
#	assets/workspace/.devcontainer/CHANGELOG.md
…' into feature/635-portable-testinfra

# Conflicts:
#	CHANGELOG.md
#	assets/workspace/.devcontainer/CHANGELOG.md
## Summary

Implements C2 (#627): replaces the `cursor-agent` CLI with the `claude`
CLI throughout the worktree pipelines. This is a functional change — the
recipes now drive `claude` end-to-end.

### Changes
- **`justfile.worktree`** (+ synced template
`assets/workspace/.devcontainer/justfile.worktree`, regenerated via
`sync-manifest`):
- Prereq check `command -v agent` → `command -v claude` (install hint →
`npm install -g @anthropic-ai/claude-code`).
- Auth block `agent status`/`agent login`/`CURSOR_API_KEY` → `claude
auth status`/`claude auth login`/`ANTHROPIC_API_KEY`.
- tmux launches `agent chat --yolo --approve-mcps "$PROMPT"` (and
no-prompt `agent chat --approve-mcps`) → `claude
--dangerously-skip-permissions "$PROMPT"` / `claude
--dangerously-skip-permissions`, in all three sites (existing-worktree,
new-worktree, attach-restart).
- Removed the cursor-specific `_wt_ensure_trust` helper + calls and the
`tmux send-keys "a"` approval trigger (no longer needed — see
decisions).
- **`scripts/requirements.yaml`**: `agent` (cursor.com installer) entry
→ `claude` entry (`command -v claude`, `claude --version`, `npm install
-g @anthropic-ai/claude-code`).
- **Docs**: `README.md` / `CONTRIBUTE.md` recipe help regenerated;
`docs/templates/SKILL_PIPELINE.md.j2` (and generated
`docs/SKILL_PIPELINE.md`) updated to describe the `claude` runtime.
- **`tests/bats/worktree-claude-cli.bats`**: lightweight recipe-grep
tests (no `cursor-agent`/`agent chat` survives; `claude` is driven;
prereq checks `claude`). The full `worktree.bats` functional rewrite is
C5's (#630) — not done here.
- **`CHANGELOG.md`** Unreleased / Changed entry.

### Decisions (flag-mapping)
- `--yolo` (auto-approve shell commands) **and** `--approve-mcps`
(auto-approve MCP servers) both map onto **`claude
--dangerously-skip-permissions`**, which bypasses all permission and MCP
approval prompts — the autonomous, no-human-at-terminal equivalent.
- **tmux pattern kept**: the detached `tmux new-session` driving is
retained (so `worktree-attach`, list/stop/clean lifecycle and
idle/dashboard features still work). The prompt is now passed as a
positional arg to `claude` at launch instead of via the interactive
session, so the post-launch `send-keys "a"` accept-trigger (which
dismissed cursor-agent's trust prompt) is **removed** —
`--dangerously-skip-permissions` means there is no prompt to accept.
- **Trust helper removed**: `_wt_ensure_trust` wrote
`~/.cursor/cli-config.json` `trustedDirectories`, which is
cursor-agent-only and unread by `claude`; with
`--dangerously-skip-permissions` directory trust is moot, so it is dead
code and was dropped. `jq` requirement stays (still used for
issue-metadata parsing).
- Did **not** touch `_read_model`/`.cursor/agent-models.toml` or
`.cursor/rules` paths (W1/C1's domain).

### Verification
- `grep -n 'cursor-agent\|agent chat' justfile.worktree
assets/workspace/.devcontainer/justfile.worktree` → empty.
- `scripts/requirements.yaml` lists `claude`, not `agent`.
- `just precommit` → all hooks green (including `sync-manifest`,
`generate-docs`, `shellcheck`, `just` format).
- `just --list` parses the worktree recipes; help text shows "launch the
claude CLI".

Refs: #627
…' into feature/635-portable-testinfra

# Conflicts:
#	CHANGELOG.md
#	assets/workspace/.devcontainer/CHANGELOG.md
…es (#645)

## Summary

Makes `tests/test_image.py` path-agnostic (T2.2) so the testinfra suite
stays valid against **both** the current Debian image and the future Nix
image. Pure test refactor — no `conftest.py` image source/name changes.

- Convert dpkg `host.package(...).is_installed` checks (`git`, `curl`,
`openssh-client`, `nano`, `tmux`, `rsync`) to `--version`/`-V` runs via
a small `assert_tool_runs` helper.
- Resolve `gh`, `just`, `hadolint`, `taplo` and cargo-installed tools
via PATH (`command -v`, new `assert_tool_on_path` helper) instead of
hardcoded `/usr/local/bin`, `/root/.cargo/bin`, `/root/.local/bin`.
- Drop the `DEBIAN_FRONTEND` env assertion and the apt-sourced
version-prefix checks (`git`, `curl`, `tmux`, `rsync`) from
`EXPECTED_VERSIONS`.
- Reviewed the `/root/assets/workspace/` mount assertions: they use
POSIX `host.file(...)` checks on image-controlled `/root/...` paths (not
Debian-FHS/dpkg), so they are already portable and left functionally
intact.

Note: bumped the manually-installed `just` version pin `1.53.` ->
`1.54.` to match the current latest-release binary in the image (the old
pin was already failing on a fresh build, independent of this refactor).

## Verification

- Built the Debian image with isolated tag `wt635` (`./scripts/build.sh
wt635 ...`), no `:latest`/`:dev` clobber, nothing pushed.
- `just test-image wt635`: **64 passed in 193.32s** (green).
- `just precommit`: all hooks pass.
- No Debian/FHS-only assertions remain (no
`is_installed`/`host.package`, no hardcoded `/usr/local/bin` etc., no
`DEBIAN_FRONTEND`, no apt version prefixes) — remaining textual matches
are docstrings/comments only.

Refs: #635
Delete the unpinned cursor.com/install build step and its
/root/.local/bin PATH entry, leaving an all-nixpkgs toolchain
ahead of the Nix migration.

Refs: #628
Remove test_cursor_agent_installed, which asserts a feature removed
in the same change; keeps the suite coherent and green.

Refs: #628
Remove the CVE-2026-55388 (piscina) .trivyignore entry, which only
existed for the now-removed cursor-agent CLI.

Refs: #628
Replace the stale assets/workspace/.cursor/ template tree with the
Claude-native .claude/ payload (skills, agent-models.toml, worktrees.json)
via the sync manifest, and drop Cursor editor glue:

- Remove assets/workspace/.cursor/; add .claude/agent-models.toml to the
  workspace sync manifest so the template carries the same payload the old
  .cursor/ template did.
- Drop the cursor-remote-ssh socket glob from verify-auth.sh.
- Drop the command -v cursor fallback in justfile.devc open recipe (VS Code only).
- COMMIT_MESSAGE_STANDARD.md: VS Code / Cursor -> VS Code.

Refs: #629
## C4 #629 — Migrate templates & editor glue off Cursor (VS Code only)

Reconciles the workspace template left behind by C1 (#626) and removes
the
remaining Cursor **editor** glue in #629's scope. Decision: **VS Code
only**.

### Changes
- **Template `.cursor/` → `.claude/`**: deleted the stale
`assets/workspace/.cursor/`
  tree. C1's sync-manifest hook already propagated `.claude/skills/` and
  `.claude/worktrees.json`; this PR adds `.claude/agent-models.toml` to
`scripts/manifest.toml` so the template carries the **same payload the
old
`.cursor/` template did** (skills + agent-models.toml + worktrees.json).
The
template's synced `subagent-delegation` skill references
`agent-models.toml`,
  so this also fixes a dangling reference C1 left.
- **`verify-auth.sh`**: dropped the `/tmp/cursor-remote-ssh-*.sock` glob
from the
  SSH-agent socket scan.
- **`justfile.devc`**: `open` recipe now launches VS Code only (removed
the
  `command -v cursor` fallback).
- **`docs/COMMIT_MESSAGE_STANDARD.md`** (root SSoT + synced template
copy):
  "VS Code / Cursor" → "VS Code".
- **CHANGELOG**: added an `## Unreleased` Changed entry.

### Scope boundaries (intentionally NOT touched)
- `justfile.worktree` and `solve-and-pr/SKILL.md` `cursor-agent`
references →
owned by **#627** (worktree pipelines cursor-agent → claude); they sync
from
  the root SSoT, so editing them here would collide with #627.
- `.github/agent-blocklist.toml` "cursor" entries → AI commit-identity
blocklist,
  explicitly **kept** per **#630**. Not editor glue.
- `setup-git-conf.sh` had no remaining `cursor` references on the epic
tip.

### TDD
- RED: `tests/bats/init-workspace.bats` — assert template scaffolds
`.claude/`
(+ `skills/`), does NOT scaffold `.cursor/`, and carries no
`cursor-remote` /
  `command -v cursor` glue. Committed failing first.
- GREEN: implementation makes all four pass; full `init-workspace.bats`
suite
  27/27 green.
- Build-free rationale: the integration `initialized_workspace` fixture
requires
a container image build (out of bounds this batch). `init-workspace.sh`
rsyncs
`assets/workspace/` verbatim, so structural assertions on the template
tree are
  a faithful proxy for what new workspaces scaffold.

### Verification
- `just precommit` — all hooks pass (sync-manifest, check-skill-names,
  generate-docs, shellcheck, taplo, etc.).
- `grep -rn 'cursor' assets/workspace justfile.devc` (excluding
CHANGELOG prose)
  returns only the out-of-scope #627/#630 hits listed above.
- No `assets/workspace/.cursor/` remains.

Refs: #629
Removes the unpinned `cursor-agent` CLI install from the devcontainer
image and the CVE ignore tied to it.

- Delete the cursor-agent install block from `Containerfile` and
`build/Containerfile` (+ dead PATH note)
- Drop `CVE-2026-55388` (piscina, bundled in cursor-agent) from
`.trivyignore`
- Remove the now-invalid `test_cursor_agent_installed` image test
(atomically coupled to the install removal; pre-empts that one bullet of
C5 #630)
- Changelog entry

Verification deferred to CI (image suite): build + image tests + Trivy
security scan. Local build was not completed in-worktree.

Refs: #628
…650)

## Summary

Implements C5 (#630) of the Nix/Claude migration epic (#625): adapts the
Cursor-coupled worktree test to the `claude` CLI and locks in the
AI-identity blocklist so removing Cursor never weakens the org "never
name an AI in history" control.

- **`tests/bats/worktree.bats`** — replaced the `send-keys 'a' approves
agent trust prompt` case (which skipped on `command -v agent` and
asserted `"Cursor Agent"`) with `claude CLI launches in tmux without an
interactive trust prompt`: skips on `command -v claude`, launches
`claude --dangerously-skip-permissions --version` the way the migrated
recipes do, and asserts no trust prompt stalls the pane. No assertion
expecting `cursor-agent`/"Cursor Agent" remains.
- **Blocklist regression test** — added `TestCanonicalBlocklist` in
`packages/vig-utils/tests/test_check_pr_agent_fingerprints.py`
exercising the REAL `.github/agent-blocklist.toml` (not a mock): a
parametrized test proves BOTH `cursor` and `claude` are rejected in a
commit message, plus a guard that both names stay in the blocklist. The
`cursor` entries are intentionally kept.
- **CHANGELOG** — `## Unreleased` Changed entry for #630.

## Reconciliation with C2 (#627)
C2 added `tests/bats/worktree-claude-cli.bats` (static recipe-grep:
justfiles drive `claude`, no `cursor-agent` survives). That file is kept
as-is — it covers the recipe layer. This PR covers the complementary
runtime/behavioral layer in `worktree.bats`, so there is no duplication.
C3 (#628) already removed `test_cursor_agent_installed`; not touched.

## Verification
- `just precommit` — all hooks pass.
- `uv run pytest` (vig-utils) — 495 passed (incl. 3 new blocklist
tests).
- `CI=true npx bats tests/bats/worktree.bats
tests/bats/worktree-claude-cli.bats` — 13 passed (tmux integration cases
skip under CI by design).
- Blocklist test confirmed proving cursor + claude both rejected against
the canonical TOML.

Done via TDD: blocklist regression test committed first (passes against
current blocklist as a guard), then the bats rewrite, then the
changelog.

Refs: #630
Factor a single devTools list as the source of truth shared by the dev-shell
now and the image later. Absorb the #545 agent-CLI toolkit (rg, fd, bat, eza,
delta, lazygit, zoxide, starship, freeze, expect, neovim, claude). Pin nixpkgs
to nixos-25.05 and overlay fast-movers (uv, gh, claude-code) from
nixpkgs-unstable. Add reusable lib.mkProjectShell, overlays.default and a
packages.devcontainerImage stub, and refresh flake.lock.

Refs: #631
Build the flake dev-shell and push its closure to the vig-os Cachix cache via
cachix/install-nix-action (upstream CppNix) + cachix/cachix-action. The job is
a standalone, non-required workflow with continue-on-error so it never affects
the existing CI gate, and adds workflow_dispatch for on-branch validation.

Refs: #631
## Summary

Implements **T1.1 (#631)** — collapses the flake dev-shell and the
(future) image tool list into a single `devTools` source of truth and
lays the reusable flake outputs the rest of the Nix track depends on.

### What changed
- **Single `devTools` SSoT** in `flake.nix` — shared basis for the
dev-shell now and the image later (#634). Absorbs the #545 agent-CLI
toolkit (`rg`, `fd`, `bat`, `eza`, `delta`, `lazygit`, `zoxide`,
`starship`, `freeze`, `expect`, `nvim`) plus `claude`, on top of the
existing toolchain (`just`, `git`, `gh`, `uv`, `nodejs`, `jq`, `tmux`,
`shellcheck`, `hadolint`, `taplo`, `podman`).
- **Channel switch** — `nixpkgs` pinned to `nixos-25.05`; new
`nixpkgs-unstable` input overlaid **only** for fast-movers `uv`, `gh`,
`claude-code`. `flake.lock` refreshed.
- **Reusable outputs** — `lib.mkProjectShell` (downstream repos build
the shared shell + extra packages), `overlays.default` (the fast-mover
overlay), and a `packages.devcontainerImage` **stub** (placeholder; real
image is T2.1/#634).
- **Cachix CI** — new non-blocking `nix-cachix.yml` workflow that builds
the dev-shell and pushes its closure to the `vig-os` cache.
- **TDD parity test** — `tests/test_flake_devshell.py` reads the binary
names straight from the flake (`nix eval .#devShellTools.<system>`) and
runs `nix develop -c <tool> <version-flag>` for each, so it can never
drift from `devTools`.

### How `claude` is provided
`claude` is the **`claude-code`** package from nixpkgs (binary `claude`,
via `meta.mainProgram`). It is a fast-mover, so it is sourced from
`nixpkgs-unstable` through `overlays.default` (unstable `2.1.x` vs
stable `1.0.85`). No custom fetch/overlay-from-scratch needed — it is
packaged cleanly in nixpkgs.

> Note: nixpkgs `freeze` is an EDR-bypass payload toolkit
(optiv/Freeze), **not** the charmbracelet terminal-screenshot tool #545
intended. Used **`charm-freeze`** (binary `freeze`) instead.

### Evaluator choice + rationale
**Upstream CppNix** via `cachix/install-nix-action` (SHA-pinned
`v31.10.6`). It is the most broadly supported installer, pairs natively
with `cachix/cachix-action`, and needs no extra infra. The flake is
**installer-agnostic** — swapping to the Lix `lix-installer` or the
Determinate installer requires **zero flake changes**, so this decision
is cheaply reversible.

### Cachix wiring
- `cachix/install-nix-action@…v31.10.6` (flakes enabled) →
`cachix/cachix-action@…v17` with `name: ${{ vars.CACHIX_CACHE }}` and
`authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}` (token never
printed/hardcoded).
- Builds `nix develop --profile dev-profile` and pushes `nix path-info
-r ./dev-profile | cachix push`.
- **Non-blocking:** standalone workflow (not a required check) +
`continue-on-error: true` → existing CI is unaffected.
- Adds **`workflow_dispatch`** plus a push trigger on the epic branch
for on-branch validation.
- Actions are SHA-pinned per `check-action-pins` policy.

### Verification (local, against the public `vig-os` cache)
- `nix flake check` → **all checks passed** (`devShellTools` shows only
a benign "unknown flake output" warning).
- `tests/test_flake_devshell.py` → **2 passed** — every one of the 23
tools runs inside `nix develop` (incl. `claude --version`, `nvim
--version`, `rg --version`, `freeze --version`, `tmux -V`, `expect -v`).
- `just precommit` → **all hooks pass** (incl. `check-action-pins`,
agent-identity, yamllint).

### TDD trail
- `test(nix):` failing parity test committed first (RED).
- `feat(nix):` flake SSoT + outputs making it pass (GREEN).
- `ci(nix):` non-blocking Cachix workflow.

Refs: #631
Switch .envrc from bare `use flake` to nix-direnv so the dev-shell
evaluation is GC-rooted and cached under .direnv/, making re-entry
instant and protecting the closure from garbage collection. nix-direnv
self-bootstraps on first `direnv allow` and falls back to bare
`use flake` when unavailable.

Document the clone -> `direnv allow` onboarding flow, the vig-os Cachix
substituter (binary fetch instead of from-source build on first allow),
and enabling the nix-command/flakes experimental features in the
CONTRIBUTE.md.j2 source template; regenerate with `just docs`. Folds in
the Nix-flake-as-alternative-dev-setup documentation request.

Refs: #633
Add a provision-via-flake mode to the setup-env action that installs
Nix (SHA-pinned) plus the vig-os Cachix substituter, builds the flake
dev-shell, and prepends its tools to PATH so subsequent steps run inside
the shell. The ad-hoc installs of uv/Python, just, hadolint, and taplo
are gated off in this mode; podman, Node.js, BATS, and the devcontainer
CLI keep their dedicated paths. Enable the mode across the CI build/test
path (build-image, test-image, test-integration, project-checks). The
Debian image is still built unchanged and the Docker type=gha cache stays
intact.

Refs: #632
c-vigo and others added 2 commits June 30, 2026 15:43
Split the substituters/trusted-public-keys lines into whitespace tokens
and assert exact membership instead of URL-substring-in-string, clearing
the CodeQL py/incomplete-url-substring-sanitization alerts and making the
assertions stricter.

Refs: #784
… url-substring) (#785)

Closes #784.

CodeQL flagged two high-severity
`py/incomplete-url-substring-sanitization` alerts at
`tests/test_image.py:1118,1121` — the #773 `nix.conf` assertions used
`"https://cache.nixos.org" in sub_line` (URL-substring-in-string), which
CodeQL treats as bypassable host validation.

**Fix:** split the `substituters` / `trusted-public-keys` lines into
whitespace tokens (`split("=", 1)[1].split()` — maxsplit=1 preserves the
base64 keys' trailing `=`) and assert **exact membership** in the token
list. Clears the alerts and tightens the assertion (URL/key must be a
whole token, not an accidental substring).

No behaviour change; test-only. Verified: `ast.parse` OK, `ruff check` +
`ruff format --check` clean. In-container assertions validated by the
dispatched image-suite CI.
Comment thread tests/test_image.py Dismissed
Comment thread tests/test_image.py Dismissed
@c-vigo

c-vigo commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

Replying to the forward-looking roadmap.

Took you up on the offer — all of A–E are now filed as tracked, scoped issues, with the move-in/stay-out (relocate-vs-eliminate) framing preserved in each body. I also pulled the two small, low-risk A items onto the migration branch now rather than deferring them, since one is security-critical and both are cheap; everything heavier stays sequenced as you intended.

Done now — landed on the migration branch (sub-issues of #625)

Deferred — sequenced follow-ups (separate issues, NOT on this branch)

Thread Issue
A · uv2nix/pyproject-nix scoping (dissolve the FHS/manylinux scar tissue) #775
A · first-class blocking Cachix push of the image closure #776
A · flake polish (treefmt-nix, deadnix/statix, nixos/homeManager modules, nix run .#install) #777
B · git-hooks.nix + package = pkgs.prek (supersedes #40) #778
C · flake-checks-as-CI Tier 0 (garnix / nix-fast-build) #779
D · secrets — sops-nix/age + OIDC #780
E · rename → devkit (sequenced after the gated publish-cutover #639) #781

Agree these deserve their own focused PRs — bundling the architectural ones (uv2nix, sops-nix, garnix, Cachix) into #670 would defeat the gating. Thanks again for the depth here; the Tier-0 move-in/stay-out table in particular made #779 trivial to scope.

@c-vigo
c-vigo enabled auto-merge June 30, 2026 15:35

@gerchowl gerchowl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve ✅ (for the gated scope)

Did a second verification round against the updated branch — not just reading the reply, but checking the diffs and CI. Everything load-bearing is genuinely landed:

  • B1 — release retag — release.yml:1004-1008 captures the loaded tag (docker load | sed -n 's/^Loaded image: //p') and retags from it; no more static $BUILD_VERSION-$arch assumption against the baked nix-dev tag. ✔
  • B2 — vulnix gate on publish — dedicated vulnix-gate job (release.yml:807) over .#devcontainerImageEnv, in both publish's and rollback's needs:, with the cancelled/failure guard. Hard CVE gate on the publish path now. ✔
  • M1 — two-sided parity gate — tests/test_image.py reads the tool list from nix eval .#devShellTools (never hardcoded), parametrizes per-tool, and asserts each resolves on PATH inside the running container. The "never drift" claim is now backed by an actual image-side gate. ✔
  • M2 — fail-loud gate — vulnix_gate.py:72-76 blocks on unscored (score is None) findings; security-scan.yml:85-90 drops the blanket || true and fails on a vulnix exit > 2. ✔

CI is green across the board, including the now-blocking Security Scan (9m44s). The remaining majors/nits are all attributed to merged sub-PRs with issue refs, and A–E are filed as #773–#781 with the relocate-vs-eliminate framing intact — with the two cheap/security-critical A items (#773 baked accept-flake-config removal, #774 uvPythonDownloadsJsonUrl drift) correctly pulled forward.

One non-blocking observation on M1: the parity gate skips (rather than fails) if nix eval can't resolve the tool list at collection time. The reasoning in the comment is sound (both image-test lanes provision nix), but it does mean a future CI change that drops nix from the test-image lane would turn the gate into a silent green skip rather than a failure. Worth a one-line guard later (e.g. assert the list is non-empty in the lanes that should have nix) — not a merge concern.

Accepted carve-out: the unparenthesized except A, B: — agreed. The repo is 3.14-only and ruff format (PEP 758) removes the parens, so parenthesizing would fail the formatter gate. My original concern was the pre-3.14 SyntaxError, which is moot here.

Model review loop — every item addressed traceably, the architectural work correctly kept out of #670 to preserve the gating, and one well-reasoned pushback. Approving on the understanding that the versioned/:latest publish-cutover remains the separate, deliberate step after this merges (#639), where B1/B2 first do real work.

@c-vigo
c-vigo merged commit ae50df2 into dev Jun 30, 2026
14 checks passed
@c-vigo
c-vigo deleted the feature/625-nix-claude-migration branch June 30, 2026 16:51
c-vigo added a commit that referenced this pull request Jul 1, 2026
…#787)

## Summary

Design-first ADR (issue #780, PR #670 roadmap thread D) recording the
secrets-management **pattern** — not a migration.

- `docs/security/ADR-secrets-management.md` — the decision record:
- **Two secret classes:** runtime/downstream-consumer secrets →
**sops-nix + age**
(each consumer decrypts with their own key, no per-repo GitHub-secret
dance);
cloud/registry auth → **GitHub OIDC** (the real no-stored-secret lever).
GitHub App installation tokens (`RELEASE_APP_*`, `COMMIT_APP_*`) stay
as-is.
- **Honest trust-model caveat:** on GitHub-hosted runners SOPS
*relocates* the
root of trust to one bootstrap key (`SOPS_AGE_KEY`) — it does not
eliminate
    the GitHub secret. Only OIDC reaches zero stored credentials.
- **Current landscape cited (file:line):** GHCR-via-`GITHUB_TOKEN` and
keyless
cosign are already correct; per-secret OIDC/sops/keep classification
table.
- **Concrete "now" lever:** honestly, OIDC retires zero *current*
secrets today
(GHCR already tokenless, cosign already keyless, App keys must stay);
the win
is preventive (never add a stored registry/cloud PAT — federate) plus
    `CACHIX_AUTH_TOKEN` as the one realistic future migration target.
- `docs/security/examples/sops-nix/` — a small, clearly-marked **inert**
reference
example (`.sops.yaml`, plaintext `secrets.example.yaml`, `example.nix`,
README).
Placeholder recipients, no real key material, not wired into any live
path.
- `CHANGELOG.md` — one `Added` entry (mirrored to the workspace template
copy by
  the managed sync-manifest hook).

## Relationship to #786

This is the **plumbing** layer (how secrets are stored/delivered); #786
is the
**agent-behaviour** layer (how an agent must act around a secret). They
compose
and do not restate each other — the ADR cross-links #786 and vice-versa.

No workflow is modified. Design only.

Refs: #780
c-vigo added a commit that referenced this pull request Jul 1, 2026
…tall` (#777) (#790)

## Summary

Lands the **A7 flake-polish bucket** (roadmap thread A, PR #670 review),
full scope per the plan:

- **treefmt-nix** — `nix fmt` and the flake format gate now run
`treefmt` across nix (`nixfmt-rfc-style`), python (`ruff-format`), and
toml (`taplo`) in one pass, wrapping the same formatters the pre-commit
hooks already run. `checks.format` → `checks.formatting` (`treefmt
--fail-on-change`).
- **deadnix + statix** — new `checks.deadnix` / `checks.statix` (scoped
to the authored `flake.nix`; the downstream scaffold + example keep
their idiomatic `{ self, … }` signatures), and both join `devTools`.
Fixed the two findings this surfaced: unused overlay args
(`_final`/`_prev`) and `inherit (pkgs) vulnix`.
- **Modules** — `nixosModules.default` / `homeManagerModules.default`
install the shared `devTools` toolchain via
`programs.vigos-devtools.enable = true`.
- **Install app** — `apps.install`, so `nix run
github:vig-os/devcontainer#install` bootstraps a consumer project
straight from the flake (`install.sh` stays the behavior SSoT).

## Verification

- `nix flake check --accept-flake-config` → **all checks passed**
(formatting, deadnix, statix, devShell, devShellTools).
- `nix run .#install -- --help` exits 0.
- `tests/test_flake_checks.py` extended (TDD RED→GREEN): formatter is
treefmt, checks expose the new gates, install app is runnable, both
modules are exposed. 4 passed.
- Pre-commit clean (nixfmt, pymarkdown, typos, sync-manifest,
agent-identity).

Docs: `docs/NIX.md` (formatting/checks/modules/install app) +
`CHANGELOG.md` (Added + Changed).

Refs: #777
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.

3 participants