From b30a815d9abc4d89757c154a27dcec72b119a66b Mon Sep 17 00:00:00 2001 From: NAHO <90870942+trueNAHO@users.noreply.github.com> Date: Fri, 11 Oct 2024 16:26:57 +0200 Subject: [PATCH 1/2] latex: merge LaTeX packages into a single derivation Merge the packages used by the chktex, lacheck, and latexindent hooks into a single pkgs.texlive.combine derivation to reduce installation size and build time. Only enabled hooks are included in the derivation. Link: https://github.com/cachix/git-hooks.nix/pull/513 --- modules/hooks.nix | 20 +++++++++++++++++--- nix/tools.nix | 10 ---------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/modules/hooks.nix b/modules/hooks.nix index 63bcc1cb..a33a893a 100644 --- a/modules/hooks.nix +++ b/modules/hooks.nix @@ -22,6 +22,20 @@ let if hook.settings.binPath == null then "${hook.package}${binPath}" else hook.settings.binPath; + + texliveCombine = pkgs.texlive.combine ( + lib.mergeAttrsList + ( + map + (package: { ${package} = pkgs.texlive.${package}; }) + ( + builtins.filter + (hook: hooks.${hook}.enable) + [ "chktex" "lacheck" "latexindent" ] + ) + ) + // { inherit (pkgs.texlive) scheme-basic; } + ); in { imports = @@ -2228,7 +2242,7 @@ in name = "chktex"; description = "LaTeX semantic checker"; types = [ "file" "tex" ]; - package = tools.chktex; + package = texliveCombine; entry = "${hooks.chktex.package}/bin/chktex"; }; clang-format = @@ -2903,7 +2917,7 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol name = "latexindent"; description = "Perl script to add indentation to LaTeX files."; types = [ "file" "tex" ]; - package = tools.latexindent; + package = texliveCombine; entry = "${hooks.latexindent.package}/bin/latexindent ${hooks.latexindent.settings.flags}"; }; lacheck = @@ -2918,7 +2932,7 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol name = "lacheck"; description = "A consistency checker for LaTeX documents."; types = [ "file" "tex" ]; - package = tools.lacheck; + package = texliveCombine; entry = "${script}"; }; lua-ls = diff --git a/nix/tools.nix b/nix/tools.nix index c509f8d3..2ed61d9d 100644 --- a/nix/tools.nix +++ b/nix/tools.nix @@ -91,11 +91,6 @@ }: -let - tex = texlive.combine { - inherit (texlive) latexindent chktex scheme-basic; - }; -in { clang-tools = llvmPackages_latest.clang-tools; inherit @@ -191,11 +186,6 @@ in tflint = callPackage ./tflint { }; dune-build-opam-files = callPackage ./dune-build-opam-files { dune = dune_3; inherit (pkgsBuildBuild) ocaml; }; dune-fmt = callPackage ./dune-fmt { dune = dune_3; inherit (pkgsBuildBuild) ocaml; }; - latexindent = tex; - lacheck = texlive.combine { - inherit (texlive) lacheck scheme-basic; - }; - chktex = tex; commitizen = commitizen.overrideAttrs (_: _: { doCheck = false; }); bats = if bats ? withLibraries then (bats.withLibraries (p: [ p.bats-support p.bats-assert p.bats-file ])) else bats; git-annex = if stdenv.isDarwin then null else git-annex; From beb04f93ce5624ca774bd3bf1d060dbfd98b7df9 Mon Sep 17 00:00:00 2001 From: NAHO <90870942+trueNAHO@users.noreply.github.com> Date: Fri, 11 Oct 2024 16:27:01 +0200 Subject: [PATCH 2/2] latex: reduce footprint by replacing scheme-basic with scheme-minimal Reduce installation size and build time by replacing the pkgs.texlive.scheme-basic package with pkgs.texlive.scheme-minimal. Keeping this dependency simplifies the integration implementation without significantly impacting install size, considering that most LaTeX projects already require the pkgs.texlive.scheme-minimal packages. Link: https://github.com/cachix/git-hooks.nix/pull/513 --- modules/hooks.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hooks.nix b/modules/hooks.nix index a33a893a..cc3d639f 100644 --- a/modules/hooks.nix +++ b/modules/hooks.nix @@ -34,7 +34,7 @@ let [ "chktex" "lacheck" "latexindent" ] ) ) - // { inherit (pkgs.texlive) scheme-basic; } + // { inherit (pkgs.texlive) scheme-minimal; } ); in {