diff options
author | Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de> | 2018-08-08 15:29:18 +0200 |
---|---|---|
committer | Ricardo Wurmus <rekado@elephly.net> | 2018-08-11 18:53:46 +0200 |
commit | a92859616201dbf0cec36d3c746125d645c88c79 (patch) | |
tree | abaf6e32686cf88628572d71c8b979179140f63b /guix/scripts/import | |
parent | 424fd768288b8629fff5ff3b56a8f4870eafc5dd (diff) |
import: hackage: Support recursive importing.
* guix/import/hackage.scm (hackage-recursive-import): New procedure.
(hackage-module->sexp): Return dependencies alongside dependencies.
(hackage->guix-package): Memoize results.
* guix/scripts/import/hackage.scm (show-help, %options, guix-import-hackage):
Support recursive importing.
* doc/guix.texi (Invoking guix import): Document option.
Diffstat (limited to 'guix/scripts/import')
-rw-r--r-- | guix/scripts/import/hackage.scm | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/guix/scripts/import/hackage.scm b/guix/scripts/import/hackage.scm index 969f637846..f4aac61078 100644 --- a/guix/scripts/import/hackage.scm +++ b/guix/scripts/import/hackage.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch> +;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net> ;;; ;;; This file is part of GNU Guix. ;;; @@ -26,6 +27,7 @@ #:use-module (srfi srfi-1) #:use-module (srfi srfi-11) #:use-module (srfi srfi-37) + #:use-module (srfi srfi-41) #:use-module (ice-9 match) #:use-module (ice-9 format) #:export (guix-import-hackage)) @@ -57,6 +59,8 @@ version.\n")) (display (G_ " -h, --help display this help and exit")) (display (G_ " + -r, --recursive import packages recursively")) + (display (G_ " -s, --stdin read from standard input")) (display (G_ " -t, --no-test-dependencies don't include test-only dependencies")) @@ -89,6 +93,9 @@ version.\n")) (alist-cons 'cabal-environment (read/eval arg) (alist-delete 'cabal-environment result)))) + (option '(#\r "recursive") #f #f + (lambda (opt name arg result) + (alist-cons 'recursive #t result))) %standard-import-options)) @@ -107,15 +114,27 @@ version.\n")) %default-options)) (define (run-importer package-name opts error-fn) - (let ((sexp (hackage->guix-package - package-name - #:include-test-dependencies? - (assoc-ref opts 'include-test-dependencies?) - #:port (if (assoc-ref opts 'read-from-stdin?) - (current-input-port) - #f) - #:cabal-environment - (assoc-ref opts 'cabal-environment)))) + (let* ((arguments (list + package-name + #:include-test-dependencies? + (assoc-ref opts 'include-test-dependencies?) + #:port (if (assoc-ref opts 'read-from-stdin?) + (current-input-port) + #f) + #:cabal-environment + (assoc-ref opts 'cabal-environment))) + (sexp (if (assoc-ref opts 'recursive) + ;; Recursive import + (map (match-lambda + ((and ('package ('name name) . rest) pkg) + `(define-public ,(string->symbol name) + ,pkg)) + (_ #f)) + (reverse + (stream->list + (apply hackage-recursive-import arguments)))) + ;; Single import + (apply hackage->guix-package arguments)))) (unless sexp (error-fn)) sexp)) |