Skip to content

Commit f7650ba

Browse files
committed
latexindent: add hooks.latexindent.settings.disableExtraFiles option
Add the hooks.latexindent.settings.disableExtraFiles option to prevent the creation of backup and log files. Upstream refuses adding an option to disable backup and log file creation to protect non-version-controlled users from data loss, despite it being considered unnecessary for those using version control. [1] [2] [3] Considering that Git is the standard in Nix and required for flakes, providing this option is reasonable. [1]: cmhughes/latexindent.pl#145 [2]: cmhughes/latexindent.pl#333 [3]: cmhughes/latexindent.pl#354 Link: #514
1 parent 6c51b09 commit f7650ba

File tree

1 file changed

+36
-9
lines changed

1 file changed

+36
-9
lines changed

modules/hooks.nix

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,13 @@ in
636636
type = types.submodule {
637637
imports = [ hookModule ];
638638
options.settings = {
639+
disableExtraFiles =
640+
mkEnableOption
641+
(throw "initial description should never be evaluated")
642+
// {
643+
description = "Whether to disable the creation of backup and log files.";
644+
};
645+
639646
extraConfig = mkOption {
640647
type = types.attrs;
641648
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`.";
@@ -2773,21 +2780,41 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol
27732780
'';
27742781
};
27752782
latexindent =
2783+
let
2784+
hook = hooks.latexindent;
2785+
in
27762786
{
27772787
name = "latexindent";
27782788
description = "Perl script to add indentation to LaTeX files.";
27792789
types = [ "file" "tex" ];
27802790
package = tools.latexindent;
27812791

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-
)
2792+
entry = "${pkgs.runtimeShell} -c ${
2793+
lib.escapeShellArg ''
2794+
${hook.package}/bin/latexindent ${
2795+
lib.optionalString
2796+
hook.settings.disableExtraFiles
2797+
''--cruft "$(mktemp --directory)"''
2798+
} ${
2799+
lib.cli.toGNUCommandLineShell {} (
2800+
lib.mergeAttrsList (
2801+
{
2802+
local = true;
2803+
silent = true;
2804+
}
2805+
2806+
(
2807+
lib.optionalAttrs hook.settings.disableExtraFiles {
2808+
logfile = toString /dev/null;
2809+
overwriteIfDifferent = true;
2810+
}
2811+
)
2812+
2813+
hook.settings.extraConfig
2814+
)
2815+
)
2816+
} "$@"
2817+
''
27912818
}";
27922819
};
27932820
lacheck =

0 commit comments

Comments
 (0)