Skip to content

Commit

Permalink
latexindent: add hooks.latexindent.settings.extraConfig option
Browse files Browse the repository at this point in the history
Replace the hooks.latexindent.settings.flags option with
hooks.latexindent.settings.extraConfig to support arbitrary upstream
flags and allow users to override default values.

Link: cachix#514
  • Loading branch information
trueNAHO committed Oct 12, 2024
1 parent 06bb597 commit 6c51b09
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions modules/hooks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
let
inherit (config) hooks tools settings;
cfg = config;
inherit (lib) flatten mapAttrs mapAttrsToList mkDefault mkOption mkRemovedOptionModule mkRenamedOptionModule types;
inherit (lib) flatten mapAttrs mapAttrsToList mkDefault mkEnableOption mkOption mkRemovedOptionModule mkRenamedOptionModule types;

cargoManifestPathArg =
lib.optionalString
Expand Down Expand Up @@ -33,6 +33,11 @@ in
(mkRemovedOptionModule [ "settings" "yamllint" "relaxed" ] ''
This option has been removed. Use `hooks.yamllint.settings.preset = "relaxed"`.
'')
(
mkRemovedOptionModule
[ "hooks" "latexindent" "settings" "flags" ]
"Use hooks.latexindent.settings.extraConfig instead."
)
]
# Manually rename options that had a package or a config option
++ flatten (mapAttrsToList (name: map (o: mkRenamedOptionModule [ "settings" name o ] [ "hooks" name "settings" o ])) {
Expand Down Expand Up @@ -631,12 +636,17 @@ 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";
};
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 @@ -2768,7 +2778,17 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol
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 = "${hooks.latexindent.package}/bin/latexindent ${
lib.cli.toGNUCommandLineShell {} (
{
local = true;
overwriteIfDifferent = true;
silent = true;
}
// hooks.latexindent.settings.extraConfig
)
}";
};
lacheck =
let
Expand Down

0 comments on commit 6c51b09

Please sign in to comment.