Skip to content

Commit

Permalink
Merge pull request #525 from terlar/treefmt-add-settings-disable-cache
Browse files Browse the repository at this point in the history
feat(treefmt): add options to settings and disable cache by default
  • Loading branch information
sandydoo authored Nov 11, 2024
2 parents d70155f + b87ed05 commit cd1af27
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 cd1af27

Please sign in to comment.