Skip to content

Commit

Permalink
Merge pull request #481 from cachix/shfmt-simplify
Browse files Browse the repository at this point in the history
hook(shfmt): add `simplify` toggle to settings
  • Loading branch information
sandydoo authored Aug 7, 2024
2 parents 866eecb + 49b141a commit 3c977f1
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion modules/hooks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1369,6 +1369,19 @@ in
];
});
};
shfmt = mkOption {
description = "shfmt hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
simplify = mkOption {
type = types.bool;
description = "Simplify the code.";
default = true;
};
};
};
};
statix = mkOption {
description = "statix hook";
type = types.submodule {
Expand Down Expand Up @@ -3229,7 +3242,11 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol
description = "Format shell files.";
types = [ "shell" ];
package = tools.shfmt;
entry = "${hooks.shfmt.package}/bin/shfmt -w -s -l";
entry =
let
simplify = if hooks.shfmt.settings.simplify then "-s" else "";
in
"${hooks.shfmt.package}/bin/shfmt -w -l ${simplify}";
};
single-quoted-strings =
{
Expand Down

0 comments on commit 3c977f1

Please sign in to comment.