all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Herman Rimm via Guix-patches via <guix-patches@gnu.org>
To: 70923@debbugs.gnu.org
Cc: Sarah Morgensen <iskarian@mgsn.dev>,
	Efraim Flashner <efraim@flashner.co.il>
Subject: [bug#70923] [PATCH v3 03/11] import: crate: Emit new-style package inputs.
Date: Tue, 24 Sep 2024 22:13:09 +0200	[thread overview]
Message-ID: <a8da5c9ad4c8dea79bd332ae25f3d042204a74a0.1727207512.git.herman@rimm.ee> (raw)
In-Reply-To: <cover.1727207512.git.herman@rimm.ee>

From: Sarah Morgensen <iskarian@mgsn.dev>

* guix/import/crate.scm (maybe-cargo-inputs,
maybe-cargo-development-inputs, maybe-arguments): Delete procedures.
(make-crate-sexp): Add 'unwrap' procedure, use with maybe-packages-field
and fix indentation.
* tests/crate.scm: Adjust accordingly.

Change-Id: Ie8debd2553a338c3c623162b843e0a9827314074
---
 guix/import/crate.scm |  51 ++++++------------
 tests/crate.scm       | 119 +++++++++++++++++-------------------------
 2 files changed, 65 insertions(+), 105 deletions(-)

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





  parent reply	other threads:[~2024-09-24 20:22 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-13 19:59 [bug#70923] [PATCH 00/13] Add (guix import utils) procedures Herman Rimm via Guix-patches via
2024-05-13 20:07 ` [bug#70923] [PATCH 01/13] build-system: cargo: Accept unlabeled #:cargo-inputs Herman Rimm via Guix-patches via
2024-05-13 20:07 ` [bug#70923] [PATCH 02/13] import: utils: Emit new-style package inputs Herman Rimm via Guix-patches via
2024-05-13 20:08 ` [bug#70923] [PATCH 03/13] tests: go: Adjust to " Herman Rimm via Guix-patches via
2024-05-13 20:08 ` [bug#70923] [PATCH 04/13] tests: elm: " Herman Rimm via Guix-patches via
2024-05-13 20:08 ` [bug#70923] [PATCH 05/13] import: crate: Emit " Herman Rimm via Guix-patches via
2024-05-13 20:08 ` [bug#70923] [PATCH 06/13] import: utils: Add 'maybe-upstream-inputs' procedure Herman Rimm via Guix-patches via
2024-05-13 20:08 ` [bug#70923] [PATCH 07/13] import: pypi: Use 'maybe-list-field' procedure Herman Rimm via Guix-patches via
2024-05-13 20:08 ` [bug#70923] [PATCH 08/13] import: elpa: Use maybe-propagated-inputs procedure Herman Rimm via Guix-patches via
2024-05-13 20:08 ` [bug#70923] [PATCH 09/13] import: hackage: Use 'maybe-list-field' procedure Herman Rimm via Guix-patches via
2024-05-13 20:08 ` [bug#70923] [PATCH 10/13] import: cran: " Herman Rimm via Guix-patches via
2024-05-13 20:08 ` [bug#70923] [PATCH 11/13] import: cpan: Use 'maybe-upstream-inputs' procedure Herman Rimm via Guix-patches via
2024-05-13 20:08 ` [bug#70923] [PATCH 12/13] import: egg: Use maybe-*inputs procedures Herman Rimm via Guix-patches via
2024-05-13 20:08 ` [bug#70923] [PATCH 13/13] import: hexpm: Use (guix import utils) 'maybe-inputs' procedure Herman Rimm via Guix-patches via
2024-09-04 20:32 ` [bug#70923] [PATCH v2 01/12] build-system: cargo: Accept unlabeled #:cargo-inputs Herman Rimm via Guix-patches via
2024-09-04 20:32   ` [bug#70923] [PATCH v2 02/12] import: utils: Emit new-style inputs from maybe-*inputs procedures Herman Rimm via Guix-patches via
2024-09-04 20:32   ` [bug#70923] [PATCH v2 03/12] tests: elm: Adjust to new-style package inputs Herman Rimm via Guix-patches via
2024-09-04 20:32   ` [bug#70923] [PATCH v2 04/12] import: crate: Use (guix import utils) procedures Herman Rimm via Guix-patches via
2024-09-04 20:32   ` [bug#70923] [PATCH v2 05/12] import: utils: Add maybe-upstream-inputs Herman Rimm via Guix-patches via
2024-09-04 20:33   ` [bug#70923] [PATCH v2 06/12] import: pypi: Use maybe-upstream-inputs Herman Rimm via Guix-patches via
2024-09-04 20:33   ` [bug#70923] [PATCH v2 07/12] import: elpa: Use maybe-propagated-inputse Herman Rimm via Guix-patches via
2024-09-04 20:33   ` [bug#70923] [PATCH v2 08/12] import: hackage: Use maybe-list-field Herman Rimm via Guix-patches via
2024-09-04 20:33   ` [bug#70923] [PATCH v2 09/12] import: cran: Refactor format-inputs and use maybe-list-field Herman Rimm via Guix-patches via
2024-09-04 20:33   ` [bug#70923] [PATCH v2 10/12] import: cpan: Use maybe-upstream-inputs Herman Rimm via Guix-patches via
2024-09-04 20:33   ` [bug#70923] [PATCH v2 11/12] import: egg: Use maybe-*inputs procedures Herman Rimm via Guix-patches via
2024-09-04 20:33   ` [bug#70923] [PATCH v2 12/12] import: hexpm: Use maybe-inputs Herman Rimm via Guix-patches via
2024-09-24 20:13 ` [bug#70923] [PATCH v3 00/11] Add (guix import utils) procedures Herman Rimm via Guix-patches via
2024-09-24 20:13   ` [bug#70923] [PATCH v3 01/11] build-system: cargo: Accept unlabeled #:cargo-inputs Herman Rimm via Guix-patches via
2024-09-24 20:13   ` [bug#70923] [PATCH v3 02/11] import: utils: Emit new-style package inputs Herman Rimm via Guix-patches via
2024-09-24 20:13   ` Herman Rimm via Guix-patches via [this message]
2024-09-24 20:13   ` [bug#70923] [PATCH v3 04/11] import: utils: Add 'maybe-upstream-inputs' procedure Herman Rimm via Guix-patches via
2024-09-24 20:13   ` [bug#70923] [PATCH v3 05/11] import: pypi: Use 'maybe-list-field' procedure Herman Rimm via Guix-patches via
2024-09-24 20:13   ` [bug#70923] [PATCH v3 06/11] import: elpa: Use maybe-propagated-inputs procedure Herman Rimm via Guix-patches via
2024-09-24 20:13   ` [bug#70923] [PATCH v3 07/11] import: hackage: Use 'maybe-list-field' procedure Herman Rimm via Guix-patches via
2024-09-24 20:13   ` [bug#70923] [PATCH v3 08/11] import: cran: " Herman Rimm via Guix-patches via
2024-09-24 20:13   ` [bug#70923] [PATCH v3 09/11] import: cpan: Use 'maybe-upstream-inputs' procedure Herman Rimm via Guix-patches via
2024-09-24 20:13   ` [bug#70923] [PATCH v3 10/11] import: egg: Use maybe-*inputs procedures Herman Rimm via Guix-patches via
2024-09-24 20:13   ` [bug#70923] [PATCH v3 11/11] import: hexpm: Use (guix import utils) 'maybe-inputs' procedure Herman Rimm via Guix-patches via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a8da5c9ad4c8dea79bd332ae25f3d042204a74a0.1727207512.git.herman@rimm.ee \
    --to=guix-patches@gnu.org \
    --cc=70923@debbugs.gnu.org \
    --cc=efraim@flashner.co.il \
    --cc=herman@rimm.ee \
    --cc=iskarian@mgsn.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.