Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 53 additions & 7 deletions modules/hooks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -683,12 +683,24 @@ in
type = types.submodule {
imports = [ hookModule ];
options.settings = {
flags =
mkOption {
type = types.str;
description = "Flags passed to latexindent. See available flags [here](https://latexindentpl.readthedocs.io/en/latest/sec-how-to-use.html#from-the-command-line)";
default = "--local --silent --overwriteIfDifferent";
};
disableExtraFiles = mkOption {
default = true;
example = false;
description = "Whether to disable the creation of backup and log files.";
type = types.bool;
};

extraConfig = mkOption {
type = types.attrs;
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`.";
default = { };

example = lib.literalExpression ''
{
yaml = "defaultIndent: ' '";
}
'';
};
};
};
};
Expand Down Expand Up @@ -2899,12 +2911,46 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol
'';
};
latexindent =
let
hook = hooks.latexindent;
in
{
name = "latexindent";
description = "Perl script to add indentation to LaTeX files.";
types = [ "file" "tex" ];
package = tools.latexindent;
entry = "${hooks.latexindent.package}/bin/latexindent ${hooks.latexindent.settings.flags}";

entry = lib.getExe (
pkgs.writeShellApplication {
name = "git-hooks-nix-hooks-latexindent-entry";

text = ''
${hook.package}/bin/latexindent ${
lib.optionalString
hook.settings.disableExtraFiles
''--cruft "$(mktemp --directory)"''
} ${
lib.cli.toGNUCommandLineShell {} (
lib.mergeAttrsList [
{
local = true;
silent = true;
}

(
lib.optionalAttrs hook.settings.disableExtraFiles {
logfile = toString /dev/null;
overwriteIfDifferent = true;
}
)

hook.settings.extraConfig
]
)
} "$@"
'';
}
);
};
lacheck =
let
Expand Down