summaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2017-02-10 17:40:25 +0100
committerLudovic Courtès <ludo@gnu.org>2017-02-10 17:40:25 +0100
commit768f0ac9dd9993827430d62d0f72a5020f476892 (patch)
tree600f7ca7cedb221147edfc92356e11bc6c56f311 /guix
parent955ba55c6bf3a22264b56274ec22cad1551c1ce6 (diff)
parent49dbae548e92e0521ae125239282a04d8ea924cf (diff)
Merge branch 'master' into core-updates
Diffstat (limited to 'guix')
-rw-r--r--guix/build-system/dub.scm147
-rw-r--r--guix/build/dub-build-system.scm125
-rw-r--r--guix/git-download.scm43
-rw-r--r--guix/import/hackage.scm24
-rw-r--r--guix/import/json.scm3
-rw-r--r--guix/import/pypi.scm13
-rw-r--r--guix/import/stackage.scm135
-rw-r--r--guix/profiles.scm26
-rw-r--r--guix/scripts/environment.scm26
-rw-r--r--guix/scripts/import.scm3
-rw-r--r--guix/scripts/import/stackage.scm115
-rw-r--r--guix/scripts/refresh.scm1
12 files changed, 618 insertions, 43 deletions
diff --git a/guix/build-system/dub.scm b/guix/build-system/dub.scm
new file mode 100644
index 0000000000..13c89e8648
--- /dev/null
+++ b/guix/build-system/dub.scm
@@ -0,0 +1,147 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
+;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
+;;; Copyright © 2016 David Craven <david@craven.ch>
+;;; Copyright © 2016 Danny Milosavljevic <dannym@scratchpost.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build-system dub)
+ #:use-module (guix search-paths)
+ #:use-module (guix store)
+ #:use-module (guix utils)
+ #:use-module (guix derivations)
+ #:use-module (guix packages)
+ #:use-module (guix build-system)
+ #:use-module (guix build-system gnu)
+ #:use-module (ice-9 match)
+ #:use-module (srfi srfi-26)
+ #:export (dub-build-system))
+
+(define (default-ldc)
+ "Return the default ldc package."
+ ;; Lazily resolve the binding to avoid a circular dependency.
+ (let ((ldc (resolve-interface '(gnu packages ldc))))
+ (module-ref ldc 'ldc)))
+
+(define (default-dub)
+ "Return the default dub package."
+ ;; Lazily resolve the binding to avoid a circular dependency.
+ (let ((ldc (resolve-interface '(gnu packages ldc))))
+ (module-ref ldc 'dub)))
+
+(define (default-pkg-config)
+ "Return the default pkg-config package."
+ ;; Lazily resolve the binding to avoid a circular dependency.
+ (let ((pkg-config (resolve-interface '(gnu packages pkg-config))))
+ (module-ref pkg-config 'pkg-config)))
+
+(define %dub-build-system-modules
+ ;; Build-side modules imported by default.
+ `((guix build dub-build-system)
+ (guix build syscalls)
+ ,@%gnu-build-system-modules))
+
+(define* (dub-build store name inputs
+ #:key
+ (tests? #t)
+ (test-target #f)
+ (dub-build-flags ''())
+ (phases '(@ (guix build dub-build-system)
+ %standard-phases))
+ (outputs '("out"))
+ (search-paths '())
+ (system (%current-system))
+ (guile #f)
+ (imported-modules %dub-build-system-modules)
+ (modules '((guix build dub-build-system)
+ (guix build utils))))
+ "Build SOURCE using DUB, and with INPUTS."
+ (define builder
+ `(begin
+ (use-modules ,@modules)
+ (dub-build #:name ,name
+ #:source ,(match (assoc-ref inputs "source")
+ (((? derivation? source))
+ (derivation->output-path source))
+ ((source)
+ source)
+ (source
+ source))
+ #:system ,system
+ #:test-target ,test-target
+ #:dub-build-flags ,dub-build-flags
+ #:tests? ,tests?
+ #:phases ,phases
+ #:outputs %outputs
+ #:search-paths ',(map search-path-specification->sexp
+ search-paths)
+ #:inputs %build-inputs)))
+
+ (define guile-for-build
+ (match guile
+ ((? package?)
+ (package-derivation store guile system #:graft? #f))
+ (#f ; the default
+ (let* ((distro (resolve-interface '(gnu packages commencement)))
+ (guile (module-ref distro 'guile-final)))
+ (package-derivation store guile system #:graft? #f)))))
+
+ (build-expression->derivation store name builder
+ #:inputs inputs
+ #:system system
+ #:modules imported-modules
+ #:outputs outputs
+ #:guile-for-build guile-for-build))
+
+(define* (lower name
+ #:key source inputs native-inputs outputs system target
+ (ldc (default-ldc))
+ (dub (default-dub))
+ (pkg-config (default-pkg-config))
+ #:allow-other-keys
+ #:rest arguments)
+ "Return a bag for NAME."
+
+ (define private-keywords
+ '(#:source #:target #:ldc #:dub #:pkg-config #:inputs #:native-inputs #:outputs))
+
+ (and (not target) ;; TODO: support cross-compilation
+ (bag
+ (name name)
+ (system system)
+ (target target)
+ (host-inputs `(,@(if source
+ `(("source" ,source))
+ '())
+ ,@inputs
+
+ ;; Keep the standard inputs of 'gnu-build-system'
+ ,@(standard-packages)))
+ (build-inputs `(("ldc" ,ldc)
+ ("dub" ,dub)
+ ,@native-inputs))
+ (outputs outputs)
+ (build dub-build)
+ (arguments (strip-keyword-arguments private-keywords arguments)))))
+
+(define dub-build-system
+ (build-system
+ (name 'dub)
+ (description
+ "DUB build system, to build D packages")
+ (lower lower)))
diff --git a/guix/build/dub-build-system.scm b/guix/build/dub-build-system.scm
new file mode 100644
index 0000000000..7c7cd8803c
--- /dev/null
+++ b/guix/build/dub-build-system.scm
@@ -0,0 +1,125 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2016 David Craven <david@craven.ch>
+;;; Copyright © 2017 Danny Milosavljevic <dannym@scratchpost.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build dub-build-system)
+ #:use-module ((guix build gnu-build-system) #:prefix gnu:)
+ #:use-module (guix build syscalls)
+ #:use-module (guix build utils)
+ #:use-module (ice-9 popen)
+ #:use-module (ice-9 rdelim)
+ #:use-module (ice-9 ftw)
+ #:use-module (ice-9 format)
+ #:use-module (ice-9 match)
+ #:use-module (rnrs io ports)
+ #:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-26)
+ #:export (%standard-phases
+ dub-build))
+
+;; Commentary:
+;;
+;; Builder-side code of the DUB (the build tool for D) build system.
+;;
+;; Code:
+
+;; FIXME: Needs to be parsed from url not package name.
+(define (package-name->d-package-name name)
+ "Return the package name of NAME."
+ (match (string-split name #\-)
+ (("d" rest ...)
+ (string-join rest "-"))
+ (_ #f)))
+
+(define* (configure #:key inputs #:allow-other-keys)
+ "Prepare one new directory with all the required dependencies.
+ It's necessary to do this (instead of just using /gnu/store as the
+ directory) because we want to hide the libraries in subdirectories
+ lib/dub/... instead of polluting the user's profile root."
+ (let* ((dir (mkdtemp! "/tmp/dub.XXXXXX"))
+ (vendor-dir (string-append dir "/vendor")))
+ (setenv "HOME" dir)
+ (mkdir vendor-dir)
+ (for-each
+ (match-lambda
+ ((name . path)
+ (let* ((d-package (package-name->d-package-name name))
+ (d-basename (basename path)))
+ (when (and d-package path)
+ (match (string-split (basename path) #\-)
+ ((_ ... version)
+ (symlink (string-append path "/lib/dub/" d-basename)
+ (string-append vendor-dir "/" d-basename))))))))
+ inputs)
+ (zero? (system* "dub" "add-path" vendor-dir))))
+
+(define (grep string file-name)
+ "Find the first occurence of STRING in the file named FILE-NAME.
+ Return the position of this occurence, or #f if none was found."
+ (string-contains (call-with-input-file file-name get-string-all)
+ string))
+
+(define (grep* string file-name)
+ "Find the first occurence of STRING in the file named FILE-NAME.
+ Return the position of this occurence, or #f if none was found.
+ If the file named FILE-NAME doesn't exist, return #f."
+ (catch 'system-error
+ (lambda ()
+ (grep string file-name))
+ (lambda args
+ #f)))
+
+(define* (build #:key (dub-build-flags '())
+ #:allow-other-keys)
+ "Build a given DUB package."
+ (if (or (grep* "sourceLibrary" "package.json")
+ (grep* "sourceLibrary" "dub.sdl") ; note: format is different!
+ (grep* "sourceLibrary" "dub.json"))
+ #t
+ (let ((status (zero? (apply system* `("dub" "build" ,@dub-build-flags)))))
+ (system* "dub" "run") ; might fail for "targetType": "library"
+ status)))
+
+(define* (check #:key tests? #:allow-other-keys)
+ (if tests?
+ (zero? (system* "dub" "test"))
+ #t))
+
+(define* (install #:key inputs outputs #:allow-other-keys)
+ "Install a given DUB package."
+ (let* ((out (assoc-ref outputs "out"))
+ (outbin (string-append out "/bin"))
+ (outlib (string-append out "/lib/dub/" (basename out))))
+ (mkdir-p outbin)
+ ;; TODO remove "-test-application"
+ (copy-recursively "bin" outbin)
+ (mkdir-p outlib)
+ (copy-recursively "." (string-append outlib))
+ #t))
+
+(define %standard-phases
+ (modify-phases gnu:%standard-phases
+ (replace 'configure configure)
+ (replace 'build build)
+ (replace 'check check)
+ (replace 'install install)))
+
+(define* (dub-build #:key inputs (phases %standard-phases)
+ #:allow-other-keys #:rest args)
+ "Build the given DUB package, applying all of PHASES in order."
+ (apply gnu:gnu-build #:inputs inputs #:phases phases args))
diff --git a/guix/git-download.scm b/guix/git-download.scm
index 62e625c715..5d86ab2b62 100644
--- a/guix/git-download.scm
+++ b/guix/git-download.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2017 Mathieu Lirzin <mthl@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -17,6 +18,7 @@
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (guix git-download)
+ #:use-module (guix build utils)
#:use-module (guix gexp)
#:use-module (guix store)
#:use-module (guix monads)
@@ -24,6 +26,9 @@
#:use-module (guix packages)
#:autoload (guix build-system gnu) (standard-packages)
#:use-module (ice-9 match)
+ #:use-module (ice-9 popen)
+ #:use-module (ice-9 rdelim)
+ #:use-module (srfi srfi-1)
#:export (git-reference
git-reference?
git-reference-url
@@ -32,7 +37,8 @@
git-fetch
git-version
- git-file-name))
+ git-file-name
+ git-predicate))
;;; Commentary:
;;;
@@ -119,4 +125,39 @@ HASH-ALGO (a symbol). Use NAME as the file name, or a generic name if #f."
"Return the file-name for packages using git-download."
(string-append name "-" version "-checkout"))
+(define (git-predicate directory)
+ "Return a predicate that returns true if a file is part of the Git checkout
+living at DIRECTORY. Upon Git failure, return #f instead of a predicate.
+
+The returned predicate takes two arguments FILE and STAT where FILE is an
+absolute file name and STAT is the result of 'lstat'."
+ (define (parent-directory? thing directory)
+ ;; Return #t if DIRECTORY is the parent of THING.
+ (or (string-suffix? thing directory)
+ (and (string-index thing #\/)
+ (parent-directory? (dirname thing) directory))))
+
+ (let* ((pipe (with-directory-excursion directory
+ (open-pipe* OPEN_READ "git" "ls-files")))
+ (files (let loop ((lines '()))
+ (match (read-line pipe)
+ ((? eof-object?)
+ (reverse lines))
+ (line
+ (loop (cons line lines))))))
+ (status (close-pipe pipe)))
+ (and (zero? status)
+ (lambda (file stat)
+ (match (stat:type stat)
+ ('directory
+ ;; 'git ls-files' does not list directories, only regular files,
+ ;; so we need this special trick.
+ (any (lambda (f) (parent-directory? f file))
+ files))
+ ((or 'regular 'symlink)
+ (any (lambda (f) (string-suffix? f file))
+ files))
+ (_
+ #f))))))
+
;;; git-download.scm ends here
diff --git a/guix/import/hackage.scm b/guix/import/hackage.scm
index 9af78ea888..2c9df073d3 100644
--- a/guix/import/hackage.scm
+++ b/guix/import/hackage.scm
@@ -21,6 +21,7 @@
(define-module (guix import hackage)
#:use-module (ice-9 match)
#:use-module (ice-9 regex)
+ #:use-module (srfi srfi-34)
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-11)
#:use-module (srfi srfi-1)
@@ -37,7 +38,13 @@
#:use-module (guix packages)
#:use-module ((guix utils) #:select (call-with-temporary-output-file))
#:export (hackage->guix-package
- %hackage-updater))
+ %hackage-updater
+
+ guix-package->hackage-name
+ hackage-fetch
+ hackage-source-url
+ hackage-cabal-url
+ hackage-package?))
(define ghc-standard-libraries
;; List of libraries distributed with ghc (7.10.2). We include GHC itself as
@@ -109,12 +116,15 @@ version is returned."
"Return the Cabal file for the package NAME-VERSION, or #f on failure. If
the version part is omitted from the package name, then return the latest
version."
- (let-values (((name version) (package-name->name+version name-version)))
- (let* ((url (hackage-cabal-url name version))
- (port (http-fetch url))
- (result (read-cabal (canonical-newline-port port))))
- (close-port port)
- result)))
+ (guard (c ((and (http-get-error? c)
+ (= 404 (http-get-error-code c)))
+ #f)) ;"expected" if package is unknown
+ (let-values (((name version) (package-name->name+version name-version)))
+ (let* ((url (hackage-cabal-url name version))
+ (port (http-fetch url))
+ (result (read-cabal (canonical-newline-port port))))
+ (close-port port)
+ result))))
(define string->license
;; List of valid values from
diff --git a/guix/import/json.scm b/guix/import/json.scm
index 5940f5e48f..c76bc9313c 100644
--- a/guix/import/json.scm
+++ b/guix/import/json.scm
@@ -29,7 +29,8 @@
(guard (c ((and (http-get-error? c)
(= 404 (http-get-error-code c)))
#f)) ;"expected" if package is unknown
- (let* ((port (http-fetch url))
+ (let* ((port (http-fetch url #:headers '((user-agent . "GNU Guile")
+ (Accept . "application/json"))))
(result (hash-table->alist (json->scm port))))
(close-port port)
result)))
diff --git a/guix/import/pypi.scm b/guix/import/pypi.scm
index ed0d4297a4..1e433e3fb3 100644
--- a/guix/import/pypi.scm
+++ b/guix/import/pypi.scm
@@ -1,7 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014 David Thompson <davet@gnu.org>
;;; Copyright © 2015 Cyril Roelandt <tipecaml@gmail.com>
-;;; Copyright © 2015, 2016 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -89,9 +89,16 @@ package."
(define (guix-package->pypi-name package)
"Given a Python PACKAGE built from pypi.python.org, return the name of the
package on PyPI."
- (let ((source-url (and=> (package-source package) origin-uri)))
+ (define (url->pypi-name url)
(hyphen-package-name->name+version
- (basename (file-sans-extension source-url)))))
+ (basename (file-sans-extension url))))
+
+ (match (and=> (package-source package) origin-uri)
+ ((? string? url)
+ (url->pypi-name url))
+ ((lst ...)
+ (any url->pypi-name lst))
+ (#f #f)))
(define (wheel-url->extracted-directory wheel-url)
(match (string-split (basename wheel-url) #\-)
diff --git a/guix/import/stackage.scm b/guix/import/stackage.scm
new file mode 100644
index 0000000000..542b718083
--- /dev/null
+++ b/guix/import/stackage.scm
@@ -0,0 +1,135 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Federico Beffa <beffa@fbengineering.ch>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix import stackage)
+ #:use-module (ice-9 match)
+ #:use-module (ice-9 regex)
+ #:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-26)
+ #:use-module (guix import json)
+ #:use-module (guix import hackage)
+ #:use-module (guix memoization)
+ #:use-module (guix packages)
+ #:use-module (guix upstream)
+ #:use-module (guix ui)
+ #:export (stackage->guix-package
+ %stackage-updater))
+
+
+;;;
+;;; Stackage info fetcher and access functions
+;;;
+
+(define %stackage-url "http://www.stackage.org")
+
+(define (lts-info-ghc-version lts-info)
+ "Retruns the version of the GHC compiler contained in LTS-INFO."
+ (match lts-info
+ ((("snapshot" ("ghc" . version) _ _) _) version)
+ (_ #f)))
+
+(define (lts-info-packages lts-info)
+ "Retruns the alist of packages contained in LTS-INFO."
+ (match lts-info
+ ((_ ("packages" pkg ...)) pkg)
+ (_ '())))
+
+(define stackage-lts-info-fetch
+ ;; "Retrieve the information about the LTS Stackage release VERSION."
+ (memoize
+ (lambda* (#:optional (version ""))
+ (let* ((url (if (string=? "" version)
+ (string-append %stackage-url "/lts")
+ (string-append %stackage-url "/lts-" version)))
+ (lts-info (json-fetch url)))
+ (if lts-info
+ (reverse lts-info)
+ (leave (_ "LTS release version not found: ~A~%") version))))))
+
+(define (stackage-package-name pkg-info)
+ (assoc-ref pkg-info "name"))
+
+(define (stackage-package-version pkg-info)
+ (assoc-ref pkg-info "version"))
+
+(define (lts-package-version pkgs-info name)
+ "Return the version of the package with upstream NAME included in PKGS-INFO."
+ (let ((pkg (find (lambda (pkg) (string=? (stackage-package-name pkg) name))
+ pkgs-info)))
+ (stackage-package-version pkg)))
+
+
+;;;
+;;; Importer entry point
+;;;
+
+(define (hackage-name-version name version)
+ (and version (string-append name "@" version)))
+
+(define* (stackage->guix-package package-name ; upstream name
+ #:key
+ (include-test-dependencies? #t)
+ (lts-version "")
+ (packages-info
+ (lts-info-packages
+ (stackage-lts-info-fetch lts-version))))
+ "Fetch Cabal file for PACKAGE-NAME from hackage.haskell.org. The retrieved
+vesion corresponds to the version of PACKAGE-NAME specified in the LTS-VERSION
+release at stackage.org. Return the `package' S-expression corresponding to
+that package, or #f on failure. PACKAGES-INFO is the alist with the packages
+included in the Stackage LTS release."
+ (let* ((version (lts-package-version packages-info package-name))
+ (name-version (hackage-name-version package-name version)))
+ (if name-version
+ (hackage->guix-package name-version
+ #:include-test-dependencies?
+ include-test-dependencies?)
+ (leave (_ "package not found: ~A~%") package-name))))
+
+
+;;;
+;;; Updater
+;;;
+
+(define latest-lts-release
+ (let ((pkgs-info (mlambda () (lts-info-packages (stackage-lts-info-fetch)))))
+ (lambda* (package)
+ "Return an <upstream-source> for the latest Stackage LTS release of
+PACKAGE or #f it the package is not inlucded in the Stackage LTS release."
+ (let* ((hackage-name (guix-package->hackage-name package))
+ (version (lts-package-version (pkgs-info) hackage-name))
+ (name-version (hackage-name-version hackage-name version)))
+ (match (and=> name-version hackage-fetch)
+ (#f (format (current-error-port)
+ "warning: failed to parse ~a~%"
+ (hackage-cabal-url hackage-name))
+ #f)
+ (_ (let ((url (hackage-source-url hackage-name version)))
+ (upstream-source
+ (package (package-name package))
+ (version version)
+ (urls (list url))))))))))
+
+(define %stackage-updater
+ (upstream-updater
+ (name 'stackage)
+ (description "Updater for Stackage LTS packages")
+ (pred hackage-package?)
+ (latest latest-lts-release)))
+
+;;; stackage.scm ends here
diff --git a/guix/profiles.scm b/guix/profiles.scm
index 495a9e2e7c..de82eae348 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -739,7 +739,7 @@ for both major versions of GTK+."
(mlet %store-monad ((gtk+ (manifest-lookup-package manifest "gtk+" "3"))
(gtk+-2 (manifest-lookup-package manifest "gtk+" "2")))
- (define (build gtk gtk-version)
+ (define (build gtk gtk-version query)
(let ((major (string-take gtk-version 1)))
(with-imported-modules '((guix build utils)
(guix build union)
@@ -756,8 +756,6 @@ for both major versions of GTK+."
(let* ((prefix (string-append "/lib/gtk-" #$major ".0/"
#$gtk-version))
- (query (string-append #$gtk "/bin/gtk-query-immodules-"
- #$major ".0"))
(destdir (string-append #$output prefix))
(moddirs (cons (string-append #$gtk prefix "/immodules")
(filter file-exists?
@@ -768,7 +766,7 @@ for both major versions of GTK+."
;; Generate a new immodules cache file.
(mkdir-p (string-append #$output prefix))
- (let ((pipe (apply open-pipe* OPEN_READ query modules))
+ (let ((pipe (apply open-pipe* OPEN_READ #$query modules))
(outfile (string-append #$output prefix
"/immodules-gtk" #$major ".cache")))
(dynamic-wind
@@ -783,9 +781,23 @@ for both major versions of GTK+."
(close-pipe pipe)))))))))
;; Don't run the hook when there's nothing to do.
- (let ((gexp #~(begin
- #$(if gtk+ (build gtk+ "3.0.0") #t)
- #$(if gtk+-2 (build gtk+-2 "2.10.0") #t))))
+ (let* ((pkg-gtk+ (module-ref ; lazy reference
+ (resolve-interface '(gnu packages gtk)) 'gtk+))
+ (gexp #~(begin
+ #$(if gtk+
+ (build
+ gtk+ "3.0.0"
+ ;; Use 'gtk-query-immodules-3.0' from the 'bin'
+ ;; output of latest gtk+ package.
+ #~(string-append
+ #$pkg-gtk+:bin "/bin/gtk-query-immodules-3.0"))
+ #t)
+ #$(if gtk+-2
+ (build
+ gtk+-2 "2.10.0"
+ #~(string-append
+ #$gtk+-2 "/bin/gtk-query-immodules-2.0"))
+ #t))))
(if (or gtk+ gtk+-2)
(gexp->derivation "gtk-im-modules" gexp
#:local-build? #t
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index 8a3a935a10..44f490043c 100644
--- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -60,12 +60,6 @@ directories in PROFILE, the store path of a profile."
(define %default-shell
(or (getenv "SHELL") "/bin/sh"))
-(define %network-configuration-files
- '("/etc/resolv.conf"
- "/etc/nsswitch.conf"
- "/etc/services"
- "/etc/hosts"))
-
(define (purify-environment)
"Unset almost all environment variables. A small number of variables such
as 'HOME' and 'USER' are left untouched."
@@ -408,22 +402,7 @@ host file systems to mount inside the container."
;; When in Rome, do as Nix build.cc does: Automagically
;; map common network configuration files.
(if network?
- (filter-map (lambda (file)
- (and (file-exists? file)
- (file-system-mapping
- (source file)
- (target file)
- ;; XXX: On some GNU/Linux
- ;; systems, /etc/resolv.conf is a
- ;; symlink to a file in a tmpfs
- ;; which, for an unknown reason,
- ;; cannot be bind mounted
- ;; read-only within the
- ;; container.
- (writable?
- (string=? file
- "/etc/resolv.conf")))))
- %network-configuration-files)
+ %network-file-mappings
'())
;; Mappings for the union closure of all inputs.
(map (lambda (dir)
@@ -433,7 +412,8 @@ host file systems to mount inside the container."
(writable? #f)))
reqs)))
(file-systems (append %container-file-systems
- (map mapping->file-system mappings))))
+ (map file-system-mapping->bind-mount
+ mappings))))
(exit/status
(call-with-container file-systems
(lambda ()
diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index 4d07e0fd69..8c2f705738 100644
--- a/guix/scripts/import.scm
+++ b/guix/scripts/import.scm
@@ -73,7 +73,8 @@ rather than \\n."
;;; Entry point.
;;;
-(define importers '("gnu" "nix" "pypi" "cpan" "hackage" "elpa" "gem" "cran" "crate"))
+(define importers '("gnu" "nix" "pypi" "cpan" "hackage" "stackage" "elpa" "gem"
+ "cran" "crate"))
(define (resolve-importer name)
(let ((module (resolve-interface
diff --git a/guix/scripts/import/stackage.scm b/guix/scripts/import/stackage.scm
new file mode 100644
index 0000000000..cf47bff259
--- /dev/null
+++ b/guix/scripts/import/stackage.scm
@@ -0,0 +1,115 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Federico Beffa <beffa@fbengineering.ch>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix scripts import stackage)
+ #:use-module (guix ui)
+ #:use-module (guix utils)
+ #:use-module (guix packages)
+ #:use-module (guix scripts)
+ #:use-module (guix import stackage)
+ #:use-module (guix scripts import)
+ #:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-11)
+ #:use-module (srfi srfi-37)
+ #:use-module (ice-9 match)
+ #:use-module (ice-9 format)
+ #:export (guix-import-stackage))
+
+
+;;;
+;;; Command-line options.
+;;;
+
+(define %default-options
+ `((lts-version . "")
+ (include-test-dependencies? . #t)))
+
+(define (show-help)
+ (display (_ "Usage: guix import stackage PACKAGE-NAME
+Import and convert the LTS Stackage package for PACKAGE-NAME.\n"))
+ (display (_ "
+ -r VERSION, --lts-version=VERSION
+ specify the LTS version to use"))
+ (display (_ "
+ -h, --help display this help and exit"))
+ (display (_ "
+ -t, --no-test-dependencies don't include test-only dependencies"))
+ (display (_ "
+ -V, --version display version information and exit"))
+ (newline)
+ (show-bug-report-information))
+
+(define %options
+ ;; Specification of the command-line options.
+ (cons* (option '(#\h "help") #f #f
+ (lambda args
+ (show-help)
+ (exit 0)))
+ (option '(#\V "version") #f #f
+ (lambda args
+ (show-version-and-exit "guix import stackage")))
+ (option '(#\t "no-test-dependencies") #f #f
+ (lambda (opt name arg result)
+ (alist-cons 'include-test-dependencies? #f
+ (alist-delete 'include-test-dependencies?
+ result))))
+ (option '(#\r "lts-version") #t #f
+ (lambda (opt name arg result)
+ (alist-cons 'lts-version arg
+ (alist-delete 'lts-version
+ result))))
+ %standard-import-options))
+
+
+;;;
+;;; Entry point.
+;;;
+
+(define (guix-import-stackage . args)
+ (define (parse-options)
+ ;; Return the alist of option values.
+ (args-fold* args %options
+ (lambda (opt name arg result)
+ (leave (_ "~A: unrecognized option~%") name))
+ (lambda (arg result)
+ (alist-cons 'argument arg result))
+ %default-options))
+
+ (let* ((opts (parse-options))
+ (args (filter-map (match-lambda
+ (('argument . value)
+ value)
+ (_ #f))
+ (reverse opts))))
+ (match args
+ ((package-name)
+ (let ((sexp (stackage->guix-package
+ package-name
+ #:include-test-dependencies?
+ (assoc-ref opts 'include-test-dependencies?)
+ #:lts-version (assoc-ref opts 'lts-version))))
+ (unless sexp
+ (leave (_ "failed to download cabal file for package '~a'~%")
+ package-name))
+ sexp))
+ (()
+ (leave (_ "too few arguments~%")))
+ ((many ...)
+ (leave (_ "too many arguments~%"))))))
+
+;;; stackage.scm ends here
diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm
index 0dd7eee974..4d3c695aaf 100644
--- a/guix/scripts/refresh.scm
+++ b/guix/scripts/refresh.scm
@@ -205,6 +205,7 @@ unavailable optional dependencies such as Guile-JSON."
%elpa-updater
%cran-updater
%bioconductor-updater
+ ((guix import stackage) => %stackage-updater)
%hackage-updater
((guix import cpan) => %cpan-updater)
((guix import pypi) => %pypi-updater)