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