summary refs log tree commit diff
path: root/gnu/packages/idris.scm
diff options
context:
space:
mode:
authorDavid Craven <david@craven.ch>2016-12-15 12:35:20 +0100
committerDavid Craven <david@craven.ch>2017-01-04 12:11:14 +0100
commitea3b38f1e14296a421d9df8d6c11c894d631b373 (patch)
tree3529aadd2e23df58d668e7f5fcb7889f20eae4db /gnu/packages/idris.scm
parentae482ce12d19f7d8d58677a8c56c9581fa1c50fc (diff)
downloadguix-ea3b38f1e14296a421d9df8d6c11c894d631b373.tar.gz
gnu: Add idris-lightyear.
* gnu/packages/idris.scm (idris-lightyear, idris-default-arguments):
  New variables.
Diffstat (limited to 'gnu/packages/idris.scm')
-rw-r--r--gnu/packages/idris.scm72
1 files changed, 71 insertions, 1 deletions
diff --git a/gnu/packages/idris.scm b/gnu/packages/idris.scm
index 2049c3eea8..60d20a1d64 100644
--- a/gnu/packages/idris.scm
+++ b/gnu/packages/idris.scm
@@ -21,8 +21,8 @@
   #:use-module (gnu packages haskell)
   #:use-module (gnu packages multiprecision)
   #:use-module (gnu packages ncurses)
+  #:use-module (guix build-system gnu)
   #:use-module (guix build-system haskell)
-  #:use-module (guix build-system idris)
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module ((guix licenses) #:prefix license:)
@@ -109,3 +109,73 @@ be predicated on values, meaning that some aspects of a program's behaviour
 can be specified precisely in the type.  The language is closely related to
 Epigram and Agda.")
     (license license:bsd-3)))
+
+;; Idris modules use the gnu-build-system so that the IDRIS_LIBRARY_PATH is set.
+(define (idris-default-arguments name)
+  `(#:modules ((guix build gnu-build-system)
+               (guix build utils)
+               (ice-9 ftw)
+               (ice-9 match))
+    #:phases
+    (modify-phases %standard-phases
+      (delete 'configure)
+      (delete 'build)
+      (delete 'check)
+      (replace 'install
+        (lambda* (#:key inputs outputs #:allow-other-keys)
+          (let* ((out (assoc-ref outputs "out"))
+                 (idris (assoc-ref inputs "idris"))
+                 (idris-bin (string-append idris "/bin/idris"))
+                 (idris-libs (string-append idris "/lib/idris/libs"))
+                 (module-name (and (string-prefix? "idris-" ,name)
+                                   (substring ,name 6)))
+                 (ibcsubdir (string-append out "/lib/idris/" module-name))
+                 (ipkg (string-append module-name ".ipkg"))
+                 (idris-library-path (getenv "IDRIS_LIBRARY_PATH"))
+                 (idris-path (string-split idris-library-path #\:))
+                 (idris-path-files (apply append
+                                          (map (lambda (path)
+                                                 (map (lambda (dir)
+                                                        (string-append path "/" dir))
+                                                      (scandir path))) idris-path)))
+                 (idris-path-subdirs (filter (lambda (path)
+                                               (and path (match (stat:type (stat path))
+                                                           ('directory #t)
+                                                           (_ #f))))
+                                                    idris-path-files))
+                 (install-cmd (cons* idris-bin
+                                     "--ibcsubdir" ibcsubdir
+                                     "--install" ipkg
+                                     (apply append (map (lambda (path)
+                                                          (list "--idrispath"
+                                                                path))
+                                                        idris-path-subdirs)))))
+            (setenv "IDRIS_LIBRARY_PATH" idris-libs)
+            ;; FIXME: Seems to be a bug in idris that causes a dubious failure.
+            (apply system* install-cmd)
+            #t))))))
+
+(define-public idris-lightyear
+  (let ((commit "6d65ad111b4bed2bc131396f8385528fc6b3678a"))
+    (package
+      (name "idris-lightyear")
+      (version (git-version "0.1" "1" commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/ziman/lightyear")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "1pkxnn3ryr0v0cin4nasw7kgkc9dnnpja1nfbj466mf3qv5s98af"))))
+      (build-system gnu-build-system)
+      (native-inputs
+       `(("idris" ,idris)))
+      (arguments (idris-default-arguments name))
+      (home-page "https://github.com/ziman/lightyear")
+      (synopsis "Lightweight parser combinator library for Idris")
+      (description "Lightweight parser combinator library for Idris, inspired
+by Parsec.  This package is used (almost) the same way as Parsec, except for one
+difference: backtracking.")
+      (license license:bsd-2))))