guix: Add profile hook to build TeX live configuration.

* guix/profiles.scm (texlive-configuration): New procedure.
(%default-profile-hooks): Add it.
* guix/status.scm (hook-message): Handle "texlive-configuration" hook type.
This commit is contained in:
Ricardo Wurmus 2019-01-15 13:03:48 +01:00
parent c4153008f7
commit 743497b565
No known key found for this signature in database
GPG key ID: 197A5888235FACAC
2 changed files with 49 additions and 2 deletions

View file

@ -4,7 +4,7 @@
;;; Copyright © 2014, 2016 Alex Kost <alezost@gmail.com>
;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2015 Sou Bunnbu <iyzsong@gmail.com>
;;; Copyright © 2016, 2018 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2016, 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2016 Chris Marusich <cmmarusich@gmail.com>
;;; Copyright © 2017 Huang Ying <huang.ying.caritas@gmail.com>
;;; Copyright © 2017 Maxim Cournoyer <maxim.cournoyer@gmail.com>
@ -1338,6 +1338,50 @@ (define man-directory
`((type . profile-hook)
(hook . manual-database))))
(define (texlive-configuration manifest)
"Return a derivation that builds a TeXlive configuration for the entries in
MANIFEST."
(define entry->texlive-input
(match-lambda
(($ <manifest-entry> name version output thing deps)
(if (string-prefix? "texlive-" name)
(cons (gexp-input thing output)
(append-map entry->texlive-input deps))
'()))))
(define build
(with-imported-modules '((guix build utils)
(guix build union))
#~(begin
(use-modules (guix build utils)
(guix build union))
;; Build a modifiable union of all texlive inputs. We do this so
;; that TeX live can resolve the parent and grandparent directories
;; correctly. There might be a more elegant way to accomplish this.
(union-build #$output
'#$(append-map entry->texlive-input
(manifest-entries manifest))
#:create-all-directories? #t
#:log-port (%make-void-port "w"))
(substitute* (string-append #$output
"/share/texmf-dist/web2c/texmf.cnf")
(("^TEXMFROOT = .*")
(string-append "TEXMFROOT = " #$output "/share\n"))
(("^TEXMF = .*")
"TEXMF = $TEXMFROOT/share/texmf-dist\n"))
#t)))
(with-monad %store-monad
(if (any (cut string-prefix? "texlive-" <>)
(map manifest-entry-name (manifest-entries manifest)))
(gexp->derivation "texlive-configuration" build
#:substitutable? #f
#:local-build? #t
#:properties
`((type . profile-hook)
(hook . texlive-configuration)))
(return #f))))
(define %default-profile-hooks
;; This is the list of derivation-returning procedures that are called by
;; default when making a non-empty profile.
@ -1349,6 +1393,7 @@ (define %default-profile-hooks
glib-schemas
gtk-icon-themes
gtk-im-modules
texlive-configuration
xdg-desktop-database
xdg-mime-database))

View file

@ -1,6 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
;;;
;;; This file is part of GNU Guix.
;;;
@ -318,6 +318,8 @@ (define (hook-message hook-type)
(G_ "building XDG MIME database..."))
('fonts-dir
(G_ "building fonts directory..."))
('texlive-configuration
(G_ "building TeX Live configuration..."))
('manual-database
(G_ "building database for manual pages..."))
(_ #f)))