Skip to content

Commit 750711b

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 1484798 commit 750711b

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
@@ -683,6 +683,13 @@ in
683683
type = types.submodule {
684684
imports = [ hookModule ];
685685
options.settings = {
686+
disableExtraFiles =
687+
mkEnableOption
688+
(throw "initial description should never be evaluated")
689+
// {
690+
description = "Whether to disable the creation of backup and log files.";
691+
};
692+
686693
extraConfig = mkOption {
687694
type = types.attrs;
688695
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`.";
@@ -2904,22 +2911,46 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol
29042911
'';
29052912
};
29062913
latexindent =
2914+
let
2915+
hook = hooks.latexindent;
2916+
in
29072917
{
29082918
name = "latexindent";
29092919
description = "Perl script to add indentation to LaTeX files.";
29102920
types = [ "file" "tex" ];
29112921
package = tools.latexindent;
29122922

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-
}";
2923+
entry = lib.getExe (
2924+
pkgs.writeShellApplication {
2925+
name = "git-hooks-nix-hooks-latexindent-entry";
2926+
2927+
text = ''
2928+
${hook.package}/bin/latexindent ${
2929+
lib.optionalString
2930+
hook.settings.disableExtraFiles
2931+
''--cruft "$(mktemp --directory)"''
2932+
} ${
2933+
lib.cli.toGNUCommandLineShell {} (
2934+
lib.mergeAttrsList [
2935+
{
2936+
local = true;
2937+
silent = true;
2938+
}
2939+
2940+
(
2941+
lib.optionalAttrs hook.settings.disableExtraFiles {
2942+
logfile = toString /dev/null;
2943+
overwriteIfDifferent = true;
2944+
}
2945+
)
2946+
2947+
hook.settings.extraConfig
2948+
]
2949+
)
2950+
} "$@"
2951+
'';
2952+
}
2953+
);
29232954
};
29242955
lacheck =
29252956
let

0 commit comments

Comments
 (0)