Open aciceri opened 1 year ago
Hey @aciceri good stuff!
Check out https://github.com/mlabs-haskell/protobufs.nix/blob/main/src/pre-commit-hooks.nix for how to add a new hook, and https://github.com/mlabs-haskell/protobufs.nix/blob/main/pre-commit-check.nix#L16 on how to provide your own 'tools' (primarily fourmolu, but perhaps works with ghc as well).
Note that each repo comes with their own needs
hooks = {
nixpkgs-fmt.enable = true;
nix-linter.enable = true;
cabal-fmt.enable = true;
fourmolu.enable = true;
shellcheck.enable = true;
hlint.enable = true;
typos.enable = true;
markdownlint.enable = true;
} // protoHooks;
For the most part, mlabs-tooling can assume some common checks (nix, cabal, haskell), but we should have the ability to configure (remove and add hooks) as desired.
Additionally, most of these code quality tools have their own configuration files, would be nice to have those in a reusable but also configurable mode. Example config files: https://github.com/mlabs-haskell/protobufs.nix/blob/main/.markdownlint.yaml and https://github.com/mlabs-haskell/protobufs.nix/blob/main/_typos.toml
Hope that helps.
@bladyjoker Thank you! We'll definitely check these links when we'll work on this (don't know how soon).
We should just allow overriding the script added to the pre-commit hook.
Several people working on different projects asked for help to have pre-commit hooks in their projects, in my opinion it would make sense centralize this here.
pre-commit-hooks.nix
seems to be the de facto standard for this but I agree with @L-as that it would be bloated for our purposes (we already have ourlinter
/formatter
derivations and we don't want to fetch a differentghc
only to build the formatter executable).I see two possible solutions:
pre-commit-hooks.nix
(the "core" ofpre-commit-hooks.nix
should be quite trivial, if its repo "seems big" is because of the many supported languages)pre-commit-hooks.nix
adding our own custom hooks that leverages on our,format
and,lint
scripts (overriding default hooks for haskell possibly)By the way I would make this optional.
cc @bladyjoker @maciej-bendkowski @brainrake