Patchwork [1/2] gnu: idris: Update to 0.99.

login
register
mail settings
Submitter David Craven
Date Dec. 15, 2016, 5:28 p.m.
Message ID <20161215172835.7300-1-david@craven.ch>
Download mbox | patch
Permalink /patch/18487/
State New
Headers show

Comments

David Craven - Dec. 15, 2016, 5:28 p.m.
* gnu/packages/haskell.scm (idris): Update to 0.99.
---
 gnu/local.mk                                       |  2 +
 gnu/packages/haskell.scm                           | 35 ++++++++--------
 .../patches/idris-IDRIS_LIBRARY_PATH.patch         | 46 ++++++++++++++++++++++
 gnu/packages/patches/idris-install-to-TARGET.patch | 27 +++++++++++++
 4 files changed, 91 insertions(+), 19 deletions(-)
 create mode 100644 gnu/packages/patches/idris-IDRIS_LIBRARY_PATH.patch
 create mode 100644 gnu/packages/patches/idris-install-to-TARGET.patch

Patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 739d92a7b..af6e36618 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -632,6 +632,8 @@  dist_patch_DATA =						\
   %D%/packages/patches/icu4c-CVE-2014-6585.patch		\
   %D%/packages/patches/icu4c-CVE-2015-1270.patch		\
   %D%/packages/patches/icu4c-CVE-2015-4760.patch		\
+  %D%/packages/patches/idris-IDRIS_LIBRARY_PATH.patch		\
+  %D%/packages/patches/idris-install-to-TARGET.patch		\
   %D%/packages/patches/id3lib-CVE-2007-4460.patch			\
   %D%/packages/patches/ilmbase-fix-tests.patch			\
   %D%/packages/patches/inkscape-drop-wait-for-targets.patch	\
diff --git a/gnu/packages/haskell.scm b/gnu/packages/haskell.scm
index 8e5927a00..2f75c6c37 100644
--- a/gnu/packages/haskell.scm
+++ b/gnu/packages/haskell.scm
@@ -32,6 +32,7 @@ 
   #:use-module (guix utils)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system haskell)
+  #:use-module (gnu packages)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages compression)
@@ -6670,24 +6671,9 @@  constant-time:
     (license license:bsd-3)))
 
 (define-public idris
-  ;; TODO: IDRIS_LIBRARY_PATH only accepts a single path and not a colon
-  ;; separated list.
-  ;; TODO: When installing idris the location of the standard libraries
-  ;; cannot be specified.
-  ;; NOTE: Creating an idris build system:
-  ;; Idris packages can be packaged and installed using a trivial
-  ;; build system.
-  ;; (zero? (system* (string-append idris "/bin/idris")
-  ;;                                "--ibcsubdir"
-  ;;                                (string-append out "/idris/libs/lightyear")
-  ;;                                "--install" "lightyear.ipkg")
-  ;; (native-search-paths
-  ;;   (list (search-path-specification
-  ;;          (variable "IDRIS_LIBRARY_PATH")
-  ;;          (files '("idris/libs")))))
   (package
     (name "idris")
-    (version "0.12.3")
+    (version "0.99")
     (source (origin
               (method url-fetch)
               (uri (string-append
@@ -6695,7 +6681,9 @@  constant-time:
                     "idris-" version "/idris-" version ".tar.gz"))
               (sha256
                (base32
-                "1ijrbgzaahw9aagn4al55nqcggrg9ajlrkq2fjc1saq3xdd3v7rs"))))
+                "1sd4vy5rx0mp32xj99qijhknkgw4d2rxvz6wiy3pym6kaqmc497i"))
+              (patches (search-patches "idris-IDRIS_LIBRARY_PATH.patch"
+                                       "idris-install-to-TARGET.patch"))))
     (build-system haskell-build-system)
     (arguments
      `(;; FIXME: runhaskell Setup.hs test doesn't set paths required by test
@@ -6704,8 +6692,13 @@  constant-time:
        #:phases
        (modify-phases %standard-phases
          (add-before 'configure 'patch-cc-command
-           (lambda _
-             (setenv "CC" "gcc"))))))
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (lib (string-append out "/idris")))
+               (setenv "CC" "gcc")
+               ;; TARGET sets the path that the idris stdlibs are installed to.
+               (setenv "TARGET" lib))
+             #t)))))
     (inputs
      `(("gmp" ,gmp)
        ("ncurses" ,ncurses)
@@ -6741,6 +6734,10 @@  constant-time:
        ("ghc-vector" ,ghc-vector)
        ("ghc-zip-archive" ,ghc-zip-archive)
        ("ghc-zlib" ,ghc-zlib)))
+    (native-search-paths
+     (list (search-path-specification
+            (variable "IDRIS_LIBRARY_PATH")
+            (files '("idris/libs")))))
     (home-page "http://www.idris-lang.org")
     (synopsis "General purpose language with full dependent types")
     (description "Idris is a general purpose language with full dependent
diff --git a/gnu/packages/patches/idris-IDRIS_LIBRARY_PATH.patch b/gnu/packages/patches/idris-IDRIS_LIBRARY_PATH.patch
new file mode 100644
index 000000000..97a2f5bd3
--- /dev/null
+++ b/gnu/packages/patches/idris-IDRIS_LIBRARY_PATH.patch
@@ -0,0 +1,46 @@ 
+From 8617ba8f391da875ea0d59c6b8fdce26b64e2abd Mon Sep 17 00:00:00 2001
+From: David Craven <david@craven.ch>
+Date: Sun, 6 Nov 2016 15:46:50 +0100
+Subject: [PATCH 1/2] IDRIS_LIBRARY_PATH accepts a colon separated search path.
+
+* src/Idris/Imports.hs (installedPackages): SplitOn colon and concatMap
+  the results.
+---
+ src/Idris/Imports.hs | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/src/Idris/Imports.hs b/src/Idris/Imports.hs
+index f7bec7be..7018ec57 100644
+--- a/src/Idris/Imports.hs
++++ b/src/Idris/Imports.hs
+@@ -18,6 +18,7 @@ import IRTS.System (getIdrisLibDir)
+ import Control.Applicative ((<$>))
+ import Control.Monad.State.Strict
+ import Data.List (isSuffixOf)
++import Data.List.Split (splitOn)
+ import System.Directory
+ import System.FilePath
+ 
+@@ -94,7 +95,7 @@ findPkgIndex p = do let idx = pkgIndex p
+ installedPackages :: IO [String]
+ installedPackages = do
+   idir <- getIdrisLibDir
+-  filterM (goodDir idir) =<< dirContents idir
++  filterM (goodDir idir) =<< concat <$> (mapM dirContents (splitOn ":" idir))
+   where
+   allFilesInDir base fp = do
+     let fullpath = base </> fp
+@@ -102,7 +103,9 @@ installedPackages = do
+     if isDir
+       then fmap concat (mapM (allFilesInDir fullpath) =<< dirContents fullpath)
+       else return [fp]
+-  dirContents = fmap (filter (not . (`elem` [".", ".."]))) . getDirectoryContents
++  prependDirname dir = fmap (fmap (dir </>))
++  filterPaths = fmap (filter (not . (`elem` [".", ".."])))
++  dirContents dir = prependDirname dir (filterPaths (getDirectoryContents dir))
+   goodDir idir d = any (".ibc" `isSuffixOf`) <$> allFilesInDir idir d
+ 
+ 
+-- 
+2.11.0
+
diff --git a/gnu/packages/patches/idris-install-to-TARGET.patch b/gnu/packages/patches/idris-install-to-TARGET.patch
new file mode 100644
index 000000000..695044e8d
--- /dev/null
+++ b/gnu/packages/patches/idris-install-to-TARGET.patch
@@ -0,0 +1,27 @@ 
+From 51d84e9adde98b4acf734c0f2631c8d956d2e281 Mon Sep 17 00:00:00 2001
+From: David Craven <david@craven.ch>
+Date: Sun, 6 Nov 2016 16:12:54 +0100
+Subject: [PATCH 2/2] Override default library install path with TARGET.
+
+* Setup.hs (idrisInstall): installStdLib to TARGET when set.
+---
+ Setup.hs | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/Setup.hs b/Setup.hs
+index 8f58b6b3..affb61dc 100644
+--- a/Setup.hs
++++ b/Setup.hs
+@@ -254,7 +254,8 @@ idrisInstall verbosity copy pkg local = unless (execOnly (configFlags local)) $
+       target = datadir $ L.absoluteInstallDirs pkg local copy
+ 
+       installStdLib = do
+-        let target' = target -- </> "libs"
++        envTarget <- lookupEnv "TARGET"
++        let target' = maybe target id envTarget -- </> "libs"
+         putStrLn $ "Installing libraries in " ++ target'
+         makeInstall "libs" target'
+ 
+-- 
+2.11.0
+