cachix / git-hooks.nix

Seamless integration of https://pre-commit.com git hooks with Nix.
Apache License 2.0
511 stars 154 forks source link

`pass_filenames` broken when used with flakes #139

Open DavHau opened 2 years ago

DavHau commented 2 years ago

I'm currently trying to set up a hook for a flake to run treefmt only on changed files. With flakes nix always removes the .git directory before even starting the evaluation. Therefore there is no chance for the hook to learn about which files have been changed.

One solution could be to support nix run based checks.

RonnyPfannschmidt commented 1 year ago

the pre commit hook when installed correctly runs on the git repo on changed/added files if your hook runs on a store path, the setup is completely wrong, it must run on the real path

roberth commented 1 year ago

In my view that covers all use cases.

Something based on nix run would be a slower version of what the actual pre-commit command and the actual hooks do for you. The only benefit I see to this is that if you always regenerate the config file, it can't go stale, but stale config isn't a problem because you the guaranteed complete and up to date check in CI.

I guess this needs to be explained in docs?