Toggle diff (314 lines)
diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index 84c178ea3e..5110e6124f 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -7,6 +7,7 @@
;;; Copyright © 2023 Simon Tournier <zimon.toutoune@gmail.com>
;;; Copyright © 2023, 2024 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2023, 2024 David Elsing <david.elsing@posteo.net>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -158,27 +159,6 @@ (define* (package-names->package-inputs names #:optional (output #f))
(input (make-input input #f)))
names))
-(define (maybe-cargo-inputs package-names)
- (match (package-names->package-inputs package-names)
- (()
- '())
- ((package-inputs ...)
- `(#:cargo-inputs ,package-inputs))))
-
-(define (maybe-cargo-development-inputs package-names)
- (match (package-names->package-inputs package-names)
- (()
- '())
- ((package-inputs ...)
- `(#:cargo-development-inputs ,package-inputs))))
-
-(define (maybe-arguments arguments)
- (match arguments
- (()
- '())
- ((args ...)
- `((arguments (,'quasiquote ,args))))))
-
(define (version->semver-prefix version)
"Return the version up to and including the first non-zero part"
(first
@@ -202,8 +182,14 @@ (define* (make-crate-sexp #:key name version cargo-inputs cargo-development-inpu
(let* ((port (http-fetch (crate-uri name version)))
(guix-name (crate-name->package-name name))
- (cargo-inputs (format-inputs cargo-inputs))
- (cargo-development-inputs (format-inputs cargo-development-inputs))
+ (unwrap (match-lambda
+ ((lst) lst)
+ (() '())))
+ (cargo-inputs (maybe-packages-field '#:cargo-inputs
+ (format-inputs cargo-inputs)))
+ (cargo-development-inputs
+ (maybe-packages-field '#:cargo-development-inputs
+ (format-inputs cargo-development-inputs)))
(description (beautify-description description))
(pkg `(package
(name ,guix-name)
@@ -222,12 +208,10 @@ (define* (make-crate-sexp #:key name version cargo-inputs cargo-development-inpu
`((properties '((crate-version-yanked? . #t))))
'())
(build-system cargo-build-system)
- ,@(maybe-arguments (append (if build?
- '()
- '(#:skip-build? #t))
- (maybe-cargo-inputs cargo-inputs)
- (maybe-cargo-development-inputs
- cargo-development-inputs)))
+ ,@(maybe-list-field 'arguments
+ (append (if build? '() '(#:skip-build? #t))
+ (unwrap cargo-inputs)
+ (unwrap cargo-development-inputs)))
(home-page ,home-page)
(synopsis ,(beautify-synopsis synopsis))
(description ,(if (string-prefix? "This" description)
@@ -239,11 +223,10 @@ (define* (make-crate-sexp #:key name version cargo-inputs cargo-development-inpu
(#f #f)
((license) license)
(_ `(list ,@license)))))))
- (close-port port)
- (package->definition pkg
- (if yanked?
- (string-append version "-yanked")
- (version->semver-prefix version)))))
+ (close-port port)
+ (package->definition pkg (if yanked?
+ (string-append version "-yanked")
+ (version->semver-prefix version)))))
(define (string->license string)
(filter-map (lambda (license)
diff --git a/tests/crate.scm b/tests/crate.scm
index 5b4ad08c3c..8e3da2e72c 100644
--- a/tests/crate.scm
+++ b/tests/crate.scm
@@ -5,6 +5,8 @@
;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
;;; Copyright © 2023 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2023 David Elsing <david.elsing@posteo.net>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -497,10 +499,10 @@ (define have-guile-semver?
(? string? hash)))))
(build-system 'cargo-build-system)
(arguments
- ('quasiquote
- (#:skip-build? #t
+ (list
+ #:skip-build? #t
#:cargo-inputs
- (("rust-leaf-alice" ('unquote 'rust-leaf-alice-0.7))))))
+ (list rust-leaf-alice-0.7)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -589,7 +591,7 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:skip-build? #t)))
+ (list #:skip-build? #t))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -608,7 +610,7 @@ (define have-guile-semver?
(base32
(? string? hash)))))
(build-system cargo-build-system)
- (arguments ('quasiquote (#:skip-build? #t)))
+ (arguments (list #:skip-build? #t))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -627,7 +629,7 @@ (define have-guile-semver?
(base32
(? string? hash)))))
(build-system cargo-build-system)
- (arguments ('quasiquote (#:skip-build? #t)))
+ (arguments (list #:skip-build? #t))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -647,10 +649,9 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:skip-build? #t
- #:cargo-inputs
- (("rust-leaf-bob"
- ('unquote rust-leaf-bob-3))))))
+ (list #:skip-build? #t
+ #:cargo-inputs
+ (list rust-leaf-bob-3)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -670,14 +671,11 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:skip-build? #t
- #:cargo-inputs
- (("rust-intermediate-b"
- ('unquote rust-intermediate-b-1))
- ("rust-leaf-alice"
- ('unquote 'rust-leaf-alice-0.7))
- ("rust-leaf-bob"
- ('unquote rust-leaf-bob-3))))))
+ (list #:skip-build? #t
+ #:cargo-inputs
+ (list rust-intermediate-b-1
+ rust-leaf-alice-0.7
+ rust-leaf-bob-3)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -697,18 +695,13 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- (("rust-intermediate-a"
- ('unquote rust-intermediate-a-1))
- ("rust-intermediate-b"
- ('unquote rust-intermediate-b-1))
- ("rust-leaf-alice"
- ('unquote 'rust-leaf-alice-0.7))
- ("rust-leaf-bob"
- ('unquote rust-leaf-bob-3)))
- #:cargo-development-inputs
- (("rust-intermediate-c"
- ('unquote rust-intermediate-c-1))))))
+ (list #:cargo-inputs
+ (list rust-intermediate-a-1
+ rust-intermediate-b-1
+ rust-leaf-alice-0.7
+ rust-leaf-bob-3)
+ #:cargo-development-inputs
+ ((list rust-intermediate-c-1))))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -735,9 +728,8 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-development-inputs
- (("rust-leaf-alice"
- ('unquote rust-leaf-alice-0.7))))))
+ (list #:cargo-development-inputs
+ (list rust-leaf-alice-0.7)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -793,9 +785,8 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- (("rust-leaf-bob"
- ('unquote rust-leaf-bob-3))))))
+ (list #:cargo-inputs
+ (list rust-leaf-bob-3)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -815,13 +806,10 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- (("rust-intermediate-b"
- ('unquote rust-intermediate-b-1))
- ("rust-leaf-alice"
- ('unquote 'rust-leaf-alice-0.7))
- ("rust-leaf-bob"
- ('unquote rust-leaf-bob-3))))))
+ (list #:cargo-inputs
+ (list rust-intermediate-b-1
+ rust-leaf-alice-0.7
+ rust-leaf-bob-3)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -841,18 +829,13 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- (("rust-intermediate-a"
- ('unquote rust-intermediate-a-1))
- ("rust-intermediate-b"
- ('unquote rust-intermediate-b-1))
- ("rust-leaf-alice"
- ('unquote 'rust-leaf-alice-0.7))
- ("rust-leaf-bob"
- ('unquote rust-leaf-bob-3)))
- #:cargo-development-inputs
- (("rust-intermediate-c"
- ('unquote rust-intermediate-c-1))))))
+ (list #:cargo-inputs
+ (list rust-intermediate-a-1
+ rust-intermediate-b-1
+ rust-leaf-alice-0.7
+ rust-leaf-bob-3)
+ #:cargo-development-inputs
+ (list rust-intermediate-c-1)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -962,14 +945,11 @@ (define rust-leaf-bob-3.0.2-yanked
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- (("rust-leaf-bob"
- ('unquote 'rust-leaf-bob-3)))
- #:cargo-development-inputs
- (("rust-leaf-bob"
- ('unquote 'rust-leaf-bob-3.0.2-yanked))
- ("rust-leaf-bob"
- ('unquote 'rust-leaf-bob-4.0.0-yanked))))))
+ (list #:cargo-inputs
+ (list rust-leaf-bob-3)
+ #:cargo-development-inputs
+ (list rust-leaf-bob-3.0.2-yanked
+ rust-leaf-bob-4.0.0-yanked)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -1093,14 +1073,11 @@ (define rust-leaf-bob-3.0.2-yanked
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- (("rust-leaf-bob"
- ('unquote 'rust-leaf-bob-3)))
- #:cargo-development-inputs
- (("rust-leaf-bob"
- ('unquote 'rust-leaf-bob-3.0.2-yanked))
- ("rust-leaf-bob"
- ('unquote 'rust-leaf-bob-4.0.0-yanked))))))
+ (list #:cargo-inputs
+ (list rust-leaf-bob-3)
+ #:cargo-development-inputs
+ (list rust-leaf-bob-3.0.2-yanked
+ rust-leaf-bob-4.0.0-yanked)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
--
2.45.2