diff --git a/guix/import/crate.scm b/guix/import/crate.scm index da92c43b8c..355aaa140a 100644 --- a/guix/import/crate.scm +++ b/guix/import/crate.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2016 David Craven ;;; Copyright © 2019 Ludovic Courtès ;;; Copyright © 2019 Martin Becze +;;; Copyright © 2019 Efraim Flashner ;;; ;;; This file is part of GNU Guix. ;;; @@ -88,6 +89,7 @@ (id crate-dependency-id "crate_id") ;string (kind crate-dependency-kind "kind" ;'normal | 'dev | 'build string->symbol) + (optional crate-dependency-optional "optional") ; 'true | 'false (requirement crate-dependency-requirement "req")) ;string (define (lookup-crate name) @@ -108,12 +110,16 @@ record or #f if it was not found." (define (crate-version-dependencies version) "Return the list of records of VERSION, a ." + (define (optional-dependency? dependency) + (eq? (crate-dependency-optional dependency) #t)) + (let* ((path (assoc-ref (crate-version-links version) "dependencies")) (url (string-append (%crate-base-url) path))) (match (assoc-ref (or (json-fetch url) '()) "dependencies") ((? vector? vector) (filter (lambda (dep) - (not (eq? (crate-dependency-kind dep) 'dev))) + (not (or (eq? (crate-dependency-kind dep) 'dev) + (optional-dependency? dep)))) (map json->crate-dependency (vector->list vector)))) (_ '()))))