diff --git a/pkgs/test/texlive/default.nix b/pkgs/test/texlive/default.nix index 052bfa5e6636..3b65bdb6ba20 100644 --- a/pkgs/test/texlive/default.nix +++ b/pkgs/test/texlive/default.nix @@ -421,6 +421,26 @@ rec { l3build install --full --texmfhome "$out" ''; + # verify that minted can highlight code via latexminted + minted = mkTeXTest { + name = "minted"; + format = "pdflatex"; + texLive = texliveSmall.withPackages (ps: [ ps.minted ]); + text = '' + \documentclass{article} + \usepackage{minted} + \begin{document} + \begin{minted}{python} + def fib(n): + a, b = 0, 1 + for _ in range(n): + a, b = b, a + b + return a + \end{minted} + \end{document} + ''; + }; + # verify that the restricted mode gets enabled when # needed (detected by checking if it disallows --gscmd) repstopdf = diff --git a/pkgs/tools/typesetting/tex/texlive/default.nix b/pkgs/tools/typesetting/tex/texlive/default.nix index 94a7f51089a4..644526e1cafb 100644 --- a/pkgs/tools/typesetting/tex/texlive/default.nix +++ b/pkgs/tools/typesetting/tex/texlive/default.nix @@ -6,7 +6,7 @@ { lib, stdenv, - fetchpatch, + fetchpatch2, fetchurl, runCommand, writeShellScript, @@ -47,6 +47,7 @@ luajit, texinfo, # for bin.nix + fetchpatch, gnum4, jdk_headless, perlPackages, @@ -102,7 +103,7 @@ let inherit stdenv lib - fetchpatch + fetchpatch2 bin tlpdb tlpdbxz @@ -128,6 +129,7 @@ let zip luajit texinfo + unzip ; }; in diff --git a/pkgs/tools/typesetting/tex/texlive/tlpdb-overrides.nix b/pkgs/tools/typesetting/tex/texlive/tlpdb-overrides.nix index 2eb1eec2366f..1cf117752f3a 100644 --- a/pkgs/tools/typesetting/tex/texlive/tlpdb-overrides.nix +++ b/pkgs/tools/typesetting/tex/texlive/tlpdb-overrides.nix @@ -1,6 +1,6 @@ { stdenv, - fetchpatch, + fetchpatch2, lib, tlpdb, bin, @@ -27,6 +27,7 @@ zip, luajit, texinfo, + unzip, }: oldTlpdb: let @@ -470,9 +471,31 @@ lib.recursiveUpdate orig rec { ''; # find files in script directory, not in binary directory - minted.postFixup = '' - substituteInPlace "$out"/bin/latexminted --replace-fail "__file__" "\"$scriptsFolder/latexminted.py\"" - ''; + # fix compatibility with Python 3.14 by loading a patched copy of the latexminted package + # (the patch is applied here rather than in postUnpack, since repacking the wheel inside the + # fixed-output tex container would make its hash depend on the zip/zlib implementation) + minted.extraNativeBuildInputs = [ unzip ]; + minted.postFixup = + let + patch = fetchpatch2 { + name = "minted-python314-compat.patch"; + url = "https://github.com/gpoore/minted/commit/2a7b3a48e47b834bbc4a616679a0ef9710896a16.diff"; + hash = "sha256-JcaQjSDqBQFsWLNRaOSNxCvPNa2HktfuzjsMKAWUPl8="; + includes = [ "python/latexminted/cmdline.py" ]; + }; + in + '' + substituteInPlace "$out"/bin/latexminted --replace-fail "__file__" "\"$scriptsFolder/latexminted.py\"" + + latexmintedLib="$out"/share/minted/python + mkdir -p "$latexmintedLib" + unzip -q "$scriptsFolder"/latexminted-0.6.0-py3-none-any.whl 'latexminted/*' -d "$latexmintedLib" + sed -i 's/\r$//' "$latexmintedLib"/latexminted/cmdline.py + patch -p2 -d "$latexmintedLib" -i "${patch}" + substituteInPlace "$out"/bin/latexminted \ + --replace-fail "from latexminted.cmdline import main" \ + "sys.path.insert(0, '$latexmintedLib')"$'\n'"from latexminted.cmdline import main" + ''; # find files in source container, fix incompatibilities with snobol4 texaccents.postFixup = ''