gnu: Add qtwebkit.
[jackhill/guix/guix.git] / gnu / packages / tex.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2014, 2015, 2016 Andreas Enge <andreas@enge.fr>
3 ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
4 ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
5 ;;; Copyright © 2016 Roel Janssen <roel@gnu.org>
6 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
7 ;;; Copyright © 2016 Federico Beffa <beffa@fbengineering.ch>
8 ;;;
9 ;;; This file is part of GNU Guix.
10 ;;;
11 ;;; GNU Guix is free software; you can redistribute it and/or modify it
12 ;;; under the terms of the GNU General Public License as published by
13 ;;; the Free Software Foundation; either version 3 of the License, or (at
14 ;;; your option) any later version.
15 ;;;
16 ;;; GNU Guix is distributed in the hope that it will be useful, but
17 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;;; GNU General Public License for more details.
20 ;;;
21 ;;; You should have received a copy of the GNU General Public License
22 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23
24 (define-module (gnu packages tex)
25 #:use-module ((guix licenses) #:prefix license:)
26 #:use-module (guix packages)
27 #:use-module (guix download)
28 #:use-module (guix build-system gnu)
29 #:use-module (guix build-system trivial)
30 #:use-module (guix utils)
31 #:use-module (guix git-download)
32 #:use-module (gnu packages)
33 #:use-module (gnu packages autotools)
34 #:use-module (gnu packages bash)
35 #:use-module (gnu packages compression)
36 #:use-module (gnu packages fontutils)
37 #:use-module (gnu packages gd)
38 #:use-module (gnu packages ghostscript)
39 #:use-module (gnu packages gtk)
40 #:use-module (gnu packages icu4c)
41 #:use-module (gnu packages image)
42 #:use-module (gnu packages lua)
43 #:use-module (gnu packages multiprecision)
44 #:use-module (gnu packages pdf)
45 #:use-module (gnu packages perl)
46 #:use-module (gnu packages pkg-config)
47 #:use-module (gnu packages python)
48 #:use-module (gnu packages qt)
49 #:use-module (gnu packages ruby)
50 #:use-module (gnu packages shells)
51 #:use-module (gnu packages base)
52 #:use-module (gnu packages xorg)
53 #:use-module (gnu packages xdisorg)
54 #:use-module (gnu packages zip)
55 #:autoload (gnu packages texinfo) (texinfo)
56 #:use-module (ice-9 ftw)
57 #:use-module (srfi srfi-1))
58
59 (define texlive-extra-src
60 (origin
61 (method url-fetch)
62 (uri "ftp://tug.org/historic/systems/texlive/2016/texlive-20160523-extra.tar.xz")
63 (sha256 (base32
64 "0q4a92zmwhn4ry6xgrp4k8wq11ax2sg9rg9yrsrdkr719y0x887a"))))
65
66 (define texlive-texmf-src
67 (origin
68 (method url-fetch)
69 (uri "ftp://tug.org/historic/systems/texlive/2016/texlive-20160523b-texmf.tar.xz")
70 (sha256 (base32
71 "1dv8vgfzpczqw82hv9g7a8djhhyzywljmrarlcyy6g2qi5q51glr"))))
72
73 (define texlive-bin
74 (package
75 (name "texlive-bin")
76 (version "2016")
77 (source
78 (origin
79 (method url-fetch)
80 (uri "ftp://tug.org/historic/systems/texlive/2016/texlive-20160523b-source.tar.xz")
81 (sha256 (base32
82 "1v91vahxlxkdra0qz3f132vvx5d9cx2jy84yl1hkch0agyj2rcx8"))))
83 (build-system gnu-build-system)
84 (inputs
85 `(("texlive-extra-src" ,texlive-extra-src)
86 ("cairo" ,cairo)
87 ("fontconfig" ,fontconfig)
88 ("fontforge" ,fontforge)
89 ("freetype" ,freetype)
90 ("gd" ,gd)
91 ("gmp" ,gmp)
92 ("ghostscript" ,ghostscript)
93 ("graphite2" ,graphite2)
94 ("harfbuzz" ,harfbuzz)
95 ("icu4c" ,icu4c)
96 ("libpaper" ,libpaper)
97 ("libpng" ,libpng)
98 ("libxaw" ,libxaw)
99 ("libxt" ,libxt)
100 ("mpfr" ,mpfr)
101 ("perl" ,perl)
102 ("pixman" ,pixman)
103 ("poppler" ,poppler)
104 ("potrace" ,potrace)
105 ("python" ,python-2) ; incompatible with Python 3 (print syntax)
106 ("ruby" ,ruby)
107 ("tcsh" ,tcsh)
108 ("teckit" ,teckit)
109 ("zlib" ,zlib)
110 ("zziplib" ,zziplib)))
111 (native-inputs
112 `(("pkg-config" ,pkg-config)))
113 (arguments
114 `(#:out-of-source? #t
115 #:configure-flags
116 `("--disable-native-texlive-build"
117 "--with-system-cairo"
118 "--with-system-freetype2"
119 "--with-system-gd"
120 "--with-system-gmp"
121 "--with-system-graphite2"
122 "--with-system-harfbuzz"
123 "--with-system-icu"
124 "--with-system-libgs"
125 "--with-system-libpaper"
126 "--with-system-libpng"
127 "--with-system-mpfr"
128 "--with-system-pixman"
129 "--with-system-poppler"
130 "--with-system-potrace"
131 "--with-system-teckit"
132 "--with-system-xpdf"
133 "--with-system-zlib"
134 "--with-system-zziplib")
135
136 ;; Disable tests on mips64 to cope with a failure of luajiterr.test.
137 ;; XXX FIXME fix luajit properly on mips64.
138 #:tests? ,(not (string-prefix? "mips64" (or (%current-target-system)
139 (%current-system))))
140 #:phases
141 (modify-phases %standard-phases
142 (add-after 'install 'postint
143 (lambda* (#:key inputs outputs #:allow-other-keys #:rest args)
144 (let* ((out (assoc-ref outputs "out"))
145 (share (string-append out "/share"))
146 (texlive-extra (assoc-ref inputs "texlive-extra-src"))
147 (unpack (assoc-ref %standard-phases 'unpack))
148 (patch-source-shebangs
149 (assoc-ref %standard-phases 'patch-source-shebangs)))
150 ;; Create symbolic links for the latex variants and their
151 ;; man pages.
152 (with-directory-excursion (string-append out "/bin/")
153 (for-each symlink
154 '("pdftex" "pdftex" "xetex" "luatex")
155 '("latex" "pdflatex" "xelatex" "lualatex")))
156 (with-directory-excursion (string-append share "/man/man1/")
157 (symlink "luatex.1" "lualatex.1"))
158 ;; Unpack texlive-extra and install tlpkg.
159 (mkdir "texlive-extra")
160 (with-directory-excursion "texlive-extra"
161 (apply unpack (list #:source texlive-extra))
162 (apply patch-source-shebangs (list #:source texlive-extra))
163 (system* "mv" "tlpkg" share))))))))
164 (synopsis "TeX Live, a package of the TeX typesetting system")
165 (description
166 "TeX Live provides a comprehensive TeX document production system.
167 It includes all the major TeX-related programs, macro packages, and fonts
168 that are free software, including support for many languages around the
169 world.
170
171 This package contains the binaries.")
172 (license (license:fsf-free "https://www.tug.org/texlive/copying.html"))
173 (home-page "https://www.tug.org/texlive/")))
174
175 (define texlive-texmf
176 (package
177 (name "texlive-texmf")
178 (version "2016")
179 (source texlive-texmf-src)
180 (build-system gnu-build-system)
181 (inputs
182 `(("texlive-bin" ,texlive-bin)
183 ("lua" ,lua)
184 ("perl" ,perl)
185 ("python" ,python-2) ; incompatible with Python 3 (print syntax)
186 ("ruby" ,ruby)
187 ("tcsh" ,tcsh)))
188 (arguments
189 `(#:modules ((guix build gnu-build-system)
190 (guix build utils)
191 (srfi srfi-26))
192
193 ;; This package takes 4 GiB, which we can't afford to distribute from
194 ;; our servers.
195 #:substitutable? #f
196
197 #:phases
198 (modify-phases (map (cut assq <> %standard-phases)
199 '(set-paths unpack patch-source-shebangs))
200 (add-after 'patch-source-shebangs 'install
201 (lambda* (#:key outputs #:allow-other-keys)
202 (let ((share (string-append (assoc-ref outputs "out") "/share")))
203 (mkdir-p share)
204 (system* "mv" "texmf-dist" share))))
205 (add-after 'install 'texmf-config
206 (lambda* (#:key inputs outputs #:allow-other-keys)
207 (let* ((out (assoc-ref outputs "out"))
208 (share (string-append out "/share"))
209 (texmfroot (string-append share "/texmf-dist/web2c"))
210 (texmfcnf (string-append texmfroot "/texmf.cnf"))
211 (texlive-bin (assoc-ref inputs "texlive-bin"))
212 (texbin (string-append texlive-bin "/bin"))
213 (tlpkg (string-append texlive-bin "/share/tlpkg")))
214 ;; Register SHARE as TEXMFROOT in texmf.cnf.
215 (substitute* texmfcnf
216 (("TEXMFROOT = \\$SELFAUTOPARENT")
217 (string-append "TEXMFROOT = " share))
218 (("TEXMFLOCAL = \\$SELFAUTOGRANDPARENT/texmf-local")
219 "TEXMFLOCAL = $SELFAUTODIR/share/texmf-local")
220 (("!!\\$TEXMFLOCAL") "$TEXMFLOCAL"))
221 ;; Register paths in texmfcnf.lua, needed for context.
222 (substitute* (string-append texmfroot "/texmfcnf.lua")
223 (("selfautodir:") out)
224 (("selfautoparent:") (string-append share "/")))
225 ;; Set path to TeXLive Perl modules
226 (setenv "PERL5LIB"
227 (string-append (getenv "PERL5LIB") ":" tlpkg))
228 ;; Configure the texmf-dist tree; inspired from
229 ;; http://slackbuilds.org/repository/13.37/office/texlive/
230 (setenv "PATH" (string-append (getenv "PATH") ":" texbin))
231 (setenv "TEXMFCNF" texmfroot)
232 (system* "updmap-sys" "--nohash" "--syncwithtrees")
233 (system* "mktexlsr")
234 (system* "fmtutil-sys" "--all")))))))
235 (properties `((max-silent-time . 9600))) ; don't time out while grafting
236 (synopsis "TeX Live, a package of the TeX typesetting system")
237 (description
238 "TeX Live provides a comprehensive TeX document production system.
239 It includes all the major TeX-related programs, macro packages, and fonts
240 that are free software, including support for many languages around the
241 world.
242
243 This package contains the complete tree of texmf-dist data.")
244 (license (license:fsf-free "https://www.tug.org/texlive/copying.html"))
245 (home-page "https://www.tug.org/texlive/")))
246
247 (define-public texlive
248 (package
249 (name "texlive")
250 (version "2016")
251 (source #f)
252 (build-system trivial-build-system)
253 (inputs `(("bash" ,bash) ; for wrap-program
254 ("texlive-bin" ,texlive-bin)
255 ("texlive-texmf" ,texlive-texmf)))
256 (native-search-paths
257 (list (search-path-specification
258 (variable "TEXMFLOCAL")
259 (files '("share/texmf-local")))))
260 (arguments
261 `(#:modules ((guix build utils))
262 #:builder
263 ;; Build the union of texlive-bin and texlive-texmf, but take the
264 ;; conflicting subdirectory share/texmf-dist from texlive-texmf.
265 (begin
266 (use-modules (guix build utils))
267 (let ((out (assoc-ref %outputs "out"))
268 (bin (assoc-ref %build-inputs "texlive-bin"))
269 (texmf (assoc-ref %build-inputs "texlive-texmf"))
270 (bash (assoc-ref %build-inputs "bash")))
271 (mkdir out)
272 (with-directory-excursion out
273 (for-each
274 (lambda (name)
275 (symlink (string-append bin "/" name) name))
276 '("include" "lib"))
277 (mkdir "bin")
278 (with-directory-excursion "bin"
279 (setenv "PATH" (string-append bash "/bin"))
280 (for-each
281 (lambda (name)
282 (symlink name (basename name))
283 (wrap-program
284 (basename name)
285 `("TEXMFCNF" =
286 (,(string-append texmf "/share/texmf-dist/web2c")))))
287 (find-files (string-append bin "/bin/") "")))
288 (mkdir "share")
289 (with-directory-excursion "share"
290 (for-each
291 (lambda (name)
292 (symlink (string-append bin "/share/" name) name))
293 '("info" "man" "tlpkg"))
294 (for-each
295 (lambda (name)
296 (symlink (string-append texmf "/share/" name) name))
297 '("texmf-dist" "texmf-var"))))))))
298 (synopsis "TeX Live, a package of the TeX typesetting system")
299 (description
300 "TeX Live provides a comprehensive TeX document production system.
301 It includes all the major TeX-related programs, macro packages, and fonts
302 that are free software, including support for many languages around the
303 world.
304
305 This package contains the complete TeX Live distribution.")
306 (license (license:fsf-free "https://www.tug.org/texlive/copying.html"))
307 (home-page "https://www.tug.org/texlive/")))
308
309
310 ;; texlive-texmf-minimal is a pruned, small version of the texlive tree,
311 ;; in particular dropping documentation and fonts. It weighs in at 470 MiB
312 ;; instead of 4 GiB.
313 (define texlive-texmf-minimal
314 (package (inherit texlive-texmf)
315 (name "texlive-texmf-minimal")
316 (arguments
317 (substitute-keyword-arguments
318 (package-arguments texlive-texmf)
319 ((#:modules modules)
320 `((ice-9 ftw)
321 (srfi srfi-1)
322 ,@modules))
323 ((#:phases phases)
324 `(modify-phases ,phases
325 (add-after 'unpack 'prune
326 (lambda _
327 (define (delete subdir exclude)
328 "Delete all files and directories in SUBDIR except for those
329 given in the list EXCLUDE."
330 (with-directory-excursion subdir
331 (for-each delete-file-recursively
332 (lset-difference equal?
333 (scandir ".")
334 (append '("." "..")
335 exclude)))))
336 (with-directory-excursion "texmf-dist"
337 (for-each delete-file-recursively
338 '("doc" "source" "tex4ht"))
339 ;; Delete all subdirectories of "fonts", except for "tfm" and
340 ;; any directories named "cm".
341 (delete "fonts" '("afm" "map" "pk" "source" "tfm" "type1"))
342 (delete "fonts/afm" '("public"))
343 (delete "fonts/afm/public" '("amsfonts"))
344 (delete "fonts/afm/public/amsfonts" '("cm"))
345 (delete "fonts/map" '("dvips"))
346 (delete "fonts/map/dvips" '("cm"))
347 (delete "fonts/source" '("public"))
348 (delete "fonts/source/public" '("cm"))
349 (delete "fonts/tfm" '("public"))
350 (delete "fonts/type1" '("public"))
351 (delete "fonts/type1/public" '("amsfonts"))
352 (delete "fonts/type1/public/amsfonts" '("cm")))
353 #t))))))
354 (description
355 "TeX Live provides a comprehensive TeX document production system.
356 It includes all the major TeX-related programs, macro packages, and fonts
357 that are free software, including support for many languages around the
358 world.
359
360 This package contains a small subset of the texmf-dist data.")))
361
362
363 ;; texlive-minimal is the same as texlive, but using texlive-texmf-minimal
364 ;; instead of the full texlive-texmf. It can be used, for instance, as a
365 ;; native input to packages that need texlive to build their documentation.
366 (define-public texlive-minimal
367 (package (inherit texlive)
368 (name "texlive-minimal")
369 (inputs
370 `(("texlive-texmf" ,texlive-texmf-minimal)
371 ,@(alist-delete "texlive-texmf" (package-inputs texlive))))
372 (native-search-paths
373 (list (search-path-specification
374 (variable "TEXMFLOCAL")
375 (files '("share/texmf-local")))))
376 (description
377 "TeX Live provides a comprehensive TeX document production system.
378 It includes all the major TeX-related programs, macro packages, and fonts
379 that are free software, including support for many languages around the
380 world.
381
382 This package contains a small working part of the TeX Live distribution.")))
383
384
385 (define-public rubber
386 (package
387 (name "rubber")
388 (version "1.1")
389 (source (origin
390 (method url-fetch)
391 (uri (list (string-append "https://launchpad.net/rubber/trunk/"
392 version "/+download/rubber-"
393 version ".tar.gz")
394 (string-append "http://ebeffara.free.fr/pub/rubber-"
395 version ".tar.gz")))
396 (sha256
397 (base32
398 "1xbkv8ll889933gyi2a5hj7hhh216k04gn8fwz5lfv5iz8s34gbq"))))
399 (build-system gnu-build-system)
400 (arguments '(#:tests? #f)) ; no `check' target
401 (inputs `(("texinfo" ,texinfo)
402 ("python" ,python-2) ; incompatible with Python 3 (print syntax)
403 ("which" ,which)))
404 (home-page "https://launchpad.net/rubber")
405 (synopsis "Wrapper for LaTeX and friends")
406 (description
407 "Rubber is a program whose purpose is to handle all tasks related to the
408 compilation of LaTeX documents. This includes compiling the document itself,
409 of course, enough times so that all references are defined, and running BibTeX
410 to manage bibliographic references. Automatic execution of dvips to produce
411 PostScript documents is also included, as well as usage of pdfLaTeX to produce
412 PDF documents.")
413 (license license:gpl2+)))
414
415 (define-public texmaker
416 (package
417 (name "texmaker")
418 (version "4.5")
419 (source (origin
420 (method url-fetch)
421 (uri (string-append "http://www.xm1math.net/texmaker/texmaker-"
422 version ".tar.bz2"))
423 (sha256
424 (base32
425 "056njk6j8wma23mlp7xa3rgfaxx0q8ynwx8wkmj7iy0b85p9ds9c"))))
426 (build-system gnu-build-system)
427 (arguments
428 `(#:phases
429 (modify-phases %standard-phases
430 ;; Qt has its own configuration utility.
431 (replace 'configure
432 (lambda* (#:key outputs #:allow-other-keys)
433 (let ((out (assoc-ref outputs "out")))
434 (zero? (system* "qmake"
435 (string-append "PREFIX=" out)
436 (string-append "DESKTOPDIR=" out
437 "/share/applications")
438 (string-append "ICONDIR=" out "/share/pixmaps")
439 "texmaker.pro"))))))))
440 (inputs
441 `(("poppler-qt5" ,poppler-qt5)
442 ("qt" ,qt)
443 ("zlib" ,zlib)))
444 (native-inputs
445 `(("pkg-config" ,pkg-config)))
446 (home-page "http://www.xm1math.net/texmaker/")
447 (synopsis "LaTeX editor")
448 (description "Texmaker is a program that integrates many tools needed to
449 develop documents with LaTeX, in a single application.")
450 (license license:gpl2+)))
451
452
453 (define-public teximpatient
454 (package
455 (name "teximpatient")
456 (version "2.4")
457 (source (origin
458 (method url-fetch)
459 (uri (string-append "mirror://gnu/" name "/" name "-"
460 version ".tar.gz"))
461 (sha256
462 (base32
463 "0h56w22d99dh4fgld4ssik8ggnmhmrrbnrn1lnxi1zr0miphn1sd"))))
464 (build-system gnu-build-system)
465 (arguments
466 `(#:phases
467 (modify-phases %standard-phases
468 (delete 'check)
469 ;; Unfortunately some mistakes have been made in packaging.
470 ;; Work around them here ...
471 (replace 'unpack
472 (lambda* (#:key inputs outputs #:allow-other-keys)
473 (let ((srcdir "teximpatient-2.4"))
474 (system* "tar" "-xzf" (assoc-ref inputs "source")
475 (string-append "--one-top-level=" srcdir))
476 (delete-file (string-append srcdir "/book.pdf"))
477 (install-file (car
478 (find-files
479 (assoc-ref inputs "automake")
480 "^install-sh$"))
481 srcdir)
482 (chdir srcdir)))))))
483 (native-inputs
484 `(("texlive" ,texlive)
485 ("automake" ,automake)))
486 (home-page "http://www.gnu.org/software/teximpatient")
487 (synopsis "Book on TeX, plain TeX and Eplain")
488 (description "@i{TeX for the Impatient} is a ~350 page book on TeX,
489 plain TeX, and Eplain, originally written by Paul Abrahams, Kathryn Hargreaves,
490 and Karl Berry.")
491 (license license:fdl1.3+)))