Skip to content

Commit 392184d

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: cachix#514
1 parent 7dca34c commit 392184d

File tree

1 file changed

+36
-9
lines changed

1 file changed

+36
-9
lines changed

modules/hooks.nix

+36-9
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,13 @@ in
631631
type = types.submodule {
632632
imports = [ hookModule ];
633633
options.settings = {
634+
disableExtraFiles =
635+
mkEnableOption
636+
(throw "initial description should never be evaluated")
637+
// {
638+
description = "Whether to disable the creation of backup and log files.";
639+
};
640+
634641
extraConfig = mkOption {
635642
type = types.attrs;
636643
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`.";
@@ -2768,21 +2775,41 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol
27682775
'';
27692776
};
27702777
latexindent =
2778+
let
2779+
hook = hooks.latexindent;
2780+
in
27712781
{
27722782
name = "latexindent";
27732783
description = "Perl script to add indentation to LaTeX files.";
27742784
types = [ "file" "tex" ];
27752785
package = tools.latexindent;
27762786

2777-
entry = "${hooks.latexindent.package}/bin/latexindent ${
2778-
lib.cli.toGNUCommandLineShell {} (
2779-
{
2780-
local = true;
2781-
overwriteIfDifferent = true;
2782-
silent = true;
2783-
}
2784-
// hooks.latexindent.settings.extraConfig
2785-
)
2787+
entry = "${pkgs.runtimeShell} -c ${
2788+
lib.escapeShellArg ''
2789+
${hook.package}/bin/latexindent ${
2790+
lib.optionalString
2791+
hook.settings.disableExtraFiles
2792+
''--cruft "$(mktemp --directory)"''
2793+
} ${
2794+
lib.cli.toGNUCommandLineShell {} (
2795+
lib.mergeAttrsList [
2796+
{
2797+
local = true;
2798+
silent = true;
2799+
}
2800+
2801+
(
2802+
lib.optionalAttrs hook.settings.disableExtraFiles {
2803+
logfile = toString /dev/null;
2804+
overwriteIfDifferent = true;
2805+
}
2806+
)
2807+
2808+
hook.settings.extraConfig
2809+
]
2810+
)
2811+
} "$@"
2812+
''
27862813
}";
27872814
};
27882815
lacheck =

0 commit comments

Comments
 (0)