From d4a78d5f094e0c837b9104f0cd3a4fb2cf966932 Mon Sep 17 00:00:00 2001 From: apfelkuchen06 Date: Wed, 8 Mar 2023 23:37:01 +0100 Subject: [PATCH 1/2] texlive: add test for lualatex fonts --- pkgs/test/texlive/default.nix | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pkgs/test/texlive/default.nix b/pkgs/test/texlive/default.nix index 217a862e1c56..cb607f3a1328 100644 --- a/pkgs/test/texlive/default.nix +++ b/pkgs/test/texlive/default.nix @@ -1,6 +1,26 @@ { lib, runCommand, fetchurl, file, texlive, writeShellScript }: { + + luaotfload-fonts = runCommand "texlive-test-lualatex" { + nativeBuildInputs = [ + (with texlive; combine { inherit scheme-medium libertinus-fonts; }) + ]; + input = builtins.toFile "lualatex-testfile.tex" '' + \documentclass{article} + \usepackage{fontspec} + \setmainfont{Libertinus Serif} + \begin{document} + \LaTeX{} is great + \end{document} + ''; + } + '' + export HOME="$(mktemp -d)" + lualatex -halt-on-error "$input" + echo success > $out + ''; + chktex = runCommand "texlive-test-chktex" { nativeBuildInputs = [ (with texlive; combine { inherit scheme-infraonly chktex; }) From bab298bf031eb322c1ec95922e87c552a9c90f90 Mon Sep 17 00:00:00 2001 From: apfelkuchen06 Date: Wed, 8 Mar 2023 23:37:14 +0100 Subject: [PATCH 2/2] texlive: fix kpathsea path expansion. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When expanding path variables, kpathsea uses a trick to speed up identifying leaf directories. The manual says > The trick is that in every real Unix implementation (as opposed to the POSIX > specification), a directory which contains no subdirectories will have > exactly two links (namely, one for . and one for ..). That is to say, the > st_nlink field in the ‘stat’ structure will be two. Thus, we don’t have to > stat everything in the bottom-level (leaf) directories—we can just check > st_nlink, notice it’s two, and do no more work. > > But if you have a directory that contains a single subdirectory and 500 > regular files, st_nlink will be 3, and Kpathsea has to stat every one of those > 501 entries. Therein lies slowness. > > You can disable the trick by undefining ST_NLINK_TRICK in > kpathsea/config.h. (It is undefined by default except under Unix.) This does not work as expected with nixpkgs symlink trees and programs that rely on kpathsea path expansion do not work properly. One example is luaotfload's font database, which is populated by the font files in the directories obtained by path-expanding the value of the `OPENTYPEFONTS` configuration variable with kpathsea. The expanded value can be checked with `kpsewhich --show-path="opentype fonts"`. Before this change, the expanded value does not include the various font directories symlinked into `/texmf/fonts/opentype/public`, since kpathsea considers this a leaf directory (every child is a symlink, not a directory). Hence luaotfload does not find the fonts in the texlive installation. This patch disables this trick. --- pkgs/tools/typesetting/tex/texlive/bin.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkgs/tools/typesetting/tex/texlive/bin.nix b/pkgs/tools/typesetting/tex/texlive/bin.nix index 6876e4090074..255c208783f9 100644 --- a/pkgs/tools/typesetting/tex/texlive/bin.nix +++ b/pkgs/tools/typesetting/tex/texlive/bin.nix @@ -30,6 +30,14 @@ let for i in texk/kpathsea/mktex*; do sed -i '/^mydir=/d' "$i" done + + # ST_NLINK_TRICK causes kpathsea to treat folders with no real subfolders + # as leaves, even if they contain symlinks to other folders; must be + # disabled to work correctly with the nix store", see section 5.3.6 + # “Subdirectory expansion” of the kpathsea manual + # http://mirrors.ctan.org/systems/doc/kpathsea/kpathsea.pdf for more + # details + sed -i '/^#define ST_NLINK_TRICK/d' texk/kpathsea/config.h ''; configureFlags = [