idris.scm 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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. "idris-build-with-haskeline-0.8.patch"
  50. "idris-build-with-megaparsec-9.patch"))))
  51. (build-system haskell-build-system)
  52. (native-inputs ;For tests
  53. (list perl ghc-cheapskate ghc-tasty ghc-tasty-golden
  54. ghc-tasty-rerun))
  55. (inputs
  56. (list gmp
  57. ncurses
  58. ghc-aeson
  59. ghc-annotated-wl-pprint
  60. ghc-ansi-terminal
  61. ghc-ansi-wl-pprint
  62. ghc-async
  63. ghc-base64-bytestring
  64. ghc-blaze-html
  65. ghc-blaze-markup
  66. ghc-cheapskate
  67. ghc-code-page
  68. ghc-fingertree
  69. ghc-fsnotify
  70. ghc-ieee754
  71. ghc-libffi
  72. ghc-megaparsec
  73. ghc-network
  74. ghc-optparse-applicative
  75. ghc-regex-tdfa
  76. ghc-safe
  77. ghc-split
  78. ghc-terminal-size
  79. ghc-uniplate
  80. ghc-unordered-containers
  81. ghc-utf8-string
  82. ghc-vector
  83. ghc-vector-binary-instances
  84. ghc-zip-archive))
  85. (arguments
  86. `(#:configure-flags
  87. (list (string-append "--datasubdir="
  88. (assoc-ref %outputs "out") "/lib/idris")
  89. "-fFFI" "-fGMP")
  90. #:phases
  91. (modify-phases %standard-phases
  92. ;; This allows us to call the 'idris' binary before installing.
  93. (add-after 'unpack 'set-ld-library-path
  94. (lambda _
  95. (setenv "LD_LIBRARY_PATH" (string-append (getcwd) "/dist/build"))
  96. #t))
  97. (add-before 'configure 'update-constraints
  98. (lambda _
  99. (substitute* "idris.cabal"
  100. (("(aeson|ansi-terminal|haskeline|megaparsec|optparse-applicative)\\s+[^,]+" all dep)
  101. dep))))
  102. (add-before 'configure 'set-cc-command
  103. (lambda _
  104. (setenv "CC" "gcc")
  105. #t))
  106. (add-after 'install 'fix-libs-install-location
  107. (lambda* (#:key outputs #:allow-other-keys)
  108. (let* ((out (assoc-ref outputs "out"))
  109. (lib (string-append out "/lib/idris"))
  110. (modules (string-append lib "/libs")))
  111. (for-each
  112. (lambda (module)
  113. (symlink (string-append modules "/" module)
  114. (string-append lib "/" module)))
  115. '("prelude" "base" "contrib" "effects" "pruviloj")))))
  116. (delete 'check) ;Run check later
  117. (add-after 'install 'check
  118. (lambda* (#:key outputs #:allow-other-keys #:rest args)
  119. (let ((out (assoc-ref outputs "out")))
  120. (chmod "test/scripts/timeout" #o755) ;must be executable
  121. (setenv "TASTY_NUM_THREADS" (number->string (parallel-job-count)))
  122. (setenv "IDRIS_CC" "gcc") ;Needed for creating executables
  123. (setenv "PATH" (string-append out "/bin:" (getenv "PATH")))
  124. (apply (assoc-ref %standard-phases 'check) args))))
  125. (add-before 'check 'restore-libidris_rts
  126. (lambda* (#:key outputs #:allow-other-keys)
  127. ;; The Haskell build system moves this library to the
  128. ;; "static" output. Idris only knows how to find it in the
  129. ;; "out" output, so we restore it here.
  130. (let ((out (assoc-ref outputs "out"))
  131. (static (assoc-ref outputs "static"))
  132. (filename "/lib/idris/rts/libidris_rts.a"))
  133. (rename-file (string-append static filename)
  134. (string-append out filename))
  135. #t))))))
  136. (native-search-paths
  137. (list (search-path-specification
  138. (variable "IDRIS_LIBRARY_PATH")
  139. (files '("lib/idris")))))
  140. (home-page "https://www.idris-lang.org")
  141. (synopsis "General purpose language with full dependent types")
  142. (description "Idris is a general purpose language with full dependent
  143. types. It is compiled, with eager evaluation. Dependent types allow types to
  144. be predicated on values, meaning that some aspects of a program's behaviour
  145. can be specified precisely in the type. The language is closely related to
  146. Epigram and Agda.")
  147. (license license:bsd-3)))
  148. ;; Idris modules use the gnu-build-system so that the IDRIS_LIBRARY_PATH is set.
  149. (define (idris-default-arguments name)
  150. `(#:modules ((guix build gnu-build-system)
  151. (guix build utils)
  152. (ice-9 ftw)
  153. (ice-9 match))
  154. #:phases
  155. (modify-phases %standard-phases
  156. (delete 'configure)
  157. (delete 'build)
  158. (delete 'check)
  159. (replace 'install
  160. (lambda* (#:key inputs outputs #:allow-other-keys)
  161. (let* ((out (assoc-ref outputs "out"))
  162. (idris (assoc-ref inputs "idris"))
  163. (idris-bin (string-append idris "/bin/idris"))
  164. (idris-libs (string-append idris "/lib/idris/libs"))
  165. (module-name (and (string-prefix? "idris-" ,name)
  166. (substring ,name 6)))
  167. (ibcsubdir (string-append out "/lib/idris/" module-name))
  168. (ipkg (string-append module-name ".ipkg"))
  169. (idris-library-path (getenv "IDRIS_LIBRARY_PATH"))
  170. (idris-path (string-split idris-library-path #\:))
  171. (idris-path-files (apply append
  172. (map (lambda (path)
  173. (map (lambda (dir)
  174. (string-append path "/" dir))
  175. (scandir path))) idris-path)))
  176. (idris-path-subdirs (filter (lambda (path)
  177. (and path (match (stat:type (stat path))
  178. ('directory #t)
  179. (_ #f))))
  180. idris-path-files))
  181. (install-cmd (cons* idris-bin
  182. "--ibcsubdir" ibcsubdir
  183. "--build" ipkg
  184. ;; only trigger a build, as --ibcsubdir
  185. ;; already installs .ibc files.
  186. (apply append (map (lambda (path)
  187. (list "--idrispath"
  188. path))
  189. idris-path-subdirs)))))
  190. ;; FIXME: Seems to be a bug in idris that causes a dubious failure.
  191. (apply system* install-cmd)
  192. #t))))))
  193. (define-public idris-lightyear
  194. (let ((commit "6d65ad111b4bed2bc131396f8385528fc6b3678a"))
  195. (package
  196. (name "idris-lightyear")
  197. (version (git-version "0.1" "1" commit))
  198. (source (origin
  199. (method git-fetch)
  200. (uri (git-reference
  201. (url "https://github.com/ziman/lightyear")
  202. (commit commit)))
  203. (file-name (git-file-name name version))
  204. (sha256
  205. (base32
  206. "1pkxnn3ryr0v0cin4nasw7kgkc9dnnpja1nfbj466mf3qv5s98af"))))
  207. (build-system gnu-build-system)
  208. (native-inputs
  209. (list idris))
  210. (arguments (idris-default-arguments name))
  211. (home-page "https://github.com/ziman/lightyear")
  212. (synopsis "Lightweight parser combinator library for Idris")
  213. (description "Lightweight parser combinator library for Idris, inspired
  214. by Parsec. This package is used (almost) the same way as Parsec, except for one
  215. difference: backtracking.")
  216. (license license:bsd-2))))
  217. (define-public idris-wl-pprint
  218. (let ((commit "1d365fcf4ba075859844dbc5eb96a90f57b9f338"))
  219. (package
  220. (name "idris-wl-pprint")
  221. (version (git-version "0.1" "1" commit))
  222. (source (origin
  223. (method git-fetch)
  224. (uri (git-reference
  225. (url "https://github.com/shayan-najd/wl-pprint")
  226. (commit commit)))
  227. (file-name (git-file-name name version))
  228. (sha256
  229. (base32
  230. "0g7c3y9smifdz4sivi3qmvymhdr7v9kfq45fmfmmvkqcrix0spzn"))))
  231. (build-system gnu-build-system)
  232. (native-inputs
  233. (list idris))
  234. (arguments (idris-default-arguments name))
  235. (home-page "https://github.com/shayan-najd/wl-pprint")
  236. (synopsis "Pretty printing library")
  237. (description "A pretty printing library for Idris based on Phil Wadler's
  238. paper A Prettier Printer and on Daan Leijen's extensions in the Haskell
  239. wl-pprint library.")
  240. (license license:bsd-2))))
  241. (define-public idris-bifunctors
  242. (let ((commit "53d06a6ccfe70c49c9ae8c8a4135981dd2173202"))
  243. (package
  244. (name "idris-bifunctors")
  245. (version (git-version "0.1" "1" commit))
  246. (source (origin
  247. (method git-fetch)
  248. (uri (git-reference
  249. (url "https://github.com/HuwCampbell/Idris-Bifunctors")
  250. (commit commit)))
  251. (file-name (string-append name "-" version "-checkout"))
  252. (sha256
  253. (base32
  254. "02vbsd3rmgnj0l1qq787709qcxjbr9890cbad4ykn27f77jk81h4"))))
  255. (build-system gnu-build-system)
  256. (native-inputs
  257. (list idris))
  258. (arguments (idris-default-arguments name))
  259. (home-page "https://github.com/HuwCampbell/Idris-Bifunctors")
  260. (synopsis "Bifunctor library")
  261. (description "This is a bifunctor library for Idris based off the
  262. excellent Haskell Bifunctors package from Edward Kmett.")
  263. (license license:bsd-3))))
  264. (define-public idris-lens
  265. (let ((commit "26f012005f6849806cea630afe317e42cae97f29"))
  266. (package
  267. (name "idris-lens")
  268. (version (git-version "0.1" "1" commit))
  269. (source (origin
  270. (method git-fetch)
  271. (uri (git-reference
  272. (url "https://github.com/HuwCampbell/idris-lens")
  273. (commit commit)))
  274. (file-name (git-file-name name version))
  275. (sha256
  276. (base32
  277. "06jzfj6rad08rk92w8jk5byi79svmyg0mrcqhibgx8rkjjy6vmai"))))
  278. (build-system gnu-build-system)
  279. (native-inputs
  280. (list idris))
  281. (propagated-inputs
  282. (list idris-bifunctors))
  283. (arguments (idris-default-arguments name))
  284. (home-page "https://github.com/HuwCampbell/idris-lens")
  285. (synopsis "Van Laarhoven lenses for Idris")
  286. (description "Lenses are composable functional references. They allow
  287. accessing and modifying data within a structure.")
  288. (license license:bsd-3))))