From c83f6eed44cc98ca2d191f985159a314544c08ef Mon Sep 17 00:00:00 2001 From: Benedikt Rips Date: Sat, 18 Oct 2025 10:55:06 +0200 Subject: [PATCH] gitlint: add `flags` option `gitlint.args` can not be used since pre-commits appends it to the commandline but the `--msg-filename` option has to come last. See #641 for more information. --- modules/hooks.nix | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/hooks.nix b/modules/hooks.nix index 8efaf3db..216e27a4 100644 --- a/modules/hooks.nix +++ b/modules/hooks.nix @@ -639,6 +639,18 @@ in }; }; }; + gitlint = mkOption { + description = "gitlint hook"; + type = types.submodule { + imports = [ hookModule ]; + options.flags = mkOption { + type = types.listOf types.str; + description = "Flags passed to gitlint. See all available [here](https://jorisroovers.com/gitlint/latest/configuration/cli/)"; + default = [ ]; + example = [ "-c" "title-max-length.line-length=120" ]; + }; + }; + }; golines = mkOption { description = "golines hook"; type = types.submodule { @@ -2933,7 +2945,11 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.fourm name = "gitlint"; description = "Linting for your git commit messages"; package = tools.gitlint; - entry = "${hooks.gitlint.package}/bin/gitlint --staged --msg-filename"; + entry = lib.escapeShellArgs ( + [ "${hooks.gitlint.package}/bin/gitlint" ] + ++ hooks.gitlint.flags + ++ [ "--staged" "--msg-filename" ] + ); stages = [ "commit-msg" ]; }; gofmt =