1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015, 2016 Federico Beffa <beffa@fbengineering.ch>
3 ;;; Copyright © 2015 Siniša Biđin <sinisa@bidin.eu>
4 ;;; Copyright © 2015 Paul van der Walt <paul@denknerd.org>
5 ;;; Copyright © 2015, 2019 Eric Bavier <bavier@member.fsf.org>
6 ;;; Copyright © 2016, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
7 ;;; Copyright © 2016, 2017 Nikita <nikita@n0.is>
8 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
9 ;;; Copyright © 2015, 2016, 2017, 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
10 ;;; Copyright © 2016, 2017 David Craven <david@craven.ch>
11 ;;; Copyright © 2017 Danny Milosavljevic <dannym@scratchpost.org>
12 ;;; Copyright © 2017 Peter Mikkelsen <petermikkelsen10@gmail.com>
13 ;;; Copyright © 2017, 2018 Alex Vong <alexvong1995@gmail.com>
14 ;;; Copyright © 2017 rsiddharth <s@ricketyspace.net>
15 ;;; Copyright © 2017, 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
16 ;;; Copyright © 2018 Tonton <tonton@riseup.net>
17 ;;; Copyright © 2018, 2019 Timothy Sample <samplet@ngyro.com>
18 ;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net>
19 ;;; Copyright © 2018, 2019 Gabriel Hondet <gabrielhondet@gmail.com>
20 ;;; Copyright © 2019 Robert Vollmert <rob@vllmrt.net>
21 ;;; Copyright © 2019 Jacob MacDonald <jaccarmac@gmail.com>
22 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
24 ;;; This file is part of GNU Guix.
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.
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.
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/>.
39 (define-module (gnu packages haskell)
40 #:use-module (gnu packages)
41 #:use-module (gnu packages bootstrap)
42 #:use-module (gnu packages elf)
43 #:use-module (gnu packages ghostscript)
44 #:use-module (gnu packages libffi)
45 #:use-module (gnu packages lisp)
46 #:use-module (gnu packages multiprecision)
47 #:use-module (gnu packages ncurses)
48 #:use-module (gnu packages perl)
49 #:use-module (gnu packages python)
50 #:use-module (guix build-system gnu)
51 #:use-module (guix download)
52 #:use-module (guix git-download)
53 #:use-module ((guix licenses) #:prefix license:)
54 #:use-module (guix packages)
55 #:use-module (guix utils)
56 #:use-module (ice-9 match)
57 #:use-module (ice-9 regex))
59 (define-public cl-yale-haskell
60 (let ((commit "85f94c72a16c5f70301dd8db04cde9de2d7dd270")
63 (name "cl-yale-haskell")
64 (version (string-append "2.0.5-" revision "." (string-take commit 9)))
68 (url "https://git.elephly.net/software/yale-haskell.git")
70 (file-name (string-append "yale-haskell-" commit "-checkout"))
73 "0bal3m6ryrjamz5p93bhs9rp5msk8k7lpcqr44wd7xs9b9k8w74g"))))
74 (build-system gnu-build-system)
76 `(#:tests? #f ; no tests
77 ;; Stripping binaries leads to a broken executable lisp system image.
80 (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
82 (modify-phases %standard-phases
85 (setenv "PRELUDE" "./progs/prelude")
86 (setenv "HASKELL_LIBRARY" "./progs/lib")
87 (setenv "PRELUDEBIN" "./progs/prelude/clisp")
88 (setenv "HASKELLPROG" "./bin/clisp-haskell")
92 (home-page "https://git.elephly.net/software/yale-haskell.git")
93 (synopsis "Port of the Yale Haskell system to CLISP")
94 (description "This package provides the Yale Haskell system running on
96 (license license:bsd-4))))
98 (define ghc-bootstrap-x86_64-7.8.4
102 "https://www.haskell.org/ghc/dist/7.8.4/ghc-7.8.4-x86_64-unknown-linux-deb7.tar.xz")
105 "13azsl53xgj20mi1hj9x0xb32vvcvs6cpmvwx6znxhas7blh0bpn"))))
107 (define ghc-bootstrap-i686-7.8.4
111 "https://www.haskell.org/ghc/dist/7.8.4/ghc-7.8.4-i386-unknown-linux-deb7.tar.xz")
114 "0wj5s435j0zgww70bj1d3f6wvnnpzlxwvwcyh2qv4qjq5z8j64kg"))))
116 ;; 43 tests out of 3965 fail.
118 ;; Most of them do not appear to be serious:
120 ;; - some tests generate files referring to "/bin/sh" and "/bin/ls". I've not
121 ;; figured out how these references are generated.
123 ;; - Some tests allocate more memory than expected (ca. 3% above upper limit)
125 ;; - Some tests try to load unavailable libriries: Control.Concurrent.STM,
126 ;; Data.Vector, Control.Monad.State.
128 ;; - Test posix010 tries to check the existence of a user on the system:
129 ;; getUserEntryForName: does not exist (no such user)
137 (uri (string-append "https://www.haskell.org/ghc/dist/"
138 version "/" name "-" version "-src.tar.xz"))
141 "1x8m4rp2v7ydnrz6z9g8x7z3x3d3pxhv2pixy7i7hkbqbdsp7kal"))))
142 (build-system gnu-build-system)
143 (supported-systems '("i686-linux" "x86_64-linux"))
144 (outputs '("out" "doc"))
153 "https://www.haskell.org/ghc/dist/"
154 version "/" name "-" version "-testsuite.tar.xz"))
157 "0qp9da9ar87zbyn6wjgacd2ic1vgzbi3cklxnhsmjqyafv9qaj4b"))))))
160 ("python" ,python-2) ; for tests (fails with python-3)
161 ("ghostscript" ,ghostscript) ; for tests
162 ("patchelf" ,patchelf)
163 ;; GHC is built with GHC. Therefore we need bootstrap binaries.
165 ,(if (string-match "x86_64" (or (%current-target-system) (%current-system)))
166 ghc-bootstrap-x86_64-7.8.4
167 ghc-bootstrap-i686-7.8.4))))
169 `(#:test-target "test"
170 ;; We get a smaller number of test failures by disabling parallel test
174 ;; Don't pass --build=<triplet>, because the configure script
175 ;; auto-detects slightly different triplets for --host and --target and
176 ;; then complains that they don't match.
179 #:modules ((guix build gnu-build-system)
185 (string-append "--with-gmp-libraries="
186 (assoc-ref %build-inputs "gmp") "/lib")
187 (string-append "--with-gmp-includes="
188 (assoc-ref %build-inputs "gmp") "/include")
189 "--with-system-libffi"
190 (string-append "--with-ffi-libraries="
191 (assoc-ref %build-inputs "libffi") "/lib")
192 (string-append "--with-ffi-includes="
193 (assoc-ref %build-inputs "libffi") "/include"))
194 ;; FIXME: The user-guide needs dblatex, docbook-xsl and docbook-utils.
195 ;; Currently we do not have the last one.
197 ;; (list "BUILD_DOCBOOK_HTML = YES")
199 (let* ((ghc-bootstrap-path
200 (string-append (getcwd) "/" ,name "-" ,version "/ghc-bin"))
201 (ghc-bootstrap-prefix
202 (string-append ghc-bootstrap-path "/usr" )))
204 'unpack-bin 'unpack-testsuite-and-fix-bins
205 (lambda* (#:key inputs outputs #:allow-other-keys)
206 (with-directory-excursion ".."
207 (copy-file (assoc-ref inputs "ghc-testsuite")
208 "ghc-testsuite.tar.xz")
209 (invoke "tar" "xvf" "ghc-testsuite.tar.xz"))
211 (list "testsuite/timeout/Makefile"
212 "testsuite/timeout/timeout.py"
213 "testsuite/timeout/timeout.hs"
214 "testsuite/tests/rename/prog006/Setup.lhs"
215 "testsuite/tests/programs/life_space_leak/life.test"
216 "libraries/process/System/Process/Internals.hs"
217 "libraries/unix/cbits/execvpe.c")
218 (("/bin/sh") (which "sh"))
223 (lambda* (#:key inputs outputs #:allow-other-keys)
224 (mkdir-p ghc-bootstrap-prefix)
225 (with-directory-excursion ghc-bootstrap-path
226 (copy-file (assoc-ref inputs "ghc-binary")
228 (invoke "tar" "xvf" "ghc-bin.tar.xz")))
230 'install-bin 'configure-bin
231 (lambda* (#:key inputs outputs #:allow-other-keys)
234 "./utils/ghc-pwd/dist-install/build/tmp/ghc-pwd"
235 "./utils/hpc/dist-install/build/tmp/hpc"
236 "./utils/haddock/dist/build/tmp/haddock"
237 "./utils/hsc2hs/dist-install/build/tmp/hsc2hs"
238 "./utils/runghc/dist-install/build/tmp/runghc"
239 "./utils/ghc-cabal/dist-install/build/tmp/ghc-cabal"
240 "./utils/hp2ps/dist/build/tmp/hp2ps"
241 "./utils/ghc-pkg/dist-install/build/tmp/ghc-pkg"
242 "./utils/unlit/dist/build/tmp/unlit"
243 "./ghc/stage2/build/tmp/ghc-stage2"))
244 (gmp (assoc-ref inputs "gmp"))
245 (gmp-lib (string-append gmp "/lib"))
246 (gmp-include (string-append gmp "/include"))
248 (string-append (assoc-ref inputs "ncurses") "/lib"))
249 (ld-so (string-append (assoc-ref inputs "libc")
250 ,(glibc-dynamic-linker)))
252 (string-append ghc-bootstrap-prefix
253 "/lib/ghc-7.8.4/terminfo-0.4.0.0")))
254 (with-directory-excursion
255 (string-append ghc-bootstrap-path "/ghc-7.8.4")
256 (setenv "CONFIG_SHELL" (which "bash"))
257 (setenv "LD_LIBRARY_PATH" gmp-lib)
258 ;; The binaries have "/lib64/ld-linux-x86-64.so.2" hardcoded.
260 (cut invoke "patchelf" "--set-interpreter" ld-so <>)
262 ;; The binaries include a reference to libtinfo.so.5 which
263 ;; is a subset of libncurses.so.5. We create a symlink in a
264 ;; directory included in the bootstrap binaries rpath.
265 (mkdir-p libtinfo-dir)
267 (string-append ncurses-lib "/libncursesw.so."
268 ;; Extract "6.0" from "6.0-20170930" if a
269 ;; dash-separated version tag exists.
270 ,(let* ((v (package-version ncurses))
271 (d (or (string-index v #\-)
273 (version-major+minor (string-take v d))))
274 (string-append libtinfo-dir "/libtinfo.so.5"))
277 (string-append (getenv "PATH") ":"
278 ghc-bootstrap-prefix "/bin"))
280 (string-append (getcwd) "/configure")
281 (string-append "--prefix=" ghc-bootstrap-prefix)
282 (string-append "--with-gmp-libraries=" gmp-lib)
283 (string-append "--with-gmp-includes=" gmp-include)))))
285 'configure 'install-bin
286 (lambda* (#:key inputs outputs #:allow-other-keys)
287 (with-directory-excursion
288 (string-append ghc-bootstrap-path "/ghc-7.8.4")
289 (invoke "make" "install")))
290 %standard-phases)))))))
291 (native-search-paths (list (search-path-specification
292 (variable "GHC_PACKAGE_PATH")
294 (string-append "lib/ghc-" version)))
295 (file-pattern ".*\\.conf\\.d$")
296 (file-type 'directory))))
297 (home-page "https://www.haskell.org/ghc")
298 (synopsis "The Glasgow Haskell Compiler")
300 "The Glasgow Haskell Compiler (GHC) is a state-of-the-art compiler and
301 interactive environment for the functional language Haskell.")
302 (license license:bsd-3)))
304 (define-public ghc-8.0
311 (uri (string-append "https://www.haskell.org/ghc/dist/"
312 version "/" name "-" version "-src.tar.xz"))
314 (base32 "1c8qc4fhkycynk4g1f9hvk53dj6a1vvqi6bklqznns6hw59m8qhi"))
316 (search-patches "ghc-8.0-fall-back-to-madv_dontneed.patch"))))
317 (build-system gnu-build-system)
318 (supported-systems '("i686-linux" "x86_64-linux"))
319 (outputs '("out" "doc"))
328 "https://www.haskell.org/ghc/dist/"
329 version "/" name "-" version "-testsuite.tar.xz"))
331 (base32 "1wjc3x68l305bl1h1ijd3yhqp2vqj83lkp3kqbr94qmmkqlms8sj"))))))
334 ("python" ,python-2) ; for tests
335 ("ghostscript" ,ghostscript) ; for tests
336 ;; GHC is built with GHC.
337 ("ghc-bootstrap" ,ghc-7)))
339 `(#:test-target "test"
340 ;; We get a smaller number of test failures by disabling parallel test
344 ;; Don't pass --build=<triplet>, because the configure script
345 ;; auto-detects slightly different triplets for --host and --target and
346 ;; then complains that they don't match.
351 (string-append "--with-gmp-libraries="
352 (assoc-ref %build-inputs "gmp") "/lib")
353 (string-append "--with-gmp-includes="
354 (assoc-ref %build-inputs "gmp") "/include")
355 "--with-system-libffi"
356 (string-append "--with-ffi-libraries="
357 (assoc-ref %build-inputs "libffi") "/lib")
358 (string-append "--with-ffi-includes="
359 (assoc-ref %build-inputs "libffi") "/include")
360 (string-append "--with-curses-libraries="
361 (assoc-ref %build-inputs "ncurses") "/lib")
362 (string-append "--with-curses-includes="
363 (assoc-ref %build-inputs "ncurses") "/include"))
365 (modify-phases %standard-phases
366 (add-after 'unpack 'unpack-testsuite
367 (lambda* (#:key inputs #:allow-other-keys)
368 (with-directory-excursion ".."
369 (copy-file (assoc-ref inputs "ghc-testsuite")
370 "ghc-testsuite.tar.xz")
371 (zero? (system* "tar" "xvf" "ghc-testsuite.tar.xz")))))
372 (add-before 'build 'fix-lib-paths
375 (list "libraries/process/System/Process/Posix.hs"
376 "libraries/process/tests/process001.hs"
377 "libraries/process/tests/process002.hs"
378 "libraries/unix/cbits/execvpe.c")
379 (("/bin/sh") (which "sh"))
380 (("/bin/ls") (which "ls")))
382 (add-before 'build 'fix-environment
384 (unsetenv "GHC_PACKAGE_PATH")
385 (setenv "CONFIG_SHELL" (which "bash"))
387 (add-before 'check 'fix-testsuite
390 (list "testsuite/timeout/Makefile"
391 "testsuite/timeout/timeout.py"
392 "testsuite/timeout/timeout.hs"
393 "testsuite/tests/programs/life_space_leak/life.test")
394 (("/bin/sh") (which "sh"))
397 (native-search-paths (list (search-path-specification
398 (variable "GHC_PACKAGE_PATH")
400 (string-append "lib/ghc-" version)))
401 (file-pattern ".*\\.conf\\.d$")
402 (file-type 'directory))))
403 (home-page "https://www.haskell.org/ghc")
404 (synopsis "The Glasgow Haskell Compiler")
406 "The Glasgow Haskell Compiler (GHC) is a state-of-the-art compiler and
407 interactive environment for the functional language Haskell.")
408 (license license:bsd-3)))
410 (define-public ghc-8.4
411 (package (inherit ghc-8.0)
417 (uri (string-append "https://www.haskell.org/ghc/dist/"
418 version "/" name "-" version "-src.tar.xz"))
420 (base32 "1ch4j2asg7pr52ai1hwzykxyj553wndg7wq93i47ql4fllspf48i"))))
427 ("python" ,python) ; for tests
428 ("ghostscript" ,ghostscript) ; for tests
429 ;; GHC 8.4.3 is built with GHC 8.
430 ("ghc-bootstrap" ,ghc-8.0)
435 "https://www.haskell.org/ghc/dist/"
436 version "/" name "-" version "-testsuite.tar.xz"))
439 "0s8lf9sxj7n89pjagi58b3fahnp34qvmwhnn0j1fbg6955vbrfj6"))))))
441 `(#:test-target "test"
442 ;; We get a smaller number of test failures by disabling parallel test
446 ;; Don't pass --build=<triplet>, because the configure script
447 ;; auto-detects slightly different triplets for --host and --target and
448 ;; then complains that they don't match.
453 (string-append "--with-gmp-libraries="
454 (assoc-ref %build-inputs "gmp") "/lib")
455 (string-append "--with-gmp-includes="
456 (assoc-ref %build-inputs "gmp") "/include")
457 "--with-system-libffi"
458 (string-append "--with-ffi-libraries="
459 (assoc-ref %build-inputs "libffi") "/lib")
460 (string-append "--with-ffi-includes="
461 (assoc-ref %build-inputs "libffi") "/include")
462 (string-append "--with-curses-libraries="
463 (assoc-ref %build-inputs "ncurses") "/lib")
464 (string-append "--with-curses-includes="
465 (assoc-ref %build-inputs "ncurses") "/include"))
467 (modify-phases %standard-phases
468 (add-after 'unpack 'unpack-testsuite
469 (lambda* (#:key inputs #:allow-other-keys)
471 (assoc-ref inputs "ghc-testsuite")
472 "--strip-components=1")
474 ;; This phase patches the 'ghc-pkg' command so that it sorts the list
475 ;; of packages in the binary cache it generates.
476 (add-before 'build 'fix-ghc-pkg-nondeterminism
478 (substitute* "utils/ghc-pkg/Main.hs"
479 (("confs = map \\(path </>\\) \\$ filter \\(\".conf\" `isSuffixOf`\\) fs")
480 "confs = map (path </>) $ filter (\".conf\" `isSuffixOf`) (sort fs)"))
482 (add-after 'unpack-testsuite 'fix-shell-wrappers
484 (substitute* '("driver/ghci/ghc.mk"
485 "utils/mkdirhier/ghc.mk"
486 "rules/shell-wrapper.mk")
487 (("echo '#!/bin/sh'")
488 (format #f "echo '#!~a'" (which "sh"))))
490 ;; This is necessary because the configure system no longer uses
491 ;; “AC_PATH_” but “AC_CHECK_”, setting the variables to just the
492 ;; plain command names.
493 (add-before 'configure 'set-target-programs
494 (lambda* (#:key inputs #:allow-other-keys)
495 (let ((binutils (assoc-ref inputs "binutils"))
496 (gcc (assoc-ref inputs "gcc"))
497 (ld-wrapper (assoc-ref inputs "ld-wrapper")))
498 (setenv "CC" (string-append gcc "/bin/gcc"))
499 (setenv "CXX" (string-append gcc "/bin/g++"))
500 (setenv "LD" (string-append ld-wrapper "/bin/ld"))
501 (setenv "NM" (string-append binutils "/bin/nm"))
502 (setenv "RANLIB" (string-append binutils "/bin/ranlib"))
503 (setenv "STRIP" (string-append binutils "/bin/strip"))
504 ;; The 'ar' command does not follow the same pattern.
505 (setenv "fp_prog_ar" (string-append binutils "/bin/ar"))
507 (add-before 'build 'fix-references
509 (substitute* '("testsuite/timeout/Makefile"
510 "testsuite/timeout/timeout.py"
511 "testsuite/timeout/timeout.hs"
512 "testsuite/tests/programs/life_space_leak/life.test"
514 "libraries/process/System/Process/Posix.hs"
515 "libraries/process/tests/process001.hs"
516 "libraries/process/tests/process002.hs"
517 "libraries/unix/cbits/execvpe.c")
518 (("/bin/sh") (which "sh"))
519 (("/bin/ls") (which "ls"))
522 (add-before 'build 'fix-environment
524 (unsetenv "GHC_PACKAGE_PATH")
525 (setenv "CONFIG_SHELL" (which "bash"))
527 (native-search-paths (list (search-path-specification
528 (variable "GHC_PACKAGE_PATH")
530 (string-append "lib/ghc-" version)))
531 (file-pattern ".*\\.conf\\.d$")
532 (file-type 'directory))))))
534 (define-public ghc-8.6
535 (package (inherit ghc-8.4)
541 (uri (string-append "https://www.haskell.org/ghc/dist/"
542 version "/" name "-" version "-src.tar.xz"))
544 (base32 "0qg3zsmbk4rkwkc3jpas3zs74qaxmw4sp4v1mhsbj0a0dzls2jjd"))))
546 `(;; GHC 8.6.5 must be built with GHC >= 8.2.
547 ("ghc-bootstrap" ,ghc-8.4)
552 "https://www.haskell.org/ghc/dist/"
553 version "/" name "-" version "-testsuite.tar.xz"))
554 (patches (search-patches "ghc-testsuite-dlopen-pie.patch"))
557 "0pw9r91g2np3i806g2f4f8z4jfdd7mx226cmdizk4swa7av1qf91"))))
558 ,@(filter (match-lambda
559 (("ghc-bootstrap" . _) #f)
560 (("ghc-testsuite" . _) #f)
562 (package-native-inputs ghc-8.4))))
564 (substitute-keyword-arguments (package-arguments ghc-8.4)
565 ((#:make-flags make-flags ''())
566 `(cons "EXTRA_RUNTEST_OPTS=--skip-perf-tests"
568 ((#:phases phases '%standard-phases)
569 `(modify-phases ,phases
570 (add-after 'unpack-testsuite 'skip-tests
572 ;; These two tests refer to the root user, which doesn't exist
573 ;; (see <https://bugs.gnu.org/36692>).
574 (substitute* "libraries/unix/tests/all.T"
575 (("^test\\('T8108'") "# guix skipped: test('T8108'"))
576 (substitute* "libraries/unix/tests/libposix/all.T"
577 (("^test\\('posix010'") "# guix skipped: test('posix010'"))
579 (native-search-paths (list (search-path-specification
580 (variable "GHC_PACKAGE_PATH")
582 (string-append "lib/ghc-" version)))
583 (file-pattern ".*\\.conf\\.d$")
584 (file-type 'directory))))))
586 (define-public ghc-8 ghc-8.6)
588 (define-public ghc ghc-8)
590 ;;; haskell.scm ends here