From a000076d5817163ffb320b2531875c3a92b18677 Mon Sep 17 00:00:00 2001 From: Vincenzo Mantova <1962985+xworld21@users.noreply.github.com> Date: Sun, 5 Feb 2023 19:32:09 +0000 Subject: texlive.combine: split static $TEXMFDIST into a separate derivation --- pkgs/test/texlive/default.nix | 6 +- pkgs/tools/typesetting/tex/texlive/combine.nix | 124 +++++++++++++------------ 2 files changed, 70 insertions(+), 60 deletions(-) (limited to 'pkgs') diff --git a/pkgs/test/texlive/default.nix b/pkgs/test/texlive/default.nix index 217a862e1c563..a848119aacac1 100644 --- a/pkgs/test/texlive/default.nix +++ b/pkgs/test/texlive/default.nix @@ -145,10 +145,10 @@ for fname in language.{dat,def,dat.lua} ; do diff --ignore-matching-lines='^\(%\|--\) Generated by ' -u \ - {"$hyphenBase","$schemeFull"/share/texmf}/tex/generic/config/"$fname" \ + {"$hyphenBase","$schemeFull"/share/texmf-var}/tex/generic/config/"$fname" \ | tee "$out/scheme-full/$fname.patch" diff --ignore-matching-lines='^\(%\|--\) Generated by ' -u \ - {,"$schemeInfraOnly"/share/texmf/tex/generic/config/}"$fname" \ + {,"$schemeInfraOnly"/share/texmf-var/tex/generic/config/}"$fname" \ | tee "$out/scheme-infraonly/$fname.patch" done ''; @@ -161,7 +161,7 @@ mkdir -p "$out" diff --ignore-matching-lines='^# Generated by ' -u \ - {"$kpathsea","$schemeFull"/share/texmf}/web2c/fmtutil.cnf \ + {"$kpathsea","$schemeFull"/share/texmf-var}/web2c/fmtutil.cnf \ | tee "$out/fmtutil.cnf.patch" ''; } diff --git a/pkgs/tools/typesetting/tex/texlive/combine.nix b/pkgs/tools/typesetting/tex/texlive/combine.nix index 012f03d0e1203..2f18214134b36 100644 --- a/pkgs/tools/typesetting/tex/texlive/combine.nix +++ b/pkgs/tools/typesetting/tex/texlive/combine.nix @@ -38,16 +38,37 @@ let mkUniqueOutPaths = pkgs: lib.unique (map (p: p.outPath) (builtins.filter lib.isDerivation pkgs)); -in (buildEnv { name = "texlive-${extraName}-${bin.texliveYear}${extraVersion}"; - extraPrefix = "/share/texmf"; + texmf = (buildEnv { + name = "${name}-texmf"; + + paths = pkgList.nonbin; + extraPrefix = "/share/texmf"; + + nativeBuildInputs = [ perl bin.core.out ]; + + postBuild = + '' + # generate ls-R database + perl -I "${bin.core.out}/share/texmf-dist/scripts/texlive" \ + -- "$out/share/texmf/scripts/texlive/mktexlsr.pl" --sort "$out/share/texmf" + # link info and man pages + for d in {info,man}; do + [[ -e "$out/share/texmf/doc/$d" ]] && ln -s "texmf/doc/$d" "$out/share/$d" + done + ''; + }).overrideAttrs (_: { allowSubstitutes = true; }); + +in (buildEnv { + + inherit name; ignoreCollisions = false; - paths = pkgList.nonbin; + paths = pkgList.bin ++ [ texmf ]; pathsToLink = [ "/" - "/tex/generic/config" # make it a real directory for scheme-infraonly + "/bin" # ensure these are writeable directories ]; nativeBuildInputs = [ makeWrapper libfaketime perl bin.texlinks ]; @@ -57,54 +78,40 @@ in (buildEnv { passthru.packages = pkgList.all; postBuild = '' - mkdir -p "$out"/bin - '' + - lib.concatMapStrings - (path: '' - for f in '${path}'/bin/*; do - if [[ -L "$f" ]]; then - cp -d "$f" "$out"/bin/ - else - ln -s "$f" "$out"/bin/ - fi - done - '') - pkgList.bin - + - '' - export PATH="$out/bin:$out/share/texmf/scripts/texlive:$PATH" - export TEXMFCNF="$out/share/texmf/web2c" + TEXMFDIST="${texmf}/share/texmf" + export PATH="$out/bin:$PATH" + export PERL5LIB="$TEXMFDIST/scripts/texlive:${bin.core.out}/share/texmf-dist/scripts/texlive" TEXMFSYSCONFIG="$out/share/texmf-config" TEXMFSYSVAR="$out/share/texmf-var" - export PERL5LIB="$out/share/texmf/scripts/texlive:${bin.core.out}/share/texmf-dist/scripts/texlive" + export TEXMFCNF="$TEXMFSYSVAR/web2c" '' + - # patch texmf-dist -> $out/share/texmf + # patch texmf-dist -> $TEXMFDIST # patch texmf-local -> $out/share/texmf-local + # patch texmf.cnf -> $TEXMFSYSVAR/web2c/texmf.cnf # TODO: perhaps do lua actions? # tried inspiration from install-tl, sub do_texmf_cnf '' - if [ -e "$TEXMFCNF/texmfcnf.lua" ]; then + mkdir -p "$TEXMFCNF" + if [ -e "$TEXMFDIST/web2c/texmfcnf.lua" ]; then sed \ - -e 's,texmf-dist,texmf,g' \ + -e "s,\(TEXMFDIST[ ]*=[ ]*\)[^\,]*,\1\"$TEXMFDIST\",g" \ -e "s,\(TEXMFLOCAL[ ]*=[ ]*\)[^\,]*,\1\"$out/share/texmf-local\",g" \ -e "s,\$SELFAUTOLOC,$out,g" \ -e "s,selfautodir:/,$out/share/,g" \ -e "s,selfautodir:,$out/share/,g" \ -e "s,selfautoparent:/,$out/share/,g" \ -e "s,selfautoparent:,$out/share/,g" \ - -i "$TEXMFCNF/texmfcnf.lua" + "$TEXMFDIST/web2c/texmfcnf.lua" > "$TEXMFCNF/texmfcnf.lua" fi sed \ - -e 's,texmf-dist,texmf,g' \ + -e "s,\(TEXMFDIST[ ]*=[ ]*\)[^\,]*,\1$TEXMFDIST,g" \ -e "s,\$SELFAUTOLOC,$out,g" \ -e "s,\$SELFAUTODIR,$out/share,g" \ -e "s,\$SELFAUTOPARENT,$out/share,g" \ -e "s,\$SELFAUTOGRANDPARENT,$out/share,g" \ -e "/^mpost,/d" `# CVE-2016-10243` \ - -i "$TEXMFCNF/texmf.cnf" - - mkdir "$out/share/texmf-local" + "$TEXMFDIST/web2c/texmf.cnf" > "$TEXMFCNF/texmf.cnf" '' + # now filter hyphenation patterns and formats (let @@ -132,18 +139,31 @@ in (buildEnv { + lib.concatMapStrings (pname: section "^-- from ${pname}:$" "^}$|^-- from") hyphenPNames + "$p;\n" ); + # formats not being installed must be disabled by prepending #! (see man fmtutil) + # sed expression that enables the formats in /start/,/end/ + enableFormats = pname: "/^# from ${pname}:$/,/^# from/{ s/^#! //; };\n"; fmtutilSed = writeText "fmtutil.sed" ( - "1{ s/^(# Generated by .*)$/\\1, modified by texlive.combine/; p; }\n" - + "2,/^# from/{ /^# from/!p; };\n" - + lib.concatMapStrings (pname: section "^# from ${pname}:$" "^# from") formatPNames + # document how file was generated + "1{ s/^(# Generated by .*)$/\\1, modified by texlive.combine/; }\n" + # disable all formats, even those already disabled + + "s/^([^#]|#! )/#! \\1/;\n" + # enable the formats from the packages being installed + + lib.concatMapStrings enableFormats formatPNames + # clean up formats that have been disabled twice + + "s/^#! #! /#! /;\n" ); in '' - for fname in "$out"/share/texmf/tex/generic/config/language.{dat,def}; do - [[ -e "$fname" ]] && sed -E -n -f '${script}' -i "$fname" + mkdir -p "$TEXMFSYSVAR/tex/generic/config" + for fname in tex/generic/config/language.{dat,def}; do + [[ -e "$TEXMFDIST/$fname" ]] && sed -E -n -f '${script}' "$TEXMFDIST/$fname" > "$TEXMFSYSVAR/$fname" done - [[ -e "$out"/share/texmf/tex/generic/config/language.dat.lua ]] && sed -E -n -f '${scriptLua}' -i "$out"/share/texmf/tex/generic/config/language.dat.lua - [[ -e "$TEXMFCNF"/fmtutil.cnf ]] && sed -E -n -f '${fmtutilSed}' -i "$TEXMFCNF"/fmtutil.cnf + [[ -e "$TEXMFDIST"/tex/generic/config/language.dat.lua ]] && sed -E -n -f '${scriptLua}' \ + "$TEXMFDIST"/tex/generic/config/language.dat.lua > "$TEXMFSYSVAR"/tex/generic/config/language.dat.lua + [[ -e "$TEXMFDIST"/web2c/fmtutil.cnf ]] && sed -E -f '${fmtutilSed}' "$TEXMFDIST"/web2c/fmtutil.cnf > "$TEXMFCNF"/fmtutil.cnf + + # make new files visible to kpathsea + perl "$TEXMFDIST"/scripts/texlive/mktexlsr.pl --sort "$TEXMFSYSVAR" '') + # function to wrap created executables with required env vars @@ -191,16 +211,15 @@ in (buildEnv { '' + # texlive post-install actions '' - ln -sf "$out"/share/texmf/scripts/texlive/updmap.pl "$out"/bin/updmap + ln -sf "$TEXMFDIST"/scripts/texlive/updmap.pl "$out"/bin/updmap '' + # now hack to preserve "$0" for mktexfmt '' - cp "$out"/share/texmf/scripts/texlive/fmtutil.pl "$out/bin/fmtutil" + cp "$TEXMFDIST"/scripts/texlive/fmtutil.pl "$out/bin/fmtutil" patchShebangs "$out/bin/fmtutil" - sed "1s|$| -I $out/share/texmf/scripts/texlive|" -i "$out/bin/fmtutil" + sed "1s|$| -I $TEXMFDIST/scripts/texlive|" -i "$out/bin/fmtutil" ln -sf fmtutil "$out/bin/mktexfmt" - perl "$out"/share/texmf/scripts/texlive/mktexlsr.pl --sort "$out"/share/texmf texlinks "$out/bin" && wrapBin FORCE_SOURCE_DATE=1 fmtutil --sys --all | grep '^fmtutil' # too verbose #texlinks "$out/bin" && wrapBin # do we need to regenerate format links? @@ -224,16 +243,16 @@ in (buildEnv { # sort entries to improve reproducibility [[ -f "$TEXMFSYSCONFIG"/web2c/updmap.cfg ]] && sort -o "$TEXMFSYSCONFIG"/web2c/updmap.cfg "$TEXMFSYSCONFIG"/web2c/updmap.cfg - perl "$out"/share/texmf/scripts/texlive/mktexlsr.pl --sort "$out"/share/texmf-* # to make sure + perl "$TEXMFDIST"/scripts/texlive/mktexlsr.pl --sort "$TEXMFSYSCONFIG" "$TEXMFSYSVAR" # to make sure '' + # install (wrappers for) scripts, based on a list from upstream texlive '' source '${bin.core.out}/share/texmf-dist/scripts/texlive/scripts.lst' for s in $texmf_scripts; do - [[ -x "$out/share/texmf/scripts/$s" ]] || continue + [[ -x "$TEXMFDIST/scripts/$s" ]] || continue tName="$(basename $s | sed 's/\.[a-z]\+$//')" # remove extension [[ ! -e "$out/bin/$tName" ]] || continue - ln -sv "$(realpath $out/share/texmf/scripts/$s)" "$out/bin/$tName" # wrapped below + ln -sv "$(realpath "$TEXMFDIST/scripts/$s")" "$out/bin/$tName" # wrapped below done '' + # A hacky way to provide repstopdf @@ -241,8 +260,9 @@ in (buildEnv { # * ./bin/repstopdf needs to be a symlink to be processed by wrapBin '' if [[ -e "$out"/bin/epstopdf ]]; then - cp "$out"/bin/epstopdf "$out"/share/texmf/scripts/repstopdf - ln -s "$out"/share/texmf/scripts/repstopdf "$out"/bin/repstopdf + mkdir -p "$TEXMFSYSVAR/scripts" + cp "$out"/bin/epstopdf "$TEXMFSYSVAR"/scripts/repstopdf + ln -s "$TEXMFSYSVAR"/scripts/repstopdf "$out"/bin/repstopdf fi '' + # finish up the wrappers @@ -262,16 +282,6 @@ in (buildEnv { # TODO: a context trigger https://www.preining.info/blog/2015/06/debian-tex-live-2015-the-new-layout/ # http://wiki.contextgarden.net/ConTeXt_Standalone#Unix-like_platforms_.28Linux.2FMacOS_X.2FFreeBSD.2FSolaris.29 - # I would just create links from "$out"/share/{man,info}, - # but buildenv has problems with merging symlinks with directories; - # note: it's possible we might need deepen the work-around to man/*. - '' - for d in {man,info}; do - [[ -e "$out/share/texmf/doc/$d" ]] || continue; - mkdir -p "$out/share/$d" - ln -s -t "$out/share/$d" "$out/share/texmf/doc/$d"/* - done - '' + # MkIV uses its own lookup mechanism and we need to initialize # caches for it. '' @@ -283,7 +293,7 @@ in (buildEnv { # Get rid of all log files. They are not needed, but take up space # and render the build unreproducible by their embedded timestamps. '' - find $TEXMFSYSVAR/web2c -name '*.log' -delete + find "$TEXMFSYSVAR"/web2c -name '*.log' -delete '' ; }).overrideAttrs (_: { allowSubstitutes = true; }) -- cgit 1.4.1 From 40a8b1a8053e049ff224c701ad5d763135d7b965 Mon Sep 17 00:00:00 2001 From: Vincenzo Mantova <1962985+xworld21@users.noreply.github.com> Date: Sun, 5 Feb 2023 19:32:38 +0000 Subject: texlive.combine: use separate derivation for info and man pages --- pkgs/tools/typesetting/tex/texlive/combine.nix | 27 ++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'pkgs') diff --git a/pkgs/tools/typesetting/tex/texlive/combine.nix b/pkgs/tools/typesetting/tex/texlive/combine.nix index 2f18214134b36..03b256dc18366 100644 --- a/pkgs/tools/typesetting/tex/texlive/combine.nix +++ b/pkgs/tools/typesetting/tex/texlive/combine.nix @@ -44,28 +44,35 @@ let name = "${name}-texmf"; paths = pkgList.nonbin; - extraPrefix = "/share/texmf"; nativeBuildInputs = [ perl bin.core.out ]; - postBuild = + postBuild = # generate ls-R database '' - # generate ls-R database perl -I "${bin.core.out}/share/texmf-dist/scripts/texlive" \ - -- "$out/share/texmf/scripts/texlive/mktexlsr.pl" --sort "$out/share/texmf" - # link info and man pages - for d in {info,man}; do - [[ -e "$out/share/texmf/doc/$d" ]] && ln -s "texmf/doc/$d" "$out/share/$d" - done + -- "$out/scripts/texlive/mktexlsr.pl" --sort "$out" ''; }).overrideAttrs (_: { allowSubstitutes = true; }); + # expose info and man pages in usual /share/{info,man} location + doc = buildEnv { + name = "${name}-doc"; + + paths = [ (texmf.outPath + "/doc") ]; + extraPrefix = "/share"; + + pathsToLink = [ + "/info" + "/man" + ]; + }; + in (buildEnv { inherit name; ignoreCollisions = false; - paths = pkgList.bin ++ [ texmf ]; + paths = pkgList.bin ++ [ doc ]; pathsToLink = [ "/" "/bin" # ensure these are writeable directories @@ -78,7 +85,7 @@ in (buildEnv { passthru.packages = pkgList.all; postBuild = '' - TEXMFDIST="${texmf}/share/texmf" + TEXMFDIST="${texmf}" export PATH="$out/bin:$PATH" export PERL5LIB="$TEXMFDIST/scripts/texlive:${bin.core.out}/share/texmf-dist/scripts/texlive" TEXMFSYSCONFIG="$out/share/texmf-config" -- cgit 1.4.1