Integrate git hooks with treefmt and devshell
Background
I was looking for a way to integrate
pre-commit-hooks.nix
and numtide/devshell, I came
across this github
issue. It seems zimbatm
added git.hooks
extra module to support git hook integration in
devshell. So I decide to give a try.
Code
I am configuring my devshell using nix, rather than toml file.
I think for toml version, you should just do
devshell.toml
assuming you already added devshell overlay, we need to import git extra
module, and enable git.hooks
and add script for the hook we want to
use. Here i am using
numtide/treefmt.
assuming you have a treefmt.toml
in your project root directory, you
should be to ready to go