From c3d18b52502b47b0913235008c184db60c8a09c8 Mon Sep 17 00:00:00 2001 From: surtur Date: Tue, 24 May 2022 12:20:52 +0200 Subject: [PATCH] pre-commit: optimise local hook triggers * rm 'require_serial = false' occurences as that's the default value, which makes it redundant here. * do not "always_run" hooks * only run relevant local hooks when pertaining files/file groups have changed, e.g. there is no need to run statix linter when no nix files have changed or equally it is not necessary to run 'nix build' when none of the flake files (flake.{nix,lock}), any '*.nix' or go source, mod or sum files have changed. all of the above results in much faster pre-commit runs, i.e. shorter feedback loops, i.e. faster iteration cycles. --- .pre-commit-config.yaml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index eadcf2d..bc32f49 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,23 +16,25 @@ repos: - id: statix name: statix entry: statix check . + always_run: false pass_filenames: false + files: '\.*.nix$' language: system - id: nixpkgs-fmt - require_serial: false name: nixpkgs-fmt entry: ./check-fmt + always_run: false pass_filenames: false + files: '\.*.nix$' language: system - id: flake-check - require_serial: false name: nix flake check entry: nix flake check --impure + always_run: false pass_filenames: false - files: "flake.nix" + files: "flake.(nix|lock)$" language: system - id: addlicense - require_serial: false name: addlicence -check entry: > go run github.com/google/addlicense@v1.0.0 -check -v @@ -63,4 +65,7 @@ repos: name: nix build entry: nix build .#go-xkcdreader pass_filenames: false + # trigger this hook on changes to any of nix (also flake.lock) files + # and go's src, mod or sum files + files: '\.*.(nix|lock|go|mod|sum)$' language: system