ngz pushed a commit to branch tex-team
in repository guix.

commit cb357c703e07beab24e830f7c56b3c53f5bae24d
Author: Nicolas Goaziou <[email protected]>
AuthorDate: Sat May 18 16:18:06 2024 +0200

    gnu: texlive: Fix ConTeXt.
    
    * gnu/packages/tex.scm (texlive-luatex)[arguments]<#:phases>: Add a phase to
    tweak "texmfcnf.lua".
    * gnu/packages/tex.scm (texlive-context)[arguments]<#:link-scripts>: Do not
    consider "context.lua" as a script to link.
    <#:phases>: Add a phase to point to the "texmfcnf.lua" location and another
    one to create a "context" wrapper.
    
    Change-Id: Iba52184aa244266209de86c1d90c8c9476d864e3
---
 gnu/packages/tex.scm | 40 +++++++++++++++++++++++++++++++---------
 1 file changed, 31 insertions(+), 9 deletions(-)

diff --git a/gnu/packages/tex.scm b/gnu/packages/tex.scm
index c02fcf65e0..40be7c352c 100644
--- a/gnu/packages/tex.scm
+++ b/gnu/packages/tex.scm
@@ -49450,8 +49450,17 @@ in the same way as BSD/GNU @code{getopt_long(3)} 
functions do.")
     (outputs '("out" "doc"))
     (build-system texlive-build-system)
     (arguments
-     (list #:texlive-latex-bin? #f
-           #:create-formats #~(list "dviluatex" "luatex")))
+     (list
+      #:texlive-latex-bin? #f
+      #:create-formats #~(list "dviluatex" "luatex")
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'unpack 'customize-texmfcnf.lua
+            (lambda _
+              (substitute* "web2c/texmfcnf.lua"
+                (("TEXMFDIST *=.*") "TEXMFDIST = os.getenv(\"GUIX_TEXMF\"),\n")
+                (("TEXMF *=.*")
+                 "TEXMF = 
\"{$TEXMFCONFIG;$TEXMFVAR;$TEXMFHOME;$TEXMFLOCAL;$TEXMFDIST}\",\n")))))))
     (propagated-inputs
      (list texlive-cm
            texlive-etex
@@ -60199,17 +60208,30 @@ a counter to be reset when another is incremented) and
     (build-system texlive-build-system)
     (arguments
      (list
-      #:link-scripts #~(list "context.lua" "mtxrun.lua")
+      #:link-scripts #~(list "mtxrun.lua")
       #:phases
       #~(modify-phases %standard-phases
-          (add-after 'link-scripts 'add-symlinks
+          (add-after 'unpack 'locate-texmfcnf.lua
+            ;; Out of the box, "mtxrun" first looks for "texmfcnf.lua" in
+            ;; "~/texmf", then in TEXMFCNF.  The latter is set within
+            ;; TEXLIVE-LIBKPATHSEA; it cannot contain the configuration file
+            ;; provided by TEXLIVE-LUATEX.  Point to the right file instead.
+            (lambda* (#:key inputs #:allow-other-keys)
+              (let ((texmfcnf.lua
+                     (search-input-file inputs
+                                        
"share/texmf-dist/web2c/texmfcnf.lua")))
+                (substitute* (find-files "." "\\.lua$")
+                  (("kpse\\.default_texmfcnf\\(\\)")
+                   (format #f "\"~a\"" (dirname texmfcnf.lua)))))))
+          (add-after 'unpack 'create-context-wrapper
+            ;; Create a "context" script for convenience.
             (lambda _
+              (mkdir-p (string-append #$output "/bin"))
               (with-directory-excursion (string-append #$output "/bin")
-                (symlink "../share/texmf-dist/scripts/context/lua/context.lua"
-                         "context.lua")
-                (symlink "../share/texmf-dist/scripts/context/lua/mtxrun.lua"
-                         "mtxrun.lua")
-                (symlink "mtxrun" "luametatex")))))))
+                (call-with-output-file "context"
+                  (lambda (port)
+                    (format port "#!/bin/sh~%mtxrun --script context \"$@\"")))
+                (chmod "context" #o755)))))))
     (propagated-inputs
      (list texlive-amsfonts
            texlive-lm

Reply via email to