Skip to content

Commit b87ed05

Browse files
committed
feat(treefmt): add options to settings and disable cache by default
The bootstrapping of the cache does not work well with the parallelization of pre-commit, also it introduces quite a slow-down. Another option that works is to configure `require_serial = true`. But with this there was still an initial slowdown when the cache was not in place. While disabling the cache was fast every time. This might work different in different setups thus it makes sense to make it configurable.
1 parent d70155f commit b87ed05

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)