gnu: Add TeXLive.
[jackhill/guix/guix.git] / gnu / packages / texlive.scm
CommitLineData
eb0119ef
AE
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
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 (gnu packages texlive)
20 #:use-module ((guix licenses)
21 #:renamer (symbol-prefix-proc 'license:))
22 #:use-module (guix packages)
23 #:use-module (guix download)
24 #:use-module (guix build-system gnu)
25 #:use-module (gnu packages)
26 #:use-module (gnu packages compression)
27 #:use-module (gnu packages freetype)
28 #:use-module (gnu packages ghostscript)
29 #:use-module (gnu packages icu4c)
30 #:use-module (gnu packages libpng)
31 #:use-module (gnu packages pdf)
32 #:use-module (gnu packages perl)
33 #:use-module (gnu packages pkg-config)
34 #:use-module (gnu packages python)
35 #:use-module (gnu packages zip))
36
37(define texlive-extra-src
38 (origin
39 (method url-fetch)
40 (uri "ftp://tug.org/historic/systems/texlive/2012/texlive-20120701-extra.tar.xz")
41 (sha256 (base32
42 "0cb8fnv4x281gy5ka779f00ssdmdpjj4x3pkh9j9vq45hrwg3522"))))
43
44(define texlive-texmf-src
45 (origin
46 (method url-fetch)
47 (uri "ftp://tug.org/historic/systems/texlive/2012/texlive-20120701-texmf.tar.xz")
48 (sha256 (base32
49 "1fn1dg9k7pnh8a80j23zfkbrfnqyc4c2w4ss30dpkqj490nxsywq"))))
50
51(define-public texlive
52 (package
53 (name "texlive")
54 (version "2012")
55 (source (origin
56 (method url-fetch)
57 (uri "ftp://tug.org/historic/systems/texlive/2012/texlive-20120701-source.tar.xz")
58 (sha256 (base32
59 "10bcrdfsqnc6y3gqcb8ndnjy07i5kz63as39irbq4gmcbmyn2rln"))))
60 (build-system gnu-build-system)
61 (inputs `(("texlive-extra-src" ,texlive-extra-src)
62 ("texlive-texmf-src" ,texlive-texmf-src)
63 ("fontconfig" ,fontconfig)
64 ("freetype" ,freetype)
65 ("icu4c" ,icu4c)
66 ("ghostscript" ,ghostscript)
67 ("libpng" ,libpng)
68 ("perl" ,perl)
69 ("poppler" ,poppler)
70 ("pkg-config" ,pkg-config)
71 ;; FIXME: Add interpreters csh, fontforge and ruby,
72 ;; once they are available.
73 ("python" ,python)
74 ("teckit" ,teckit)
75 ("t1lib" ,t1lib)
76 ("zlib" ,zlib)
77 ("zziplib" ,zziplib)))
78 (outputs '("out" "data"))
79 (arguments
80 `(#:out-of-source? #t
81 #:configure-flags
82 `("--disable-native-texlive-build"
83 ;; Although the texmf and texmf-dist data is taken from
84 ;; texlive-texmf, setting datarootdir is still useful:
85 ;; "make install" creates symbolic links to scripts in this place.
86 ,(string-append "--datarootdir=" (assoc-ref %outputs "data"))
87 ,(string-append "--infodir=" (assoc-ref %outputs "out") "/share/info")
88 ,(string-append "--mandir=" (assoc-ref %outputs "out") "/share/man")
89 "--without-x" ; FIXME: Drop as soon as X is available.
90 "--with-system-freetype2"
91 ;; "--with-system-gd"
92 ;; "--with-system-graphite"
93 "--with-system-icu"
94 "--with-system-libgs"
95 "--with-system-libpng"
96 "--with-system-poppler"
97 "--with-system-t1lib"
98 "--with-system-teckit"
99 "--with-system-xpdf"
100 "--with-system-zlib"
101 "--with-system-zziplib")
102 #:phases
103 (alist-replace
104 'configure
105 (lambda* (#:key outputs #:allow-other-keys #:rest args)
106 (let ((configure (assoc-ref %standard-phases 'configure)))
107 (substitute* "utils/psutils/Makefile.in"
108 (("/usr/bin/env perl") (which "perl")))
109 (apply configure args)))
110 (alist-cons-after
111 'install 'postinst
112 (lambda* (#:key inputs outputs #:allow-other-keys #:rest args)
113 (let ((texlive-extra (assoc-ref inputs "texlive-extra-src"))
114 (texlive-texmf (assoc-ref inputs "texlive-texmf-src"))
115 (out (assoc-ref outputs "out"))
116 (data (assoc-ref outputs "data"))
117 (unpack (assoc-ref %standard-phases 'unpack))
118 (patch-source-shebangs
119 (assoc-ref %standard-phases 'patch-source-shebangs)))
120 ;; Create symbolic links for the latex variants and their
121 ;; man pages.
122 (with-directory-excursion (string-append out "/bin/")
123 (for-each symlink
124 '("pdftex" "pdftex" "xetex" "luatex")
125 '("latex" "pdflatex" "xelatex" "lualatex")))
126 (with-directory-excursion (string-append out "/share/man/man1/")
127 (symlink "luatex.1" "lualatex.1"))
128 ;; Delete texmf and texmf-dist from "data", since they
129 ;; will be reinstalled from texlive-texmf.
130 (system* "rm" "-r" (string-append data "/texmf"))
131 (system* "rm" "-r" (string-append data "/texmf-dist"))
132 ;; Unpack texlive-extra and install tlpkg.
133 (mkdir "texlive-extra")
134 (with-directory-excursion "texlive-extra"
135 (apply unpack (list #:source texlive-extra))
136 (apply patch-source-shebangs (list #:source texlive-extra))
137 (system* "mv" "tlpkg" data)
138 (chdir ".."))
139 ;; Unpack and install texlive-texmf.
140 (mkdir "texlive-texmf")
141 (with-directory-excursion "texlive-texmf"
142 (apply unpack (list #:source texlive-texmf))
143 (apply patch-source-shebangs (list #:source texlive-texmf))
144 ;; Register "data" for kpathsea in texmf.cnf.
145 (substitute* "texmf/web2c/texmf.cnf"
146 (("TEXMFROOT = \\$SELFAUTOPARENT")
147 (string-append "TEXMFROOT = " data)))
148 (system* "mv" "texmf" data)
149 (system* "mv" "texmf-dist" data)
150 (chdir ".."))
151 ;; texmf.cnf must also be placed in "out", since kpsewhich does
152 ;; not know about "data" until it has found this file.
153 (mkdir (string-append out "/share/texmf"))
154 (mkdir (string-append out "/share/texmf/web2c"))
155 (copy-file (string-append data "/texmf/web2c/texmf.cnf")
156 (string-append out "/share/texmf/web2c/texmf.cnf"))))
157 (alist-cons-after 'patch-shebangs 'texconfig
158 (lambda* (#:key outputs #:allow-other-keys)
159 (let ((out (assoc-ref outputs "out")))
160 ;; Configure the texlive system; inspired from
161 ;; http://slackbuilds.org/repository/13.37/office/texlive/
162 (setenv "PATH" (string-append (getenv "PATH") ":" out "/bin"))
163 (system* "updmap-sys" "--nohash" "--syncwithtrees")
164 (system* "mktexlsr")
165 (system* "fmtutil-sys" "--all")))
166 %standard-phases)))))
167 (synopsis "Tex Live, a package of the TeX typesetting system")
168 (description
169 "TeX Live provides a comprehensive TeX document production system.
170It includes all the major TeX-related programs, macro packages, and fonts
171that are free software, including support for many languages around the
172world.")
173 (license (license:fsf-free "http://tug.org/texlive/copying.html"))
174 (home-page "http://www.tug.org/texlive/")))