Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion modules/hooks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,19 @@ in
imports = [ hookModule ];
};
};
nil = mkOption {
description = "nil hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
denyWarnings = mkOption {
type = types.bool;
description = "Treat warnings like errors and exit with non-zero code";
default = false;
};
};
};
};
nixfmt = mkOption {
description = "nixfmt hook";
type = types.submodule {
Expand Down Expand Up @@ -3439,11 +3452,14 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.fourm
package = tools.nil;
entry =
let
cmdArgs = mkCmdArgs (with hooks.nil.settings; [
[ denyWarnings "--deny-warnings" ]
]);
script = pkgs.writeShellScript "precommit-nil" ''
errors=false
echo Checking: $@
for file in $(echo "$@"); do
${hooks.nil.package}/bin/nil diagnostics "$file"
${hooks.nil.package}/bin/nil diagnostics ${cmdArgs} "$file"
exit_code=$?

if [[ $exit_code -ne 0 ]]; then
Expand Down