In less than 40 lines of nix, most of which is boilerplate, you have fully cross-platform automatically installed and declaratively managed hooks, as part of your repo.
Need to run it in CI too? Well, no problem! Nix runs equally well in CI as it does locally.
Check this flake for example:
https://github.com/Azeirah/remarks/blob/main/flake.nix
See line 62 in the shell script.
This flake:
1. Manages ALL my dev env dependencies. Including even the specific version of bash that the script is running on, also the specific python dependencies down to the bit.
2. It's (posix-compliant) cross-platform, so it runs on MacOS, WSL, Linux, NixOS, ARM, x86 etc. Also docker.
3. It uses no specialized tools other than Nix, which is now a 20 year old Linux project which is quickly gaining even more traction. Nix is a programming language for reproducible, reliable and declarative dependency management (think docker but with a pure and functional programming language, rather than a recipe with installation instructions)
4. It also creates binaries as well as docker images from the binary. The docker image is like 2 lines of extra code.
Highly highly recommended. It's a bit difficult to wrap your head around initially, but holy damn if all dependency management problems don't just magically disappear forever once you learn Nix.
And I mean ALL of them. Whether it's Linux packages, docker containers, development environments, CI, virtual machines, containers, compilers, C headers from a 1970 Bell Labs project. No matter the architecture or OS (except Windows! :D).
Oh, did I mention it has a lockfile? So you can rollback or upgrade piecewise? Whenever you want?
It's like a programmable version of the superset of npm, cargo, pip, apt, brew, composer, gem, make, cmake, docker, git, Jenkins and even Linux itself (if you dare go the way of NixOS)
I'm sure it's something that can be engineered away and optimized in the Nix core though. Because yeah it isn't a hyperspecialized tool for specifically git hooks alone written in Rust. No.
It's not a saw nor a hammer. It's an entire workshop.
Flakes are less of a workshop, but more like a bus with tools or a heavy-duty toolbox.