Skip to content

build(nix): source ruff/ruff-format/typos pre-commit hooks from the flake - #699

Merged
c-vigo merged 3 commits into
feature/625-nix-claude-migrationfrom
bugfix/697-precommit-flake-hooks
Jun 24, 2026
Merged

c-vigo merged 3 commits into
feature/625-nix-claude-migrationfrom
bugfix/697-precommit-flake-hooks

Conversation

@c-vigo

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

Copy link
Copy Markdown
Contributor

Description

On a NixOS host, the ruff, ruff-format, and typos pre-commit hooks could
not run because they were sourced from upstream astral-sh/ruff-pre-commit and
crate-ci/typos as generic-linux (manylinux) wheels, which NixOS cannot execute
out of the box (no FHS ld-linux). This forced --no-verify on every local
commit. This PR sources those tools from the Nix flake (the #625 toolchain
SSoT) via language: system hooks, consistent with the other local hooks
(taplo, just, nixfmt, uv run ...).

Sub-issue of the #625 Nix-migration epic.

Type of Change

  • feat -- New feature
  • fix -- Bug fix
  • docs -- Documentation only
  • chore -- Maintenance task (deps, config, etc.)
  • refactor -- Code restructuring (no behavior change)
  • test -- Adding or updating tests
  • ci -- CI/CD pipeline changes
  • build -- Build system or dependency changes
  • revert -- Reverts a previous commit
  • style -- Code style (formatting, whitespace)

Modifiers

  • Breaking change (!) -- This change breaks backward compatibility

Changes Made

  • flake.nix: added ruff and typos to the devTools SSoT list (kept
    nixfmt-clean). Removed the now-duplicate ruff entry from imageTools
    (it inherits ruff from devTools).
  • .pre-commit-config.yaml: replaced the astral-sh/ruff-pre-commit and
    crate-ci/typos repo blocks with repo: local / language: system hooks —
    ruff (entry: ruff check --fix, types: [python]), ruff-format
    (entry: ruff format, types: [python]), typos (entry: typos).
    Existing behaviour/args/filters preserved.
  • Re-synced the scaffolded assets/workspace/.pre-commit-config.yaml via
    scripts/sync_manifest.py.
  • CHANGELOG.md: added a ### Fixed entry under ## Unreleased; re-synced the
    .devcontainer CHANGELOG copy.
  • tests/test_flake_devshell.py: added a parity assertion that ruff and
    typos are in devShellTools (mirrors the existing bats / agent-toolkit
    superset tests).

Changelog Entry

Fixed

  • pre-commit ruff/ruff-format/typos hooks now run on NixOS hosts (sourced from the flake) (#697)
    • The ruff, ruff-format, and typos hooks pulled compiled tools as generic-linux (manylinux) wheels from astral-sh/ruff-pre-commit and crate-ci/typos; a NixOS host cannot execute those binaries out of the box (no FHS ld-linux), forcing --no-verify on every local commit
    • Added ruff and typos to the flake devTools SSoT and converted the three hooks to repo: local / language: system (ruff check --fix, ruff format, typos), so they resolve their tool from the Nix dev-shell like the other local hooks — no host setup needed inside the dev-shell. Re-synced the scaffolded assets/workspace/.pre-commit-config.yaml. Hook versions now track nixpkgs/flake.lock (Renovate nix manager) instead of upstream rev: pins, consistent with the [MASTER] Migrate devcontainer to a Nix toolchain + Claude-native setup #625 toolchain consolidation

Testing

  • Tests pass locally (just test)
  • Manual testing performed (describe below)

Manual Testing Details

Run on a NixOS host (export NIX_CONFIG="experimental-features = nix-command flakes"):

  • uv run pytest tests/test_flake_devshell.py → 7 passed (new
    test_devshell_provides_precommit_binary_hooks was RED before the flake
    change, GREEN after).
  • nix develop -c ruff --version → ruff 0.15.14;
    nix develop -c typos --version → typos-cli 1.46.3.
  • nix develop -c bash -c 'uv run pre-commit run typos --all-files' → Passed
    (resolved from the flake).
  • nixfmt --check flake.nix → clean; nix eval of
    .#devShells.<sys>.default.drvPath and .#checks.<sys> evaluate
    (devShell, devShellTools, format).

Commits used git commit --no-verify: the very hooks being fixed
(ruff/ruff-format/typos) cannot execute on this NixOS host pre-fix, which
is the bug. CI re-runs the full pre-commit suite under provision-via-flake
(FHS runner) so the PR is still gated.

Reviewer note — known gap for ruff/ruff-format: ruff is also a
project Python dependency (pyproject.toml lint/devcontainer groups), so
.venv/bin/ruff (a manylinux wheel) exists. Both justfile (just lint /
just format / just precommit) and CI launch pre-commit via uv run, which
puts .venv/bin first on PATH and shadows the flake's ruff. On a NixOS
host this means the ruff/ruff-format hooks still hit the broken venv binary
under uv run pre-commit, whereas typos (not a venv dep) resolves cleanly
from the flake. Fully closing the ruff case requires removing ruff from the
project venv and repointing justfile's lint/format recipes at the flake
ruff (and refreshing uv.lock) — changes that touch pyproject.toml,
uv.lock, and justfile, which are outside this issue's stated scope (and
overlap with sibling #698). Flagging for a decision: extend this PR, or split a
follow-up. CI stays green regardless because the FHS runner can execute the venv
ruff wheel.

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly (edit docs/templates/, then run just docs)
  • I have updated CHANGELOG.md in the [Unreleased] section (and pasted the entry above)
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

The docs acceptance-criterion item (note that pre-commit runs inside the
dev-shell, no host setup) is intentionally left for a docs pass / the #698
sibling that is also editing the Nix docs; this PR keeps a minimal diff focused
on the flake + hook config.

Merge-conflict heads-up: sibling issue #698 (in progress in parallel) also
edits flake.nix (devTools / mkShell), .pre-commit-config.yaml, and
CHANGELOG.md. Expect conflicts in: the devTools list region of flake.nix,
the pre-commit hook blocks, and the ## Unreleased ### Fixed section of
CHANGELOG.md (and its synced assets/workspace/.devcontainer/CHANGELOG.md
copy).

Refs: #697

c-vigo added 2 commits June 24, 2026 18:37
…lake

Add ruff and typos to the flake devTools SSoT and convert the ruff,
ruff-format, and typos pre-commit hooks to repo: local / language: system
so they resolve their tool from the Nix dev-shell instead of upstream
manylinux wheels, which a NixOS host cannot execute. Remove the now-duplicate
ruff entry from imageTools (it inherits ruff from devTools). Re-sync the
scaffolded assets/workspace/.pre-commit-config.yaml and the CHANGELOG copy.

Refs: #697
@c-vigo c-vigo self-assigned this Jun 24, 2026
The venv's ruff (a manylinux wheel) shadowed the flake ruff under
`uv run` — which is how .githooks/pre-commit and the `just lint`/`format`
recipes invoke it — so ruff stayed broken on NixOS even after it was
added to devTools. Remove ruff from the uv dependency groups
(pyproject.toml/uv.lock) and repoint the recipes to the flake ruff; the
flake is now the single ruff source (its [tool.ruff] config is unchanged).

Refs: #697
@c-vigo

c-vigo commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

Extended this PR to fully close the ruff gap (per review): removed ruff from the uv dependency groups (pyproject.toml/uv.lock) and repointed just lint/format to the flake ruff. The venv ruff (manylinux wheel) was shadowing the flake ruff under uv run — which is how .githooks/pre-commit and the recipes invoke it — so ruff stayed broken on NixOS otherwise. Verified: uv run pre-commit run ruff/ruff-format/typos all pass resolving flake ruff 0.15.14, ruff check ./ruff format --check . clean, 7 parity tests pass.

@c-vigo
c-vigo merged commit f30f4f9 into feature/625-nix-claude-migration Jun 24, 2026
2 checks passed
@c-vigo
c-vigo deleted the bugfix/697-precommit-flake-hooks branch June 24, 2026 16:57
c-vigo added a commit that referenced this pull request Jun 24, 2026
…ooks

#699 converted ruff/ruff-format/typos to repo-local language:system hooks
and synced that into the scaffolded config. A downstream workspace commits
inside the published image without the flake toolchain on PATH, so those
hooks fail with "Executable not found" (the integration suite caught this
on the typos hook). Add a ReplacePrecommitRepoBlock sync-manifest transform
that restores self-contained upstream ruff/typos hooks in the scaffolded
config only; the repo's own config keeps language:system for NixOS-host dev.

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