about summary refs log tree commit diff
path: root/pkgs/tools/typesetting/tex/texlive/build-tex-env.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/tools/typesetting/tex/texlive/build-tex-env.nix')
-rw-r--r--pkgs/tools/typesetting/tex/texlive/build-tex-env.nix21
1 files changed, 14 insertions, 7 deletions
diff --git a/pkgs/tools/typesetting/tex/texlive/build-tex-env.nix b/pkgs/tools/typesetting/tex/texlive/build-tex-env.nix
index 5497e6b6dd4bd..148e51f55de58 100644
--- a/pkgs/tools/typesetting/tex/texlive/build-tex-env.nix
+++ b/pkgs/tools/typesetting/tex/texlive/build-tex-env.nix
@@ -35,6 +35,8 @@ lib.fix (self: {
 , __combine ? false
 # adjust behavior further if called from the texlive.combine wrapper
 , __fromCombineWrapper ? false
+# build only the formats of a package (for internal use!)
+, __formatsOf ? null
 }@args:
 
 let
@@ -116,7 +118,8 @@ let
     hyphenPatterns = lib.filter (p: p ? hyphenPatterns && (p.tlOutputName or p.outputName == "tex")) nonbin;
     sortedHyphenPatterns = builtins.sort (a: b: a.pname < b.pname) hyphenPatterns;
     formatPkgs = lib.filter (p: p ? formats && (p.outputSpecified or false -> p.tlOutputName or p.outputName == "tex") && builtins.any (f: f.enabled or true) p.formats) all;
-    sortedFormatPkgs = builtins.sort (a: b: a.pname < b.pname) formatPkgs;
+    sortedFormatPkgs = if __formatsOf != null then [ __formatsOf ] else builtins.sort (a: b: a.pname < b.pname) formatPkgs;
+    formats = map (p: self { requiredTeXPackages = ps: [ ps.scheme-infraonly p ] ++ hyphenPatterns; __formatsOf = p; }) sortedFormatPkgs;
   };
 
   # list generated by inspecting `grep -IR '\([^a-zA-Z]\|^\)gs\( \|$\|"\)' "$TEXMFDIST"/scripts`
@@ -125,7 +128,7 @@ let
   needsGhostscript = lib.any (p: lib.elem p.pname [ "context" "dvipdfmx" "latex-papersize" "lyluatex" ]) pkgList.bin;
 
   name = if __combine then "texlive-${__extraName}-${bin.texliveYear}${__extraVersion}" # texlive.combine: old name name
-    else "texlive-${bin.texliveYear}-env";
+    else "texlive-${bin.texliveYear}-" + (if __formatsOf != null then "${__formatsOf.pname}-fmt" else "env");
 
   texmfdist = buildEnv' {
     name = "${name}-texmfdist";
@@ -260,11 +263,11 @@ buildEnv' {
   inherit name;
 
   # use attrNames, attrValues to ensure the two lists are sorted in the same way
-  outputs = [ "out" ] ++ lib.optionals (! __combine) (builtins.attrNames nonEnvOutputs);
-  otherOutputs = lib.optionals (! __combine) (builtins.attrValues nonEnvOutputs);
+  outputs = [ "out" ] ++ lib.optionals (! __combine && __formatsOf == null) (builtins.attrNames nonEnvOutputs);
+  otherOutputs = lib.optionals (! __combine && __formatsOf == null) (builtins.attrValues nonEnvOutputs);
 
   # remove fake derivations (without 'outPath') to avoid undesired build dependencies
-  paths = builtins.catAttrs "outPath" pkgList.bin
+  paths = builtins.catAttrs "outPath" pkgList.bin ++ lib.optionals (! __combine && __formatsOf == null) pkgList.formats
     ++ lib.optional __combine doc;
   pathsToLink = [
     "/"
@@ -286,7 +289,8 @@ buildEnv' {
 
   buildInputs = [ coreutils gawk gnugrep gnused ] ++ lib.optional needsGhostscript ghostscript;
 
-  inherit meta passthru;
+  inherit meta passthru __combine;
+  __formatsOf = __formatsOf.pname or null;
 
   inherit texmfdist texmfroot;
 
@@ -304,6 +308,9 @@ buildEnv' {
   postBuild = ''
     . "${./build-tex-env.sh}"
   '';
+
+  allowSubstitutes = true;
+  preferLocalBuild = false;
 };
   # outputsToInstall must be set *after* overrideAttrs (used in buildEnv') or it fails the checkMeta tests
-in if __combine then out else lib.addMetaAttrs { inherit (pkgList) outputsToInstall; } out)
+in if __combine || __formatsOf != null then out else lib.addMetaAttrs { inherit (pkgList) outputsToInstall; } out)