Repository navigation
Conversation
…n is committed devenv writes .pre-commit-config.yaml from devenv.nix's git-hooks (named pre-commit before devenv 1.4) when its shell starts, and git-ignores the file. Where no configuration is committed, `pre-commit run` and `prek run` now run the hooks devenv.nix enables, each by its id, as hooks: a hook fails the run when it changes a file. devenv.nix is read structurally by a small reader of Nix attribute paths (facts/nix_syntax.py): nested and dotted attribute sets, past `let … in` and function arguments, with strings and comments hiding their braces. Part of cpp-best-practices#285 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #339 +/- ##
=======================================
Coverage 99.75% 99.75%
=======================================
Files 299 300 +1
Lines 18136 18212 +76
Branches 2086 2105 +19
=======================================
+ Hits 18092 18168 +76
Misses 44 44 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #285: devenv's
git-hooks.What changes
cachix/devenv defines its hooks in
devenv.nix, not in a committed.pre-commit-config.yaml:When devenv's shell starts, it writes
.pre-commit-config.yamlfrom those hooks and git-ignores the file. CI then runsdevenv shell -- prek run -a.Until now,
prek runfound no configuration, so its hooks were unknown. Now, where no configuration is committed (and none is named with-c/--config),pre-commit runandprek runrun the hooks thatdevenv.nixenables:prek run <id>andSKIP=select hooks as they do for a YAML configuration.from_hook), so a formatter that changes a file fails the run.pre-commit.hooks, is read too.devenv.nixis read structurally by a new, small reader of Nix attribute paths,project_validator/facts/nix_syntax.py. It handles:let … inand function arguments before an attribute set;A computed value such as
lib.mkIf cond { … }or a list is not read as an attribute set.On the corpus
devenv's three enabled hooks (nixfmt, nixpkgs-fmt, rustfmt) are now found. Its workflow runs them as
devenv shell -- prek run -a || trueand commits the result back, so with #338 they are reported asrustfmt runs in CI but cannot fail it (|| true), where before it said "CI never runs rustfmt". The check results don't change.Tests
tests/test_nix_syntax.py, for the reader.PreCommitTestsintests/test_expansion.py, for enabled hooks, selection, SKIP, the older name, and a committed or named configuration winning.test_devenv_git_hooks_are_preksnow passes, so its marker is removed.enable = truefilter.Gates: ruff, ruff format, mypy, lizard (30 lines), all 2,483 tests passing (12 expected failures), coverage 99% (100% on the changed files), 0 jscpd clones, and strict self-validation.
The rest of #285 is the
git diff --quietinside anifcondition, which waits on the commit-back decision in #324.🤖 Generated with Claude Code
https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt