Pre-commit git hooks with Nix


pre-commit manages a set of hooks that are executed by git before committing code:

pre-commit.png

Common hooks range from static analysis or linting to source formatting.

Since we’re managing quite a couple of repositories, maintaining the duplicated definitions became a burden.

Hence we created:

nix-pre-commit-hooks

The goal is to manage these hooks with Nix and solve the following:

  • Simpler integration into Nix projects, doing the wiring up behind the scenes

  • Provide a low-overhead build of all the tooling available for the hooks to use (calling nix-shell for every check does bring some latency when committing)

  • Common package set of hooks for popular languages like Haskell, Elm, etc.

  • Two trivial Nix functions to run hooks as part of development and on your CI

Currently the following hooks are provided:

Nix

  • canonix: a Nix formatter (currently incomplete, requiring some manual formatting as well)

Haskell

Elm

Shell

We encourage everyone to contribute additional hooks.

Installation

See project’s README for latest up-to-date installation steps.


What we do

Automated hosted infrastructure for Nix, reliable and reproducible developer tooling, to speed up adoption and lower integration cost. We offer Continuous Integration and binary caches.