idris.scm 13 KB

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