summaryrefslogtreecommitdiff
path: root/guix/import
diff options
context:
space:
mode:
authorRicardo Wurmus <ricardo.wurmus@mdc-berlin.de>2018-08-20 17:38:56 +0200
committerRicardo Wurmus <rekado@elephly.net>2018-08-30 15:22:06 +0200
commita3ece51a29241c7060323cbbfc602c83200ffe4a (patch)
tree6b7e7de74fd84539734a6473a0cdcba06bce0e4e /guix/import
parentb5d1286f2d796ce6dfcf45b9eeb0cf5630c191a9 (diff)
import: stackage: Support recursive importing.
* guix/import/hackage.scm (hackage-name->package-name): Export procedure. * guix/import/stackage.scm (lts-info-packages-lts-info): Fix match expression. (stackage-recursive-import): New procedure. (stackage->guix-package): Memoize results. * guix/scripts/import/stackage.scm (show-help, %options, guix-import-stackage): Support recursive importing. * doc/guix.texi (Invoking guix import): Document option.
Diffstat (limited to 'guix/import')
-rw-r--r--guix/import/hackage.scm1
-rw-r--r--guix/import/stackage.scm45
2 files changed, 29 insertions, 17 deletions
diff --git a/guix/import/hackage.scm b/guix/import/hackage.scm
index 3c00f680bf..54301de2e8 100644
--- a/guix/import/hackage.scm
+++ b/guix/import/hackage.scm
@@ -44,6 +44,7 @@
%hackage-updater
guix-package->hackage-name
+ hackage-name->package-name
hackage-fetch
hackage-source-url
hackage-cabal-url
diff --git a/guix/import/stackage.scm b/guix/import/stackage.scm
index ec93fbced6..afd5d997ae 100644
--- a/guix/import/stackage.scm
+++ b/guix/import/stackage.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017 Federico Beffa <beffa@fbengineering.ch>
+;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -25,10 +26,12 @@
#:use-module (srfi srfi-35)
#:use-module (guix import json)
#:use-module (guix import hackage)
+ #:use-module (guix import utils)
#:use-module (guix memoization)
#:use-module (guix packages)
#:use-module (guix upstream)
#:export (stackage->guix-package
+ stackage-recursive-import
%stackage-updater))
@@ -45,9 +48,9 @@
(_ #f)))
(define (lts-info-packages lts-info)
- "Retruns the alist of packages contained in LTS-INFO."
+ "Returns the alist of packages contained in LTS-INFO."
(match lts-info
- ((_ ("packages" pkg ...)) pkg)
+ ((("packages" pkg ...) . _) pkg)
(_ '())))
(define (leave-with-message fmt . args)
@@ -85,25 +88,33 @@
(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
+(define stackage->guix-package
+ (memoize
+ (lambda* (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-with-message "~a: Stackage package not found" package-name))))
+ (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-with-message "~a: Stackage package not found" package-name))))))
+
+(define (stackage-recursive-import package-name . args)
+ (recursive-import package-name #f
+ #:repo->guix-package (lambda (name repo)
+ (apply stackage->guix-package (cons name args)))
+ #:guix-name hackage-name->package-name))
;;;