git-hooks.nix
git-hooks.nix copied to clipboard
Make hook installation optional
A highly opinionated workflow doesn't work for all projects, especially ones that already have a long history, notably NixOS/nix. Some people hate pre-commit with a passion.
These things should not be showstoppers.
To quote the docs:
Opting out, opting in
Users can enforce their own preference by setting NIX_PRE_COMMIT_HOOKS_INSTALL to 0 or 1 in their environment, e.g. in .profile or in home.sessionVariables for home-manager users.
Furthermore, project maintainers can set a default preference via the installByDefault option.
Finally, regardless of these settings, you may install the hooks manually by running nix-pre-commit-hooks-install in your shell. This does what it says, and the shell hook will detect that the hooks exist and keep them up to date.
I'm confused why this is needed, can't you make the call to pre-commit run optional based on a boolean?
I don't think run is responsible for installation.
The goal is to let a project choose not to install any hooks into .git by default, unless the devShell user has opted in. I think something might done at the project level, but it won't be quite as user friendly, as it doesn't standardize this installation logic.
I've re-done it. This time it just (cleanly) refactors the existing logic, so that it can be called without installing the hooks into .git.
Solved some tech debt along with that. We now have shellcheck on the script.
@roberth I'd love to have this. Are you willing to refresh your PR?
Sorry for the mess, we revamed module structure in https://github.com/cachix/pre-commit-hooks.nix/pull/397, could you port these changes over?
Closing as outdated
Is the functionality request outdated or just the state of the PR?
Is there a replacement?
I think having enable option would make this a lot simpler, I'm happy to merge it if someone makes a PR.