gnu: emacs-svg-icon: Fix grammar.
[jackhill/guix/guix.git] / gnu / packages / haskell.scm
CommitLineData
246b3437 1;;; GNU Guix --- Functional package management for GNU
95595618 2;;; Copyright © 2015, 2016 Federico Beffa <beffa@fbengineering.ch>
df1db767 3;;; Copyright © 2015 Siniša Biđin <sinisa@bidin.eu>
0e03d76a 4;;; Copyright © 2015 Paul van der Walt <paul@denknerd.org>
fb038f32 5;;; Copyright © 2015, 2019 Eric Bavier <bavier@member.fsf.org>
2d040763 6;;; Copyright © 2016, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
3c986a7d 7;;; Copyright © 2016, 2017 Nikita <nikita@n0.is>
7531b1fc 8;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
f737d3dd 9;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020 Ricardo Wurmus <rekado@elephly.net>
c7a7129c 10;;; Copyright © 2016, 2017 David Craven <david@craven.ch>
ee719fba 11;;; Copyright © 2017 Danny Milosavljevic <dannym@scratchpost.org>
df7309fc 12;;; Copyright © 2017 Peter Mikkelsen <petermikkelsen10@gmail.com>
98b90194 13;;; Copyright © 2017, 2018 Alex Vong <alexvong1995@gmail.com>
78d8b8f3 14;;; Copyright © 2017 rsiddharth <s@ricketyspace.net>
233eb6c8 15;;; Copyright © 2017, 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
e5d92c1c 16;;; Copyright © 2018 Tonton <tonton@riseup.net>
54c9b5bf 17;;; Copyright © 2018, 2019, 2020 Timothy Sample <samplet@ngyro.com>
b1a16000 18;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net>
57cd7d92 19;;; Copyright © 2018, 2019 Gabriel Hondet <gabrielhondet@gmail.com>
a4f4e227 20;;; Copyright © 2019 Robert Vollmert <rob@vllmrt.net>
3c69d462 21;;; Copyright © 2019 Jacob MacDonald <jaccarmac@gmail.com>
c75db693 22;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
246b3437
FB
23;;;
24;;; This file is part of GNU Guix.
25;;;
26;;; GNU Guix is free software; you can redistribute it and/or modify it
27;;; under the terms of the GNU General Public License as published by
28;;; the Free Software Foundation; either version 3 of the License, or (at
29;;; your option) any later version.
30;;;
31;;; GNU Guix is distributed in the hope that it will be useful, but
32;;; WITHOUT ANY WARRANTY; without even the implied warranty of
33;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34;;; GNU General Public License for more details.
35;;;
36;;; You should have received a copy of the GNU General Public License
37;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
38
39(define-module (gnu packages haskell)
d8e85b20 40 #:use-module (gnu packages)
c0d5b645 41 #:use-module (gnu packages bootstrap)
246b3437 42 #:use-module (gnu packages elf)
246b3437 43 #:use-module (gnu packages ghostscript)
c0d5b645 44 #:use-module (gnu packages libffi)
95e654ae 45 #:use-module (gnu packages lisp)
246b3437
FB
46 #:use-module (gnu packages multiprecision)
47 #:use-module (gnu packages ncurses)
c0d5b645 48 #:use-module (gnu packages perl)
c0d5b645 49 #:use-module (gnu packages python)
54c9b5bf 50 #:use-module (gnu packages version-control)
c0d5b645 51 #:use-module (guix build-system gnu)
c0d5b645 52 #:use-module (guix download)
ee719fba 53 #:use-module (guix git-download)
c0d5b645
DC
54 #:use-module ((guix licenses) #:prefix license:)
55 #:use-module (guix packages)
56 #:use-module (guix utils)
cce84c34 57 #:use-module (ice-9 match)
dddbc90c 58 #:use-module (ice-9 regex))
246b3437 59
95e654ae
RW
60(define-public cl-yale-haskell
61 (let ((commit "85f94c72a16c5f70301dd8db04cde9de2d7dd270")
62 (revision "1"))
63 (package
64 (name "cl-yale-haskell")
65 (version (string-append "2.0.5-" revision "." (string-take commit 9)))
66 (source (origin
67 (method git-fetch)
68 (uri (git-reference
98b90194 69 (url "https://git.elephly.net/software/yale-haskell.git")
95e654ae
RW
70 (commit commit)))
71 (file-name (string-append "yale-haskell-" commit "-checkout"))
72 (sha256
73 (base32
74 "0bal3m6ryrjamz5p93bhs9rp5msk8k7lpcqr44wd7xs9b9k8w74g"))))
75 (build-system gnu-build-system)
76 (arguments
77 `(#:tests? #f ; no tests
78 ;; Stripping binaries leads to a broken executable lisp system image.
79 #:strip-binaries? #f
80 #:make-flags
81 (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
82 #:phases
83 (modify-phases %standard-phases
84 (replace 'configure
85 (lambda _
86 (setenv "PRELUDE" "./progs/prelude")
87 (setenv "HASKELL_LIBRARY" "./progs/lib")
88 (setenv "PRELUDEBIN" "./progs/prelude/clisp")
89 (setenv "HASKELLPROG" "./bin/clisp-haskell")
90 #t)))))
91 (inputs
92 `(("clisp" ,clisp)))
98b90194 93 (home-page "https://git.elephly.net/software/yale-haskell.git")
95e654ae
RW
94 (synopsis "Port of the Yale Haskell system to CLISP")
95 (description "This package provides the Yale Haskell system running on
96top of CLISP.")
97 (license license:bsd-4))))
98
5868a8bf 99(define ghc-bootstrap-x86_64-7.8.4
246b3437
FB
100 (origin
101 (method url-fetch)
5868a8bf
FB
102 (uri
103 "https://www.haskell.org/ghc/dist/7.8.4/ghc-7.8.4-x86_64-unknown-linux-deb7.tar.xz")
246b3437
FB
104 (sha256
105 (base32
5868a8bf
FB
106 "13azsl53xgj20mi1hj9x0xb32vvcvs6cpmvwx6znxhas7blh0bpn"))))
107
108(define ghc-bootstrap-i686-7.8.4
109 (origin
110 (method url-fetch)
111 (uri
112 "https://www.haskell.org/ghc/dist/7.8.4/ghc-7.8.4-i386-unknown-linux-deb7.tar.xz")
113 (sha256
114 (base32
115 "0wj5s435j0zgww70bj1d3f6wvnnpzlxwvwcyh2qv4qjq5z8j64kg"))))
246b3437
FB
116
117;; 43 tests out of 3965 fail.
118;;
119;; Most of them do not appear to be serious:
120;;
121;; - some tests generate files referring to "/bin/sh" and "/bin/ls". I've not
122;; figured out how these references are generated.
123;;
124;; - Some tests allocate more memory than expected (ca. 3% above upper limit)
125;;
126;; - Some tests try to load unavailable libriries: Control.Concurrent.STM,
127;; Data.Vector, Control.Monad.State.
128;;
129;; - Test posix010 tries to check the existence of a user on the system:
130;; getUserEntryForName: does not exist (no such user)
e2dc97d6 131(define-public ghc-7
246b3437
FB
132 (package
133 (name "ghc")
0e03d76a 134 (version "7.10.2")
246b3437
FB
135 (source
136 (origin
137 (method url-fetch)
138 (uri (string-append "https://www.haskell.org/ghc/dist/"
139 version "/" name "-" version "-src.tar.xz"))
140 (sha256
141 (base32
0e03d76a 142 "1x8m4rp2v7ydnrz6z9g8x7z3x3d3pxhv2pixy7i7hkbqbdsp7kal"))))
246b3437
FB
143 (build-system gnu-build-system)
144 (supported-systems '("i686-linux" "x86_64-linux"))
145 (outputs '("out" "doc"))
146 (inputs
147 `(("gmp" ,gmp)
148 ("ncurses" ,ncurses)
149 ("libffi" ,libffi)
246b3437
FB
150 ("ghc-testsuite"
151 ,(origin
152 (method url-fetch)
153 (uri (string-append
154 "https://www.haskell.org/ghc/dist/"
155 version "/" name "-" version "-testsuite.tar.xz"))
156 (sha256
157 (base32
0e03d76a 158 "0qp9da9ar87zbyn6wjgacd2ic1vgzbi3cklxnhsmjqyafv9qaj4b"))))))
246b3437
FB
159 (native-inputs
160 `(("perl" ,perl)
161 ("python" ,python-2) ; for tests (fails with python-3)
162 ("ghostscript" ,ghostscript) ; for tests
163 ("patchelf" ,patchelf)
164 ;; GHC is built with GHC. Therefore we need bootstrap binaries.
5868a8bf
FB
165 ("ghc-binary"
166 ,(if (string-match "x86_64" (or (%current-target-system) (%current-system)))
167 ghc-bootstrap-x86_64-7.8.4
168 ghc-bootstrap-i686-7.8.4))))
246b3437
FB
169 (arguments
170 `(#:test-target "test"
171 ;; We get a smaller number of test failures by disabling parallel test
172 ;; execution.
173 #:parallel-tests? #f
fb799cb7 174
bbd19615
MW
175 ;; Don't pass --build=<triplet>, because the configure script
176 ;; auto-detects slightly different triplets for --host and --target and
177 ;; then complains that they don't match.
178 #:build #f
179
246b3437
FB
180 #:modules ((guix build gnu-build-system)
181 (guix build utils)
246b3437
FB
182 (srfi srfi-26)
183 (srfi srfi-1))
246b3437
FB
184 #:configure-flags
185 (list
186 (string-append "--with-gmp-libraries="
187 (assoc-ref %build-inputs "gmp") "/lib")
188 (string-append "--with-gmp-includes="
189 (assoc-ref %build-inputs "gmp") "/include")
190 "--with-system-libffi"
191 (string-append "--with-ffi-libraries="
192 (assoc-ref %build-inputs "libffi") "/lib")
193 (string-append "--with-ffi-includes="
194 (assoc-ref %build-inputs "libffi") "/include"))
195 ;; FIXME: The user-guide needs dblatex, docbook-xsl and docbook-utils.
196 ;; Currently we do not have the last one.
197 ;; #:make-flags
198 ;; (list "BUILD_DOCBOOK_HTML = YES")
199 #:phases
200 (let* ((ghc-bootstrap-path
201 (string-append (getcwd) "/" ,name "-" ,version "/ghc-bin"))
202 (ghc-bootstrap-prefix
203 (string-append ghc-bootstrap-path "/usr" )))
204 (alist-cons-after
48d21d6c 205 'unpack-bin 'unpack-testsuite-and-fix-bins
246b3437
FB
206 (lambda* (#:key inputs outputs #:allow-other-keys)
207 (with-directory-excursion ".."
208 (copy-file (assoc-ref inputs "ghc-testsuite")
209 "ghc-testsuite.tar.xz")
f20d1cfb 210 (invoke "tar" "xvf" "ghc-testsuite.tar.xz"))
246b3437
FB
211 (substitute*
212 (list "testsuite/timeout/Makefile"
213 "testsuite/timeout/timeout.py"
214 "testsuite/timeout/timeout.hs"
215 "testsuite/tests/rename/prog006/Setup.lhs"
48d21d6c
EB
216 "testsuite/tests/programs/life_space_leak/life.test"
217 "libraries/process/System/Process/Internals.hs"
218 "libraries/unix/cbits/execvpe.c")
246b3437
FB
219 (("/bin/sh") (which "sh"))
220 (("/bin/rm") "rm"))
221 #t)
222 (alist-cons-after
223 'unpack 'unpack-bin
224 (lambda* (#:key inputs outputs #:allow-other-keys)
225 (mkdir-p ghc-bootstrap-prefix)
226 (with-directory-excursion ghc-bootstrap-path
227 (copy-file (assoc-ref inputs "ghc-binary")
228 "ghc-bin.tar.xz")
f20d1cfb 229 (invoke "tar" "xvf" "ghc-bin.tar.xz")))
246b3437
FB
230 (alist-cons-before
231 'install-bin 'configure-bin
232 (lambda* (#:key inputs outputs #:allow-other-keys)
233 (let* ((binaries
234 (list
235 "./utils/ghc-pwd/dist-install/build/tmp/ghc-pwd"
236 "./utils/hpc/dist-install/build/tmp/hpc"
237 "./utils/haddock/dist/build/tmp/haddock"
238 "./utils/hsc2hs/dist-install/build/tmp/hsc2hs"
239 "./utils/runghc/dist-install/build/tmp/runghc"
240 "./utils/ghc-cabal/dist-install/build/tmp/ghc-cabal"
241 "./utils/hp2ps/dist/build/tmp/hp2ps"
242 "./utils/ghc-pkg/dist-install/build/tmp/ghc-pkg"
243 "./utils/unlit/dist/build/tmp/unlit"
244 "./ghc/stage2/build/tmp/ghc-stage2"))
245 (gmp (assoc-ref inputs "gmp"))
246 (gmp-lib (string-append gmp "/lib"))
247 (gmp-include (string-append gmp "/include"))
248 (ncurses-lib
249 (string-append (assoc-ref inputs "ncurses") "/lib"))
250 (ld-so (string-append (assoc-ref inputs "libc")
251 ,(glibc-dynamic-linker)))
252 (libtinfo-dir
253 (string-append ghc-bootstrap-prefix
254 "/lib/ghc-7.8.4/terminfo-0.4.0.0")))
255 (with-directory-excursion
0e03d76a 256 (string-append ghc-bootstrap-path "/ghc-7.8.4")
246b3437
FB
257 (setenv "CONFIG_SHELL" (which "bash"))
258 (setenv "LD_LIBRARY_PATH" gmp-lib)
259 ;; The binaries have "/lib64/ld-linux-x86-64.so.2" hardcoded.
260 (for-each
f20d1cfb 261 (cut invoke "patchelf" "--set-interpreter" ld-so <>)
246b3437
FB
262 binaries)
263 ;; The binaries include a reference to libtinfo.so.5 which
264 ;; is a subset of libncurses.so.5. We create a symlink in a
265 ;; directory included in the bootstrap binaries rpath.
266 (mkdir-p libtinfo-dir)
267 (symlink
268 (string-append ncurses-lib "/libncursesw.so."
74733195
RW
269 ;; Extract "6.0" from "6.0-20170930" if a
270 ;; dash-separated version tag exists.
ae785e5e 271 ,(let* ((v (package-version ncurses))
74733195
RW
272 (d (or (string-index v #\-)
273 (string-length v))))
ae785e5e 274 (version-major+minor (string-take v d))))
246b3437 275 (string-append libtinfo-dir "/libtinfo.so.5"))
ae785e5e 276
246b3437
FB
277 (setenv "PATH"
278 (string-append (getenv "PATH") ":"
279 ghc-bootstrap-prefix "/bin"))
f20d1cfb 280 (invoke
246b3437
FB
281 (string-append (getcwd) "/configure")
282 (string-append "--prefix=" ghc-bootstrap-prefix)
283 (string-append "--with-gmp-libraries=" gmp-lib)
284 (string-append "--with-gmp-includes=" gmp-include)))))
285 (alist-cons-before
286 'configure 'install-bin
287 (lambda* (#:key inputs outputs #:allow-other-keys)
288 (with-directory-excursion
0e03d76a 289 (string-append ghc-bootstrap-path "/ghc-7.8.4")
f20d1cfb 290 (invoke "make" "install")))
246b3437 291 %standard-phases)))))))
e17d5133
EB
292 (native-search-paths (list (search-path-specification
293 (variable "GHC_PACKAGE_PATH")
294 (files (list
295 (string-append "lib/ghc-" version)))
296 (file-pattern ".*\\.conf\\.d$")
297 (file-type 'directory))))
246b3437
FB
298 (home-page "https://www.haskell.org/ghc")
299 (synopsis "The Glasgow Haskell Compiler")
7d95c000
FB
300 (description
301 "The Glasgow Haskell Compiler (GHC) is a state-of-the-art compiler and
302interactive environment for the functional language Haskell.")
303 (license license:bsd-3)))
304
9587544b 305(define-public ghc-8.0
7d95c000
FB
306 (package
307 (name "ghc")
d8e85b20 308 (version "8.0.2")
7d95c000
FB
309 (source
310 (origin
311 (method url-fetch)
312 (uri (string-append "https://www.haskell.org/ghc/dist/"
313 version "/" name "-" version "-src.tar.xz"))
314 (sha256
d8e85b20
FB
315 (base32 "1c8qc4fhkycynk4g1f9hvk53dj6a1vvqi6bklqznns6hw59m8qhi"))
316 (patches
f4e18332 317 (search-patches "ghc-8.0-fall-back-to-madv_dontneed.patch"))))
7d95c000
FB
318 (build-system gnu-build-system)
319 (supported-systems '("i686-linux" "x86_64-linux"))
320 (outputs '("out" "doc"))
321 (inputs
322 `(("gmp" ,gmp)
323 ("ncurses" ,ncurses)
324 ("libffi" ,libffi)
7d95c000
FB
325 ("ghc-testsuite"
326 ,(origin
327 (method url-fetch)
328 (uri (string-append
329 "https://www.haskell.org/ghc/dist/"
330 version "/" name "-" version "-testsuite.tar.xz"))
331 (sha256
d8e85b20 332 (base32 "1wjc3x68l305bl1h1ijd3yhqp2vqj83lkp3kqbr94qmmkqlms8sj"))))))
7d95c000
FB
333 (native-inputs
334 `(("perl" ,perl)
335 ("python" ,python-2) ; for tests
336 ("ghostscript" ,ghostscript) ; for tests
337 ;; GHC is built with GHC.
e2dc97d6 338 ("ghc-bootstrap" ,ghc-7)))
7d95c000
FB
339 (arguments
340 `(#:test-target "test"
341 ;; We get a smaller number of test failures by disabling parallel test
342 ;; execution.
343 #:parallel-tests? #f
344
7d95c000
FB
345 ;; Don't pass --build=<triplet>, because the configure script
346 ;; auto-detects slightly different triplets for --host and --target and
347 ;; then complains that they don't match.
348 #:build #f
349
7d95c000
FB
350 #:configure-flags
351 (list
352 (string-append "--with-gmp-libraries="
353 (assoc-ref %build-inputs "gmp") "/lib")
354 (string-append "--with-gmp-includes="
355 (assoc-ref %build-inputs "gmp") "/include")
356 "--with-system-libffi"
357 (string-append "--with-ffi-libraries="
358 (assoc-ref %build-inputs "libffi") "/lib")
359 (string-append "--with-ffi-includes="
360 (assoc-ref %build-inputs "libffi") "/include")
361 (string-append "--with-curses-libraries="
362 (assoc-ref %build-inputs "ncurses") "/lib")
363 (string-append "--with-curses-includes="
364 (assoc-ref %build-inputs "ncurses") "/include"))
365 #:phases
366 (modify-phases %standard-phases
367 (add-after 'unpack 'unpack-testsuite
368 (lambda* (#:key inputs #:allow-other-keys)
369 (with-directory-excursion ".."
370 (copy-file (assoc-ref inputs "ghc-testsuite")
371 "ghc-testsuite.tar.xz")
372 (zero? (system* "tar" "xvf" "ghc-testsuite.tar.xz")))))
373 (add-before 'build 'fix-lib-paths
374 (lambda _
375 (substitute*
376 (list "libraries/process/System/Process/Posix.hs"
377 "libraries/process/tests/process001.hs"
378 "libraries/process/tests/process002.hs"
379 "libraries/unix/cbits/execvpe.c")
380 (("/bin/sh") (which "sh"))
381 (("/bin/ls") (which "ls")))
382 #t))
383 (add-before 'build 'fix-environment
384 (lambda _
385 (unsetenv "GHC_PACKAGE_PATH")
386 (setenv "CONFIG_SHELL" (which "bash"))
387 #t))
388 (add-before 'check 'fix-testsuite
389 (lambda _
390 (substitute*
391 (list "testsuite/timeout/Makefile"
392 "testsuite/timeout/timeout.py"
393 "testsuite/timeout/timeout.hs"
394 "testsuite/tests/programs/life_space_leak/life.test")
395 (("/bin/sh") (which "sh"))
396 (("/bin/rm") "rm"))
d8e85b20 397 #t)))))
7d95c000
FB
398 (native-search-paths (list (search-path-specification
399 (variable "GHC_PACKAGE_PATH")
400 (files (list
401 (string-append "lib/ghc-" version)))
402 (file-pattern ".*\\.conf\\.d$")
403 (file-type 'directory))))
404 (home-page "https://www.haskell.org/ghc")
405 (synopsis "The Glasgow Haskell Compiler")
246b3437
FB
406 (description
407 "The Glasgow Haskell Compiler (GHC) is a state-of-the-art compiler and
408interactive environment for the functional language Haskell.")
3ac73271 409 (license license:bsd-3)))
246b3437 410
a62ddb74 411(define-public ghc-8.4
9587544b
RW
412 (package (inherit ghc-8.0)
413 (name "ghc")
c711b6ab 414 (version "8.4.4")
9587544b
RW
415 (source
416 (origin
417 (method url-fetch)
418 (uri (string-append "https://www.haskell.org/ghc/dist/"
419 version "/" name "-" version "-src.tar.xz"))
420 (sha256
c711b6ab 421 (base32 "1ch4j2asg7pr52ai1hwzykxyj553wndg7wq93i47ql4fllspf48i"))))
9587544b
RW
422 (inputs
423 `(("gmp" ,gmp)
424 ("ncurses" ,ncurses)
a057b881 425 ("libffi" ,libffi)))
9587544b
RW
426 (native-inputs
427 `(("perl" ,perl)
428 ("python" ,python) ; for tests
429 ("ghostscript" ,ghostscript) ; for tests
430 ;; GHC 8.4.3 is built with GHC 8.
431 ("ghc-bootstrap" ,ghc-8.0)
432 ("ghc-testsuite"
433 ,(origin
434 (method url-fetch)
435 (uri (string-append
436 "https://www.haskell.org/ghc/dist/"
437 version "/" name "-" version "-testsuite.tar.xz"))
438 (sha256
439 (base32
c711b6ab 440 "0s8lf9sxj7n89pjagi58b3fahnp34qvmwhnn0j1fbg6955vbrfj6"))))))
9587544b
RW
441 (arguments
442 `(#:test-target "test"
443 ;; We get a smaller number of test failures by disabling parallel test
444 ;; execution.
445 #:parallel-tests? #f
446
9587544b
RW
447 ;; Don't pass --build=<triplet>, because the configure script
448 ;; auto-detects slightly different triplets for --host and --target and
449 ;; then complains that they don't match.
450 #:build #f
451
452 #:configure-flags
453 (list
454 (string-append "--with-gmp-libraries="
455 (assoc-ref %build-inputs "gmp") "/lib")
456 (string-append "--with-gmp-includes="
457 (assoc-ref %build-inputs "gmp") "/include")
458 "--with-system-libffi"
459 (string-append "--with-ffi-libraries="
460 (assoc-ref %build-inputs "libffi") "/lib")
461 (string-append "--with-ffi-includes="
462 (assoc-ref %build-inputs "libffi") "/include")
463 (string-append "--with-curses-libraries="
464 (assoc-ref %build-inputs "ncurses") "/lib")
465 (string-append "--with-curses-includes="
466 (assoc-ref %build-inputs "ncurses") "/include"))
467 #:phases
468 (modify-phases %standard-phases
469 (add-after 'unpack 'unpack-testsuite
470 (lambda* (#:key inputs #:allow-other-keys)
471 (invoke "tar" "xvf"
472 (assoc-ref inputs "ghc-testsuite")
473 "--strip-components=1")
474 #t))
5de93cdb
RW
475 ;; This phase patches the 'ghc-pkg' command so that it sorts the list
476 ;; of packages in the binary cache it generates.
477 (add-before 'build 'fix-ghc-pkg-nondeterminism
478 (lambda _
479 (substitute* "utils/ghc-pkg/Main.hs"
480 (("confs = map \\(path </>\\) \\$ filter \\(\".conf\" `isSuffixOf`\\) fs")
481 "confs = map (path </>) $ filter (\".conf\" `isSuffixOf`) (sort fs)"))
482 #t))
9587544b
RW
483 (add-after 'unpack-testsuite 'fix-shell-wrappers
484 (lambda _
485 (substitute* '("driver/ghci/ghc.mk"
486 "utils/mkdirhier/ghc.mk"
487 "rules/shell-wrapper.mk")
488 (("echo '#!/bin/sh'")
489 (format #f "echo '#!~a'" (which "sh"))))
490 #t))
491 ;; This is necessary because the configure system no longer uses
492 ;; “AC_PATH_” but “AC_CHECK_”, setting the variables to just the
493 ;; plain command names.
494 (add-before 'configure 'set-target-programs
495 (lambda* (#:key inputs #:allow-other-keys)
a057b881
MB
496 (let ((binutils (assoc-ref inputs "binutils"))
497 (gcc (assoc-ref inputs "gcc"))
498 (ld-wrapper (assoc-ref inputs "ld-wrapper")))
9587544b
RW
499 (setenv "CC" (string-append gcc "/bin/gcc"))
500 (setenv "CXX" (string-append gcc "/bin/g++"))
501 (setenv "LD" (string-append ld-wrapper "/bin/ld"))
502 (setenv "NM" (string-append binutils "/bin/nm"))
503 (setenv "RANLIB" (string-append binutils "/bin/ranlib"))
504 (setenv "STRIP" (string-append binutils "/bin/strip"))
505 ;; The 'ar' command does not follow the same pattern.
506 (setenv "fp_prog_ar" (string-append binutils "/bin/ar"))
507 #t)))
508 (add-before 'build 'fix-references
509 (lambda _
510 (substitute* '("testsuite/timeout/Makefile"
511 "testsuite/timeout/timeout.py"
512 "testsuite/timeout/timeout.hs"
513 "testsuite/tests/programs/life_space_leak/life.test"
514 ;; libraries
515 "libraries/process/System/Process/Posix.hs"
516 "libraries/process/tests/process001.hs"
517 "libraries/process/tests/process002.hs"
518 "libraries/unix/cbits/execvpe.c")
519 (("/bin/sh") (which "sh"))
520 (("/bin/ls") (which "ls"))
521 (("/bin/rm") "rm"))
522 #t))
523 (add-before 'build 'fix-environment
524 (lambda _
525 (unsetenv "GHC_PACKAGE_PATH")
526 (setenv "CONFIG_SHELL" (which "bash"))
527 #t)))))
528 (native-search-paths (list (search-path-specification
529 (variable "GHC_PACKAGE_PATH")
530 (files (list
531 (string-append "lib/ghc-" version)))
532 (file-pattern ".*\\.conf\\.d$")
533 (file-type 'directory))))))
534
cce84c34
RV
535(define-public ghc-8.6
536 (package (inherit ghc-8.4)
537 (name "ghc")
538 (version "8.6.5")
539 (source
540 (origin
541 (method url-fetch)
542 (uri (string-append "https://www.haskell.org/ghc/dist/"
543 version "/" name "-" version "-src.tar.xz"))
544 (sha256
545 (base32 "0qg3zsmbk4rkwkc3jpas3zs74qaxmw4sp4v1mhsbj0a0dzls2jjd"))))
546 (native-inputs
547 `(;; GHC 8.6.5 must be built with GHC >= 8.2.
548 ("ghc-bootstrap" ,ghc-8.4)
549 ("ghc-testsuite"
550 ,(origin
551 (method url-fetch)
552 (uri (string-append
553 "https://www.haskell.org/ghc/dist/"
554 version "/" name "-" version "-testsuite.tar.xz"))
c75db693 555 (patches (search-patches "ghc-testsuite-dlopen-pie.patch"))
cce84c34
RV
556 (sha256
557 (base32
558 "0pw9r91g2np3i806g2f4f8z4jfdd7mx226cmdizk4swa7av1qf91"))))
559 ,@(filter (match-lambda
560 (("ghc-bootstrap" . _) #f)
561 (("ghc-testsuite" . _) #f)
562 (_ #t))
563 (package-native-inputs ghc-8.4))))
564 (arguments
565 (substitute-keyword-arguments (package-arguments ghc-8.4)
566 ((#:make-flags make-flags ''())
567 `(cons "EXTRA_RUNTEST_OPTS=--skip-perf-tests"
568 ,make-flags))
569 ((#:phases phases '%standard-phases)
570 `(modify-phases ,phases
f737d3dd
RW
571 (add-after 'install 'remove-unnecessary-references
572 (lambda* (#:key outputs #:allow-other-keys)
573 (substitute* (find-files (string-append (assoc-ref outputs "out") "/lib/")
574 "settings")
575 (("/gnu/store/.*/bin/(.*)" m program) program))
576
577 ;; Remove references to "doc" output from "out" by rewriting
578 ;; the "haddock-interfaces" fields and removing the optional
579 ;; "haddock-html" field in the generated .conf files.
580 (let ((doc (assoc-ref outputs "doc"))
581 (out (assoc-ref outputs "out")))
582 (with-fluids ((%default-port-encoding #f))
583 (for-each (lambda (config-file)
584 (substitute* config-file
585 (("^haddock-html: .*") "\n")
586 (((format #f "^haddock-interfaces: ~a" doc))
587 (string-append "haddock-interfaces: " out))))
588 (find-files (string-append out "/lib") ".conf")))
589 ;; Move the referenced files to the "out" output.
590 (for-each (lambda (haddock-file)
591 (let* ((subdir (string-drop haddock-file (string-length doc)))
592 (new (string-append out subdir)))
593 (mkdir-p (dirname new))
594 (rename-file haddock-file new)))
595 (find-files doc "\\.haddock$")))
596 #t))
cce84c34
RV
597 (add-after 'unpack-testsuite 'skip-tests
598 (lambda _
2e9c43aa
MB
599 ;; These two tests refer to the root user, which doesn't exist
600 ;; (see <https://bugs.gnu.org/36692>).
cce84c34
RV
601 (substitute* "libraries/unix/tests/all.T"
602 (("^test\\('T8108'") "# guix skipped: test('T8108'"))
603 (substitute* "libraries/unix/tests/libposix/all.T"
604 (("^test\\('posix010'") "# guix skipped: test('posix010'"))
83aa6562
TS
605 #t))))))
606 (native-search-paths (list (search-path-specification
607 (variable "GHC_PACKAGE_PATH")
608 (files (list
609 (string-append "lib/ghc-" version)))
610 (file-pattern ".*\\.conf\\.d$")
611 (file-type 'directory))))))
cce84c34 612
54c9b5bf
TS
613(define-public ghc-8.8
614 (package (inherit ghc-8.6)
615 (name "ghc")
616 (version "8.8.3")
617 (source
618 (origin
619 (method url-fetch)
620 (uri (string-append "https://www.haskell.org/ghc/dist/"
621 version "/ghc-" version "-src.tar.xz"))
622 (sha256
623 (base32 "128g932i3wix6ic03v04nh5755vyjiidzri9iybwad72yfmc1p70"))))
624 (native-inputs
625 `(("ghc-bootstrap" ,ghc-8.6)
626 ("ghc-testsuite"
627 ,(origin
628 (method url-fetch)
629 (uri (string-append
630 "https://www.haskell.org/ghc/dist/"
631 version "/ghc-" version "-testsuite.tar.xz"))
632 (patches (search-patches "ghc-testsuite-dlopen-pie.patch"))
633 (sha256
634 (base32
635 "1l32mp94ll72skfsq1g2fqax4bkiw8b85gr3wd0bbqsqyi9a9jpr"))))
636 ("git" ,git) ; invoked during tests
637 ,@(filter (match-lambda
638 (("ghc-bootstrap" . _) #f)
639 (("ghc-testsuite" . _) #f)
640 (_ #t))
641 (package-native-inputs ghc-8.6))))
642 (arguments
643 (substitute-keyword-arguments (package-arguments ghc-8.6)
644 ((#:phases phases '%standard-phases)
645 `(modify-phases ,phases
646 (add-after 'unpack-testsuite 'skip-more-tests
647 (lambda _
648 ;; XXX: This test fails because our ld-wrapper script
649 ;; mangles the response file passed to the linker.
650 (substitute* "testsuite/tests/hp2ps/all.T"
651 (("^test\\('T15904'") "# guix skipped: test('T15904'"))
652 #t))))))
653 (native-search-paths (list (search-path-specification
654 (variable "GHC_PACKAGE_PATH")
655 (files (list
656 (string-append "lib/ghc-" version)))
657 (file-pattern ".*\\.conf\\.d$")
658 (file-type 'directory))))))
659
064a967b 660(define-public ghc-8 ghc-8.6)
a62ddb74 661
dde15fea 662(define-public ghc ghc-8)
e2dc97d6 663
246b3437 664;;; haskell.scm ends here