idris.scm 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2015 Paul van der Walt <paul@denknerd.org>
  3. ;;; Copyright © 2016, 2017 David Craven <david@craven.ch>
  4. ;;; Copyright © 2018 Alex ter Weele <alex.ter.weele@gmail.com>
  5. ;;; Copyright © 2019, 2021 Eric Bavier <bavier@posteo.net>
  6. ;;;
  7. ;;; This file is part of GNU Guix.
  8. ;;;
  9. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  10. ;;; under the terms of the GNU General Public License as published by
  11. ;;; the Free Software Foundation; either version 3 of the License, or (at
  12. ;;; your option) any later version.
  13. ;;;
  14. ;;; GNU Guix is distributed in the hope that it will be useful, but
  15. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. ;;; GNU General Public License for more details.
  18. ;;;
  19. ;;; You should have received a copy of the GNU General Public License
  20. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  21. (define-module (gnu packages idris)
  22. #:use-module (gnu packages)
  23. #:use-module (gnu packages haskell-check)
  24. #:use-module (gnu packages haskell-web)
  25. #:use-module (gnu packages haskell-xyz)
  26. #:use-module (gnu packages libffi)
  27. #:use-module (gnu packages multiprecision)
  28. #:use-module (gnu packages ncurses)
  29. #:use-module (gnu packages perl)
  30. #:use-module (guix build-system gnu)
  31. #:use-module (guix build-system haskell)
  32. #:use-module (guix download)
  33. #:use-module (guix git-download)
  34. #:use-module ((guix licenses) #:prefix license:)
  35. #:use-module (guix packages))
  36. (define-public idris
  37. (package
  38. (name "idris")
  39. (version "1.3.3")
  40. (source (origin
  41. (method url-fetch)
  42. (uri (string-append
  43. "https://hackage.haskell.org/package/"
  44. "idris-" version "/idris-" version ".tar.gz"))
  45. (sha256
  46. (base32
  47. "1pachwc6msw3n1mz2z1r1w6h518w9gbhdvbaa5vi1qp3cn3wm6q4"))
  48. (patches (search-patches "idris-disable-test.patch"))))
  49. (build-system haskell-build-system)
  50. (native-inputs ;For tests
  51. `(("perl" ,perl)
  52. ("ghc-cheapskate" ,ghc-cheapskate)
  53. ("ghc-tasty" ,ghc-tasty)
  54. ("ghc-tasty-golden" ,ghc-tasty-golden)
  55. ("ghc-tasty-rerun" ,ghc-tasty-rerun)))
  56. (inputs
  57. `(("gmp" ,gmp)
  58. ("ncurses" ,ncurses)
  59. ("ghc-aeson" ,ghc-aeson)
  60. ("ghc-annotated-wl-pprint" ,ghc-annotated-wl-pprint)
  61. ("ghc-ansi-terminal" ,ghc-ansi-terminal)
  62. ("ghc-ansi-wl-pprint" ,ghc-ansi-wl-pprint)
  63. ("ghc-async" ,ghc-async)
  64. ("ghc-base64-bytestring" ,ghc-base64-bytestring)
  65. ("ghc-blaze-html" ,ghc-blaze-html)
  66. ("ghc-blaze-markup" ,ghc-blaze-markup)
  67. ("ghc-cheapskate" ,ghc-cheapskate)
  68. ("ghc-code-page" ,ghc-code-page)
  69. ("ghc-fingertree" ,ghc-fingertree)
  70. ("ghc-fsnotify" ,ghc-fsnotify)
  71. ("ghc-ieee754" ,ghc-ieee754)
  72. ("ghc-libffi" ,ghc-libffi)
  73. ("ghc-megaparsec" ,ghc-megaparsec)
  74. ("ghc-network" ,ghc-network)
  75. ("ghc-optparse-applicative" ,ghc-optparse-applicative)
  76. ("ghc-regex-tdfa" ,ghc-regex-tdfa)
  77. ("ghc-safe" ,ghc-safe)
  78. ("ghc-split" ,ghc-split)
  79. ("ghc-terminal-size" ,ghc-terminal-size)
  80. ("ghc-uniplate" ,ghc-uniplate)
  81. ("ghc-unordered-containers" ,ghc-unordered-containers)
  82. ("ghc-utf8-string" ,ghc-utf8-string)
  83. ("ghc-vector" ,ghc-vector)
  84. ("ghc-vector-binary-instances" ,ghc-vector-binary-instances)
  85. ("ghc-zip-archive" ,ghc-zip-archive)))
  86. (arguments
  87. `(#:configure-flags
  88. (list (string-append "--datasubdir="
  89. (assoc-ref %outputs "out") "/lib/idris")
  90. "-fFFI" "-fGMP")
  91. #:phases
  92. (modify-phases %standard-phases
  93. ;; This allows us to call the 'idris' binary before installing.
  94. (add-after 'unpack 'set-ld-library-path
  95. (lambda _
  96. (setenv "LD_LIBRARY_PATH" (string-append (getcwd) "/dist/build"))
  97. #t))
  98. (add-after 'unpack 'update-constraints
  99. (lambda _
  100. (substitute* "idris.cabal"
  101. (("ansi-terminal < 0\\.9") "ansi-terminal < 0.10")
  102. (("cheapskate >= 0\\.1\\.1\\.2 && < 0\\.2") "cheapskate >= 0.1.1.1 && < 0.2"))
  103. #t))
  104. (add-before 'configure 'set-cc-command
  105. (lambda _
  106. (setenv "CC" "gcc")
  107. #t))
  108. (add-after 'install 'fix-libs-install-location
  109. (lambda* (#:key outputs #:allow-other-keys)
  110. (let* ((out (assoc-ref outputs "out"))
  111. (lib (string-append out "/lib/idris"))
  112. (modules (string-append lib "/libs")))
  113. (for-each
  114. (lambda (module)
  115. (symlink (string-append modules "/" module)
  116. (string-append lib "/" module)))
  117. '("prelude" "base" "contrib" "effects" "pruviloj")))))
  118. (delete 'check) ;Run check later
  119. (add-after 'install 'check
  120. (lambda* (#:key outputs #:allow-other-keys #:rest args)
  121. (let ((out (assoc-ref outputs "out")))
  122. (chmod "test/scripts/timeout" #o755) ;must be executable
  123. (setenv "TASTY_NUM_THREADS" (number->string (parallel-job-count)))
  124. (setenv "IDRIS_CC" "gcc") ;Needed for creating executables
  125. (setenv "PATH" (string-append out "/bin:" (getenv "PATH")))
  126. (apply (assoc-ref %standard-phases 'check) args))))
  127. (add-before 'check 'restore-libidris_rts
  128. (lambda* (#:key outputs #:allow-other-keys)
  129. ;; The Haskell build system moves this library to the
  130. ;; "static" output. Idris only knows how to find it in the
  131. ;; "out" output, so we restore it here.
  132. (let ((out (assoc-ref outputs "out"))
  133. (static (assoc-ref outputs "static"))
  134. (filename "/lib/idris/rts/libidris_rts.a"))
  135. (rename-file (string-append static filename)
  136. (string-append out filename))
  137. #t))))))
  138. (native-search-paths
  139. (list (search-path-specification
  140. (variable "IDRIS_LIBRARY_PATH")
  141. (files '("lib/idris")))))
  142. (home-page "https://www.idris-lang.org")
  143. (synopsis "General purpose language with full dependent types")
  144. (description "Idris is a general purpose language with full dependent
  145. types. It is compiled, with eager evaluation. Dependent types allow types to
  146. be predicated on values, meaning that some aspects of a program's behaviour
  147. can be specified precisely in the type. The language is closely related to
  148. Epigram and Agda.")
  149. (license license:bsd-3)))
  150. ;; Idris modules use the gnu-build-system so that the IDRIS_LIBRARY_PATH is set.
  151. (define (idris-default-arguments name)
  152. `(#:modules ((guix build gnu-build-system)
  153. (guix build utils)
  154. (ice-9 ftw)
  155. (ice-9 match))
  156. #:phases
  157. (modify-phases %standard-phases
  158. (delete 'configure)
  159. (delete 'build)
  160. (delete 'check)
  161. (replace 'install
  162. (lambda* (#:key inputs outputs #:allow-other-keys)
  163. (let* ((out (assoc-ref outputs "out"))
  164. (idris (assoc-ref inputs "idris"))
  165. (idris-bin (string-append idris "/bin/idris"))
  166. (idris-libs (string-append idris "/lib/idris/libs"))
  167. (module-name (and (string-prefix? "idris-" ,name)
  168. (substring ,name 6)))
  169. (ibcsubdir (string-append out "/lib/idris/" module-name))
  170. (ipkg (string-append module-name ".ipkg"))
  171. (idris-library-path (getenv "IDRIS_LIBRARY_PATH"))
  172. (idris-path (string-split idris-library-path #\:))
  173. (idris-path-files (apply append
  174. (map (lambda (path)
  175. (map (lambda (dir)
  176. (string-append path "/" dir))
  177. (scandir path))) idris-path)))
  178. (idris-path-subdirs (filter (lambda (path)
  179. (and path (match (stat:type (stat path))
  180. ('directory #t)
  181. (_ #f))))
  182. idris-path-files))
  183. (install-cmd (cons* idris-bin
  184. "--ibcsubdir" ibcsubdir
  185. "--build" ipkg
  186. ;; only trigger a build, as --ibcsubdir
  187. ;; already installs .ibc files.
  188. (apply append (map (lambda (path)
  189. (list "--idrispath"
  190. path))
  191. idris-path-subdirs)))))
  192. ;; FIXME: Seems to be a bug in idris that causes a dubious failure.
  193. (apply system* install-cmd)
  194. #t))))))
  195. (define-public idris-lightyear
  196. (let ((commit "6d65ad111b4bed2bc131396f8385528fc6b3678a"))
  197. (package
  198. (name "idris-lightyear")
  199. (version (git-version "0.1" "1" commit))
  200. (source (origin
  201. (method git-fetch)
  202. (uri (git-reference
  203. (url "https://github.com/ziman/lightyear")
  204. (commit commit)))
  205. (file-name (git-file-name name version))
  206. (sha256
  207. (base32
  208. "1pkxnn3ryr0v0cin4nasw7kgkc9dnnpja1nfbj466mf3qv5s98af"))))
  209. (build-system gnu-build-system)
  210. (native-inputs
  211. `(("idris" ,idris)))
  212. (arguments (idris-default-arguments name))
  213. (home-page "https://github.com/ziman/lightyear")
  214. (synopsis "Lightweight parser combinator library for Idris")
  215. (description "Lightweight parser combinator library for Idris, inspired
  216. by Parsec. This package is used (almost) the same way as Parsec, except for one
  217. difference: backtracking.")
  218. (license license:bsd-2))))
  219. (define-public idris-wl-pprint
  220. (let ((commit "1d365fcf4ba075859844dbc5eb96a90f57b9f338"))
  221. (package
  222. (name "idris-wl-pprint")
  223. (version (git-version "0.1" "1" commit))
  224. (source (origin
  225. (method git-fetch)
  226. (uri (git-reference
  227. (url "https://github.com/shayan-najd/wl-pprint")
  228. (commit commit)))
  229. (file-name (git-file-name name version))
  230. (sha256
  231. (base32
  232. "0g7c3y9smifdz4sivi3qmvymhdr7v9kfq45fmfmmvkqcrix0spzn"))))
  233. (build-system gnu-build-system)
  234. (native-inputs
  235. `(("idris" ,idris)))
  236. (arguments (idris-default-arguments name))
  237. (home-page "https://github.com/shayan-najd/wl-pprint")
  238. (synopsis "Pretty printing library")
  239. (description "A pretty printing library for Idris based on Phil Wadler's
  240. paper A Prettier Printer and on Daan Leijen's extensions in the Haskell
  241. wl-pprint library.")
  242. (license license:bsd-2))))
  243. (define-public idris-bifunctors
  244. (let ((commit "53d06a6ccfe70c49c9ae8c8a4135981dd2173202"))
  245. (package
  246. (name "idris-bifunctors")
  247. (version (git-version "0.1" "1" commit))
  248. (source (origin
  249. (method git-fetch)
  250. (uri (git-reference
  251. (url "https://github.com/HuwCampbell/Idris-Bifunctors")
  252. (commit commit)))
  253. (file-name (string-append name "-" version "-checkout"))
  254. (sha256
  255. (base32
  256. "02vbsd3rmgnj0l1qq787709qcxjbr9890cbad4ykn27f77jk81h4"))))
  257. (build-system gnu-build-system)
  258. (native-inputs
  259. `(("idris" ,idris)))
  260. (arguments (idris-default-arguments name))
  261. (home-page "https://github.com/HuwCampbell/Idris-Bifunctors")
  262. (synopsis "Bifunctor library")
  263. (description "This is a bifunctor library for Idris based off the
  264. excellent Haskell Bifunctors package from Edward Kmett.")
  265. (license license:bsd-3))))
  266. (define-public idris-lens
  267. (let ((commit "26f012005f6849806cea630afe317e42cae97f29"))
  268. (package
  269. (name "idris-lens")
  270. (version (git-version "0.1" "1" commit))
  271. (source (origin
  272. (method git-fetch)
  273. (uri (git-reference
  274. (url "https://github.com/HuwCampbell/idris-lens")
  275. (commit commit)))
  276. (file-name (git-file-name name version))
  277. (sha256
  278. (base32
  279. "06jzfj6rad08rk92w8jk5byi79svmyg0mrcqhibgx8rkjjy6vmai"))))
  280. (build-system gnu-build-system)
  281. (native-inputs
  282. `(("idris" ,idris)))
  283. (propagated-inputs
  284. `(("idris-bifunctors" ,idris-bifunctors)))
  285. (arguments (idris-default-arguments name))
  286. (home-page "https://github.com/HuwCampbell/idris-lens")
  287. (synopsis "Van Laarhoven lenses for Idris")
  288. (description "Lenses are composable functional references. They allow
  289. accessing and modifying data within a structure.")
  290. (license license:bsd-3))))