Skip to content

chore(nix): migrate pre-commit runner to prek#957

Merged
cpcloud merged 1 commit intomicasa-dev:mainfrom
cpcloud:worktree-sparkling-floating-simon
Apr 19, 2026
Merged

chore(nix): migrate pre-commit runner to prek#957
cpcloud merged 1 commit intomicasa-dev:mainfrom
cpcloud:worktree-sparkling-floating-simon

Conversation

@cpcloud
Copy link
Copy Markdown
Collaborator

@cpcloud cpcloud commented Apr 19, 2026

Summary

  • Swap the Python pre-commit binary for prek (Rust rewrite, drop-in
    compatible) via git-hooks.nix's package option
  • Shim prek install calls to inject --git-dir and --overwrite so
    hook install works in git worktrees and stays quiet on reinstall
  • Patch the generated shellHook to --unset core.hooksPath instead of
    setting it to "", which prek 0.3.9+ rejects
  • run-pre-commit app now invokes prek run; CI (nix run '.#pre-commit')
    picks up the change transparently

Swap python-based pre-commit for prek via git-hooks.nix's `package`
option. Two caveats worked around in `flake.nix`:

- Upstream git-hooks.nix hardcodes `prek install` without `--git-dir`,
  which breaks in git worktrees where `.git` is a file. A shim injects
  `--git-dir` from `git rev-parse --git-common-dir` for install calls.

- prek 0.3.9+ rejects empty `core.hooksPath` (git resolves "" to ".").
  Patch the generated shellHook to `--unset core.hooksPath` instead.

The shim also passes `--overwrite` so reinstalls are silent. prek 0.3.8's
`uninstall` subcommand rejects `--git-dir`, so the shim only adds the
flag on `install`; the subsequent overwrite install supersedes any stale
hook left behind.
@cpcloud cpcloud added chore Maintenance and housekeeping nix Nix packaging and build labels Apr 19, 2026
@cpcloud cpcloud merged commit 45b341b into micasa-dev:main Apr 19, 2026
28 checks passed
@cpcloud cpcloud deleted the worktree-sparkling-floating-simon branch April 19, 2026 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Maintenance and housekeeping nix Nix packaging and build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant