Skip to content

Commit cd1af27

Browse files
authored
Merge pull request #525 from terlar/treefmt-add-settings-disable-cache
feat(treefmt): add options to settings and disable cache by default
2 parents d70155f + b87ed05 commit cd1af27

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

modules/hooks.nix

+22-1
Original file line numberDiff line numberDiff line change
@@ -1618,6 +1618,18 @@ in
16181618
};
16191619
};
16201620
options.settings = {
1621+
fail-on-change =
1622+
mkOption {
1623+
type = types.bool;
1624+
description = "Fail if some files require re-formatting.";
1625+
default = true;
1626+
};
1627+
no-cache =
1628+
mkOption {
1629+
type = types.bool;
1630+
description = "Ignore the evaluation cache entirely.";
1631+
default = true;
1632+
};
16211633
formatters = mkOption {
16221634
type = types.listOf types.package;
16231635
description = "The formatter packages configured by treefmt";
@@ -3693,7 +3705,16 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol
36933705
pass_filenames = true;
36943706
package = wrapper;
36953707
packageOverrides = { treefmt = tools.treefmt; };
3696-
entry = "${hooks.treefmt.package}/bin/treefmt --fail-on-change";
3708+
entry =
3709+
let
3710+
cmdArgs =
3711+
mkCmdArgs
3712+
(with hooks.treefmt.settings; [
3713+
[ fail-on-change "--fail-on-change" ]
3714+
[ no-cache "--no-cache" ]
3715+
]);
3716+
in
3717+
"${hooks.treefmt.package}/bin/treefmt ${cmdArgs}";
36973718
};
36983719
trim-trailing-whitespace =
36993720
{

0 commit comments

Comments
 (0)