From 32bde06a1685123ee811492d346695b404b4e117 Mon Sep 17 00:00:00 2001 From: Paul Hinze Date: Wed, 18 Oct 2023 21:16:52 -0500 Subject: [PATCH] nix: add lefthook Allows pre-commit linters to run in Nix development environments. Lefthook needs to be able to invoke `node` directly so explicitly add `nodejs` to dependencies as well. This is probably worthwhile for asset generation stuff anyways. --- NIX.md | 10 ++++++++++ flake.nix | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/NIX.md b/NIX.md index d264e10c6..f5e1e7ac1 100644 --- a/NIX.md +++ b/NIX.md @@ -87,3 +87,13 @@ $ bin/rails test:system The Selenium tests are run by having Nix install Chromium and ChromeDriver and set a `SELENIUM_CHROME_BINARY` environment variable to point Selenium at Chromium in `test/application_system_test_case.rb`. + +## Precommit Hooks + +Precommit hooks are managed by `lefthook`, which is automatically installed +into the Nix development shell. Install the hooks to get them to run on every +commit: + +```shell-session +$ lefthook install +``` diff --git a/flake.nix b/flake.nix index b0d775996..07566f966 100644 --- a/flake.nix +++ b/flake.nix @@ -26,6 +26,7 @@ mkShell { buildInputs = [ ruby + nodejs yarn foreman @@ -38,6 +39,9 @@ # for selenium tests chromium chromedriver + + # for linters and git hooks + lefthook ]; # Keep gems installed in a subdirectory