From 743497b5650713e082f4775a3b7dfd03babc8191 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Tue, 15 Jan 2019 13:03:48 +0100 Subject: [PATCH] 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. --- guix/profiles.scm | 47 ++++++++++++++++++++++++++++++++++++++++++++++- guix/status.scm | 4 +++- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/guix/profiles.scm b/guix/profiles.scm index 8142e5e8e2..d22539bdb2 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -4,7 +4,7 @@ ;;; Copyright © 2014, 2016 Alex Kost ;;; Copyright © 2015 Mark H Weaver ;;; Copyright © 2015 Sou Bunnbu -;;; Copyright © 2016, 2018 Ricardo Wurmus +;;; Copyright © 2016, 2018, 2019 Ricardo Wurmus ;;; Copyright © 2016 Chris Marusich ;;; Copyright © 2017 Huang Ying ;;; Copyright © 2017 Maxim Cournoyer @@ -1338,6 +1338,50 @@ the entries in MANIFEST." `((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 + (($ 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 @@ the entries in MANIFEST." glib-schemas gtk-icon-themes gtk-im-modules + texlive-configuration xdg-desktop-database xdg-mime-database)) diff --git a/guix/status.scm b/guix/status.scm index 478c475f8c..67bb9e338e 100644 --- a/guix/status.scm +++ b/guix/status.scm @@ -1,6 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017, 2018, 2019 Ludovic Courtès -;;; Copyright © 2018 Ricardo Wurmus +;;; Copyright © 2018, 2019 Ricardo Wurmus ;;; ;;; This file is part of GNU Guix. ;;; @@ -318,6 +318,8 @@ on." (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)))