Skip to content

Commit 1484798

Browse files
committed
latexindent: add hooks.latexindent.settings.extraConfig option
Replace the hooks.latexindent.settings.flags option with hooks.latexindent.settings.extraConfig to support arbitrary upstream flags and allow users to override default values. Link: #514
1 parent 9364dc0 commit 1484798

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

modules/hooks.nix

+23-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
let
33
inherit (config) hooks tools settings;
44
cfg = config;
5-
inherit (lib) flatten mapAttrs mapAttrsToList mkDefault mkOption mkRemovedOptionModule mkRenamedOptionModule types;
5+
inherit (lib) flatten mapAttrs mapAttrsToList mkDefault mkEnableOption mkOption mkRemovedOptionModule mkRenamedOptionModule types;
66

77
cargoManifestPathArg =
88
lib.optionalString
@@ -683,12 +683,17 @@ in
683683
type = types.submodule {
684684
imports = [ hookModule ];
685685
options.settings = {
686-
flags =
687-
mkOption {
688-
type = types.str;
689-
description = "Flags passed to latexindent. See available flags [here](https://latexindentpl.readthedocs.io/en/latest/sec-how-to-use.html#from-the-command-line)";
690-
default = "--local --silent --overwriteIfDifferent";
691-
};
686+
extraConfig = mkOption {
687+
type = types.attrs;
688+
description = "[latexindent command-line options](https://latexindentpl.readthedocs.io/en/latest/sec-how-to-use.html#from-the-command-line) converted through `lib.cli.toGNUCommandLine`.";
689+
default = { };
690+
691+
example = lib.literalExpression ''
692+
{
693+
yaml = "defaultIndent: ' '";
694+
}
695+
'';
696+
};
692697
};
693698
};
694699
};
@@ -2904,7 +2909,17 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol
29042909
description = "Perl script to add indentation to LaTeX files.";
29052910
types = [ "file" "tex" ];
29062911
package = tools.latexindent;
2907-
entry = "${hooks.latexindent.package}/bin/latexindent ${hooks.latexindent.settings.flags}";
2912+
2913+
entry = "${hooks.latexindent.package}/bin/latexindent ${
2914+
lib.cli.toGNUCommandLineShell {} (
2915+
{
2916+
local = true;
2917+
overwriteIfDifferent = true;
2918+
silent = true;
2919+
}
2920+
// hooks.latexindent.settings.extraConfig
2921+
)
2922+
}";
29082923
};
29092924
lacheck =
29102925
let

0 commit comments

Comments
 (0)