Commit | Line | Data |
---|---|---|
205794c8 RW |
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net> | |
3 | ;;; | |
4 | ;;; This file is part of GNU Guix. | |
5 | ;;; | |
6 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
7 | ;;; under the terms of the GNU General Public License as published by | |
8 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
9 | ;;; your option) any later version. | |
10 | ;;; | |
11 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
12 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | ;;; GNU General Public License for more details. | |
15 | ;;; | |
16 | ;;; You should have received a copy of the GNU General Public License | |
17 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
18 | ||
19 | (define-module (guix build-system texlive) | |
20 | #:use-module (guix store) | |
21 | #:use-module (guix utils) | |
22 | #:use-module (guix packages) | |
23 | #:use-module (guix derivations) | |
24 | #:use-module (guix search-paths) | |
25 | #:use-module (guix build-system) | |
26 | #:use-module (guix build-system gnu) | |
27 | #:use-module (guix svn-download) | |
28 | #:use-module (ice-9 match) | |
29 | #:export (%texlive-build-system-modules | |
30 | texlive-build | |
31 | texlive-build-system | |
32 | texlive-ref | |
2541379e | 33 | texlive-origin |
205794c8 RW |
34 | %texlive-tag |
35 | %texlive-revision)) | |
36 | ||
37 | ;; Commentary: | |
38 | ;; | |
39 | ;; Standard build procedure for Texlive packages. | |
40 | ;; | |
41 | ;; Code: | |
42 | ||
d4d9a1ec RW |
43 | ;; These variables specify the SVN tag and the matching SVN revision. They |
44 | ;; are taken from https://www.tug.org/svn/texlive/tags/ | |
cebe0777 MB |
45 | (define %texlive-tag "texlive-2019.3") |
46 | (define %texlive-revision 51265) | |
205794c8 | 47 | |
2541379e RW |
48 | (define (texlive-origin name version locations hash) |
49 | "Return an <origin> object for a TeX Live package consisting of multiple | |
50 | LOCATIONS with a provided HASH. Use NAME and VERSION to compute a prettier | |
51 | name for the checkout directory." | |
52 | (origin | |
53 | (method svn-multi-fetch) | |
54 | (uri (svn-multi-reference | |
55 | (url (string-append "svn://www.tug.org/texlive/tags/" | |
56 | %texlive-tag "/Master/texmf-dist/")) | |
57 | (locations locations) | |
58 | (revision %texlive-revision))) | |
59 | (file-name (string-append name "-" version "-checkout")) | |
60 | (sha256 hash))) | |
61 | ||
205794c8 RW |
62 | (define (texlive-ref component id) |
63 | "Return a <svn-reference> object for the package ID, which is part of the | |
64 | given Texlive COMPONENT." | |
65 | (svn-reference | |
66 | (url (string-append "svn://www.tug.org/texlive/tags/" | |
67 | %texlive-tag "/Master/texmf-dist/" | |
68 | "source/" component "/" id)) | |
69 | (revision %texlive-revision))) | |
70 | ||
71 | (define %texlive-build-system-modules | |
72 | ;; Build-side modules imported by default. | |
73 | `((guix build texlive-build-system) | |
bb3b3597 | 74 | (guix build union) |
205794c8 RW |
75 | ,@%gnu-build-system-modules)) |
76 | ||
77 | (define (default-texlive-bin) | |
78 | "Return the default texlive-bin package." | |
79 | ;; Lazily resolve the binding to avoid a circular dependency. | |
80 | (let ((tex-mod (resolve-interface '(gnu packages tex)))) | |
81 | (module-ref tex-mod 'texlive-bin))) | |
82 | ||
83 | (define (default-texlive-latex-base) | |
84 | "Return the default texlive-latex-base package." | |
85 | ;; Lazily resolve the binding to avoid a circular dependency. | |
86 | (let ((tex-mod (resolve-interface '(gnu packages tex)))) | |
87 | (module-ref tex-mod 'texlive-latex-base))) | |
88 | ||
89 | (define* (lower name | |
90 | #:key | |
91 | source inputs native-inputs outputs | |
92 | system target | |
93 | (texlive-latex-base (default-texlive-latex-base)) | |
94 | (texlive-bin (default-texlive-bin)) | |
95 | #:allow-other-keys | |
96 | #:rest arguments) | |
97 | "Return a bag for NAME." | |
98 | (define private-keywords | |
99 | '(#:source #:target #:inputs #:native-inputs | |
100 | #:texlive-latex-base #:texlive-bin)) | |
101 | ||
102 | (bag | |
103 | (name name) | |
104 | (system system) | |
105 | (host-inputs `(,@(if source | |
106 | `(("source" ,source)) | |
107 | '()) | |
108 | ,@inputs | |
109 | ||
110 | ;; Keep the standard inputs of 'gnu-build-system'. | |
111 | ,@(standard-packages))) | |
112 | (build-inputs `(("texlive-bin" ,texlive-bin) | |
113 | ("texlive-latex-base" ,texlive-latex-base) | |
114 | ,@native-inputs)) | |
115 | (outputs outputs) | |
116 | (build texlive-build) | |
117 | (arguments (strip-keyword-arguments private-keywords arguments)))) | |
118 | ||
119 | (define* (texlive-build store name inputs | |
120 | #:key | |
121 | (tests? #f) | |
122 | tex-directory | |
123 | (build-targets #f) | |
124 | (tex-format "luatex") | |
125 | (phases '(@ (guix build texlive-build-system) | |
126 | %standard-phases)) | |
127 | (outputs '("out")) | |
128 | (search-paths '()) | |
129 | (system (%current-system)) | |
130 | (guile #f) | |
131 | (substitutable? #t) | |
132 | (imported-modules %texlive-build-system-modules) | |
133 | (modules '((guix build texlive-build-system) | |
bb3b3597 | 134 | (guix build union) |
205794c8 RW |
135 | (guix build utils)))) |
136 | "Build SOURCE with INPUTS." | |
137 | (define builder | |
138 | `(begin | |
139 | (use-modules ,@modules) | |
140 | (texlive-build #:name ,name | |
141 | #:source ,(match (assoc-ref inputs "source") | |
142 | (((? derivation? source)) | |
143 | (derivation->output-path source)) | |
144 | ((source) | |
145 | source) | |
146 | (source | |
147 | source)) | |
148 | #:tex-directory ,tex-directory | |
149 | #:build-targets ,build-targets | |
150 | #:tex-format ,tex-format | |
151 | #:system ,system | |
152 | #:tests? ,tests? | |
153 | #:phases ,phases | |
154 | #:outputs %outputs | |
155 | #:search-paths ',(map search-path-specification->sexp | |
156 | search-paths) | |
157 | #:inputs %build-inputs))) | |
158 | ||
159 | (define guile-for-build | |
160 | (match guile | |
161 | ((? package?) | |
162 | (package-derivation store guile system #:graft? #f)) | |
163 | (#f ; the default | |
164 | (let* ((distro (resolve-interface '(gnu packages commencement))) | |
165 | (guile (module-ref distro 'guile-final))) | |
166 | (package-derivation store guile system #:graft? #f))))) | |
167 | ||
168 | (build-expression->derivation store name builder | |
169 | #:inputs inputs | |
170 | #:system system | |
171 | #:modules imported-modules | |
172 | #:outputs outputs | |
173 | #:guile-for-build guile-for-build | |
174 | #:substitutable? substitutable?)) | |
175 | ||
176 | (define texlive-build-system | |
177 | (build-system | |
178 | (name 'texlive) | |
179 | (description "The build system for TeX Live packages") | |
180 | (lower lower))) | |
181 | ||
182 | ;;; texlive.scm ends here |