From d1948b48c9857727f2c44eec85fa511714bc6e9c Mon Sep 17 00:00:00 2001 From: Joe DeVivo Date: Fri, 22 Mar 2024 09:15:56 -0700 Subject: [PATCH 1/2] Added `args` and `exclude_types` to hook type --- modules/hook.nix | 19 ++++++++++++++++++- modules/hooks.nix | 3 ++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/modules/hook.nix b/modules/hook.nix index 67686c88..ad0585e3 100644 --- a/modules/hook.nix +++ b/modules/hook.nix @@ -118,6 +118,15 @@ in default = [ ]; }; + exclude_types = mkOption { + type = types.listOf types.str; + description = lib.mdDoc + '' + List of file types to exclude. See [Filtering files with types](https://pre-commit.com/#plugins). + ''; + default = [ ]; + }; + pass_filenames = mkOption { type = types.bool; description = '' @@ -166,12 +175,20 @@ in if true this hook will run even if there are no matching files. ''; }; + + args = mkOption { + type = types.listOf types.str; + description = lib.mdDoc '' + List of additional parameters to pass to the hook. + ''; + default = [ ]; + }; }; config = { raw = { - inherit (config) name entry language files types types_or pass_filenames fail_fast require_serial stages verbose always_run; + inherit (config) name entry language files types types_or exclude_types pass_filenames fail_fast require_serial stages verbose always_run args; id = config.name; exclude = mergeExcludes config.excludes; }; diff --git a/modules/hooks.nix b/modules/hooks.nix index f1cc9127..cc283ed1 100644 --- a/modules/hooks.nix +++ b/modules/hooks.nix @@ -3229,7 +3229,8 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol description = "Format shell files."; types = [ "shell" ]; package = tools.shfmt; - entry = "${hooks.shfmt.package}/bin/shfmt -w -s -l"; + entry = "${hooks.shfmt.package}/bin/shfmt -w -l"; + args = [ "-s" ]; }; single-quoted-strings = { From c22803eaa20a9ae43e04354d1c83d2ae1862d5de Mon Sep 17 00:00:00 2001 From: Sander Date: Tue, 6 Aug 2024 15:20:26 +0000 Subject: [PATCH 2/2] fix: fixup args and exclude_types --- modules/hook.nix | 11 ++++++----- modules/hooks.nix | 3 +-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/hook.nix b/modules/hook.nix index ad0585e3..ab58c52b 100644 --- a/modules/hook.nix +++ b/modules/hook.nix @@ -120,9 +120,9 @@ in exclude_types = mkOption { type = types.listOf types.str; - description = lib.mdDoc + description = '' - List of file types to exclude. See [Filtering files with types](https://pre-commit.com/#plugins). + List of file types to exclude. See [Filtering files with types](https://pre-commit.com/#filtering-files-with-types). ''; default = [ ]; }; @@ -178,9 +178,10 @@ in args = mkOption { type = types.listOf types.str; - description = lib.mdDoc '' - List of additional parameters to pass to the hook. - ''; + description = + '' + List of additional parameters to pass to the hook. + ''; default = [ ]; }; }; diff --git a/modules/hooks.nix b/modules/hooks.nix index cc283ed1..f1cc9127 100644 --- a/modules/hooks.nix +++ b/modules/hooks.nix @@ -3229,8 +3229,7 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol description = "Format shell files."; types = [ "shell" ]; package = tools.shfmt; - entry = "${hooks.shfmt.package}/bin/shfmt -w -l"; - args = [ "-s" ]; + entry = "${hooks.shfmt.package}/bin/shfmt -w -s -l"; }; single-quoted-strings = {