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, 2022 Eric Bavier <bavier@posteo.net>
6 ;;; Copyright © 2022 Attila Lendvai <attila@lendvai.name>
8 ;;; This file is part of GNU Guix.
10 ;;; GNU Guix is free software; you can redistribute it and/or modify it
11 ;;; under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 3 of the License, or (at
13 ;;; your option) any later version.
15 ;;; GNU Guix is distributed in the hope that it will be useful, but
16 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23 (define-module (gnu packages idris)
24 #:use-module (gnu packages)
25 #:use-module (gnu packages haskell-check)
26 #:use-module (gnu packages haskell-web)
27 #:use-module (gnu packages haskell-xyz)
28 #:use-module (gnu packages libffi)
29 #:use-module (gnu packages multiprecision)
30 #:use-module (gnu packages ncurses)
31 #:use-module (gnu packages perl)
32 #:use-module (guix build-system gnu)
33 #:use-module (guix build-system haskell)
34 #:use-module (guix download)
35 #:use-module (guix git-download)
36 #:use-module (guix utils)
37 #:use-module ((guix licenses) #:prefix license:)
38 #:use-module (guix packages))
47 (url "https://github.com/idris-lang/Idris-dev.git")
48 (commit (string-append "v" version))))
49 (file-name (git-file-name name version))
52 "0cd2a92323hb9a6wy8sc0cqwnisf4pv8y9y2rxvxcbyv8cs1q8g2"))
53 (patches (search-patches "idris-test-ffi008.patch"))))
54 (build-system haskell-build-system)
55 (native-inputs ;For tests
56 (list perl ghc-cheapskate ghc-tasty ghc-tasty-golden
62 ghc-annotated-wl-pprint
77 ghc-optparse-applicative
83 ghc-unordered-containers
86 ghc-vector-binary-instances
90 (list (string-append "--datasubdir="
91 (assoc-ref %outputs "out") "/lib/idris")
94 (modify-phases %standard-phases
95 ;; This allows us to call the 'idris' binary before installing.
96 (add-after 'unpack 'set-ld-library-path
98 (setenv "LD_LIBRARY_PATH" (string-append (getcwd) "/dist/build"))))
99 (add-before 'configure 'update-constraints
101 (substitute* "idris.cabal"
102 (("(aeson|ansi-terminal|haskeline|megaparsec|optparse-applicative)\\s+[^,]+" all dep)
104 (add-before 'configure 'set-cc-command
106 (setenv "CC" ,(cc-for-target))))
107 (add-after 'install 'fix-libs-install-location
108 (lambda* (#:key outputs #:allow-other-keys)
109 (let* ((out (assoc-ref outputs "out"))
110 (lib (string-append out "/lib/idris"))
111 (modules (string-append lib "/libs")))
114 (symlink (string-append modules "/" module)
115 (string-append lib "/" module)))
116 '("prelude" "base" "contrib" "effects" "pruviloj")))))
117 (delete 'check) ;Run check later
118 (add-after 'install 'check
119 (lambda* (#:key outputs #:allow-other-keys #:rest args)
120 (let ((out (assoc-ref outputs "out")))
121 (chmod "test/scripts/timeout" #o755) ;must be executable
122 (setenv "TASTY_NUM_THREADS" (number->string (parallel-job-count)))
123 (setenv "IDRIS_CC" ,(cc-for-target)) ;Needed for creating executables
124 (setenv "PATH" (string-append out "/bin:" (getenv "PATH")))
125 (apply (assoc-ref %standard-phases 'check) args))))
126 (add-before 'check 'restore-libidris_rts
127 (lambda* (#:key outputs #:allow-other-keys)
128 ;; The Haskell build system moves this library to the
129 ;; "static" output. Idris only knows how to find it in the
130 ;; "out" output, so we restore it here.
131 (let ((out (assoc-ref outputs "out"))
132 (static (assoc-ref outputs "static"))
133 (filename "/lib/idris/rts/libidris_rts.a"))
134 (rename-file (string-append static filename)
135 (string-append out filename))))))))
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
147 (license license:bsd-3)))
149 ;; Idris modules use the gnu-build-system so that the IDRIS_LIBRARY_PATH is set.
150 (define (idris-default-arguments name)
151 `(#:modules ((guix build gnu-build-system)
156 (modify-phases %standard-phases
161 (lambda* (#:key inputs outputs #:allow-other-keys)
162 (let* ((out (assoc-ref outputs "out"))
163 (idris (assoc-ref inputs "idris"))
164 (idris-bin (string-append idris "/bin/idris"))
165 (idris-libs (string-append idris "/lib/idris/libs"))
166 (module-name (and (string-prefix? "idris-" ,name)
167 (substring ,name 6)))
168 (ibcsubdir (string-append out "/lib/idris/" module-name))
169 (ipkg (string-append module-name ".ipkg"))
170 (idris-library-path (getenv "IDRIS_LIBRARY_PATH"))
171 (idris-path (string-split idris-library-path #\:))
172 (idris-path-files (apply append
175 (string-append path "/" dir))
176 (scandir path))) idris-path)))
177 (idris-path-subdirs (filter (lambda (path)
178 (and path (match (stat:type (stat path))
182 (install-cmd (cons* idris-bin
183 "--ibcsubdir" ibcsubdir
185 ;; only trigger a build, as --ibcsubdir
186 ;; already installs .ibc files.
188 (apply append (map (lambda (path)
191 idris-path-subdirs)))))
192 ;; FIXME: Seems to be a bug in idris that causes a dubious failure.
193 (apply system* install-cmd)))))))
195 (define-public idris-lightyear
196 (let ((commit "6d65ad111b4bed2bc131396f8385528fc6b3678a"))
198 (name "idris-lightyear")
199 (version (git-version "0.1" "1" commit))
203 (url "https://github.com/ziman/lightyear")
205 (file-name (git-file-name name version))
208 "1pkxnn3ryr0v0cin4nasw7kgkc9dnnpja1nfbj466mf3qv5s98af"))))
209 (build-system gnu-build-system)
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))))
220 (define-public idris-wl-pprint
221 (let ((commit "1d365fcf4ba075859844dbc5eb96a90f57b9f338"))
223 (name "idris-wl-pprint")
224 (version (git-version "0.1" "1" commit))
228 (url "https://github.com/shayan-najd/wl-pprint")
230 (file-name (git-file-name name version))
233 "0g7c3y9smifdz4sivi3qmvymhdr7v9kfq45fmfmmvkqcrix0spzn"))))
234 (build-system gnu-build-system)
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
243 (license license:bsd-2))))
245 (define-public idris-bifunctors
246 (let ((commit "53d06a6ccfe70c49c9ae8c8a4135981dd2173202"))
248 (name "idris-bifunctors")
249 (version (git-version "0.1" "1" commit))
253 (url "https://github.com/HuwCampbell/Idris-Bifunctors")
255 (file-name (string-append name "-" version "-checkout"))
258 "02vbsd3rmgnj0l1qq787709qcxjbr9890cbad4ykn27f77jk81h4"))))
259 (build-system gnu-build-system)
262 (arguments (idris-default-arguments name))
263 (home-page "https://github.com/HuwCampbell/Idris-Bifunctors")
264 (synopsis "Bifunctor library")
265 (description "This is a bifunctor library for Idris based off the
266 excellent Haskell Bifunctors package from Edward Kmett.")
267 (license license:bsd-3))))
269 (define-public idris-lens
270 (let ((commit "26f012005f6849806cea630afe317e42cae97f29"))
273 (version (git-version "0.1" "1" commit))
277 (url "https://github.com/HuwCampbell/idris-lens")
279 (file-name (git-file-name name version))
282 "06jzfj6rad08rk92w8jk5byi79svmyg0mrcqhibgx8rkjjy6vmai"))))
283 (build-system gnu-build-system)
287 (list idris-bifunctors))
288 (arguments (idris-default-arguments name))
289 (home-page "https://github.com/HuwCampbell/idris-lens")
290 (synopsis "Van Laarhoven lenses for Idris")
291 (description "Lenses are composable functional references. They allow
292 accessing and modifying data within a structure.")
293 (license license:bsd-3))))