From 142af8d0ee43a692e64e57e6cab8dc198f397f55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20=E2=80=9CNiols=E2=80=9D=20Jeannerod?= Date: Wed, 19 Feb 2025 18:42:30 +0100 Subject: [PATCH] Make pre-commits opt-out instead of opt-in --- flake.nix | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/flake.nix b/flake.nix index 1ca6d27..96dfb89 100644 --- a/flake.nix +++ b/flake.nix @@ -41,34 +41,24 @@ formatter = pkgs.nixfmt-rfc-style; pre-commit.settings.hooks = - ## Not everybody might want pre-commit hooks, so we make them - ## opt-in. Maybe one day we will decide to have them everywhere. let - inherit (builtins) concatStringsSep; - optin = [ - "deployment" - "infra" - "keys" - "matrix" - "secrets" - "services" - "panel" - "website" - ]; - files = "^((" + concatStringsSep "|" optin + ")/.*\\.nix|[^/]*\\.nix)$"; + ## Add a directory here if pre-commit hooks shouldn't apply to it. + optout = [ "npins" ]; + excludes = map (dir: "^${dir}/") optout; in { nixfmt-rfc-style = { enable = true; - inherit files; + inherit excludes; }; deadnix = { enable = true; - inherit files; + inherit excludes; }; trim-trailing-whitespace = { enable = true; - inherit files; + files = "\\.nix$"; + inherit excludes; }; };