texlive.withPackages: generate formats in separate derivations (#291396)
Generate TeX formats into separate derivations so that they can be shared across different environments, considerably reducing build times.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -306,4 +310,4 @@ buildEnv' {
|
||||
'';
|
||||
};
|
||||
# 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)
|
||||
|
||||
@@ -143,7 +143,10 @@ installtl_do_postinst_stuff () {
|
||||
# in principle, we could use writeText and share them across different
|
||||
# environments, but the eval & build overhead is not worth the savings
|
||||
tlutils_create_fmtutil
|
||||
tlutils_create_updmap
|
||||
# can be skipped if generating formats only
|
||||
if [[ -z $__formatsOf ]] ; then
|
||||
tlutils_create_updmap
|
||||
fi
|
||||
tlutils_create_language_dat
|
||||
tlutils_create_language_def
|
||||
tlutils_create_language_lua
|
||||
@@ -152,21 +155,24 @@ installtl_do_postinst_stuff () {
|
||||
tlutils_info "running mktexlsr $TEXMFSYSVAR $TEXMFSYSCONFIG"
|
||||
mktexlsr "$TEXMFSYSVAR" "$TEXMFSYSCONFIG"
|
||||
|
||||
# update font maps
|
||||
tlutils_info "generating font maps"
|
||||
updmap-sys --quiet --force --nohash 2>&1
|
||||
# configure the paper size
|
||||
# tlmgr --no-execute-actions paper letter
|
||||
# install-tl: "rerun mktexlsr for updmap-sys and tlmgr paper updates"
|
||||
tlutils_info "re-running mktexlsr $TEXMFSYSVAR $TEXMFSYSCONFIG"
|
||||
mktexlsr "$TEXMFSYSVAR" "$TEXMFSYSCONFIG"
|
||||
# can be skipped if generating formats only
|
||||
if [[ -z $__formatsOf ]] ; then
|
||||
# update font maps
|
||||
tlutils_info "generating font maps"
|
||||
updmap-sys --quiet --force --nohash 2>&1
|
||||
# configure the paper size
|
||||
# tlmgr --no-execute-actions paper letter
|
||||
# install-tl: "rerun mktexlsr for updmap-sys and tlmgr paper updates"
|
||||
tlutils_info "re-running mktexlsr $TEXMFSYSVAR $TEXMFSYSCONFIG"
|
||||
mktexlsr "$TEXMFSYSVAR" "$TEXMFSYSCONFIG"
|
||||
|
||||
tlutils_update_context_cache
|
||||
tlutils_update_context_cache
|
||||
fi
|
||||
|
||||
# generate formats
|
||||
# install-tl would run fmtutil-sys $common_fmtutil_args --no-strict --all
|
||||
# instead, we want fmtutil to exit with error on failure
|
||||
if [[ -n $fmtutilCnf ]] ; then
|
||||
if [[ -n $fmtutilCnf && -n $__combine$__formatsOf ]] ; then
|
||||
tlutils_info "pre-generating all format files, be patient..."
|
||||
# many formats still ignore SOURCE_DATE_EPOCH even when FORCE_SOURCE_DATE=1
|
||||
# libfaketime fixes non-determinism related to timestamps ignoring FORCE_SOURCE_DATE
|
||||
@@ -177,6 +183,24 @@ installtl_do_postinst_stuff () {
|
||||
substitute "$texmfdist"/scripts/texlive/fmtutil.pl fmtutil \
|
||||
--replace-fail "my \$cmdline = \"\$eng -ini " "my \$cmdline = \"faketime -f '\@$(date +'%F %T' --date=@"$SOURCE_DATE_EPOCH") x0.001' \$eng -ini "
|
||||
FORCE_SOURCE_DATE=1 perl fmtutil --quiet --strict --sys --all 2>&1 | grep '^fmtutil' # too verbose
|
||||
|
||||
# if generating formats only, delete everything else and exit
|
||||
if [[ -n $__formatsOf ]] ; then
|
||||
# see fmtutil.pl::compute_format_destination for file extensions
|
||||
find "$out" \( -type f -or -type l \) \
|
||||
-not -path "$TEXMFSYSVAR/*.mem" \
|
||||
-not -path "$TEXMFSYSVAR/*.base" \
|
||||
-not -path "$TEXMFSYSVAR/*.fmt" \
|
||||
-delete
|
||||
find "$out" -type d -empty -delete
|
||||
exit
|
||||
fi
|
||||
elif [[ -z $__combine ]] ; then
|
||||
# double check that all formats are present
|
||||
if fmtutil --quiet --strict --sys --missing --dry-run 2>&1 | grep running ; then
|
||||
tlutils_info 'formats not found, aborting'
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
installtl_do_path_adjustments
|
||||
@@ -190,7 +214,7 @@ installtl_do_postinst_stuff () {
|
||||
### TeXLive::TLUtils
|
||||
|
||||
tlutils_info () {
|
||||
printf '%s\n' "texlive: $*"
|
||||
printf "texlive${__formatsOf:+($__formatsOf-fmt)}: %s\n" "$*"
|
||||
}
|
||||
|
||||
tlutils_create_fmtutil () {
|
||||
|
||||
Reference in New Issue
Block a user