Skip to content

Commit 0593b68

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 7dca34c commit 0593b68

File tree

1 file changed

+41
-10
lines changed

1 file changed

+41
-10
lines changed

modules/hooks.nix

+41-10
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,22 +2775,46 @@ 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-
)
2786-
}";
2787+
entry = lib.getExe (
2788+
pkgs.writeShellApplication {
2789+
name = "git-hooks-nix-hooks-latexindent-entry";
2790+
2791+
text = ''
2792+
${hook.package}/bin/latexindent ${
2793+
lib.optionalString
2794+
hook.settings.disableExtraFiles
2795+
''--cruft "$(mktemp --directory)"''
2796+
} ${
2797+
lib.cli.toGNUCommandLineShell {} (
2798+
lib.mergeAttrsList [
2799+
{
2800+
local = true;
2801+
silent = true;
2802+
}
2803+
2804+
(
2805+
lib.optionalAttrs hook.settings.disableExtraFiles {
2806+
logfile = toString /dev/null;
2807+
overwriteIfDifferent = true;
2808+
}
2809+
)
2810+
2811+
hook.settings.extraConfig
2812+
]
2813+
)
2814+
} "$@"
2815+
'';
2816+
}
2817+
);
27872818
};
27882819
lacheck =
27892820
let

0 commit comments

Comments
 (0)