Skip to content

Commit 6a79acd

Browse files
committed
feat(nil) Add option to treat warnings as errors
1 parent 50b9238 commit 6a79acd

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

modules/hooks.nix

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,19 @@ in
972972
imports = [ hookModule ];
973973
};
974974
};
975+
nil = mkOption {
976+
description = "nil hook";
977+
type = types.submodule {
978+
imports = [ hookModule ];
979+
options.settings = {
980+
denyWarnings = mkOption {
981+
type = types.bool;
982+
description = "Treat warnings like errors and exit with non-zero code";
983+
default = false;
984+
};
985+
};
986+
};
987+
};
975988
nixfmt = mkOption {
976989
description = "nixfmt hook";
977990
type = types.submodule {
@@ -3439,11 +3452,14 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.fourm
34393452
package = tools.nil;
34403453
entry =
34413454
let
3455+
cmdArgs = mkCmdArgs (with hooks.nil.settings; [
3456+
[ denyWarnings "--deny-warnings"]
3457+
]);
34423458
script = pkgs.writeShellScript "precommit-nil" ''
34433459
errors=false
34443460
echo Checking: $@
34453461
for file in $(echo "$@"); do
3446-
${hooks.nil.package}/bin/nil diagnostics "$file"
3462+
${hooks.nil.package}/bin/nil diagnostics ${cmdArgs} "$file"
34473463
exit_code=$?
34483464
34493465
if [[ $exit_code -ne 0 ]]; then

0 commit comments

Comments
 (0)