summary refs log tree commit diff
path: root/pkgs/tools/typesetting/tex/texlive/combine-wrapper.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/tools/typesetting/tex/texlive/combine-wrapper.nix')
-rw-r--r--pkgs/tools/typesetting/tex/texlive/combine-wrapper.nix42
1 files changed, 42 insertions, 0 deletions
diff --git a/pkgs/tools/typesetting/tex/texlive/combine-wrapper.nix b/pkgs/tools/typesetting/tex/texlive/combine-wrapper.nix
new file mode 100644
index 00000000000..165e7a22c66
--- /dev/null
+++ b/pkgs/tools/typesetting/tex/texlive/combine-wrapper.nix
@@ -0,0 +1,42 @@
+# legacy texlive.combine wrapper
+{ lib, toTLPkgList, toTLPkgSets, buildTeXEnv }:
+args@{
+  pkgFilter ? (pkg: pkg.tlType == "run" || pkg.tlType == "bin" || pkg.pname == "core"
+                    || pkg.hasManpages or false)
+, extraName ? "combined"
+, extraVersion ? ""
+, ...
+}:
+let
+  pkgSet = removeAttrs args [ "pkgFilter" "extraName" "extraVersion" ];
+
+  # combine a set of TL packages into a single TL meta-package
+  combinePkgs = pkgList: lib.catAttrs "pkg" (
+    let
+      # a TeX package used to be an attribute set { pkgs = [ ... ]; ... } where pkgs is a list of derivations
+      # the derivations make up the TeX package and optionally (for backward compatibility) its dependencies
+      tlPkgToSets = drv: map ({ tlType, version ? "", outputName ? "", ... }@pkg: {
+          # outputName required to distinguish among bin.core-big outputs
+          key = "${pkg.pname or pkg.name}.${tlType}-${version}-${outputName}";
+          inherit pkg;
+        }) (drv.pkgs or (toTLPkgList drv));
+      pkgListToSets = lib.concatMap tlPkgToSets; in
+    builtins.genericClosure {
+      startSet = pkgListToSets pkgList;
+      operator = { pkg, ... }: pkgListToSets (pkg.tlDeps or []);
+    });
+  combined = combinePkgs (lib.attrValues pkgSet);
+
+  # convert to specified outputs
+  tlTypeToOut = { run = "tex"; doc = "texdoc"; source = "texsource"; bin = "out"; tlpkg = "tlpkg"; };
+  toSpecified = { tlType, ... }@drv: drv // { outputSpecified = true; tlOutputName = tlTypeToOut.${tlType}; };
+  all = lib.filter pkgFilter combined ++ lib.filter (pkg: pkg.tlType == "tlpkg") combined;
+  converted = builtins.map toSpecified all;
+in
+buildTeXEnv {
+  __extraName = extraName;
+  __extraVersion = extraVersion;
+  requiredTeXPackages = _: converted;
+  __combine = true;
+  __fromCombineWrapper = true;
+}