git-hooks.nix
git-hooks.nix copied to clipboard
Add default pre-commit hooks
This PR adds almost all non-deprecated hooks from the original pre-commit-hooks repository.
Two of these hooks were asked for in https://github.com/cachix/pre-commit-hooks.nix/issues/31 by @PierreR and workarounds have been proposed, like writing custom hooks, or using the rawConfig option.
Thanks to @kalbasit, pre-commit-hooks got packaged for nixpkgs, so why not add all these default pre-commit hooks that are listed here?
I've tested them all, set some sane defaults and occasionally renamed them slightly or changed the description, so it is clearer, what the individual hooks are used for. The rest of the settings were taken from the hooks configuration in the original repository.
All the hooks seem to pass the initial checks and can be used just fine. I haven't added all the arguments for all hooks, but tried to add all that are necessary for sensible usage as a pre-commit hook.
In case someone tries to use one of these hooks and cannot find a needed option that is available in the original hook, please open an issue and feel free to assign me to it. I'll try to add it then.
~~I have yet to add all hooks to the README. Keeping this as a draft until I get around to it, which should be at the beginning of next week. Feel free to review the proposed changes in the meantime.~~
Closure size of pre-commit-hooks is rather small:
λ du -sh $(nix-build -A python3Packages.pre-commit-hooks)
860K /nix/store/g07vbn53mvqy5gaqa3dmw4w0lcr2i89a-python3.11-pre-commit-hooks-4.5.0
I have now listed all added default pre-commit hooks to the corresponding sections of the README.
Since I noticed a couple of formatting issues in the README, I fixed them in 9593b40, so that it is now standard Markdown as checked by mdl and markdownlint. I also sorted all hooks alphabetically in the subsections.
Since the various hooks includes hooks other than formatters, I renamed the section's headline from Other formatters to Various other hooks.
@domenkozar Should we add mdl to the pre-commit hooks in this repository so that the README gets linted on new contributions?
Oh thanks for all this work! We'll have to base it on top of #397 otherwise we'll get into conflicts.
Oh thanks for all this work! We'll have to base it on top of #397 otherwise we'll get into conflicts.
Sure, I'll try to rebase onto that.
@domenkozar Alright, my changes are now on top of #397.
cc @sandydoo
Some braces were missing, but now it should work fine. @sandydoo Please let me know if you need any help finishing up #196.
Great work, @totoroot!
RE #196, there are two main blockers I'd like to solve before merging:
- We'd like to offer an overridable
packagefor every hook. The problem is that a few hooks have more complex requirements: some hooks depend on several packages or have wrappers of some kind. How much do we expose here? Should we expose the wrappers to allow users to override them? Or is this an implementation detail? Shouldpackagebe a singlepackagetype or some attribute set of packages? If it's a single package (or a symlink join), can we reliably access all of the packages used by the enabled hooks to create a dev shell? - The deprecation notices for the renamed options don't currently show up. Maybe there's some trick to get these to propagate through the submodules.
If you have any ideas/thoughts on these, I'd love to hear them!
- we discussed about this one quite a bit, most likely it's best to have
cfg.packageand allow it to be a list of packages that is then used with pkgs.symlinkJoin - should be doable like so: https://github.com/NixOS/nixpkgs/pull/287506/files#diff-346cfce0bc66f4470c59870b415a1582bd5422b09d67309feb20e9e8597d2f7bR899
Hey! We merged it, could you rebase on top of master now?
Yesterday I messed up the large rebase a little, so many thanks to @9999years who fixed up the branch :bouquet:
@domenkozar Ready for review/merge now!
git-annex seems to not build on macOS, maybe we should disable it...?
git-annexseems to not build on macOS, maybe we should disable it...?
@9999years Surely a good idea, but that should be done in a separate PR, as this one did not change the git-annex hook.
Wait, the CI failures are non-blocking -- CI hasn't passed on the master branch in 2 months: https://github.com/cachix/git-hooks.nix/commit/0b6fdb0941e4dc283ff0e79e2d0aea74d713f2fc
Opened #421 to fix the CI failures on macOS.
Could you rebase on master?
Could you rebase on master?
I merged master into this branch.