Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

texlive_latest: init at 2023.20230606 #236382

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions pkgs/test/texlive/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -511,4 +511,25 @@
echo "$errorText"
false
'');

# verify that all fixed hashes are present
# 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;
in runCommand "texlive-test-fixed-hashes" {
inherit errorText;
passAsFile = [ "errorText" ];
} ''
if [[ -s "$errorTextPath" ]] ; then
cat "$errorTextPath"
echo Failed: some TeX Live packages do not have fixed output hashes. Please read UPGRADING.md for how to generate a new fixed-hashes.nix.
exit 1
else
touch "$out"
fi
'';
}
2 changes: 1 addition & 1 deletion pkgs/tools/typesetting/biber-ms/default.nix
Original file line number Diff line number Diff line change
@@ -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 = lib.head (builtins.filter (p: p.tlType == "source") texlive.pkgs.biber-ms.pkgs);
# missing test file
multiscriptBltxml = (fetchFromGitHub {
owner = "plk";
Expand Down
2 changes: 1 addition & 1 deletion pkgs/tools/typesetting/biber/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ lib, stdenv, fetchurl, perlPackages, shortenPerlShebang, texlive }:

let
biberSource = lib.head (builtins.filter (p: p.tlType == "source") texlive.biber.pkgs);
biberSource = lib.head (builtins.filter (p: p.tlType == "source") texlive.pkgs.biber.pkgs);
in

perlPackages.buildPerlModule {
Expand Down
23 changes: 23 additions & 0 deletions pkgs/tools/typesetting/tex/luametatex/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{ stdenv, lib, fetchFromGitHub, cmake, ... }:
stdenv.mkDerivation (finalAttrs: {
pname = "luametatex";
version = "2.10.08";

src = fetchFromGitHub {
owner = "contextgarden";
repo = "luametatex";
rev = "v${finalAttrs.version}";
hash = "sha256-KLRsJVzGyfbOfFSxUyT8mdxZ1Ud4EZrSxVB72i5jREU=";
};

enableParallelBuilding = true;

nativeBuildInputs = [ cmake ];

meta = with lib; {
description = "minimal tex engine based on luatex";
homepage = "https://www.pragma-ade.nl/luametatex-1.htm";
license = licenses.gpl2Plus;
maintainers = with lib.maintainers; [ apfelkuchen6 ];
};
})
46 changes: 11 additions & 35 deletions pkgs/tools/typesetting/tex/texlive/bin.nix
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How hard would it be to have bin.nix as before, and an extra bin-latest.nix with overrides only? Which I believe would be the more nixpkgs-y way of providing two versions.

Alternatively, bin-latest.nix could be a straight copy of bin.nix, which would become the new bin.nix once it becomes frozen.

Copy link
Contributor Author

@apfelkuchen6 apfelkuchen6 Jun 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly as before is rather inconvenient as the sources would have to be overridden for every derivation. Just passing in the source as an argument and doing the patches and version-specific hacks via overrides shouldn't be too hard at this time as 2023 mostly just adds hacks over 2022. This might become more inconvenient if parts of hacks have to be removed.

I don't really like either approach. Using overrides makes upgrading less convenient and having a complete copy of the file feels really wasteful. I think just keeping bin.nix mostly general and put version-specific hacks/patches somewhere else for both versions is better as the upgrade remains just moving a file.

Original file line number Diff line number Diff line change
@@ -1,35 +1,28 @@
{ lib, stdenv, fetchurl, fetchpatch, buildPackages
, texlive
, bin, combine, pkgs, src, version
, zlib, libiconv, libpng, libX11
, freetype, gd, libXaw, icu, ghostscript, libXpm, libXmu, libXext
, perl, perlPackages, python3Packages, pkg-config
, libpaper, graphite2, zziplib, harfbuzz, potrace, gmp, mpfr
, brotli, cairo, pixman, xorg, clisp, biber, woff2, xxHash
, makeWrapper, shortenPerlShebang, useFixedHashes, asymptote
, biber-ms
}:
}@args:

# Useful resource covering build options:
# http://tug.org/texlive/doc/tlbuild.html

let
withSystemLibs = map (libname: "--with-system-${libname}");

year = toString ((import ./tlpdb.nix)."00texlive.config").year;
version = year; # keep names simple for now
version = toString args.version.texliveYear; # keep names simple for now

# detect and stop redundant rebuilds that may occur when building new fixed hashes
assertFixedHash = name: src:
if ! useFixedHashes || src ? outputHash then src else throw "The TeX Live package '${src.pname}' must have a fixed hash before building '${name}'.";

common = {
src = fetchurl {
urls = [
"http://ftp.math.utah.edu/pub/tex/historic/systems/texlive/${year}/texlive-${year}0321-source.tar.xz"
"ftp://tug.ctan.org/pub/tex/historic/systems/texlive/${year}/texlive-${year}0321-source.tar.xz"
];
hash = "sha256-X/o0heUessRJBJZFD8abnXvXy55TNX2S20vNT9YXm1Y=";
};
inherit src;

prePatch = ''
for i in texk/kpathsea/mktex*; do
Expand Down Expand Up @@ -77,7 +70,7 @@ let
in rec { # un-indented

inherit (common) cleanBrokenLinks;
texliveYear = year;
texliveYear = version;


core = stdenv.mkDerivation rec {
Expand All @@ -93,8 +86,8 @@ core = stdenv.mkDerivation rec {
] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
# configure: error: tangle was not found but is required when cross-compiling.
# dev (himktables) is used when building hitex to generate the additional source file hitables.c
texlive.bin.core
texlive.bin.core.dev
bin.core
bin.core.dev
];

buildInputs = [
Expand All @@ -103,12 +96,6 @@ core = stdenv.mkDerivation rec {
perl
];

patches = [
# Fix implicit `int` on `main`, which results in an error when building with clang 16.
# This is fixed upstream and can be dropped with the 2023 release.
./fix-implicit-int.patch
];

hardeningDisable = [ "format" ];

preConfigure = ''
Expand Down Expand Up @@ -196,7 +183,7 @@ core = stdenv.mkDerivation rec {
};


inherit (core-big) metafont mflua metapost luatex luahbtex luajittex xetex;
inherit (bin.core-big) metafont mflua metapost luatex luahbtex luajittex xetex;
core-big = stdenv.mkDerivation { #TODO: upmendex
pname = "texlive-core-big.bin";
inherit version;
Expand All @@ -213,14 +200,6 @@ core-big = stdenv.mkDerivation { #TODO: upmendex
url = "https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=1009196;filename=reproducible_exception_strings.patch;msg=5";
sha256 = "sha256-RNZoEeTcWnrLaltcYrhNIORh42fFdwMzBfxMRWVurbk=";
})
# fixes a security-issue in luatex that allows arbitrary code execution even with shell-escape disabled, see https://tug.org/~mseven/luatex.html
(fetchpatch {
name = "CVE-2023-32700.patch";
url = "https://tug.org/~mseven/luatex-files/2022/patch";
hash = "sha256-o9ENLc1ZIIOMX6MdwpBIgrR/Jdw6tYLmAyzW8i/FUbY=";
excludes = [ "build.sh" ];
stripLen = 1;
})
# Fixes texluajitc crashes on aarch64, backport of the upstream fix
# https://github.com/LuaJIT/LuaJIT/commit/e9af1abec542e6f9851ff2368e7f196b6382a44c
# to the version vendored by texlive (2.1.0-beta3)
Expand All @@ -231,9 +210,6 @@ core-big = stdenv.mkDerivation { #TODO: upmendex
stripLen = 1;
extraPrefix = "libs/luajit/LuaJIT-src/";
})
# Fix implicit `int` on `main`, which results in an error when building with clang 16.
# This is fixed upstream and can be dropped with the 2023 release.
./fix-implicit-int.patch
];

hardeningDisable = [ "format" ];
Expand Down Expand Up @@ -394,7 +370,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 (lib.head (builtins.filter (p: p.tlType == "run") pkgs.pygmentex.pkgs));

propagatedBuildInputs = with python3Packages; [ pygments chardet ];

Expand Down Expand Up @@ -475,7 +451,7 @@ xdvi = stdenv.mkDerivation {

xpdfopen = stdenv.mkDerivation {
pname = "texlive-xpdfopen.bin";
inherit (lib.head texlive.xpdfopen.pkgs) version;
inherit (lib.head pkgs.xpdfopen.pkgs) version;

inherit (common) src;

Expand Down Expand Up @@ -510,7 +486,7 @@ xindy = stdenv.mkDerivation {

nativeBuildInputs = [
pkg-config perl
(texlive.combine { inherit (texlive) scheme-basic cyrillic ec; })
(combine { inherit (pkgs) scheme-basic cyrillic ec; })
];
buildInputs = [ clisp libiconv perl ];

Expand Down
42 changes: 35 additions & 7 deletions pkgs/tools/typesetting/tex/texlive/combine.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
params: with params;
{ lib, buildEnv, runCommand, writeText, makeWrapper, libfaketime, makeFontsConf
, perl, bash, coreutils, gnused, gnugrep, gawk, ghostscript
, bin, pkgs }:
# combine =
args@{
pkgFilter ? (pkg: pkg.tlType == "run" || pkg.tlType == "bin" || pkg.pname == "core"
Expand All @@ -8,6 +10,22 @@ 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 []);
});

pkgSet = removeAttrs args [ "pkgFilter" "extraName" "extraVersion" ];
pkgList = rec {
combined = combinePkgs (lib.attrValues pkgSet);
Expand All @@ -31,7 +49,7 @@ let
paths = lib.catAttrs "outPath" pkgList.nonbin;

# mktexlsr
nativeBuildInputs = [ (lib.last tl."texlive.infra".pkgs) ];
nativeBuildInputs = [ (lib.last pkgs."texlive.infra".pkgs) ];

postBuild = # generate ls-R database
''
Expand Down Expand Up @@ -89,9 +107,9 @@ 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
(lib.last pkgs."texlive.infra".pkgs) # mktexlsr
(lib.last pkgs.texlive-scripts.pkgs) # fmtutil, updmap
(lib.last pkgs.texlive-scripts-extra.pkgs) # texlinks
perl
];

Expand Down Expand Up @@ -120,6 +138,10 @@ in (buildEnv {
declare -i wrapCount=0
for link in "$out"/bin/*; do
target="$(realpath "$link")"

# don't try to wrap nonexecutable files
[[ -x $target ]] || continue

if [[ "''${target##*/}" != "''${link##*/}" ]] ; then
# detected alias with different basename, use immediate target of $link to preserve $0
# relevant for mktexfmt, repstopdf, ...
Expand Down Expand Up @@ -276,11 +298,17 @@ in (buildEnv {
# We use faketime to fix the embedded timestamps and patch the uuids
# with some random but constant values.
''
if [[ -e "$out/bin/mtxrun" ]]; then
if [[ -e "$TEXMFDIST"/scripts/context/lua/mtxrun.lua ]]; then
substitute "$TEXMFDIST"/scripts/context/lua/mtxrun.lua mtxrun.lua \
--replace 'cache_uuid=osuuid()' 'cache_uuid="e2402e51-133d-4c73-a278-006ea4ed734f"' \
--replace 'uuid=osuuid(),' 'uuid="242be807-d17e-4792-8e39-aa93326fc871",'
FORCE_SOURCE_DATE=1 TZ= faketime -f '@1980-01-01 00:00:00 x0.001' luatex --luaonly mtxrun.lua --generate
# the ConTeXt caches for luatex and luametatex are independent
if [[ -e "$out/bin/luatex" ]]; then
FORCE_SOURCE_DATE=1 TZ= faketime -f '@1980-01-01 00:00:00 x0.001' luatex --luaonly mtxrun.lua --generate
fi
if [[ -e "$out/bin/luametatex" ]]; then
FORCE_SOURCE_DATE=1 TZ= faketime -f '@1980-01-01 00:00:00 x0.001' luametatex --luaonly mtxrun.lua --generate
fi
fi
'' +
# Get rid of all log files. They are not needed, but take up space
Expand Down
Loading