Repository navigation
build: adopt git-hooks.nix + prek runner, expose checks.pre-commit, and gate flake checks as CI Tier 0 - #791
Conversation
Add the cachix/git-hooks.nix input and build a sandbox-pure checks.pre-commit driven by the prek runner (package = pkgs.prek): one treefmt formatting hook (reusing treefmtEval), the pure linters (ruff, shellcheck, yamllint, typos, taplo lint), the pre-commit-hooks meta hooks, and the vig-utils/bandit hooks wired to hermetic Nix binaries. Impure/stage-gated hooks stay runner-only. Drop the Python pre-commit from the dev-shell and image and add prek to the devTools SSoT (dev-shell + image). Rename the baked hook cache to PREK_HOME=/opt/prek-cache and the precommit alias to prek run. Refs: #778
Swap every git-hook invocation from the Python pre-commit to prek: the tracked .githooks shims (root + scaffold) call prek run, scripts/init.sh runs prek prepare-hooks, just precommit and the worktree setup use prek, and the downstream scaffold (init-precommit.sh, justfile.project) follows. Source shellcheck from the flake toolchain as a language:system hook: the shellcheck-py wheel bundles a manylinux binary the Nix userland cannot exec and prek/uv cannot build under Python 3.14, so it joins ruff/typos/nixfmt (#697, #701) as a flake-provided hook. Refs: #778
#778 drops the Python pre-commit from the image in favour of prek, so the integration tests that exec `pre-commit run` inside the container (TestDevContainerCLI:: test_pre_commit_hook and the branch-name convention tests) hit a command-not-found (exit 127) and failed. Point them at the `prek` runner the image now ships. Refs: #778
## What Adds `docs/rfcs/ADR-nix-devenv-strategy.md` — a decision record for the org's Nix dev-environment strategy, prompted by [exo-pet/exo-fleet#76](exo-pet/exo-fleet#76) (devenv→mkShell port) and its "compare devenv / devshell / mkshell / direnv" thread. The ADR's core move: that four-way question is a **category error**. It conflates **three separable axes**: 1. **Activation** — `nix-direnv` (auto on `cd`, GC-rooted) vs manual `nix develop`. Complementary. 2. **Shell definition** — `pkgs.mkShell` vs `numtide/devshell` vs `cachix/devenv`. Exclusive per repo. 3. **Local services** — `devenv up`-style MinIO/Postgres orchestration, which devenv *bundles* into axis 2. ## Decisions recorded - **Axes 1–2 (ratify existing practice):** `pkgs.mkShell` (via `mkProjectShell`) + `nix-direnv`. Reject `devenv`/`numtide-devshell` as the shared builder — both interpose their own package-declaration surface between the `devTools` SSoT and `PATH`, complicating the dev-shell↔image **parity test**; devenv additionally pays the measured ~165s IFD cold-eval (#76) and drags its own substituter. Consistent with #27 (already Superseded) and the #778/#791 move to `git-hooks.nix` + `prek`. - **Axis 3 (the one open decision):** adopt `process-compose` + `juspay/services-flake` as the nix-native `devenv up` replacement (daemon-free, versions from the same nixpkgs lock, GC-rooted, no IFD). Shared `mkProjectServices` helper + a MinIO+Postgres PoC tracked in #795. Includes two decision matrices (shell-definition; local-services), an Impact/blast-radius section (**authoritative for `vig-os`**, a **recommendation** to `exo-pet`/`exoma` siblings), and a `Reconsider if` section. ## Also - Cross-link from `docs/NIX.md` (`## See also`). - `CHANGELOG.md` Unreleased entry (`### Added`), mirrored to the scaffold copy by `sync-manifest`. ## Verification - `pre-commit run --files …` green on all changed docs (pymarkdown, typos, whitespace, generate-docs, sync-manifest, validate-commit-msg). - ADR matches the house style of `docs/rfcs/ADR-uv2nix-pyproject-nix.md` (frontmatter, TL;DR, Options, matrices, Reconsider-if, References). Refs #794
Build every checks.<system> derivation (treefmt formatting, deadnix/statix, dev-shell build, devShellTools, the git-hooks.nix pre-commit gate) in parallel with an eval cache via nix-fast-build, replacing the serial `nix flake check` step in project-checks. Expose nix-fast-build as packages.<system>.nix-fast-build (pinned-nixpkgs passthrough) so CI runs it via `nix run .#nix-fast-build` without baking a CI-only tool into the dev-shell or image. Validate the flake output schema (formatter/checks/apps/modules) with test_flake_checks.py, preserving what the removed `nix flake check` covered. Document the pure/effectful tiering in docs/rfcs/ADR-flake-checks-tier0.md. Refs: #779
Signed-off-by: Carlos Vigo <[email protected]>
|
Review finding — migration gap: CI lint gate still on
This PR removes Consequences:
Suggest either switching this step to |
|
Review finding — The It is also absent from the runner-only exclusion list enumerated in Suggest adding a |
Address the review findings on #791: the PR advertised a full runner migration and "dropped from both", but the CI lint gate and one pure hook were still left behind. - CI: switch the lint gate (.github/actions/test-project) to `prek run --all-files` (was `uv run pre-commit run --all-files`) and drop `pre-commit==4.6.0` from pyproject.toml + uv.lock, so prek — not the Python pre-commit — is what CI validates against the impure hooks too. Also drop the now-vestigial `pre-commit-` dev-shell PATH exclusion in setup-env and repoint the hook cache to PREK_HOME. - flake: mirror the pure `just-fmt` hook into `checks.pre-commit` (`just --fmt --check --unstable`) so justfile-format drift is caught by the Nix-verified gate; document it in docs/NIX.md and the ADR. - worktree setup (.claude/worktrees.json) and the skill docs now point at `prek install` instead of `pre-commit install`. Refs: #778
|
Thanks @gerchowl — both findings are valid and now fixed in Finding 1 — CI lint gate still on Finding 2 — Adjacent gap (self-found). The PR moved Verification: |
Address weak points found reviewing #791: - check-yaml: pass --allow-multiple-documents in both the committed runner config and (via git-hooks.nix' hardcoded --multi) checks.pre-commit, so the Nix gate is no longer more lenient than the runner on multi-document YAML. - worktree setup: `prek install` now wires all three hook stages (-t pre-commit -t commit-msg -t prepare-commit-msg); bare `prek install` only installs the pre-commit shim, silently dropping the commit-msg / prepare-commit-msg hooks in worktrees. - scaffold: repoint the remaining pre-commit references at prek — the lint job's dead PRE_COMMIT_HOME=/opt/pre-commit-cache env (now PREK_HOME= /opt/prek-cache), container-ci-quirks.md, and init-precommit.sh (drop the stale .pre-commit-cache idempotency guard; prek prepare-hooks is idempotent). - tests: init.bats now asserts the real `prek prepare-hooks` command instead of a string that only matched a leftover comment. Refs: #778
## Summary Closes the version-drift #720 was filed for — but by **deletion rather than by automating a sync**. Investigation showed CI already provisioned the toolchain from the flake for the image/test jobs (`setup-env`'s `provision-via-flake` mode). The drift lived only in the *other* mode: the ad-hoc path hardcoded a second `uv` version (`0.11.23`) that had to be kept in lockstep with the flake's overlaid `pkgs.uv.version`. (Concretely, they had already drifted — the flake currently resolves `uv 0.11.19`.) This makes `setup-env` **flake-only**: every job installs Nix + Cachix and enters the dev-shell, so CI and local `nix develop` run the identical toolchain from a single source (`flake.lock`). The literal pin is gone; the `uv` version now flows solely from the flake. ## Changes - **`setup-env` action** — remove the `provision-via-flake` toggle and the ad-hoc install steps (`astral-sh/setup-uv` ×2 with the `0.11.23` pin, `actions/setup-python`, `taiki-e/install-action` for just, the taplo curl, `bats-action`); drop the now-dead `install-python`/`python-version`/`install-just`/`install-taplo`/`install-bats` inputs and the unused `uv-version` output. Keep the host-integration steps (podman setuid, Node.js, devcontainer CLI) and the `UV_PYTHON_DOWNLOADS_JSON_URL` forwarding that pre-commit's manylinux hooks depend on. - **Callers** — the 4 composite actions drop `provision-via-flake`/tool flags now provided by the flake; the lightweight ad-hoc callers (`ci.yml` security jobs, `prepare-`/`promote-`/`release.yml` orchestration) are wired to the warm `vig-os` Cachix cache. - **`security-scan.yml` `scan-nix-image`** — drops its duplicate *direct* Nix/Cachix setup and routes provisioning through `setup-env` (no double install; DRY). - Docs (`NIX.md`) + CHANGELOG updated. Net `+71 / −227`. ## Trade-off (accepted) The lightweight security/release jobs now pull the warm Cachix closure instead of a ~5 s `uv` download, and the release-orchestration pipeline gains a dependency on Nix + the Cachix cache (mitigated: the closure is already warmed by `nix-cachix.yml`/build jobs, and `cache.nixos.org` is a fallback substituter). ## Verification - `grep` for `0.11.23` / `provision-via-flake` / removed inputs → clean across `.github`. - `pre-commit` green on changed files (`yamllint`, `check-action-pins`, `pymarkdown`, agent-identity). - **CI on this PR exercises the converted `ci.yml` jobs** (`python-security`, `security-scan`, `dependency-review`) — confirm they hit the warm cache. -⚠️ The `prepare-`/`promote-`/`release.yml` legs are **event-gated** (tags/release/dispatch) and cannot run on a feature-branch PR; they are verified structurally (identical shared action + YAML) and should be watched on the next release. `release.yml` `vulnix-gate` uses the same flake path already proven in `build-and-test`. ## Notes Non-testable CI config (no unit test; noted per the TDD standard). Downstream follow-up: #779 (flake-checks as CI Tier 0) is the natural next step once #791 lands. Refs: #720
gerchowl
left a comment
There was a problem hiding this comment.
Approving — re-reviewed only the changes pushed after my 07-02 findings (9e876b08 + 4908b9b9c). Both are cleanly resolved:
Finding 1 (CI lint gate still on pre-commit) — .github/actions/test-project now runs prek run --all-files (cache step + --version probe repointed to prek/PREK_HOME), pre-commit==4.6.0 and its 8 transitive deps are gone from pyproject.toml + uv.lock, and the vestigial pre-commit- PATH exclusion in setup-env (whose comment contradicted the migration) is removed. prek is now what CI validates against the whole committed config, and NIX.md's "covered by CI's prek run --all-files" is now true rather than aspirational.
Finding 2 (just-fmt uncovered) — mirrored into preCommitCheck following the taplo-lint pattern, in --check mode for the read-only sandbox, and documented in both NIX.md and the ADR. The right call over documenting-as-excluded, since just was already in devTools.
Self-found adjacent gap — good catch on .claude/worktrees.json (root + scaffold) and the skill docs still on pre-commit install; repointed to prek install --prepare-hooks. Verified --prepare-hooks is the valid current spelling of prek's old --install-hooks, so the env pre-build works. (justfile.worktree staying on bare prek install is fine — it matches the prior no-pre-build behavior there.)
No new concerns. LGTM.
…prek # Conflicts: # CHANGELOG.md # assets/workspace/.devcontainer/CHANGELOG.md # flake.nix
What
Two related build-system changes land together on this branch:
cachix/git-hooks.nixwithpackage = pkgs.prekand migrate the git-hook runner from the Pythonpre-committo the Rust prek. The flake now exposeschecks.pre-commit(the sandbox-pure hook subset, run under the flakecheck tier),
prekjoins thedevToolsSSoT (dev-shell + image), and thestandalone
pre-commitis dropped from both — one fewer manylinux/FHSconsumer in the image closure.
checks.<system>derivation (treefmt formatting, deadnix/statix, dev-shell,
devShellTools,and the new
checks.pre-commitgate) in parallel with an eval cache vianix-fast-build, replacing the serialnix flake checkstep inproject-checks. Recorded indocs/rfcs/ADR-flake-checks-tier0.md.Design: two hook artifacts, kept in agreement
checks.pre-commitbuilds in the Nix sandbox (no network, no venv), so it canonly run pure hooks. Rather than generate a store-path-bound config (which
would not be portable to the downstream scaffold and would churn on nixpkgs
bumps), the committed
.pre-commit-config.yamlstays the hand-maintained,PATH-based runner config, and
checks.pre-commitis the Nix-verifiedguarantee that its pure hooks are correct. Documented in
docs/NIX.md.Hook → mechanism mapping
In
checks.pre-commit(pure, git-hooks.nix + prek):treefmthook reusingtreefmtEval(nixfmt + ruff-format + taplo), replacing the individual nixfmt/ruff-format/taplo-format hooksruff,shellcheck,yamllint(--format parsable --strict),typos, a customtaplo-lint, andjust --fmt --check --unstable${vigUtils}/bin/…,${pkgs.bandit}/bin/bandit): check-action-pins, check-skill-names, check-expirations, banditRunner-only (excluded from
checks.pre-commit): generate-docs, sync-manifest, pip-licenses, pymarkdown (not in nixpkgs), no-commit-to-branch, destroyed-symlinks (no git-hooks.nix built-in + git-state-dependent), check-agent-identity (inspects git identity), and the commit-msg/prepare-commit-msg-stage hooks.Fidelity notes
python-debug-statementspackage pinned to the 3.14pre-commit-hooksso it parses the repo's PEP-758except A, B:(nixpkgs' default is 3.13, which rejects it) — matching the runner interpreter.shellcheckmoved from theshellcheck-pyremote hook to alanguage: systemhook (flakeshellcheck): the wheel bundles a manylinux binary the Nix userland can't exec and prek/uv can't build it under 3.14 — same reasoning as ruff/typos/nixfmt in [BUG] pre-commit: source binary hooks (ruff, ruff-format, typos) from the flake for NixOS compatibility #697/[BUG] Integration tests run the published image (DEVCONTAINER_VERSION), not the freshly-built one #701.check-yamlruns with--allow-multiple-documentsin both the runner and the Nix check (git-hooks.nix' built-in hardcodes--multi), so the gate is not more lenient than the runner on multi-document YAML.Runner/image/scaffold changes
.githooks/*(root + scaffold) callprek run;scripts/init.shrunsprek prepare-hooks;just precommit→prek run --all-files; worktree setup →prek install -t pre-commit -t commit-msg -t prepare-commit-msg; scaffoldinit-precommit.sh/justfile.projectfollow.prekvia devTools (nopre-commit), baked cache renamedPREK_HOME=/opt/prek-cache,precommitalias →prek run..github/actions/test-project) runsprek run --all-files(wasuv run pre-commit run --all-files);pre-commit==4.6.0dropped frompyproject.toml+uv.lockand the vestigialpre-commit-dev-shell PATH exclusion removed.Review follow-ups (addressed on this branch)
--multi; the runner now passes--allow-multiple-documentstoo so both agree (was: gate strictly more lenient).prek installnow installs all three stages; bareprek installonly wired the pre-commit shim, silently dropping commit-msg / prepare-commit-msg in worktrees.PRE_COMMIT_HOME=/opt/pre-commit-cache→PREK_HOME=/opt/prek-cache, updatedcontainer-ci-quirks.md, and dropped the stale.pre-commit-cacheidempotency guard ininit-precommit.sh.init.batsnow asserts the realprek prepare-hookscommand instead of a string that only matched a leftover comment.Verification
nix run .#nix-fast-build→ all checks passed (formatting, deadnix, statix, devShell, devShellTools, pre-commit).prek run --all-files→ green on the root repo and the nested scaffold (all hooks incl. the impureuv runones).prek validate-config→ passes on the root andassets/workspaceconfigs.nix build .#devcontainerImagebuilds; the image closure hasprek(0.3.11) and nopre-commit.test:committed first);tests/bats/init.batsgreen (29/29).Closes #40, #778, #779