Skip to content

Commit

Permalink
feat(treefmt): add options to settings and disable cache by default
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
terlar committed Nov 11, 2024
1 parent d70155f commit b87ed05
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion modules/hooks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1618,6 +1618,18 @@ in
};
};
options.settings = {
fail-on-change =
mkOption {
type = types.bool;
description = "Fail if some files require re-formatting.";
default = true;
};
no-cache =
mkOption {
type = types.bool;
description = "Ignore the evaluation cache entirely.";
default = true;
};
formatters = mkOption {
type = types.listOf types.package;
description = "The formatter packages configured by treefmt";
Expand Down Expand Up @@ -3693,7 +3705,16 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol
pass_filenames = true;
package = wrapper;
packageOverrides = { treefmt = tools.treefmt; };
entry = "${hooks.treefmt.package}/bin/treefmt --fail-on-change";
entry =
let
cmdArgs =
mkCmdArgs
(with hooks.treefmt.settings; [
[ fail-on-change "--fail-on-change" ]
[ no-cache "--no-cache" ]
]);
in
"${hooks.treefmt.package}/bin/treefmt ${cmdArgs}";
};
trim-trailing-whitespace =
{
Expand Down

0 comments on commit b87ed05

Please sign in to comment.