@@ -85,21 +85,6 @@ (define-module (guix import cran)
(define %input-style
(make-parameter 'variable)) ; or 'specification
-(define (format-inputs inputs)
- "Generate a sorted list of package inputs from a list of upstream inputs."
- (map (lambda (input)
- (case (%input-style)
- ((specification)
- `(specification->package ,(upstream-input-downstream-name input)))
- (else
- ((compose string->symbol
- upstream-input-downstream-name)
- input))))
- (sort inputs
- (lambda (a b)
- (string-ci<? (upstream-input-name a)
- (upstream-input-name b))))))
-
(define (string->licenses license-string license-prefix)
(let ((licenses
(map string-trim-both
@@ -188,11 +173,21 @@ (define (description->alist description)
(define* (maybe-inputs package-inputs #:optional (input-type 'inputs))
"Given a list of PACKAGE-INPUTS, tries to generate the TYPE field of a
package definition."
- (match package-inputs
- (()
- '())
- ((package-inputs ...)
- `((,input-type (list ,@(format-inputs package-inputs)))))))
+ (define (format-input input)
+ (case (%input-style)
+ ((specification)
+ `(specification->package ,(upstream-input-downstream-name input)))
+ (else
+ ((compose string->symbol
+ upstream-input-downstream-name)
+ input))))
+
+ (define (upstream-input-name<? i1 i2)
+ (string-ci<? (upstream-input-name i1)
+ (upstream-input-name i2)))
+
+ (maybe-list-field input-type
+ (map format-input (sort package-inputs upstream-input-name<?))))
(define %cran-url "https://cloud.r-project.org/web/packages/")
(define %cran-canonical-url "https://cran.r-project.org/package=")