Skip to content

Commit 6c51b09

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 06bb597 commit 6c51b09

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

modules/hooks.nix

Lines changed: 28 additions & 8 deletions
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
@@ -33,6 +33,11 @@ in
3333
(mkRemovedOptionModule [ "settings" "yamllint" "relaxed" ] ''
3434
This option has been removed. Use `hooks.yamllint.settings.preset = "relaxed"`.
3535
'')
36+
(
37+
mkRemovedOptionModule
38+
[ "hooks" "latexindent" "settings" "flags" ]
39+
"Use hooks.latexindent.settings.extraConfig instead."
40+
)
3641
]
3742
# Manually rename options that had a package or a config option
3843
++ flatten (mapAttrsToList (name: map (o: mkRenamedOptionModule [ "settings" name o ] [ "hooks" name "settings" o ])) {
@@ -631,12 +636,17 @@ in
631636
type = types.submodule {
632637
imports = [ hookModule ];
633638
options.settings = {
634-
flags =
635-
mkOption {
636-
type = types.str;
637-
description = "Flags passed to latexindent. See available flags [here](https://latexindentpl.readthedocs.io/en/latest/sec-how-to-use.html#from-the-command-line)";
638-
default = "--local --silent --overwriteIfDifferent";
639-
};
639+
extraConfig = mkOption {
640+
type = types.attrs;
641+
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`.";
642+
default = { };
643+
644+
example = lib.literalExpression ''
645+
{
646+
yaml = "defaultIndent: ' '";
647+
}
648+
'';
649+
};
640650
};
641651
};
642652
};
@@ -2768,7 +2778,17 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol
27682778
description = "Perl script to add indentation to LaTeX files.";
27692779
types = [ "file" "tex" ];
27702780
package = tools.latexindent;
2771-
entry = "${hooks.latexindent.package}/bin/latexindent ${hooks.latexindent.settings.flags}";
2781+
2782+
entry = "${hooks.latexindent.package}/bin/latexindent ${
2783+
lib.cli.toGNUCommandLineShell {} (
2784+
{
2785+
local = true;
2786+
overwriteIfDifferent = true;
2787+
silent = true;
2788+
}
2789+
// hooks.latexindent.settings.extraConfig
2790+
)
2791+
}";
27722792
};
27732793
lacheck =
27742794
let

0 commit comments

Comments
 (0)