Merge pull request #250805 from xworld21/texlive-buildenv-minimal

texlive: overrideTeXConfig/withPackages
This commit is contained in:
Dmitry Kalinkin 2023-11-01 13:29:10 -04:00 committed by GitHub
commit ec2e217c52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 564 additions and 264 deletions

View File

@ -38,6 +38,24 @@ Since release 15.09 there is a new TeX Live packaging that lives entirely under
- Note that the wrapper assumes that the result has a chance to be useful. For example, the core executables should be present, as well as some core data files. The supported way of ensuring this is by including some scheme, for example `scheme-basic`, into the combination.
- TeX Live packages are also available under `texlive.pkgs` as derivations with outputs `out`, `tex`, `texdoc`, `texsource`, `tlpkg`, `man`, `info`. They cannot be installed outside of `texlive.combine` but are available for other uses. To repackage a font, for instance, use
```nix
stdenvNoCC.mkDerivation rec {
src = texlive.pkgs.iwona;
inherit (src) pname version;
installPhase = ''
runHook preInstall
install -Dm644 fonts/opentype/nowacki/iwona/*.otf -t $out/share/fonts/opentype
runHook postInstall
'';
}
```
See `biber`, `iwona` for complete examples.
## Custom packages {#sec-language-texlive-custom-packages}
You may find that you need to use an external TeX package. A derivation for such package has to provide the contents of the "texmf" directory in its output and provide the appropriate `tlType` attribute (one of `"run"`, `"bin"`, `"doc"`, `"source"`). Dependencies on other TeX packages can be listed in the attribute `tlDeps`.

View File

@ -1,10 +1,9 @@
{ lib, stdenvNoCC, texlive }:
stdenvNoCC.mkDerivation {
pname = "iwona";
version = "0.995b";
stdenvNoCC.mkDerivation rec {
inherit (src) pname version;
src = lib.head (builtins.filter (p: p.tlType == "run") texlive.iwona.pkgs);
src = texlive.pkgs.iwona;
installPhase = ''
runHook preInstall
@ -20,7 +19,7 @@ stdenvNoCC.mkDerivation {
# "[...] GUST Font License (GFL), which is a free license, legally
# equivalent to the LaTeX Project Public # License (LPPL), version 1.3c or
# later." - GUST website
license = licenses.lppl13c;
license = src.meta.license;
maintainers = with maintainers; [ siddharthist ];
platforms = platforms.all;
};

View File

@ -1,10 +1,11 @@
{ lib
, stdenv
, fetchFromGitHub
, writeShellScript
, texlive
}:
stdenv.mkDerivation (finalAttrs: rec {
stdenv.mkDerivation rec {
pname = "sagetex";
version = "3.6.1";
@ -15,8 +16,14 @@ stdenv.mkDerivation (finalAttrs: rec {
sha256 = "sha256-OfhbXHbGI+DaDHqZCOGiSHJPHjGuT7ZqSEjKweloW38=";
};
buildInputs = [
outputs = [ "tex" ];
nativeBuildInputs = [
texlive.combined.scheme-basic
# multiple-outputs.sh fails if $out is not defined
(writeShellScript "force-tex-output.sh" ''
out="''${tex-}"
'')
];
buildPhase = ''
@ -29,11 +36,6 @@ stdenv.mkDerivation (finalAttrs: rec {
cp -va *.sty *.cfg *.def "$path/"
'';
passthru = {
tlType = "run";
pkgs = [ finalAttrs.finalPackage ];
};
meta = with lib; {
description = "Embed code, results of computations, and plots from Sage into LaTeX documents";
homepage = "https://github.com/sagemath/sagetex";
@ -41,4 +43,4 @@ stdenv.mkDerivation (finalAttrs: rec {
maintainers = with maintainers; [ alexnortung ];
platforms = platforms.all;
};
})
}

View File

@ -454,8 +454,7 @@ rec {
'';
# link all binaries in single derivation
allPackages = with lib; concatLists (catAttrs "pkgs" (filter isAttrs (attrValues texlive)));
binPackages = lib.filter (p: p.tlType == "bin") allPackages;
binPackages = lib.catAttrs "out" (lib.attrValues texlive.pkgs);
binaries = buildEnv { name = "texlive-binaries"; paths = binPackages; };
in
runCommand "texlive-test-binaries"
@ -565,8 +564,7 @@ rec {
# check that all scripts have a Nix shebang
shebangs = let
allPackages = with lib; concatLists (catAttrs "pkgs" (filter isAttrs (attrValues texlive)));
binPackages = lib.filter (p: p.tlType == "bin") allPackages;
binPackages = lib.catAttrs "out" (lib.attrValues texlive.pkgs);
in
runCommand "texlive-test-shebangs" { }
(''
@ -615,7 +613,7 @@ rec {
correctLicenses = scheme: builtins.foldl'
(acc: pkg: concatLicenses acc (lib.toList (pkg.meta.license or [])))
[]
scheme.passthru.packages;
scheme.passthru.requiredTeXPackages;
correctLicensesAttrNames = scheme:
lib.sort lt
(map licenseToAttrName (correctLicenses scheme));
@ -648,10 +646,13 @@ rec {
# this is effectively an eval-time assertion, converted into a derivation for
# ease of testing
fixedHashes = with lib; let
combine = findFirst (p: (head p.pkgs).pname == "combine") { pkgs = []; } (head texlive.collection-latexextra.pkgs).tlDeps;
all = concatLists (map (p: p.pkgs or []) (attrValues (removeAttrs texlive [ "bin" "combine" "combined" "tlpdb" ]))) ++ combine.pkgs;
fods = filter (p: isDerivation p && p.tlType != "bin") all;
errorText = concatMapStrings (p: optionalString (! p ? outputHash) "${p.pname + optionalString (p.tlType != "run") ("." + p.tlType)} does not have a fixed output hash\n") fods;
fods = lib.concatMap
(p: lib.optional (p ? tex) p.tex
++ lib.optional (p ? texdoc) p.texdoc
++ lib.optional (p ? texsource) p.texsource
++ lib.optional (p ? tlpkg) p.tlpkg)
(attrValues texlive.pkgs);
errorText = concatMapStrings (p: optionalString (! p ? outputHash) "${p.pname}-${p.tlOutputName} does not have a fixed output hash\n") fods;
in runCommand "texlive-test-fixed-hashes" {
inherit errorText;
passAsFile = [ "errorText" ];

View File

@ -1,7 +1,7 @@
{ lib, stdenv, fetchFromGitHub, fetchurl, perlPackages, shortenPerlShebang, texlive }:
let
biberSource = lib.head (builtins.filter (p: p.tlType == "source") texlive.biber-ms.pkgs);
biberSource = texlive.pkgs.biber-ms.texsource;
# missing test file
multiscriptBltxml = (fetchFromGitHub {
owner = "plk";
@ -12,8 +12,7 @@ let
in
perlPackages.buildPerlModule {
pname = "biber-ms";
inherit (biberSource) version;
inherit (biberSource) pname version;
src = "${biberSource}/source/bibtex/biber-ms/biblatex-biber-ms.tar.gz";

View File

@ -1,12 +1,11 @@
{ lib, stdenv, fetchurl, perlPackages, shortenPerlShebang, texlive }:
let
biberSource = lib.head (builtins.filter (p: p.tlType == "source") texlive.biber.pkgs);
biberSource = texlive.pkgs.biber.texsource;
in
perlPackages.buildPerlModule {
pname = "biber";
inherit (biberSource) version;
inherit (biberSource) pname version;
src = "${biberSource}/source/bibtex/biber/biblatex-biber.tar.gz";

View File

@ -43,11 +43,7 @@ stdenv.mkDerivation (finalAttrs: rec {
# experimental texlive.combine support
# (note that only the bin/ folder will be combined into texlive)
passthru = {
tlType = "bin";
tlDeps = with texlive; [ kpathsea t1utils metafont ];
pkgs = [ finalAttrs.finalPackage ];
};
passthru.tlDeps = with texlive; [ kpathsea t1utils metafont ];
meta = with lib; {
description = "Scalable PostScript Fonts for MetaFont";

View File

@ -355,7 +355,7 @@ pygmentex = python3Packages.buildPythonApplication rec {
inherit (src) version;
format = "other";
src = assertFixedHash pname (lib.head (builtins.filter (p: p.tlType == "run") texlive.pygmentex.pkgs));
src = assertFixedHash pname texlive.pkgs.pygmentex.tex;
propagatedBuildInputs = with python3Packages; [ pygments chardet ];
@ -436,7 +436,7 @@ xdvi = stdenv.mkDerivation {
xpdfopen = stdenv.mkDerivation {
pname = "texlive-xpdfopen.bin";
inherit (lib.head texlive.xpdfopen.pkgs) version;
inherit (texlive.pkgs.xpdfopen) version;
inherit (common) src;

View File

@ -1,55 +1,125 @@
{ lib, buildEnv, runCommand, writeText, makeWrapper, libfaketime, makeFontsConf
, perl, bash, coreutils, gnused, gnugrep, gawk, ghostscript
, bin, tl }:
# combine =
args@{
pkgFilter ? (pkg: pkg.tlType == "run" || pkg.tlType == "bin" || pkg.pname == "core"
|| pkg.hasManpages or false)
, extraName ? "combined"
, extraVersion ? ""
, ...
{
# texlive package set
tl
, bin
, lib
, buildEnv
, libfaketime
, makeFontsConf
, makeWrapper
, runCommand
, writeShellScript
, writeText
, toTLPkgSets
, bash
, perl
# common runtime dependencies
, coreutils
, gawk
, gnugrep
, gnused
, ghostscript
}:
lib.fix (self: {
withDocs ? false
, withSources ? false
, requiredTeXPackages ? ps: [ ps.scheme-infraonly ]
### texlive.combine backward compatibility
, __extraName ? "combined"
, __extraVersion ? ""
# emulate the old texlive.combine (e.g. add man pages to main output)
, __combine ? false
# adjust behavior further if called from the texlive.combine wrapper
, __fromCombineWrapper ? false
}@args:
let
# combine a set of TL packages into a single TL meta-package
combinePkgs = pkgList: lib.catAttrs "pkg" (
let
# a TeX package is 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 = { pkgs, ... }: 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;
}) pkgs;
pkgListToSets = lib.concatMap tlPkgToSets; in
builtins.genericClosure {
startSet = pkgListToSets pkgList;
operator = { pkg, ... }: pkgListToSets (pkg.tlDeps or []);
### texlive.combine backward compatibility
# if necessary, convert old style { pkgs = [ ... ]; } packages to attribute sets
ensurePkgSets = ps: if ! __fromCombineWrapper && builtins.any (p: p ? pkgs && builtins.all (p: p ? tlType) p.pkgs) ps
then let oldStyle = builtins.partition (p: p ? pkgs && builtins.all (p: p ? tlType) p.pkgs) ps;
in oldStyle.wrong ++ lib.concatMap toTLPkgSets oldStyle.right
else ps;
pkgList = rec {
# resolve dependencies of the packages that affect the runtime
all =
let
# order of packages is irrelevant
packages = builtins.sort (a: b: a.pname < b.pname) (ensurePkgSets (requiredTeXPackages tl));
runtime = builtins.partition
(p: p.outputSpecified or false -> builtins.elem (p.tlOutputName or p.outputName) [ "out" "tex" "tlpkg" ])
packages;
keySet = p: {
key = ((p.name or "${p.pname}-${p.version}") + "-" + p.tlOutputName or p.outputName or "");
inherit p;
tlDeps = p.tlDeps or (p.requiredTeXPackages or (_: [ ]) [ ]);
};
in
# texlive.combine: the wrapper already resolves all dependencies
if __fromCombineWrapper then requiredTeXPackages null else
builtins.catAttrs "p" (builtins.genericClosure {
startSet = map keySet runtime.right;
operator = p: map keySet p.tlDeps;
}) ++ runtime.wrong;
# group the specified outputs
specified = builtins.partition (p: p.outputSpecified or false) all;
specifiedOutputs = builtins.groupBy (p: p.tlOutputName or p.outputName) specified.right;
otherOutputNames = builtins.catAttrs "key" (builtins.genericClosure {
startSet = map (key: { inherit key; }) (lib.concatLists (builtins.catAttrs "outputs" specified.wrong));
operator = _: [ ];
});
otherOutputs = lib.genAttrs otherOutputNames (n: builtins.catAttrs n specified.wrong);
outputsToInstall = builtins.catAttrs "key" (builtins.genericClosure {
startSet = map (key: { inherit key; })
([ "out" ] ++ lib.optional (splitOutputs ? man) "man"
++ lib.concatLists (builtins.catAttrs "outputsToInstall" (builtins.catAttrs "meta" specified.wrong)));
operator = _: [ ];
});
pkgSet = removeAttrs args [ "pkgFilter" "extraName" "extraVersion" ];
pkgList = rec {
combined = combinePkgs (lib.attrValues pkgSet);
all = lib.filter pkgFilter combined;
splitBin = builtins.partition (p: p.tlType == "bin") all;
bin = splitBin.right;
nonbin = splitBin.wrong;
tlpkg = lib.filter (pkg: pkg.tlType == "tlpkg") combined;
# split binary and tlpkg from tex, texdoc, texsource
bin = if __fromCombineWrapper
then builtins.filter (p: p.tlType == "bin") all # texlive.combine: legacy filter
else otherOutputs.out or [ ] ++ specifiedOutputs.out or [ ];
tlpkg = if __fromCombineWrapper
then builtins.filter (p: p.tlType == "tlpkg") all # texlive.combine: legacy filter
else otherOutputs.tlpkg or [ ] ++ specifiedOutputs.tlpkg or [ ];
nonbin = if __fromCombineWrapper then builtins.filter (p: p.tlType != "bin" && p.tlType != "tlpkg") all # texlive.combine: legacy filter
else (if __combine then # texlive.combine: emulate old input ordering to avoid rebuilds
lib.concatMap (p: lib.optional (p ? tex) p.tex
++ lib.optional ((withDocs || p ? man) && p ? texdoc) p.texdoc
++ lib.optional (withSources && p ? texsource) p.texsource) specified.wrong
else otherOutputs.tex or [ ]
++ lib.optionals withDocs (otherOutputs.texdoc or [ ])
++ lib.optionals withSources (otherOutputs.texsource or [ ]))
++ specifiedOutputs.tex or [ ] ++ specifiedOutputs.texdoc or [ ] ++ specifiedOutputs.texsource or [ ];
# outputs that do not become part of the environment
nonEnvOutputs = lib.subtractLists [ "out" "tex" "texdoc" "texsource" "tlpkg" ] otherOutputNames;
};
# list generated by inspecting `grep -IR '\([^a-zA-Z]\|^\)gs\( \|$\|"\)' "$TEXMFDIST"/scripts`
# and `grep -IR rungs "$TEXMFDIST"`
# and ignoring luatex, perl, and shell scripts (those must be patched using postFixup)
needsGhostscript = lib.any (p: lib.elem p.pname [ "context" "dvipdfmx" "latex-papersize" "lyluatex" ]) pkgList.bin;
name = "texlive-${extraName}-${bin.texliveYear}${extraVersion}";
name = if __combine then "texlive-${__extraName}-${bin.texliveYear}${__extraVersion}" # texlive.combine: old name name
else "texlive-${bin.texliveYear}-env";
texmfdist = (buildEnv {
name = "${name}-texmfdist";
# remove fake derivations (without 'outPath') to avoid undesired build dependencies
paths = lib.catAttrs "outPath" pkgList.nonbin;
paths = builtins.catAttrs "outPath" pkgList.nonbin;
# mktexlsr
nativeBuildInputs = [ (lib.last tl."texlive.infra".pkgs) ];
nativeBuildInputs = [ tl."texlive.infra" ];
postBuild = # generate ls-R database
''
@ -61,7 +131,7 @@ let
name = "${name}-tlpkg";
# remove fake derivations (without 'outPath') to avoid undesired build dependencies
paths = lib.catAttrs "outPath" pkgList.tlpkg;
paths = builtins.catAttrs "outPath" pkgList.tlpkg;
}).overrideAttrs (_: { allowSubstitutes = true; });
# the 'non-relocated' packages must live in $TEXMFROOT/texmf-dist
@ -74,7 +144,7 @@ let
ln -s "$tlpkg" "$out"/tlpkg
'';
# expose info and man pages in usual /share/{info,man} location
# texlive.combine: expose info and man pages in usual /share/{info,man} location
doc = buildEnv {
name = "${name}-doc";
@ -87,14 +157,67 @@ let
];
};
in (buildEnv {
meta = {
description = "TeX Live environment"
+ lib.optionalString withDocs " with documentation"
+ lib.optionalString (withDocs && withSources) " and"
+ lib.optionalString withSources " with sources";
platforms = lib.platforms.all;
longDescription = "Contains the following packages and their transitive dependencies:\n - "
+ lib.concatMapStringsSep "\n - "
(p: p.pname + (lib.optionalString (p.outputSpecified or false) " (${p.tlOutputName or p.outputName})"))
(requiredTeXPackages tl);
};
# emulate split output derivation
splitOutputs = {
out = out // { outputSpecified = true; };
texmfdist = texmfdist // { outputSpecified = true; };
texmfroot = texmfroot // { outputSpecified = true; };
} // (lib.genAttrs pkgList.nonEnvOutputs (outName: (buildEnv {
inherit name;
paths = builtins.catAttrs "outPath"
(pkgList.otherOutputs.${outName} or [ ] ++ pkgList.specifiedOutputs.${outName} or [ ]);
# force the output to be ${outName} or nix-env will not work
nativeBuildInputs = [ (writeShellScript "force-output.sh" ''
export out="''${${outName}-}"
'') ];
inherit meta passthru;
}).overrideAttrs { outputs = [ outName ]; } // { outputSpecified = true; }));
passthru = lib.optionalAttrs (! __combine) (splitOutputs // {
all = builtins.attrValues splitOutputs;
outputs = [ "out" ] ++ pkgList.nonEnvOutputs;
}) // {
# This is set primarily to help find-tarballs.nix to do its job
requiredTeXPackages = builtins.filter lib.isDerivation (pkgList.bin ++ pkgList.nonbin
++ lib.optionals (! __fromCombineWrapper)
(lib.concatMap (n: (pkgList.otherOutputs.${n} or [ ] ++ pkgList.specifiedOutputs.${n} or [ ]))) pkgList.nonEnvOutputs);
# useful for inclusion in the `fonts.packages` nixos option or for use in devshells
fonts = "${texmfroot}/texmf-dist/fonts";
# support variants attrs, (prev: attrs)
__overrideTeXConfig = newArgs:
let appliedArgs = if builtins.isFunction newArgs then newArgs args else newArgs; in
self (args // { __fromCombineWrapper = false; } // appliedArgs);
withPackages = reqs: self (args // { requiredTeXPackages = ps: requiredTeXPackages ps ++ reqs ps; __fromCombineWrapper = false; });
};
out = (if (! __combine)
# meta.outputsToInstall = [ "out" "man" ] is invalid within buildEnv:
# checkMeta will notice that there is no actual "man" output, and fail
# so we set outputsToInstall from the outside, where it is safe
then lib.addMetaAttrs { inherit (pkgList) outputsToInstall; }
else x: x) # texlive.combine: man pages used to be part of out
# no indent for git diff purposes
((buildEnv {
inherit name;
ignoreCollisions = false;
# remove fake derivations (without 'outPath') to avoid undesired build dependencies
paths = lib.catAttrs "outPath" pkgList.bin ++ [ doc ];
paths = builtins.catAttrs "outPath" pkgList.bin
++ lib.optional __combine doc;
pathsToLink = [
"/"
"/share/texmf-var/scripts"
@ -107,18 +230,13 @@ in (buildEnv {
nativeBuildInputs = [
makeWrapper
libfaketime
(lib.last tl."texlive.infra".pkgs) # mktexlsr
(lib.last tl.texlive-scripts.pkgs) # fmtutil, updmap
(lib.last tl.texlive-scripts-extra.pkgs) # texlinks
tl."texlive.infra" # mktexlsr
tl.texlive-scripts # fmtutil, updmap
tl.texlive-scripts-extra # texlinks
perl
];
passthru = {
# This is set primarily to help find-tarballs.nix to do its job
packages = pkgList.all;
# useful for inclusion in the `fonts.packages` nixos option or for use in devshells
fonts = "${texmfroot}/texmf-dist/fonts";
};
inherit meta passthru;
postBuild =
# environment variables (note: only export the ones that are used in the wrappers)
@ -131,7 +249,7 @@ in (buildEnv {
export TEXMFCNF="$TEXMFSYSVAR/web2c"
'' +
# wrap executables with required env vars as early as possible
# 1. we want texlive.combine to use the wrapped binaries, to catch bugs
# 1. we use the wrapped binaries in the scripts below, to catch bugs
# 2. we do not want to wrap links generated by texlinks
''
enable -f '${bash}/lib/bash/realpath' realpath
@ -195,16 +313,16 @@ in (buildEnv {
'' +
# now filter hyphenation patterns and formats
(let
hyphens = lib.filter (p: p.hasHyphens or false && p.tlType == "run") pkgList.splitBin.wrong;
hyphens = lib.filter (p: p.hasHyphens or false && p.tlOutputName or p.outputName == "tex") pkgList.nonbin;
hyphenPNames = map (p: p.pname) hyphens;
formats = lib.filter (p: p ? formats && p.tlType == "run") pkgList.splitBin.wrong;
formats = lib.filter (p: p ? formats && p.tlOutputName or p.outputName == "tex") pkgList.nonbin;
formatPNames = map (p: p.pname) formats;
# sed expression that prints the lines in /start/,/end/ except for /end/
section = start: end: "/${start}/,/${end}/{ /${start}/p; /${end}/!p; };\n";
script =
writeText "hyphens.sed" (
# document how the file was generated (for language.dat)
"1{ s/^(% Generated by .*)$/\\1, modified by texlive.combine/; p; }\n"
"1{ s/^(% Generated by .*)$/\\1, modified by ${if __combine then "texlive.combine" else "Nixpkgs"}/; p; }\n"
# pick up the header
+ "2,/^% from/{ /^% from/!p; };\n"
# pick up all sections matching packages that we combine
@ -214,7 +332,7 @@ in (buildEnv {
);
scriptLua =
writeText "hyphens.lua.sed" (
"1{ s/^(-- Generated by .*)$/\\1, modified by texlive.combine/; p; }\n"
"1{ s/^(-- Generated by .*)$/\\1, modified by ${if __combine then "texlive.combine" else "Nixpkgs"}/; p; }\n"
+ "2,/^-- END of language.us.lua/p;\n"
+ lib.concatMapStrings (pname: section "^-- from ${pname}:$" "^}$|^-- from") hyphenPNames
+ "$p;\n"
@ -225,7 +343,7 @@ in (buildEnv {
fmtutilSed =
writeText "fmtutil.sed" (
# document how file was generated
"1{ s/^(# Generated by .*)$/\\1, modified by texlive.combine/; }\n"
"1{ s/^(# Generated by .*)$/\\1, modified by ${if __combine then "texlive.combine" else "Nixpkgs"}/; }\n"
# disable all formats, even those already disabled
+ "s/^([^#]|#! )/#! \\1/;\n"
# enable the formats from the packages being installed
@ -312,4 +430,5 @@ in (buildEnv {
ln -s "$TEXMFDIST" "$out"/share/texmf
''
;
}).overrideAttrs (_: { allowSubstitutes = true; })
}).overrideAttrs (_: { allowSubstitutes = true; }));
in out)

View File

@ -15,17 +15,27 @@
, texliveBinaries
}:
/* Convert an attribute set extracted from tlpdb.nix (with the deps attribute
already processed) to a fake multi-output derivation with possible outputs
[ "tex" "texdoc" "texsource" "tlpkg" "out" "man" "info" ]
*/
# TODO stabilise a generic interface decoupled from the finer details of the
# translation from texlive.tlpdb to tlpdb.nix
{ pname
, revision
, version ? toString revision
, extraRevision ? ""
, extraVersion ? ""
, sha512
, mirrors
, extraVersion ? ""
, fixedHashes ? { }
, postUnpack ? ""
, postFixup ? ""
, stripPrefix ? 1
, license ? [ ]
, hasHyphens ? false
, hasInfo ? false
, hasManpages ? false
, hasRunfiles ? false
, hasTlpkg ? false
@ -34,112 +44,165 @@
}@args:
let
meta = { license = map (x: lib.licenses.${x}) license; };
commonPassthru = {
inherit pname revision version;
} // lib.optionalAttrs (args ? extraRevision) {
inherit (args) extraRevision;
# common metadata
name = "${pname}-${version}${extraVersion}";
meta = {
license = map (x: lib.licenses.${x}) license;
# TeX Live packages should not be installed directly into the user profile
outputsToInstall = [ ];
};
hasBinfiles = args ? binfiles && args.binfiles != [ ];
hasDocfiles = sha512 ? doc;
hasSource = sha512 ? source;
# emulate drv.all, drv.outputs lists
all = lib.optional hasBinfiles bin ++
lib.optional hasRunfiles tex ++
lib.optional hasDocfiles texdoc ++
lib.optional hasSource texsource ++
lib.optional hasTlpkg tlpkg ++
lib.optional hasManpages man ++
lib.optional hasInfo info;
outputs = lib.catAttrs "tlOutputName" all;
mainDrv = if hasBinfiles then bin
else if hasRunfiles then tex
else if hasTlpkg then tlpkg
else if hasDocfiles then texdoc
else if hasSource then texsource
else tex; # fall back to attrset tex if there is no derivation
# emulate multi-output derivation plus additional metadata
# (out is handled in mkContainer)
passthru = {
inherit all outputs pname;
revision = toString revision + extraRevision;
version = version + extraVersion;
outputSpecified = true;
inherit tex;
} // lib.optionalAttrs (args ? deps) { tlDeps = args.deps; }
// lib.optionalAttrs (args ? formats) { inherit (args) formats; }
// lib.optionalAttrs hasHyphens { inherit hasHyphens; }
// lib.optionalAttrs (args ? postactionScript) { inherit (args) postactionScript; }
// lib.optionalAttrs hasDocfiles { texdoc = texdoc; }
// lib.optionalAttrs hasSource { texsource = texsource; }
// lib.optionalAttrs hasTlpkg { tlpkg = tlpkg; }
// lib.optionalAttrs hasManpages { man = man; }
// lib.optionalAttrs hasInfo { info = info; };
# build run, doc, source, tlpkg containers
mkContainer = tlType: passthru: sha512:
mkContainer = tlType: tlOutputName: sha512:
let
# NOTE: the fixed naming scheme must match generated-fixed-hashes.nix
# the basename used by upstream (without ".tar.xz" suffix)
urlName = pname + (lib.optionalString (tlType != "run" && tlType != "tlpkg") ".${tlType}");
# name + version for the derivation
tlName = urlName + (lib.optionalString (tlType == "tlpkg") ".tlpkg") + "-${version}${extraVersion}";
fixedHash = fixedHashes.${tlType} or null; # be graceful about missing hashes
urls = args.urls or (if args ? url then [ args.url ] else
map (up: "${up}/archive/${urlName}.r${toString revision}.tar.xz") mirrors);
# the basename used by upstream (without ".tar.xz" suffix)
# tlpkg is not a true container but a subfolder of the run container
urlName = pname + (lib.optionalString (tlType != "run" && tlType != "tlpkg") ".${tlType}");
urls = map (up: "${up}/archive/${urlName}.r${toString revision}.tar.xz") mirrors;
# TODO switch to simpler "${name}-${tlOutputName}" (requires new fixed hashes)
container = runCommand "texlive-${pname}${lib.optionalString (tlType != "run") ".${tlType}"}-${version}${extraVersion}"
({
src = fetchurl { inherit urls sha512; };
# save outputName as fixed output derivations cannot change nor override outputName
passthru = passthru // { inherit tlOutputName; };
# TODO remove tlType from derivation (requires a rebuild)
inherit meta stripPrefix tlType;
} // lib.optionalAttrs (fixedHash != null) {
outputHash = fixedHash;
outputHashAlgo = "sha256";
outputHashMode = "recursive";
})
(''
mkdir "$out"
if [[ "$tlType" == "tlpkg" ]]; then
tar -xf "$src" \
--strip-components=1 \
-C "$out" --anchored --exclude=tlpkg/tlpobj --keep-old-files \
tlpkg
else
tar -xf "$src" \
--strip-components="$stripPrefix" \
-C "$out" --anchored --exclude=tlpkg --keep-old-files
fi
'' + postUnpack);
in
runCommand "texlive-${tlName}"
({
src = fetchurl { inherit urls sha512; };
inherit meta passthru stripPrefix tlType;
} // lib.optionalAttrs (fixedHash != null) {
outputHash = fixedHash;
outputHashAlgo = "sha256";
outputHashMode = "recursive";
})
(''
mkdir "$out"
if [[ "$tlType" == "tlpkg" ]]; then
tar -xf "$src" \
--strip-components=1 \
-C "$out" --anchored --exclude=tlpkg/tlpobj --keep-old-files \
tlpkg
else
tar -xf "$src" \
--strip-components="$stripPrefix" \
-C "$out" --anchored --exclude=tlpkg --keep-old-files
fi
'' + postUnpack);
# remove the standard drv.out, optionally replace it with the bin container
builtins.removeAttrs container [ "out" ] // lib.optionalAttrs hasBinfiles { out = bin; };
tex = [
(
let passthru = commonPassthru
// lib.optionalAttrs (args ? deps) { tlDeps = args.deps; }
// lib.optionalAttrs (args ? formats) { inherit (args) formats; }
// lib.optionalAttrs hasHyphens { inherit hasHyphens; }; in
if hasRunfiles then mkContainer "run" passthru sha512.run
else (passthru // { tlType = "run"; })
)
];
tex =
if hasRunfiles then mkContainer "run" "tex" sha512.run
else passthru
// { inherit meta; tlOutputName = "tex"; }
// lib.optionalAttrs hasBinfiles { out = bin; };
doc = let passthru = commonPassthru
// lib.optionalAttrs hasManpages { inherit hasManpages; }; in
lib.optional (sha512 ? doc) (mkContainer "doc" passthru sha512.doc);
texdoc = mkContainer "doc" "texdoc" sha512.doc;
source = lib.optional (sha512 ? source) (mkContainer "source" commonPassthru sha512.source);
texsource = mkContainer "source" "texsource" sha512.source;
tlpkg = let passthru = commonPassthru
// lib.optionalAttrs (args ? postactionScript) { postactionScript = args.postactionScript; }; in
lib.optional hasTlpkg (mkContainer "tlpkg" passthru sha512.run);
tlpkg = mkContainer "tlpkg" "tlpkg" sha512.run;
bin = lib.optional (args ? binfiles && args.binfiles != [ ]) (
let
# find interpreters for the script extensions found in tlpdb
extToInput = {
jar = jdk;
lua = texliveBinaries.luatex;
py = python3;
rb = ruby;
sno = snobol4;
tcl = tk;
texlua = texliveBinaries.luatex;
tlu = texliveBinaries.luatex;
};
run = lib.head tex;
in
runCommand "texlive-${pname}.bin-${version}"
{
passthru = commonPassthru // { tlType = "bin"; };
inherit meta;
# shebang interpreters and compiled binaries
buildInputs = let outName = builtins.replaceStrings [ "-" ] [ "_" ] pname; in
[ texliveBinaries.core.${outName} or null
texliveBinaries.${pname} or null
texliveBinaries.core-big.${outName} or null ]
++ (args.extraBuildInputs or [ ]) ++ [ bash perl ]
++ (lib.attrVals (args.scriptExts or [ ]) extToInput);
nativeBuildInputs = extraNativeBuildInputs;
# absolute scripts folder
scriptsFolder = lib.optionalString (run ? outPath) (run.outPath + "/scripts/" + args.scriptsFolder or pname);
# binaries info
inherit (args) binfiles;
binlinks = builtins.attrNames (args.binlinks or { });
bintargets = builtins.attrValues (args.binlinks or { });
# build scripts
patchScripts = ./patch-scripts.sed;
makeBinContainers = ./make-bin-containers.sh;
}
''
. "$makeBinContainers"
${args.postFixup or ""}
''
);
# build bin container
extToInput = {
# find interpreters for the script extensions found in tlpdb
jar = jdk;
lua = texliveBinaries.luatex;
py = python3;
rb = ruby;
sno = snobol4;
tcl = tk;
texlua = texliveBinaries.luatex;
tlu = texliveBinaries.luatex;
};
# TODO switch to simpler "${name}" (requires a rebuild)
bin = runCommand "texlive-${pname}.bin-${version}"
{
inherit meta;
passthru = passthru // { tlOutputName = "out"; };
# shebang interpreters
buildInputs =let outName = builtins.replaceStrings [ "-" ] [ "_" ] pname; in
[ texliveBinaries.core.${outName} or null
texliveBinaries.${pname} or null
texliveBinaries.core-big.${outName} or null ]
++ (args.extraBuildInputs or [ ]) ++ [ bash perl ]
++ (lib.attrVals (args.scriptExts or [ ]) extToInput);
nativeBuildInputs = extraNativeBuildInputs;
# absolute scripts folder
scriptsFolder = lib.optionalString (tex ? outPath) (tex.outPath + "/scripts/" + args.scriptsFolder or pname);
# binaries info
inherit (args) binfiles;
binlinks = builtins.attrNames (args.binlinks or { });
bintargets = builtins.attrValues (args.binlinks or { });
# build scripts
patchScripts = ./patch-scripts.sed;
makeBinContainers = ./make-bin-containers.sh;
}
''
. "$makeBinContainers"
${args.postFixup or ""}
'';
# build man, info containers
# TODO switch to simpler "${name}-man" (requires a rebuild)
man = builtins.removeAttrs (runCommand "texlive-${pname}.man-${version}${extraVersion}"
{
inherit meta texdoc;
passthru = passthru // { tlOutputName = "man"; };
}
''
mkdir -p "$out"/share
ln -s {"$texdoc"/doc,"$out"/share}/man
'') [ "out" ] // lib.optionalAttrs hasBinfiles { out = bin; };
# TODO switch to simpler "${name}-info" (requires a rebuild)
info = builtins.removeAttrs (runCommand "texlive-${pname}.info-${version}${extraVersion}"
{
inherit meta texdoc;
passthru = passthru // { tlOutputName = "info"; };
}
''
mkdir -p "$out"/share
ln -s {"$texdoc"/doc,"$out"/share}/info
'') [ "out" ] // lib.optionalAttrs hasBinfiles { out = bin; };
in
{ pkgs = tex ++ doc ++ source ++ tlpkg ++ bin; }
builtins.removeAttrs mainDrv [ "outputSpecified" ]

View File

@ -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;
}

View File

@ -2,7 +2,7 @@
- source: ../../../../../doc/languages-frameworks/texlive.xml
- current html: https://nixos.org/nixpkgs/manual/#sec-language-texlive
*/
{ stdenv, lib, fetchurl, runCommand, writeText, buildEnv
{ stdenv, lib, fetchurl, runCommand, writeShellScript, writeText, buildEnv
, callPackage, ghostscript_headless, harfbuzz
, makeWrapper, installShellFiles
, python3, ruby, perl, tk, jdk, bash, snobol4
@ -22,13 +22,6 @@ let
tlpdb = overriddenTlpdb;
};
# function for creating a working environment from a set of TL packages
combine = import ./combine.nix {
inherit bin buildEnv lib makeWrapper writeText runCommand
perl libfaketime makeFontsConf bash tl coreutils gawk gnugrep gnused;
ghostscript = ghostscript_headless;
};
tlpdb = import ./tlpdb.nix;
tlpdbVersion = tlpdb."00texlive.config";
@ -101,12 +94,108 @@ let
// lib.optionalAttrs (args ? deps) { deps = map (n: tl.${n}) (args.deps or [ ]); })
) overriddenTlpdb;
# function for creating a working environment
buildTeXEnv = import ./build-tex-env.nix {
inherit bin tl;
ghostscript = ghostscript_headless;
inherit lib buildEnv libfaketime makeFontsConf makeWrapper runCommand
writeShellScript writeText toTLPkgSets bash perl coreutils gawk gnugrep gnused;
};
### texlive.combine compatibility layer:
# convert TeX packages to { pkgs = [ ... ]; } lists
# respecting specified outputs
toTLPkgList = drv: if drv.outputSpecified or false
then let tlType = drv.tlType or tlOutToType.${drv.tlOutputName or drv.outputName} or null; in
lib.optional (tlType != null) (drv // { inherit tlType; })
else [ (drv.tex // { tlType = "run"; }) ] ++
lib.optional (drv ? texdoc) (drv.texdoc // { tlType = "doc"; } // lib.optionalAttrs (drv ? man) { hasManpages = true; }) ++
lib.optional (drv ? texsource) (drv.texsource // { tlType = "source"; }) ++
lib.optional (drv ? tlpkg) (drv.tlpkg // { tlType = "tlpkg"; }) ++
lib.optional (drv ? out) (drv.out // { tlType = "bin"; });
tlOutToType = { out = "bin"; tex = "run"; texsource = "source"; texdoc = "doc"; tlpkg = "tlpkg"; };
# convert { pkgs = [ ... ]; } lists to TeX packages
# possibly more than one, if pkgs is also used to specify dependencies
tlTypeToOut = { run = "tex"; doc = "texdoc"; source = "texsource"; bin = "out"; tlpkg = "tlpkg"; };
toSpecifiedNV = p: rec {
name = value.tlOutputName;
value = builtins.removeAttrs p [ "pkgs" ]
// { outputSpecified = true; tlOutputName = tlTypeToOut.${p.tlType}; };
};
toTLPkgSet = pname: drvs:
let set = lib.listToAttrs (builtins.map toSpecifiedNV drvs);
mainDrv = set.out or set.tex or set.tlpkg or set.texdoc or set.texsource; in
builtins.removeAttrs mainDrv [ "outputSpecified" ];
toTLPkgSets = { pkgs, ... }: lib.mapAttrsToList toTLPkgSet
(builtins.groupBy (p: p.pname) pkgs);
# export TeX packages as { pkgs = [ ... ]; } in the top attribute set
allPkgLists = lib.mapAttrs (n: drv: { pkgs = toTLPkgList drv; }) tl;
# function for creating a working environment from a set of TL packages
# now a legacy wrapper around buildTeXEnv
combine = import ./combine-wrapper.nix { inherit buildTeXEnv lib toTLPkgList toTLPkgSets; };
assertions = with lib;
assertMsg (tlpdbVersion.year == version.texliveYear) "TeX Live year in texlive does not match tlpdb.nix, refusing to evaluate" &&
assertMsg (tlpdbVersion.frozen == version.final) "TeX Live final status in texlive does not match tlpdb.nix, refusing to evaluate";
# Pre-defined evironment packages for TeX Live schemes,
# to make nix-env usage more comfortable and build selected on Hydra.
# these license lists should be the sorted union of the licenses of the packages the schemes contain.
# The correctness of this collation is tested by tests.texlive.licenses
licenses = with lib.licenses; {
scheme-basic = [ free gfl gpl1Only gpl2 gpl2Plus knuth lgpl21 lppl1 lppl13c mit ofl publicDomain ];
scheme-context = [ bsd2 bsd3 cc-by-sa-40 free gfl gfsl gpl1Only gpl2 gpl2Plus gpl3 gpl3Plus knuth lgpl2 lgpl21
lppl1 lppl13c mit ofl publicDomain x11 ];
scheme-full = [ artistic1-cl8 artistic2 asl20 bsd2 bsd3 bsdOriginal cc-by-10 cc-by-40 cc-by-sa-10 cc-by-sa-20
cc-by-sa-30 cc-by-sa-40 cc0 fdl13Only free gfl gfsl gpl1Only gpl2 gpl2Plus gpl3 gpl3Plus isc knuth
lgpl2 lgpl21 lgpl3 lppl1 lppl12 lppl13a lppl13c mit ofl publicDomain x11 ];
scheme-gust = [ artistic1-cl8 asl20 bsd2 bsd3 cc-by-40 cc-by-sa-40 cc0 fdl13Only free gfl gfsl gpl1Only gpl2
gpl2Plus gpl3 gpl3Plus knuth lgpl2 lgpl21 lppl1 lppl12 lppl13a lppl13c mit ofl publicDomain x11 ];
scheme-infraonly = [ gpl2 gpl2Plus lgpl21 ];
scheme-medium = [ artistic1-cl8 asl20 bsd2 bsd3 cc-by-40 cc-by-sa-20 cc-by-sa-30 cc-by-sa-40 cc0 fdl13Only
free gfl gpl1Only gpl2 gpl2Plus gpl3 gpl3Plus isc knuth lgpl2 lgpl21 lgpl3 lppl1 lppl12 lppl13a lppl13c mit ofl
publicDomain x11 ];
scheme-minimal = [ free gpl1Only gpl2 gpl2Plus knuth lgpl21 lppl1 lppl13c mit ofl publicDomain ];
scheme-small = [ asl20 cc-by-40 cc-by-sa-40 cc0 fdl13Only free gfl gpl1Only gpl2 gpl2Plus gpl3 gpl3Plus knuth
lgpl2 lgpl21 lppl1 lppl12 lppl13a lppl13c mit ofl publicDomain x11 ];
scheme-tetex = [ artistic1-cl8 asl20 bsd2 bsd3 cc-by-40 cc-by-sa-10 cc-by-sa-20 cc-by-sa-30 cc-by-sa-40 cc0
fdl13Only free gfl gpl1Only gpl2 gpl2Plus gpl3 gpl3Plus isc knuth lgpl2 lgpl21 lgpl3 lppl1 lppl12 lppl13a
lppl13c mit ofl publicDomain x11];
};
meta = {
description = "TeX Live environment";
platforms = lib.platforms.all;
maintainers = with lib.maintainers; [ veprbl ];
license = licenses.scheme-infraonly;
};
combined = recurseIntoAttrs (
lib.genAttrs [ "scheme-basic" "scheme-context" "scheme-full" "scheme-gust" "scheme-infraonly"
"scheme-medium" "scheme-minimal" "scheme-small" "scheme-tetex" ]
(pname:
(buildTeXEnv {
__extraName = "combined" + lib.removePrefix "scheme" pname;
__extraVersion = with version; if final then "-final" else ".${year}${month}${day}";
requiredTeXPackages = ps: [ ps.${pname} ];
# to maintain full backward compatibility, enable texlive.combine behavior
__combine = true;
}).overrideAttrs {
meta = meta // {
description = "TeX Live environment for ${pname}";
license = licenses.${pname};
};
}
)
);
in
tl // {
allPkgLists // {
pkgs = tl;
tlpdb = {
# nested in an attribute set to prevent them from appearing in search
@ -116,55 +205,13 @@ in
bin = assert assertions; bin // {
# for backward compatibility
latexindent = lib.findFirst (p: p.tlType == "bin") tl.latexindent.pkgs;
latexindent = tl.latexindent;
};
combine = assert assertions; combine;
# Pre-defined combined packages for TeX Live schemes,
# to make nix-env usage more comfortable and build selected on Hydra.
combined = with lib;
let
# these license lists should be the sorted union of the licenses of the packages the schemes contain.
# The correctness of this collation is tested by tests.texlive.licenses
licenses = with lib.licenses; {
scheme-basic = [ free gfl gpl1Only gpl2 gpl2Plus knuth lgpl21 lppl1 lppl13c mit ofl publicDomain ];
scheme-context = [ bsd2 bsd3 cc-by-sa-40 free gfl gfsl gpl1Only gpl2 gpl2Plus gpl3 gpl3Plus knuth lgpl2 lgpl21
lppl1 lppl13c mit ofl publicDomain x11 ];
scheme-full = [ artistic1-cl8 artistic2 asl20 bsd2 bsd3 bsdOriginal cc-by-10 cc-by-40 cc-by-sa-10 cc-by-sa-20
cc-by-sa-30 cc-by-sa-40 cc0 fdl13Only free gfl gfsl gpl1Only gpl2 gpl2Plus gpl3 gpl3Plus isc knuth
lgpl2 lgpl21 lgpl3 lppl1 lppl12 lppl13a lppl13c mit ofl publicDomain x11 ];
scheme-gust = [ artistic1-cl8 asl20 bsd2 bsd3 cc-by-40 cc-by-sa-40 cc0 fdl13Only free gfl gfsl gpl1Only gpl2
gpl2Plus gpl3 gpl3Plus knuth lgpl2 lgpl21 lppl1 lppl12 lppl13a lppl13c mit ofl publicDomain x11 ];
scheme-infraonly = [ gpl2 gpl2Plus lgpl21 ];
scheme-medium = [ artistic1-cl8 asl20 bsd2 bsd3 cc-by-40 cc-by-sa-20 cc-by-sa-30 cc-by-sa-40 cc0 fdl13Only
free gfl gpl1Only gpl2 gpl2Plus gpl3 gpl3Plus isc knuth lgpl2 lgpl21 lgpl3 lppl1 lppl12 lppl13a lppl13c mit ofl
publicDomain x11 ];
scheme-minimal = [ free gpl1Only gpl2 gpl2Plus knuth lgpl21 lppl1 lppl13c mit ofl publicDomain ];
scheme-small = [ asl20 cc-by-40 cc-by-sa-40 cc0 fdl13Only free gfl gpl1Only gpl2 gpl2Plus gpl3 gpl3Plus knuth
lgpl2 lgpl21 lppl1 lppl12 lppl13a lppl13c mit ofl publicDomain x11 ];
scheme-tetex = [ artistic1-cl8 asl20 bsd2 bsd3 cc-by-40 cc-by-sa-10 cc-by-sa-20 cc-by-sa-30 cc-by-sa-40 cc0
fdl13Only free gfl gpl1Only gpl2 gpl2Plus gpl3 gpl3Plus isc knuth lgpl2 lgpl21 lgpl3 lppl1 lppl12 lppl13a
lppl13c mit ofl publicDomain x11];
};
in recurseIntoAttrs (
mapAttrs
(pname: attrs:
addMetaAttrs rec {
description = "TeX Live environment for ${pname}";
platforms = lib.platforms.all;
maintainers = with lib.maintainers; [ veprbl ];
license = licenses.${pname};
}
(combine {
${pname} = attrs;
extraName = "combined" + lib.removePrefix "scheme" pname;
extraVersion = with version; if final then "-final" else ".${year}${month}${day}";
})
)
{ inherit (tl)
scheme-basic scheme-context scheme-full scheme-gust scheme-infraonly
scheme-medium scheme-minimal scheme-small scheme-tetex;
}
);
combined = assert assertions; combined;
# convenience alias
withPackages = (buildTeXEnv { }).withPackages;
}

View File

@ -1,13 +1,13 @@
with import ../../../../.. { };
with lib; let
isFod = p: p.tlType != "bin" && isDerivation p;
getFods = drv: lib.optional (isDerivation drv.tex) (drv.tex // { tlType = "run"; })
++ lib.optional (drv ? texdoc) (drv.texdoc // { tlType = "doc"; })
++ lib.optional (drv ? texsource) (drv.texsource // { tlType = "source"; })
++ lib.optional (drv ? tlpkg) (drv.tlpkg // { tlType = "tlpkg"; });
# ugly hack to extract combine from collection-latexextra, since it is masked by texlive.combine
combine = lib.findFirst (p: (lib.head p.pkgs).pname == "combine") { pkgs = [ ]; } (lib.head texlive.collection-latexextra.pkgs).tlDeps;
all = filter (p: p ? pkgs) (attrValues (removeAttrs texlive [ "bin" "combine" "combined" "tlpdb" ])) ++ [ combine ];
sorted = sort (a: b: (head a.pkgs).pname < (head b.pkgs).pname) all;
fods = filter isFod (concatMap (p: p.pkgs or [ ]) all);
sorted = sort (a: b: a.pname < b.pname) (attrValues texlive.pkgs);
fods = concatMap getFods sorted;
computeHash = fod: runCommand "${fod.pname}-${fod.tlType}-fixed-hash"
{ buildInputs = [ nix ]; inherit fod; }
@ -15,18 +15,17 @@ with lib; let
hash = fod: fod.outputHash or (builtins.readFile (computeHash fod));
hashes = { pkgs }:
concatMapStrings ({ tlType, ... }@p: lib.optionalString (isFod p) (''${tlType}="${hash p}";'')) pkgs;
hashes = fods:
concatMapStrings ({ tlType, ... }@p: ''${tlType}="${hash p}";'') fods;
hashLine = { pkgs }@pkg:
hashLine = { pname, revision, extraRevision ? "", ... }@drv:
let
fods = lib.filter isFod pkgs;
first = lib.head fods;
fods = getFods drv;
# NOTE: the fixed naming scheme must match default.nix
fixedName = with first; "${pname}-${toString revision}${first.extraRevision or ""}";
fixedName = "${pname}-${toString revision}${extraRevision}";
in
lib.optionalString (fods != [ ]) ''
${strings.escapeNixIdentifier fixedName}={${hashes pkg}};
optionalString (fods != [ ]) ''
${strings.escapeNixIdentifier fixedName}={${hashes fods}};
'';
in
{
@ -37,6 +36,6 @@ in
fixedHashesNix = writeText "fixed-hashes.nix"
''
{
${lib.concatMapStrings hashLine sorted}}
${concatMapStrings hashLine sorted}}
'';
}

View File

@ -91,6 +91,7 @@ $a}
t next-doc # loop if the previous lines matched
/ (texmf-dist|RELOC)\/doc\/man\//i\ hasManpages = true;
/ (texmf-dist|RELOC)\/doc\/info\//i\ hasInfo = true;
D # restart cycle
}

View File

@ -126,7 +126,7 @@ in lib.recursiveUpdate orig rec {
texlive-scripts.binlinks = {
mktexfmt = "fmtutil";
texhash = (lib.last tl."texlive.infra".pkgs) + "/bin/mktexlsr";
texhash = tl."texlive.infra" + "/bin/mktexlsr";
};
texlive-scripts-extra.binlinks = {
@ -352,7 +352,7 @@ in lib.recursiveUpdate orig rec {
mkdir -p support/texdoc
touch support/texdoc/NEWS
TEXMFCNF="${lib.head tl.kpathsea.pkgs}/web2c" TEXMF="$out" TEXDOCS=. TEXMFVAR=. \
TEXMFCNF="${tl.kpathsea.tex}/web2c" TEXMF="$out" TEXDOCS=. TEXMFVAR=. \
"${bin.luatex}"/bin/texlua "$out"/scripts/texdoc/texdoc.tlu \
-c texlive_tlpdb=texlive.tlpdb -lM texdoc
@ -362,7 +362,7 @@ in lib.recursiveUpdate orig rec {
# install zsh completion
postFixup = ''
TEXMFCNF="${lib.head tl.kpathsea.pkgs}"/web2c TEXMF="$scriptsFolder/../.." \
TEXMFCNF="${tl.kpathsea.tex}"/web2c TEXMF="$scriptsFolder/../.." \
texlua "$out"/bin/texdoc --print-completion zsh > "$TMPDIR"/_texdoc
substituteInPlace "$TMPDIR"/_texdoc \
--replace 'compdef __texdoc texdoc' '#compdef texdoc' \
@ -381,14 +381,14 @@ in lib.recursiveUpdate orig rec {
license = [ "gpl2Plus" ] ++ lib.toList bin.core.meta.license.shortName ++ orig."texlive.infra".license or [ ];
scriptsFolder = "texlive";
extraBuildInputs = [ coreutils gnused gnupg (lib.last tl.kpathsea.pkgs) (perl.withPackages (ps: with ps; [ Tk ])) ];
extraBuildInputs = [ coreutils gnused gnupg tl.kpathsea (perl.withPackages (ps: with ps; [ Tk ])) ];
# make tlmgr believe it can use kpsewhich to evaluate TEXMFROOT
postFixup = ''
substituteInPlace "$out"/bin/tlmgr \
--replace 'if (-r "$bindir/$kpsewhichname")' 'if (1)'
sed -i '2i$ENV{PATH}='"'"'${lib.makeBinPath [ gnupg ]}'"'"' . ($ENV{PATH} ? ":$ENV{PATH}" : '"'''"');' "$out"/bin/tlmgr
sed -i '2iPATH="${lib.makeBinPath [ coreutils gnused (lib.last tl.kpathsea.pkgs) ]}''${PATH:+:$PATH}"' "$out"/bin/mktexlsr
sed -i '2iPATH="${lib.makeBinPath [ coreutils gnused tl.kpathsea ]}''${PATH:+:$PATH}"' "$out"/bin/mktexlsr
'';
# add minimal texlive.tlpdb

View File

@ -1707,6 +1707,7 @@ asymptote = {
sha512.run = "4f97d0d87d1f29985c83c99629fc52e8e18f6eabf95d77aa888429187b49ed9525661d9c06b46a9b2295b03df412778ede1490fa9cd8ec680c3209a4ca6d0be0";
sha512.doc = "940297c3d69de7e01caa09ff44483f7334aba14705bdcdc83661ca9be2210133e094f99a8355b4b88d076355bb4f13f64c21700bff57f452dd5dbc8d2fddb432";
hasManpages = true;
hasInfo = true;
hasRunfiles = true;
license = [ "lgpl3" ];
version = "2.85";
@ -15500,6 +15501,7 @@ dvipng = {
sha512.run = "d24be610a63a9df22ebe6f53891519ab77900611d1159dec5e97b27160f3552b4cbce42b575a036125d2b15910a72cb5e3793a3409c5d0f4b1df0c2433e828f8";
sha512.doc = "976ff6c9628fe85adca2287f04d76f2c1605f243e28b4d32cb1ef9a90d30dcae0d202e6d5156914c204fd42b0a66460755a89f7dbdeb9ec1ccf6010cfe8daf78";
hasManpages = true;
hasInfo = true;
license = [ "lgpl3" ];
version = "1.17";
};
@ -15521,6 +15523,7 @@ dvips = {
sha512.run = "a680a4685d3cbb429ad9dada0d48098f7755253ad1d7c808731f0f4fb4c37971cb937a9fa68bcecd892de93cc35a8086b742c86338460585c2912f36d00ade67";
sha512.doc = "a6acb780a45663fb21976622d7b6c3ea8d4adf1fe405ee97cd7c4cf09fa49b59069ba72b2aa14b53d3ba631b37c5cbd979929adaa274a0bec8b1272d85e1cd43";
hasManpages = true;
hasInfo = true;
hasRunfiles = true;
license = [ "free" ];
};
@ -16610,6 +16613,7 @@ eplain = {
sha512.run = "fda8158ae2bdc96187b6e6ace2a94be3e0f68201adbc02553b48a3848481352ac10ddd72babcbc2835e089ce751ade7dfa6cfd1c642c94155c2861db865f5c29";
sha512.doc = "60902b2422d2f5d7570a19daf7f586df7882505d7c156539699a0aa47a0f3bde5688dcbdc92c8a6a9878f11392bc9b9f147626aad230eecd2740d56f104928ed";
hasManpages = true;
hasInfo = true;
sha512.source = "015de2eeeaec99bd15882a190f9ef3f2112520f8c591c7e6d2351c52d8690b024750adea426bcf95f438aaa20c97dd321881ac7212ff181e148337b57f6d386c";
hasRunfiles = true;
license = [ "gpl2Plus" ];
@ -16666,6 +16670,7 @@ epspdf = {
revision = 66119;
sha512.run = "f155834a9636991c8ae752f61f70bdf22ab3172270c85aebb05462cf26e44f6e81fb83842c8515bfa54e632a3beab8bb91cccf2b5eef459d77738443c77df56d";
sha512.doc = "5d06f8a4ef295e0fac8cd1dc73ff98e266dcf4394ed76223c92d20758fa8195ef5bea9bde49b1a247acfdf67aa7717092f978b55fc4fbc8665922487d57985d6";
hasInfo = true;
hasRunfiles = true;
scriptExts = [
"tcl"
@ -18768,6 +18773,7 @@ fontname = {
stripPrefix = 0;
sha512.run = "424da4dbbc07c41840e6aeb6fabeef5d4778d206b9cb8a90e752ebeb65d962b96ad41a7e20c86a16665e2bf48ad795d85001da66ff41b01ae3c949c6eefa4593";
sha512.doc = "78199996913192f5f69423b6f412acc52b74f051b01d3e345b97b7f1d9ea4aea762a7b83488068f3091b41da69471d56b3f18ab4d299cc6adfe4e004072db303";
hasInfo = true;
hasRunfiles = true;
license = [ "gpl1Only" ];
};
@ -24499,6 +24505,7 @@ kpathsea = {
sha512.run = "8a9f0dd49470bec5ba0f963a0385bea45141d6b805682bd65e95291b02158b9d2cedd5bd43592de7c447fe87f04efa00e4d1aa191a490147adcb57ec3922b5db";
sha512.doc = "51500943de0184fd9794dbf6af80aed2fc7bbaf2a7949facb1840ad0e32344d217aa4d58ee76e3934aec891858f789b3847b9027cb2bd75e5962be98ddd9d02f";
hasManpages = true;
hasInfo = true;
hasRunfiles = true;
license = [ "lgpl21" ];
};
@ -25258,6 +25265,7 @@ latex2e-help-texinfo = {
stripPrefix = 0;
sha512.run = "34b91b19e1b71b1df6d0f57dda4d6976a93b16afac259656c9d4e331b0c23a9b0550563c1a10dd7a95640e3740b3b15597c1023f6c2721bf2a64800466b9cd09";
sha512.doc = "d4584d9259f3c1867e7445d4a219e4decc5ba3b305e20d1e780180a47fbad8df4d55552726d8288e78c8388823a2b652b81080c8139b00f4ea3ca10e5789375b";
hasInfo = true;
license = [ "free" ];
};
latex2e-help-texinfo-fr = {
@ -25265,6 +25273,7 @@ latex2e-help-texinfo-fr = {
stripPrefix = 0;
sha512.run = "96366ea420532f56ae076da48f5402c2ee78ca27fae8180795d6cd18aae118a8c7060208ff43ab64526addcdce9e4d90790583842b20c751f37865cf616e04e4";
sha512.doc = "52f6aea9ac2393a73d7dc7ce8ad4d6f08e0a224397199d5def97412502026717e8cb966552368899c50718a1049b1ad4610d2d23150a45bee55cc2c776003db7";
hasInfo = true;
license = [ "publicDomain" ];
};
latex2e-help-texinfo-spanish = {
@ -25272,6 +25281,7 @@ latex2e-help-texinfo-spanish = {
stripPrefix = 0;
sha512.run = "870c8f3af54ac42df5f4958669cf730cd16084c985f0b377c5aba9d526b8f7be14b367791d2c0a1f1a715739390ab63777ff2a92e7f9aad09897c8bbecff495e";
sha512.doc = "4c751a7305e089dab61bf991436ab1e612cfca0d17e416e21d659c04ef32eeb2d14dbeb09d63649a2b79f842766a218c43ae2c6fbeeba5549f039f991049a79d";
hasInfo = true;
license = [ "free" ];
};
latex2man = {
@ -25279,6 +25289,7 @@ latex2man = {
sha512.run = "2617f6e8059f30c0098ea896cff69f585ea2ddbd3bbbd8066e7296dd833d3a246b8fefc0af71a92abf7e2051c754c0e3e6098175a4b181780563416bc9146b95";
sha512.doc = "390666cc56ad70342c9a24ca593fe65b3760674a882ed8bba383d193f2578285727a085f823afc03fa0dbc9966612caf9a29222fd2a9f39214f01aa268acdc50";
hasManpages = true;
hasInfo = true;
hasRunfiles = true;
license = [ "lppl1" ];
version = "1.29";
@ -28873,6 +28884,7 @@ mf2pt1 = {
revision = 61217;
sha512.run = "ca93a3ae439f9cd8029720bd1d90fbe75a403e7ab4ebcbe1ba1e5a7a28aa9269197f90a4aee849fea59d734d5dc38f04eedc140ff1be64fd805a10ab5510a2f5";
sha512.doc = "6c10831fdcc48d25645be675fbf5da29da945bd79032c60e73e04a39d61c287a64e7b884381ac0b08e48f5dc9b6dec27efea874f6e13d6e4a5e3f32c22fa3ce2";
hasInfo = true;
hasRunfiles = true;
license = [ "lppl13c" ];
version = "2.7";
@ -40536,6 +40548,7 @@ tds = {
stripPrefix = 0;
sha512.run = "b03911aa9711eb5eeed77c026c4bbcf952da80322b855ac631e78c07a48ad2ff1a4afdd6e25a00257d1b70e054645f07f65c98fe74f6b1389be46625f5eb8487";
sha512.doc = "f4078e3b1693fedcbe139b67c50824845644a2b1e57dd27f9e46e44504d8fe8ac0ca706590e9149c06e71794a188b20777bfd6bf1afe85f16c806ba4f9b99cd8";
hasInfo = true;
license = [ "free" ];
version = "1.1";
};
@ -41052,6 +41065,7 @@ texdraw = {
stripPrefix = 0;
sha512.run = "f4d160e494b1579743a83b2a0926df9e8dd69fdaa79d3f4f97e0ed5f4ece31ab380ff6994a1c9015e0af9b842bdfb9b066442ca4b3018df6659922af9f746b0b";
sha512.doc = "e177209a937fa1d9d683eb805e9e8929612b4b1ff750955d38ca681b657662712a59609990f77021063a223ce61a92fdd567eee91376ef4b67fd3a322db09463";
hasInfo = true;
hasRunfiles = true;
license = [ "cc-by-40" ];
version = "v2r3";
@ -41115,6 +41129,7 @@ texlive-en = {
stripPrefix = 0;
sha512.run = "f790f2a94e67573635afb5b4c2d375bede61eb3afe271169078fe905d326119234363ee896ecc93a9892d26e0a394fc350edbda810e218b0b06cc30681fd9cf0";
sha512.doc = "48ffb3b9053250f4425992c57869c6153601e9dfaa4931ac4ff3c12df44b148dce08496acbae495fd5f9fe37e11044a3fc0669c713515d2cc99506fd6be59859";
hasInfo = true;
};
texlive-es = {
revision = 65640;