haskell.scm 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  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, 2021 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, 2020 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, 2020 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>
  23. ;;; Copyright © 2021 Matthew James Kraai <kraai@ftbfs.org>
  24. ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
  25. ;;;
  26. ;;; This file is part of GNU Guix.
  27. ;;;
  28. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  29. ;;; under the terms of the GNU General Public License as published by
  30. ;;; the Free Software Foundation; either version 3 of the License, or (at
  31. ;;; your option) any later version.
  32. ;;;
  33. ;;; GNU Guix is distributed in the hope that it will be useful, but
  34. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  35. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  36. ;;; GNU General Public License for more details.
  37. ;;;
  38. ;;; You should have received a copy of the GNU General Public License
  39. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  40. (define-module (gnu packages haskell)
  41. #:use-module (gnu packages)
  42. #:use-module (gnu packages bootstrap)
  43. #:use-module (gnu packages elf)
  44. #:use-module (gnu packages ghostscript)
  45. #:use-module (gnu packages libffi)
  46. #:use-module (gnu packages lisp)
  47. #:use-module (gnu packages multiprecision)
  48. #:use-module (gnu packages ncurses)
  49. #:use-module (gnu packages perl)
  50. #:use-module (gnu packages python)
  51. #:use-module (gnu packages version-control)
  52. #:use-module (guix build-system gnu)
  53. #:use-module (guix download)
  54. #:use-module (guix git-download)
  55. #:use-module ((guix licenses) #:prefix license:)
  56. #:use-module (guix packages)
  57. #:use-module (guix utils)
  58. #:use-module (ice-9 match)
  59. #:use-module (ice-9 regex))
  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
  69. (url "https://git.elephly.net/software/yale-haskell.git")
  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)))
  93. (home-page "https://git.elephly.net/software/yale-haskell.git")
  94. (synopsis "Port of the Yale Haskell system to CLISP")
  95. (description "This package provides the Yale Haskell system running on
  96. top of CLISP.")
  97. (license license:bsd-4))))
  98. (define ghc-bootstrap-x86_64-7.8.4
  99. (origin
  100. (method url-fetch)
  101. (uri
  102. "https://www.haskell.org/ghc/dist/7.8.4/ghc-7.8.4-x86_64-unknown-linux-deb7.tar.xz")
  103. (sha256
  104. (base32
  105. "13azsl53xgj20mi1hj9x0xb32vvcvs6cpmvwx6znxhas7blh0bpn"))))
  106. (define ghc-bootstrap-i686-7.8.4
  107. (origin
  108. (method url-fetch)
  109. (uri
  110. "https://www.haskell.org/ghc/dist/7.8.4/ghc-7.8.4-i386-unknown-linux-deb7.tar.xz")
  111. (sha256
  112. (base32
  113. "0wj5s435j0zgww70bj1d3f6wvnnpzlxwvwcyh2qv4qjq5z8j64kg"))))
  114. ;; 43 tests out of 3965 fail.
  115. ;;
  116. ;; Most of them do not appear to be serious:
  117. ;;
  118. ;; - some tests generate files referring to "/bin/sh" and "/bin/ls". I've not
  119. ;; figured out how these references are generated.
  120. ;;
  121. ;; - Some tests allocate more memory than expected (ca. 3% above upper limit)
  122. ;;
  123. ;; - Some tests try to load unavailable libriries: Control.Concurrent.STM,
  124. ;; Data.Vector, Control.Monad.State.
  125. ;;
  126. ;; - Test posix010 tries to check the existence of a user on the system:
  127. ;; getUserEntryForName: does not exist (no such user)
  128. (define-public ghc-7
  129. (package
  130. (name "ghc")
  131. (version "7.10.2")
  132. (source
  133. (origin
  134. (method url-fetch)
  135. (uri (string-append "https://www.haskell.org/ghc/dist/"
  136. version "/" name "-" version "-src.tar.xz"))
  137. (sha256
  138. (base32
  139. "1x8m4rp2v7ydnrz6z9g8x7z3x3d3pxhv2pixy7i7hkbqbdsp7kal"))))
  140. (build-system gnu-build-system)
  141. (supported-systems '("i686-linux" "x86_64-linux"))
  142. (outputs '("out" "doc"))
  143. (inputs
  144. `(("gmp" ,gmp)
  145. ("ncurses" ,ncurses)
  146. ("libffi" ,libffi)
  147. ("ghc-testsuite"
  148. ,(origin
  149. (method url-fetch)
  150. (uri (string-append
  151. "https://www.haskell.org/ghc/dist/"
  152. version "/" name "-" version "-testsuite.tar.xz"))
  153. (sha256
  154. (base32
  155. "0qp9da9ar87zbyn6wjgacd2ic1vgzbi3cklxnhsmjqyafv9qaj4b"))))))
  156. (native-inputs
  157. `(("perl" ,perl)
  158. ("python" ,python-2) ; for tests (fails with python-3)
  159. ("ghostscript" ,ghostscript) ; for tests
  160. ("patchelf" ,patchelf)
  161. ;; GHC is built with GHC. Therefore we need bootstrap binaries.
  162. ("ghc-binary"
  163. ,(if (string-match "x86_64" (or (%current-target-system) (%current-system)))
  164. ghc-bootstrap-x86_64-7.8.4
  165. ghc-bootstrap-i686-7.8.4))))
  166. (arguments
  167. `(#:test-target "test"
  168. ;; We get a smaller number of test failures by disabling parallel test
  169. ;; execution.
  170. #:parallel-tests? #f
  171. ;; Don't pass --build=<triplet>, because the configure script
  172. ;; auto-detects slightly different triplets for --host and --target and
  173. ;; then complains that they don't match.
  174. #:build #f
  175. #:modules ((guix build gnu-build-system)
  176. (guix build utils)
  177. (srfi srfi-26)
  178. (srfi srfi-1))
  179. #:configure-flags
  180. (list
  181. (string-append "--with-gmp-libraries="
  182. (assoc-ref %build-inputs "gmp") "/lib")
  183. (string-append "--with-gmp-includes="
  184. (assoc-ref %build-inputs "gmp") "/include")
  185. "--with-system-libffi"
  186. (string-append "--with-ffi-libraries="
  187. (assoc-ref %build-inputs "libffi") "/lib")
  188. (string-append "--with-ffi-includes="
  189. (assoc-ref %build-inputs "libffi") "/include"))
  190. ;; FIXME: The user-guide needs dblatex, docbook-xsl and docbook-utils.
  191. ;; Currently we do not have the last one.
  192. ;; #:make-flags
  193. ;; (list "BUILD_DOCBOOK_HTML = YES")
  194. #:phases
  195. (let* ((ghc-bootstrap-path
  196. (string-append (getcwd) "/" ,name "-" ,version "/ghc-bin"))
  197. (ghc-bootstrap-prefix
  198. (string-append ghc-bootstrap-path "/usr" )))
  199. (alist-cons-after
  200. 'unpack-bin 'unpack-testsuite-and-fix-bins
  201. (lambda* (#:key inputs outputs #:allow-other-keys)
  202. (with-directory-excursion ".."
  203. (copy-file (assoc-ref inputs "ghc-testsuite")
  204. "ghc-testsuite.tar.xz")
  205. (invoke "tar" "xvf" "ghc-testsuite.tar.xz"))
  206. (substitute*
  207. (list "testsuite/timeout/Makefile"
  208. "testsuite/timeout/timeout.py"
  209. "testsuite/timeout/timeout.hs"
  210. "testsuite/tests/rename/prog006/Setup.lhs"
  211. "testsuite/tests/programs/life_space_leak/life.test"
  212. "libraries/process/System/Process/Internals.hs"
  213. "libraries/unix/cbits/execvpe.c")
  214. (("/bin/sh") (which "sh"))
  215. (("/bin/rm") "rm"))
  216. #t)
  217. (alist-cons-after
  218. 'unpack 'unpack-bin
  219. (lambda* (#:key inputs outputs #:allow-other-keys)
  220. (mkdir-p ghc-bootstrap-prefix)
  221. (with-directory-excursion ghc-bootstrap-path
  222. (copy-file (assoc-ref inputs "ghc-binary")
  223. "ghc-bin.tar.xz")
  224. (invoke "tar" "xvf" "ghc-bin.tar.xz")))
  225. (alist-cons-before
  226. 'install-bin 'configure-bin
  227. (lambda* (#:key inputs outputs #:allow-other-keys)
  228. (let* ((binaries
  229. (list
  230. "./utils/ghc-pwd/dist-install/build/tmp/ghc-pwd"
  231. "./utils/hpc/dist-install/build/tmp/hpc"
  232. "./utils/haddock/dist/build/tmp/haddock"
  233. "./utils/hsc2hs/dist-install/build/tmp/hsc2hs"
  234. "./utils/runghc/dist-install/build/tmp/runghc"
  235. "./utils/ghc-cabal/dist-install/build/tmp/ghc-cabal"
  236. "./utils/hp2ps/dist/build/tmp/hp2ps"
  237. "./utils/ghc-pkg/dist-install/build/tmp/ghc-pkg"
  238. "./utils/unlit/dist/build/tmp/unlit"
  239. "./ghc/stage2/build/tmp/ghc-stage2"))
  240. (gmp (assoc-ref inputs "gmp"))
  241. (gmp-lib (string-append gmp "/lib"))
  242. (gmp-include (string-append gmp "/include"))
  243. (ncurses-lib
  244. (dirname (search-input-file inputs "/lib/libncurses.so")))
  245. (ld-so (search-input-file inputs ,(glibc-dynamic-linker)))
  246. (libtinfo-dir
  247. (string-append ghc-bootstrap-prefix
  248. "/lib/ghc-7.8.4/terminfo-0.4.0.0")))
  249. (with-directory-excursion
  250. (string-append ghc-bootstrap-path "/ghc-7.8.4")
  251. (setenv "CONFIG_SHELL" (which "bash"))
  252. (setenv "LD_LIBRARY_PATH" gmp-lib)
  253. ;; The binaries have "/lib64/ld-linux-x86-64.so.2" hardcoded.
  254. (for-each
  255. (cut invoke "patchelf" "--set-interpreter" ld-so <>)
  256. binaries)
  257. ;; The binaries include a reference to libtinfo.so.5 which
  258. ;; is a subset of libncurses.so.5. We create a symlink in a
  259. ;; directory included in the bootstrap binaries rpath.
  260. (mkdir-p libtinfo-dir)
  261. (symlink
  262. (string-append ncurses-lib "/libncursesw.so."
  263. ;; Extract "6.0" from "6.0-20170930" if a
  264. ;; dash-separated version tag exists.
  265. ,(let* ((v (package-version ncurses))
  266. (d (or (string-index v #\-)
  267. (string-length v))))
  268. (version-major+minor (string-take v d))))
  269. (string-append libtinfo-dir "/libtinfo.so.5"))
  270. (setenv "PATH"
  271. (string-append (getenv "PATH") ":"
  272. ghc-bootstrap-prefix "/bin"))
  273. (invoke
  274. (string-append (getcwd) "/configure")
  275. (string-append "--prefix=" ghc-bootstrap-prefix)
  276. (string-append "--with-gmp-libraries=" gmp-lib)
  277. (string-append "--with-gmp-includes=" gmp-include)))))
  278. (alist-cons-before
  279. 'configure 'install-bin
  280. (lambda* (#:key inputs outputs #:allow-other-keys)
  281. (with-directory-excursion
  282. (string-append ghc-bootstrap-path "/ghc-7.8.4")
  283. (invoke "make" "install")))
  284. %standard-phases)))))))
  285. (native-search-paths (list (search-path-specification
  286. (variable "GHC_PACKAGE_PATH")
  287. (files (list
  288. (string-append "lib/ghc-" version)))
  289. (file-pattern ".*\\.conf\\.d$")
  290. (file-type 'directory))))
  291. (home-page "https://www.haskell.org/ghc")
  292. (synopsis "The Glasgow Haskell Compiler")
  293. (description
  294. "The Glasgow Haskell Compiler (GHC) is a state-of-the-art compiler and
  295. interactive environment for the functional language Haskell.")
  296. (license license:bsd-3)))
  297. (define-public ghc-8.0
  298. (package
  299. (name "ghc")
  300. (version "8.0.2")
  301. (source
  302. (origin
  303. (method url-fetch)
  304. (uri (string-append "https://www.haskell.org/ghc/dist/"
  305. version "/" name "-" version "-src.tar.xz"))
  306. (sha256
  307. (base32 "1c8qc4fhkycynk4g1f9hvk53dj6a1vvqi6bklqznns6hw59m8qhi"))
  308. (patches
  309. (search-patches "ghc-8.0-fall-back-to-madv_dontneed.patch"))))
  310. (build-system gnu-build-system)
  311. (supported-systems '("i686-linux" "x86_64-linux"))
  312. (outputs '("out" "doc"))
  313. (inputs
  314. `(("gmp" ,gmp)
  315. ("ncurses" ,ncurses)
  316. ("libffi" ,libffi)
  317. ("ghc-testsuite"
  318. ,(origin
  319. (method url-fetch)
  320. (uri (string-append
  321. "https://www.haskell.org/ghc/dist/"
  322. version "/" name "-" version "-testsuite.tar.xz"))
  323. (sha256
  324. (base32 "1wjc3x68l305bl1h1ijd3yhqp2vqj83lkp3kqbr94qmmkqlms8sj"))))))
  325. (native-inputs
  326. `(("perl" ,perl)
  327. ("python" ,python-2) ; for tests
  328. ("ghostscript" ,ghostscript) ; for tests
  329. ;; GHC is built with GHC.
  330. ("ghc-bootstrap" ,ghc-7)))
  331. (arguments
  332. `(#:test-target "test"
  333. ;; We get a smaller number of test failures by disabling parallel test
  334. ;; execution.
  335. #:parallel-tests? #f
  336. ;; Don't pass --build=<triplet>, because the configure script
  337. ;; auto-detects slightly different triplets for --host and --target and
  338. ;; then complains that they don't match.
  339. #:build #f
  340. #:configure-flags
  341. (list
  342. (string-append "--with-gmp-libraries="
  343. (assoc-ref %build-inputs "gmp") "/lib")
  344. (string-append "--with-gmp-includes="
  345. (assoc-ref %build-inputs "gmp") "/include")
  346. "--with-system-libffi"
  347. (string-append "--with-ffi-libraries="
  348. (assoc-ref %build-inputs "libffi") "/lib")
  349. (string-append "--with-ffi-includes="
  350. (assoc-ref %build-inputs "libffi") "/include")
  351. (string-append "--with-curses-libraries="
  352. (assoc-ref %build-inputs "ncurses") "/lib")
  353. (string-append "--with-curses-includes="
  354. (assoc-ref %build-inputs "ncurses") "/include"))
  355. #:phases
  356. (modify-phases %standard-phases
  357. (add-after 'unpack 'unpack-testsuite
  358. (lambda* (#:key inputs #:allow-other-keys)
  359. (with-directory-excursion ".."
  360. (copy-file (assoc-ref inputs "ghc-testsuite")
  361. "ghc-testsuite.tar.xz")
  362. (zero? (system* "tar" "xvf" "ghc-testsuite.tar.xz")))))
  363. (add-before 'build 'fix-lib-paths
  364. (lambda _
  365. (substitute*
  366. (list "libraries/process/System/Process/Posix.hs"
  367. "libraries/process/tests/process001.hs"
  368. "libraries/process/tests/process002.hs"
  369. "libraries/unix/cbits/execvpe.c")
  370. (("/bin/sh") (which "sh"))
  371. (("/bin/ls") (which "ls")))
  372. #t))
  373. (add-before 'build 'fix-environment
  374. (lambda _
  375. (unsetenv "GHC_PACKAGE_PATH")
  376. (setenv "CONFIG_SHELL" (which "bash"))
  377. #t))
  378. (add-before 'check 'fix-testsuite
  379. (lambda _
  380. (substitute*
  381. (list "testsuite/timeout/Makefile"
  382. "testsuite/timeout/timeout.py"
  383. "testsuite/timeout/timeout.hs"
  384. "testsuite/tests/programs/life_space_leak/life.test")
  385. (("/bin/sh") (which "sh"))
  386. (("/bin/rm") "rm"))
  387. #t)))))
  388. (native-search-paths (list (search-path-specification
  389. (variable "GHC_PACKAGE_PATH")
  390. (files (list
  391. (string-append "lib/ghc-" version)))
  392. (file-pattern ".*\\.conf\\.d$")
  393. (file-type 'directory))))
  394. (home-page "https://www.haskell.org/ghc")
  395. (synopsis "The Glasgow Haskell Compiler")
  396. (description
  397. "The Glasgow Haskell Compiler (GHC) is a state-of-the-art compiler and
  398. interactive environment for the functional language Haskell.")
  399. (license license:bsd-3)))
  400. (define-public ghc-8.4
  401. (package (inherit ghc-8.0)
  402. (name "ghc")
  403. (version "8.4.4")
  404. (source
  405. (origin
  406. (method url-fetch)
  407. (uri (string-append "https://www.haskell.org/ghc/dist/"
  408. version "/" name "-" version "-src.tar.xz"))
  409. (sha256
  410. (base32 "1ch4j2asg7pr52ai1hwzykxyj553wndg7wq93i47ql4fllspf48i"))))
  411. (inputs
  412. `(("gmp" ,gmp)
  413. ("ncurses" ,ncurses)
  414. ("libffi" ,libffi)))
  415. (native-inputs
  416. `(("perl" ,perl)
  417. ("python" ,python) ; for tests
  418. ("ghostscript" ,ghostscript) ; for tests
  419. ;; GHC 8.4.3 is built with GHC 8.
  420. ("ghc-bootstrap" ,ghc-8.0)
  421. ("ghc-testsuite"
  422. ,(origin
  423. (method url-fetch)
  424. (uri (string-append
  425. "https://www.haskell.org/ghc/dist/"
  426. version "/" name "-" version "-testsuite.tar.xz"))
  427. (sha256
  428. (base32
  429. "0s8lf9sxj7n89pjagi58b3fahnp34qvmwhnn0j1fbg6955vbrfj6"))))))
  430. (arguments
  431. `(#:test-target "test"
  432. ;; We get a smaller number of test failures by disabling parallel test
  433. ;; execution.
  434. #:parallel-tests? #f
  435. ;; Don't pass --build=<triplet>, because the configure script
  436. ;; auto-detects slightly different triplets for --host and --target and
  437. ;; then complains that they don't match.
  438. #:build #f
  439. #:configure-flags
  440. (list
  441. (string-append "--with-gmp-libraries="
  442. (assoc-ref %build-inputs "gmp") "/lib")
  443. (string-append "--with-gmp-includes="
  444. (assoc-ref %build-inputs "gmp") "/include")
  445. "--with-system-libffi"
  446. (string-append "--with-ffi-libraries="
  447. (assoc-ref %build-inputs "libffi") "/lib")
  448. (string-append "--with-ffi-includes="
  449. (assoc-ref %build-inputs "libffi") "/include")
  450. (string-append "--with-curses-libraries="
  451. (assoc-ref %build-inputs "ncurses") "/lib")
  452. (string-append "--with-curses-includes="
  453. (assoc-ref %build-inputs "ncurses") "/include"))
  454. #:phases
  455. (modify-phases %standard-phases
  456. (add-after 'unpack 'unpack-testsuite
  457. (lambda* (#:key inputs #:allow-other-keys)
  458. (invoke "tar" "xvf"
  459. (assoc-ref inputs "ghc-testsuite")
  460. "--strip-components=1")
  461. #t))
  462. ;; This phase patches the 'ghc-pkg' command so that it sorts the list
  463. ;; of packages in the binary cache it generates.
  464. (add-before 'build 'fix-ghc-pkg-nondeterminism
  465. (lambda _
  466. (substitute* "utils/ghc-pkg/Main.hs"
  467. (("confs = map \\(path </>\\) \\$ filter \\(\".conf\" `isSuffixOf`\\) fs")
  468. "confs = map (path </>) $ filter (\".conf\" `isSuffixOf`) (sort fs)"))
  469. #t))
  470. (add-after 'unpack-testsuite 'fix-shell-wrappers
  471. (lambda _
  472. (substitute* '("driver/ghci/ghc.mk"
  473. "utils/mkdirhier/ghc.mk"
  474. "rules/shell-wrapper.mk")
  475. (("echo '#!/bin/sh'")
  476. (format #f "echo '#!~a'" (which "sh"))))
  477. #t))
  478. ;; This is necessary because the configure system no longer uses
  479. ;; “AC_PATH_” but “AC_CHECK_”, setting the variables to just the
  480. ;; plain command names.
  481. (add-before 'configure 'set-target-programs
  482. (lambda* (#:key inputs #:allow-other-keys)
  483. (let ((binutils (assoc-ref inputs "binutils"))
  484. (gcc (assoc-ref inputs "gcc"))
  485. (ld-wrapper (assoc-ref inputs "ld-wrapper")))
  486. (setenv "CC" (string-append gcc "/bin/gcc"))
  487. (setenv "CXX" (string-append gcc "/bin/g++"))
  488. (setenv "LD" (string-append ld-wrapper "/bin/ld"))
  489. (setenv "NM" (string-append binutils "/bin/nm"))
  490. (setenv "RANLIB" (string-append binutils "/bin/ranlib"))
  491. (setenv "STRIP" (string-append binutils "/bin/strip"))
  492. ;; The 'ar' command does not follow the same pattern.
  493. (setenv "fp_prog_ar" (string-append binutils "/bin/ar"))
  494. #t)))
  495. (add-before 'build 'fix-references
  496. (lambda _
  497. (substitute* '("testsuite/timeout/Makefile"
  498. "testsuite/timeout/timeout.py"
  499. "testsuite/timeout/timeout.hs"
  500. "testsuite/tests/programs/life_space_leak/life.test"
  501. ;; libraries
  502. "libraries/process/System/Process/Posix.hs"
  503. "libraries/process/tests/process001.hs"
  504. "libraries/process/tests/process002.hs"
  505. "libraries/unix/cbits/execvpe.c")
  506. (("/bin/sh") (which "sh"))
  507. (("/bin/ls") (which "ls"))
  508. (("/bin/rm") "rm"))
  509. #t))
  510. (add-before 'build 'fix-environment
  511. (lambda _
  512. (unsetenv "GHC_PACKAGE_PATH")
  513. (setenv "CONFIG_SHELL" (which "bash"))
  514. #t)))))
  515. (native-search-paths (list (search-path-specification
  516. (variable "GHC_PACKAGE_PATH")
  517. (files (list
  518. (string-append "lib/ghc-" version)))
  519. (file-pattern ".*\\.conf\\.d$")
  520. (file-type 'directory))))))
  521. (define-public ghc-8.6
  522. (package (inherit ghc-8.4)
  523. (name "ghc")
  524. (version "8.6.5")
  525. (source
  526. (origin
  527. (method url-fetch)
  528. (uri (string-append "https://www.haskell.org/ghc/dist/"
  529. version "/" name "-" version "-src.tar.xz"))
  530. (sha256
  531. (base32 "0qg3zsmbk4rkwkc3jpas3zs74qaxmw4sp4v1mhsbj0a0dzls2jjd"))))
  532. (native-inputs
  533. `(;; GHC 8.6.5 must be built with GHC >= 8.2.
  534. ("ghc-bootstrap" ,ghc-8.4)
  535. ("ghc-testsuite"
  536. ,(origin
  537. (method url-fetch)
  538. (uri (string-append
  539. "https://www.haskell.org/ghc/dist/"
  540. version "/" name "-" version "-testsuite.tar.xz"))
  541. (patches (search-patches "ghc-testsuite-dlopen-pie.patch"))
  542. (sha256
  543. (base32
  544. "0pw9r91g2np3i806g2f4f8z4jfdd7mx226cmdizk4swa7av1qf91"))))
  545. ,@(filter (match-lambda
  546. (("ghc-bootstrap" . _) #f)
  547. (("ghc-testsuite" . _) #f)
  548. (_ #t))
  549. (package-native-inputs ghc-8.4))))
  550. (arguments
  551. (substitute-keyword-arguments (package-arguments ghc-8.4)
  552. ((#:make-flags make-flags ''())
  553. `(cons "EXTRA_RUNTEST_OPTS=--skip-perf-tests"
  554. ,make-flags))
  555. ((#:phases phases '%standard-phases)
  556. `(modify-phases ,phases
  557. (add-after 'install 'remove-unnecessary-references
  558. (lambda* (#:key outputs #:allow-other-keys)
  559. (substitute* (find-files (string-append (assoc-ref outputs "out") "/lib/")
  560. "settings")
  561. (("/gnu/store/.*/bin/(.*)" m program) program))
  562. ;; Remove references to "doc" output from "out" by rewriting
  563. ;; the "haddock-interfaces" fields and removing the optional
  564. ;; "haddock-html" field in the generated .conf files.
  565. (let ((doc (assoc-ref outputs "doc"))
  566. (out (assoc-ref outputs "out")))
  567. (with-fluids ((%default-port-encoding #f))
  568. (for-each (lambda (config-file)
  569. (substitute* config-file
  570. (("^haddock-html: .*") "\n")
  571. (((format #f "^haddock-interfaces: ~a" doc))
  572. (string-append "haddock-interfaces: " out))))
  573. (find-files (string-append out "/lib") ".conf")))
  574. ;; Move the referenced files to the "out" output.
  575. (for-each (lambda (haddock-file)
  576. (let* ((subdir (string-drop haddock-file (string-length doc)))
  577. (new (string-append out subdir)))
  578. (mkdir-p (dirname new))
  579. (rename-file haddock-file new)))
  580. (find-files doc "\\.haddock$")))
  581. #t))
  582. (add-after 'unpack-testsuite 'skip-tests
  583. (lambda _
  584. ;; These two tests refer to the root user, which doesn't exist
  585. ;; (see <https://bugs.gnu.org/36692>).
  586. (substitute* "libraries/unix/tests/all.T"
  587. (("^test\\('T8108'") "# guix skipped: test('T8108'"))
  588. (substitute* "libraries/unix/tests/libposix/all.T"
  589. (("^test\\('posix010'") "# guix skipped: test('posix010'"))
  590. #t))))))
  591. (native-search-paths (list (search-path-specification
  592. (variable "GHC_PACKAGE_PATH")
  593. (files (list
  594. (string-append "lib/ghc-" version)))
  595. (file-pattern ".*\\.conf\\.d$")
  596. (file-type 'directory))))))
  597. ;; Versions newer than ghc defined below (i.e. the compiler
  598. ;; haskell-build-system uses) should use ghc-next as their name to
  599. ;; ensure ghc (without version specification) and ghc-* packages are
  600. ;; always compatible. See https://issues.guix.gnu.org/issue/47335.
  601. (define-public ghc-8.8
  602. (package (inherit ghc-8.6)
  603. (name "ghc-next")
  604. (version "8.8.4")
  605. (source
  606. (origin
  607. (method url-fetch)
  608. (uri (string-append "https://www.haskell.org/ghc/dist/"
  609. version "/ghc-" version "-src.tar.xz"))
  610. (sha256
  611. (base32 "0bgwbxxvdn56l91bp9p5d083gzcfdi6z8l8b17qzjpr3n8w5wl7h"))))
  612. (native-inputs
  613. `(("ghc-bootstrap" ,ghc-8.6)
  614. ("ghc-testsuite"
  615. ,(origin
  616. (method url-fetch)
  617. (uri (string-append
  618. "https://www.haskell.org/ghc/dist/"
  619. version "/ghc-" version "-testsuite.tar.xz"))
  620. (patches (search-patches "ghc-testsuite-dlopen-pie.patch"))
  621. (sha256
  622. (base32
  623. "0c55pj2820q26rikhpf636sn4mjgqsxjrl94vsywrh79dxp3k14z"))))
  624. ("git" ,git) ; invoked during tests
  625. ,@(filter (match-lambda
  626. (("ghc-bootstrap" . _) #f)
  627. (("ghc-testsuite" . _) #f)
  628. (_ #t))
  629. (package-native-inputs ghc-8.6))))
  630. (arguments
  631. (substitute-keyword-arguments (package-arguments ghc-8.6)
  632. ((#:phases phases '%standard-phases)
  633. `(modify-phases ,phases
  634. (add-after 'fix-references 'fix-cc-reference
  635. (lambda _
  636. (substitute* "utils/hsc2hs/Common.hs"
  637. (("\"cc\"") "\"gcc\""))
  638. #t))
  639. (add-after 'unpack-testsuite 'skip-more-tests
  640. (lambda _
  641. ;; XXX: This test fails because our ld-wrapper script
  642. ;; mangles the response file passed to the linker.
  643. (substitute* "testsuite/tests/hp2ps/all.T"
  644. (("^test\\('T15904'") "# guix skipped: test('T15904'"))
  645. #t))))))
  646. (native-search-paths (list (search-path-specification
  647. (variable "GHC_PACKAGE_PATH")
  648. (files (list
  649. (string-append "lib/ghc-" version)))
  650. (file-pattern ".*\\.conf\\.d$")
  651. (file-type 'directory))))))
  652. (define-public ghc-8.10
  653. (package
  654. (inherit ghc-8.8)
  655. (name "ghc-next")
  656. (version "8.10.7")
  657. (source
  658. (origin
  659. (method url-fetch)
  660. (uri (string-append "https://www.haskell.org/ghc/dist/"
  661. version "/ghc-" version "-src.tar.xz"))
  662. (sha256
  663. (base32 "179ws2q0dinl1a39wm9j37xzwm84zfz3c5543vz8v479khigdvp3"))))
  664. (native-inputs
  665. `(("ghc-bootstrap" ,ghc-8.8)
  666. ("ghc-testsuite"
  667. ,(origin
  668. (method url-fetch)
  669. (uri (string-append
  670. "https://www.haskell.org/ghc/dist/"
  671. version "/ghc-" version "-testsuite.tar.xz"))
  672. (patches (search-patches "ghc-testsuite-dlopen-pie.patch"))
  673. (sha256
  674. (base32
  675. "1zl25gg6bpx5601k8h3cqnns1xfc0nqgwnh8jvn2s65ra3f2g1nz"))))
  676. ("git" ,git-minimal) ; invoked during tests
  677. ,@(filter (match-lambda
  678. (("ghc-bootstrap" . _) #f)
  679. (("ghc-testsuite" . _) #f)
  680. (_ #t))
  681. (package-native-inputs ghc-8.8))))
  682. (arguments
  683. (substitute-keyword-arguments (package-arguments ghc-8.8)
  684. ((#:phases phases '%standard-phases)
  685. `(modify-phases ,phases
  686. (add-after 'unpack-testsuite 'patch-more-shebangs
  687. (lambda* (#:key inputs #:allow-other-keys)
  688. (let ((bash (assoc-ref inputs "bash")))
  689. (substitute* '("testsuite/tests/driver/T8602/T8602.script")
  690. (("/bin/sh")
  691. (string-append bash "/bin/sh"))))))
  692. ;; Mark failing tests as broken. Reason for failure is unknown.
  693. (add-after 'skip-more-tests 'skip-even-more-tests
  694. (lambda _
  695. (substitute* '("testsuite/tests/driver/T16521/all.T")
  696. (("extra_files" all) (string-append "[" all))
  697. (("\\]\\), " all)
  698. (string-append all "expect_broken(0)], ")))))))))
  699. (native-search-paths (list (search-path-specification
  700. (variable "GHC_PACKAGE_PATH")
  701. (files (list
  702. (string-append "lib/ghc-" version)))
  703. (file-pattern ".*\\.conf\\.d$")
  704. (file-type 'directory))))))
  705. (define-public ghc-8 ghc-8.6)
  706. (define-public ghc ghc-8)
  707. ;;; haskell.scm ends here