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 7dca34c
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 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 @@ -631,12 +631,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 +2773,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 7dca34c

Please sign in to comment.