GNU bug report logs - #49531
[PATCH core-updates 0/4] import: {utils, go, crate}: Emit new-style package inputs.

Previous Next

Package: guix-patches;

Reported by: Sarah Morgensen <iskarian <at> mgsn.dev>

Date: Mon, 12 Jul 2021 05:36:01 UTC

Severity: normal

Tags: patch

Done: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 49531 in the body.
You can then email your comments to 49531 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#49531; Package guix-patches. (Mon, 12 Jul 2021 05:36:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Sarah Morgensen <iskarian <at> mgsn.dev>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Mon, 12 Jul 2021 05:36:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: guix-patches <at> gnu.org
Subject: [PATCH core-updates 0/4] import: {utils, go,
 crate}: Emit new-style package inputs.
Date: Sun, 11 Jul 2021 22:35:11 -0700
Hello Guix,

This should bring the go and crate importers into the new input-label-less
world (they both use PACKAGE-NAMES->PACKAGE-INPUTS in import/utils.scm). Cargo
build system is correspondingly updated to accept both new- and old-style
package inputs. I successfully tested importing, building, and running
'drill', a cargo-build-system package.

I think this leaves the hackage/stackage, egg, gem, and opam importers. Should
we open a bug to track them?

--
Sarah Morgensen (4):
  import: utils: Emit new-style package inputs.
  import: go: Emit new-style package inputs.
  import: crate: Emit new-style package inputs.
  cargo-build-system: Accept new-style package inputs.

 guix/build-system/cargo.scm |  9 ++++++---
 guix/import/crate.scm       |  5 +++--
 guix/import/utils.scm       | 13 ++++++-------
 guix/packages.scm           |  2 ++
 tests/crate.scm             | 30 +++++++++++-------------------
 tests/go.scm                |  3 ++-
 6 files changed, 30 insertions(+), 32 deletions(-)


base-commit: 9b4c3c675c05870e5983c21ce4ff944e0b0bc2fa
-- 
2.31.1





Information forwarded to guix-patches <at> gnu.org:
bug#49531; Package guix-patches. (Mon, 12 Jul 2021 05:49:01 GMT) Full text and rfc822 format available.

Message #8 received at 49531 <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: 49531 <at> debbugs.gnu.org
Subject: [PATCH core-updates 1/4] import: utils: Emit new-style package inputs.
Date: Sun, 11 Jul 2021 22:48:06 -0700
* guix/import/utils.scm (package-names->package-inputs)[make-input]:
Return new-style package inputs.
(maybe-inputs): Wrap PACKAGE-INPUTS in 'list' instead of 'quasiquote'.
---
 guix/import/utils.scm | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index d817318a91..8fa017e18f 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -8,6 +8,7 @@
 ;;; Copyright © 2020 Helio Machado <0x2b3bfa0+guix <at> googlemail.com>
 ;;; Copyright © 2020 Martin Becze <mjbecze <at> riseup.net>
 ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> mgsn.dev>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -237,12 +238,10 @@ into a proper sentence and by using two spaces between sentences."
 optional OUTPUT, tries to generate a quoted list of inputs, as suitable to
 use in an 'inputs' field of a package definition."
   (define (make-input input version)
-    (cons* input (list 'unquote (string->symbol
-                                 (if version
-                                     (string-append input "-" version)
-                                     input)))
-           (or (and output (list output))
-               '())))
+    (let ((name (if version (string-append input "-" version) input)))
+      (if output
+          (list (string->symbol name) output)
+          (string->symbol name))))
 
   (map (match-lambda
          ((input version) (make-input input version))
@@ -263,7 +262,7 @@ snippet generated is for regular inputs."
       (()
        '())
       ((package-inputs ...)
-       `((,field-name (,'quasiquote ,package-inputs)))))))
+       `((,field-name (list ,@package-inputs)))))))
 
 (define* (maybe-native-inputs package-names #:optional (output #f))
   "Same as MAYBE-INPUTS, but for native inputs."
-- 
2.31.1





Information forwarded to guix-patches <at> gnu.org:
bug#49531; Package guix-patches. (Mon, 12 Jul 2021 05:49:02 GMT) Full text and rfc822 format available.

Message #11 received at 49531 <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: 49531 <at> debbugs.gnu.org
Subject: [PATCH core-updates 2/4] import: go: Emit new-style package inputs.
Date: Sun, 11 Jul 2021 22:48:07 -0700
The actual change is completely contained in the previous import/utils
commit; this commit adjusts tests.

* tests/go.scm ("go-module->guix-package"): Adjust to new-style package
inputs.
---
 tests/go.scm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/go.scm b/tests/go.scm
index b088ab50d2..ae94a31425 100644
--- a/tests/go.scm
+++ b/tests/go.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright � 2021 Fran�ois Joulaud <francois.joulaud <at> radiofrance.com>
+;;; Copyright � 2021 Sarah Morgensen <iskarian <at> mgsn.dev>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -265,7 +266,7 @@ require github.com/kr/pretty v0.2.1
      (arguments
       '(#:import-path "github.com/go-check/check"))
      (propagated-inputs
-      `(("go-github-com-kr-pretty" ,go-github-com-kr-pretty)))
+      (list go-github-com-kr-pretty))
      (home-page "https://github.com/go-check/check")
      (synopsis "Instructions")
      (description "Package check is a rich testing extension for Go's testing \
-- 
2.31.1





Information forwarded to guix-patches <at> gnu.org:
bug#49531; Package guix-patches. (Mon, 12 Jul 2021 05:49:02 GMT) Full text and rfc822 format available.

Message #14 received at 49531 <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: 49531 <at> debbugs.gnu.org
Subject: [PATCH core-updates 3/4] import: crate: Emit new-style package inputs.
Date: Sun, 11 Jul 2021 22:48:08 -0700
* guix/import/crate.scm (maybe-cargo-development-inputs)
(maybe-cargo-inputs): Wrap PACKAGE-INPUTS in unquoted 'list'.
* tests/crate.scm ("crate->guix-package")
("cargo-recursive-import")
("cargo-recursive-import-hoors-existing-packages"): Adjust accordingly.
---
 guix/import/crate.scm |  5 +++--
 tests/crate.scm       | 30 +++++++++++-------------------
 2 files changed, 14 insertions(+), 21 deletions(-)

diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index 287ffd2536..9c3bdfb9ab 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo <at> gnu.org>
 ;;; Copyright © 2019, 2020 Martin Becze <mjbecze <at> riseup.net>
 ;;; Copyright © 2021 Nicolas Goaziou <mail <at> nicolasgoaziou.fr>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> mgsn.dev>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -137,14 +138,14 @@ record or #f if it was not found."
     (()
      '())
     ((package-inputs ...)
-     `(#:cargo-inputs ,package-inputs))))
+     `(#:cargo-inputs (,'unquote (list ,@package-inputs))))))
 
 (define (maybe-cargo-development-inputs package-names)
   (match (package-names->package-inputs package-names)
     (()
      '())
     ((package-inputs ...)
-     `(#:cargo-development-inputs ,package-inputs))))
+     `(#:cargo-development-inputs (,'unquote (list ,@package-inputs))))))
 
 (define (maybe-arguments arguments)
   (match arguments
diff --git a/tests/crate.scm b/tests/crate.scm
index b6c3a7ee2e..50b46aa871 100644
--- a/tests/crate.scm
+++ b/tests/crate.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2016 David Craven <david <at> craven.ch>
 ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo <at> gnu.org>
 ;;; Copyright © 2020 Martin Becze <mjbecze <at> riseup.net>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> mgsn.dev>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -374,7 +375,7 @@
                        ('quasiquote
                         (#:skip-build? #t
                          #:cargo-inputs
-                         (("rust-leaf-alice" ('unquote 'rust-leaf-alice-0.7))))))
+                         ('unquote (list rust-leaf-alice)))))
                       (home-page "http://example.com")
                       (synopsis "summary")
                       (description "summary")
@@ -494,8 +495,7 @@
                 (arguments
                  ('quasiquote (#:skip-build? #t
                                #:cargo-inputs
-                               (("rust-leaf-bob"
-                                 ('unquote rust-leaf-bob-3))))))
+                               ('unquote (list rust-leaf-bob)))))
                 (home-page "http://example.com")
                 (synopsis "summary")
                 (description "summary")
@@ -517,12 +517,9 @@
                 (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))))))
+                               ('unquote (list rust-intermediate-b
+                                               rust-leaf-alice
+                                               rust-leaf-bob)))))
                 (home-page "http://example.com")
                 (synopsis "summary")
                 (description "summary")
@@ -543,14 +540,10 @@
                 (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))))))
+                               ('unquote (list rust-intermediate-a
+                                               rust-intermediate-b
+                                               rust-leaf-alice
+                                               rust-leaf-bob)))))
                 (home-page "http://example.com")
                 (synopsis "summary")
                 (description "summary")
@@ -651,8 +644,7 @@
                 (build-system cargo-build-system)
                 (arguments
                  ('quasiquote (#:cargo-inputs
-                               (("rust-docopt"
-                                 ('unquote 'rust-docopt-0.8))))))
+                               ('unquote (list rust-docopt)))))
                 (home-page "http://example.com")
                 (synopsis "summary")
                 (description "summary")
-- 
2.31.1





Information forwarded to guix-patches <at> gnu.org:
bug#49531; Package guix-patches. (Mon, 12 Jul 2021 05:49:02 GMT) Full text and rfc822 format available.

Message #17 received at 49531 <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: 49531 <at> debbugs.gnu.org
Subject: [PATCH core-updates 4/4] cargo-build-system: Accept new-style package
 inputs.
Date: Sun, 11 Jul 2021 22:48:09 -0700
Sanitize cargo's inputs here since the package field sanitizers don't
know about them.

* guix/packages.scm (sanitize-inputs): Export procedure.
* guix/build-system/cargo.scm (package-cargo-inputs)
(package-cargo-development-inputs)
(lower): Sanitize inputs before using them.
---
 guix/build-system/cargo.scm | 9 ++++++---
 guix/packages.scm           | 2 ++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
index 60c35eed07..a0aa9ad704 100644
--- a/guix/build-system/cargo.scm
+++ b/guix/build-system/cargo.scm
@@ -6,6 +6,7 @@
 ;;; Copyright © 2019 Ivan Petkov <ivanppetkov <at> gmail.com>
 ;;; Copyright © 2020 Jakub Kądziołka <kuba <at> kadziolka.net>
 ;;; Copyright © 2021 Efraim Flashner <efraim <at> flashner.co.il>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> mgsn.dev>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -128,13 +129,13 @@ to NAME and VERSION."
 (define (package-cargo-inputs p)
   (apply
     (lambda* (#:key (cargo-inputs '()) #:allow-other-keys)
-      cargo-inputs)
+      (sanitize-inputs cargo-inputs))
     (package-arguments p)))
 
 (define (package-cargo-development-inputs p)
   (apply
     (lambda* (#:key (cargo-development-inputs '()) #:allow-other-keys)
-      cargo-development-inputs)
+      (sanitize-inputs cargo-development-inputs))
     (package-arguments p)))
 
 (define (crate-closure inputs)
@@ -259,7 +260,9 @@ any dependent crates. This can be a benefits:
                         ,@(standard-packages)))
          (build-inputs `(("cargo" ,rust "cargo")
                          ("rustc" ,rust)
-                         ,@(expand-crate-sources cargo-inputs cargo-development-inputs)
+                         ,@(expand-crate-sources
+                            (sanitize-inputs cargo-inputs)
+                            (sanitize-inputs cargo-development-inputs))
                          ,@native-inputs))
          (outputs outputs)
          (build cargo-build)
diff --git a/guix/packages.scm b/guix/packages.scm
index dfb4c680be..56118edf16 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -7,6 +7,7 @@
 ;;; Copyright © 2019 Marius Bakke <mbakke <at> fastmail.com>
 ;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
 ;;; Copyright © 2021 Chris Marusich <cmmarusich <at> gmail.com>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> mgsn.dev>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -117,6 +118,7 @@
             prepend                               ;syntactic keyword
             replace                               ;syntactic keyword
             modify-inputs
+            sanitize-inputs
 
             package-direct-sources
             package-transitive-sources
-- 
2.31.1





Information forwarded to guix-patches <at> gnu.org:
bug#49531; Package guix-patches. (Mon, 12 Jul 2021 14:42:01 GMT) Full text and rfc822 format available.

Message #20 received at 49531 <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: 49531 <at> debbugs.gnu.org
Subject: [PATCH core-updates v2 3/4] import: crate: Emit new-style package
 inputs.
Date: Mon, 12 Jul 2021 07:41:04 -0700
* guix/import/crate.scm (maybe-cargo-development-inputs)
(maybe-cargo-inputs): Wrap PACKAGE-INPUTS in unquoted 'list'.
* tests/crate.scm ("crate->guix-package")
("cargo-recursive-import")
("cargo-recursive-import-hoors-existing-packages"): Adjust accordingly.
---

Looks like I missed the version in the test inputs. The tests passed before too
though; it looks like the expected output (or at least the symbols in the
expected output) needs to be quoted in some way, or else match just takes any
value in that slot.

 guix/import/crate.scm |  5 +++--
 tests/crate.scm       | 30 +++++++++++-------------------
 2 files changed, 14 insertions(+), 21 deletions(-)

diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index 287ffd2536..9c3bdfb9ab 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo <at> gnu.org>
 ;;; Copyright © 2019, 2020 Martin Becze <mjbecze <at> riseup.net>
 ;;; Copyright © 2021 Nicolas Goaziou <mail <at> nicolasgoaziou.fr>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> mgsn.dev>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -137,14 +138,14 @@ record or #f if it was not found."
     (()
      '())
     ((package-inputs ...)
-     `(#:cargo-inputs ,package-inputs))))
+     `(#:cargo-inputs (,'unquote (list ,@package-inputs))))))
 
 (define (maybe-cargo-development-inputs package-names)
   (match (package-names->package-inputs package-names)
     (()
      '())
     ((package-inputs ...)
-     `(#:cargo-development-inputs ,package-inputs))))
+     `(#:cargo-development-inputs (,'unquote (list ,@package-inputs))))))
 
 (define (maybe-arguments arguments)
   (match arguments
diff --git a/tests/crate.scm b/tests/crate.scm
index b6c3a7ee2e..f09a3f6628 100644
--- a/tests/crate.scm
+++ b/tests/crate.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2016 David Craven <david <at> craven.ch>
 ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo <at> gnu.org>
 ;;; Copyright © 2020 Martin Becze <mjbecze <at> riseup.net>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> mgsn.dev>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -374,7 +375,7 @@
                        ('quasiquote
                         (#:skip-build? #t
                          #:cargo-inputs
-                         (("rust-leaf-alice" ('unquote 'rust-leaf-alice-0.7))))))
+                         ('unquote (list rust-leaf-alice-0.7)))))
                       (home-page "http://example.com")
                       (synopsis "summary")
                       (description "summary")
@@ -494,8 +495,7 @@
                 (arguments
                  ('quasiquote (#:skip-build? #t
                                #:cargo-inputs
-                               (("rust-leaf-bob"
-                                 ('unquote rust-leaf-bob-3))))))
+                               ('unquote (list rust-leaf-bob-3)))))
                 (home-page "http://example.com")
                 (synopsis "summary")
                 (description "summary")
@@ -517,12 +517,9 @@
                 (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))))))
+                               ('unquote (list rust-intermediate-b-1
+                                               rust-leaf-alice-0.7
+                                               rust-leaf-bob-3)))))
                 (home-page "http://example.com")
                 (synopsis "summary")
                 (description "summary")
@@ -543,14 +540,10 @@
                 (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))))))
+                               ('unquote (list rust-intermediate-a-1
+                                               rust-intermediate-b-1
+                                               rust-leaf-alice-0.7
+                                               rust-leaf-bob-3)))))
                 (home-page "http://example.com")
                 (synopsis "summary")
                 (description "summary")
@@ -651,8 +644,7 @@
                 (build-system cargo-build-system)
                 (arguments
                  ('quasiquote (#:cargo-inputs
-                               (("rust-docopt"
-                                 ('unquote 'rust-docopt-0.8))))))
+                               ('unquote (list rust-docopt-0.8)))))
                 (home-page "http://example.com")
                 (synopsis "summary")
                 (description "summary")
-- 
2.31.1





Information forwarded to guix-patches <at> gnu.org:
bug#49531; Package guix-patches. (Tue, 20 Jul 2021 21:23:02 GMT) Full text and rfc822 format available.

Message #23 received at 49531 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Sarah Morgensen <iskarian <at> mgsn.dev>
Cc: 49531 <at> debbugs.gnu.org
Subject: Re: bug#49531: [PATCH core-updates 0/4] import: {utils, go, crate}:
 Emit new-style package inputs.
Date: Tue, 20 Jul 2021 23:22:06 +0200
Hi,

Sarah Morgensen <iskarian <at> mgsn.dev> skribis:

> * guix/import/utils.scm (package-names->package-inputs)[make-input]:
> Return new-style package inputs.
> (maybe-inputs): Wrap PACKAGE-INPUTS in 'list' instead of 'quasiquote'.

Applied this patch squeezed with patch #2, which adjusts tests/go.scm,
because tests should be modified in the same commit (ideally, one should
be able to take any commit and be sure that tests pass).

Thanks!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#49531; Package guix-patches. (Tue, 20 Jul 2021 21:30:02 GMT) Full text and rfc822 format available.

Message #26 received at 49531 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Sarah Morgensen <iskarian <at> mgsn.dev>
Cc: 49531 <at> debbugs.gnu.org, Efraim Flashner <efraim <at> flashner.co.il>
Subject: Removing input labels for Rust #:cargo-inputs & co.?
Date: Tue, 20 Jul 2021 23:29:13 +0200
Sarah Morgensen <iskarian <at> mgsn.dev> skribis:

> Sanitize cargo's inputs here since the package field sanitizers don't
> know about them.
>
> * guix/packages.scm (sanitize-inputs): Export procedure.
> * guix/build-system/cargo.scm (package-cargo-inputs)
> (package-cargo-development-inputs)
> (lower): Sanitize inputs before using them.

So, do we want to do that?  :-)

I’d say yes, but what do Rust folks think?  (Efraim?)

Are labels of #:cargo-inputs & co. used at all?  If not, we can probably
go one step further and have sanitation remove input labels instead of
adding them.

And then, how do we handle the transition?  I’m not enthusiastic about
customizing ‘guix style’ for Rust packages; should we embark on manual
changes of the 2.4K Rust packages?

> +++ b/guix/packages.scm
> @@ -7,6 +7,7 @@
>  ;;; Copyright © 2019 Marius Bakke <mbakke <at> fastmail.com>
>  ;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
>  ;;; Copyright © 2021 Chris Marusich <cmmarusich <at> gmail.com>
> +;;; Copyright © 2021 Sarah Morgensen <iskarian <at> mgsn.dev>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -117,6 +118,7 @@
>              prepend                               ;syntactic keyword
>              replace                               ;syntactic keyword
>              modify-inputs
> +            sanitize-inputs

I’d rather not export it to make sure users don’t mistakenly view it as
part of the public interface; it’s really just an internal helper.

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#49531; Package guix-patches. (Tue, 20 Jul 2021 21:37:01 GMT) Full text and rfc822 format available.

Message #29 received at 49531 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Sarah Morgensen <iskarian <at> mgsn.dev>
Cc: 49531 <at> debbugs.gnu.org
Subject: Re: bug#49531: [PATCH core-updates 0/4] import: {utils, go, crate}:
 Emit new-style package inputs.
Date: Tue, 20 Jul 2021 23:36:25 +0200
Ludovic Courtès <ludo <at> gnu.org> skribis:

> Sarah Morgensen <iskarian <at> mgsn.dev> skribis:
>
>> * guix/import/utils.scm (package-names->package-inputs)[make-input]:
>> Return new-style package inputs.
>> (maybe-inputs): Wrap PACKAGE-INPUTS in 'list' instead of 'quasiquote'.
>
> Applied this patch squeezed with patch #2, which adjusts tests/go.scm,
> because tests should be modified in the same commit (ideally, one should
> be able to take any commit and be sure that tests pass).

Actually no, I didn’t apply it in the end, because that’s tied to the
Crate/Cargo changes as well.  :-/

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#49531; Package guix-patches. (Wed, 21 Jul 2021 03:00:02 GMT) Full text and rfc822 format available.

Message #32 received at 49531 <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: 49531 <at> debbugs.gnu.org
Subject: [PATCH core-updates v2] import: go: Emit new-style package inputs.
Date: Tue, 20 Jul 2021 19:59:21 -0700
Since PACKAGE-NAMES->PACKAGE-INPUTS is used by both the go and crate
importers, give the crate importer a copy of the original so it
continues to use old-style inputs until it is updated.

* guix/import/utils.scm (package-names->package-inputs)[make-input]:
Return new-style package inputs.
(maybe-inputs): Wrap PACKAGE-INPUTS in 'list' instead of 'quasiquote'.
* guix/import/crate.scm (package-names->package-inputs): New variable.
* tests/go.scm ("go-module->guix-package"): Adjust to new-style package
inputs.
---
This patch narrows the scope to just the go importer; the crate importer can be
handled separately.

 guix/import/crate.scm | 18 ++++++++++++++++++
 guix/import/utils.scm | 13 ++++++-------
 tests/go.scm          |  2 +-
 3 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index 287ffd2536..fa8f7bf096 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo <at> gnu.org>
 ;;; Copyright © 2019, 2020 Martin Becze <mjbecze <at> riseup.net>
 ;;; Copyright © 2021 Nicolas Goaziou <mail <at> nicolasgoaziou.fr>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> mgsn.dev>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -132,6 +133,23 @@ record or #f if it was not found."
 ;;; Converting crates to Guix packages.
 ;;;
 
+(define* (package-names->package-inputs names #:optional (output #f))
+  "Given a list of PACKAGE-NAMES or (PACKAGE-NAME VERSION) pairs, and an
+optional OUTPUT, tries to generate a quoted list of inputs, as suitable to
+use in an 'inputs' field of a package definition."
+  (define (make-input input version)
+    (cons* input (list 'unquote (string->symbol
+                                 (if version
+                                     (string-append input "-" version)
+                                     input)))
+           (or (and output (list output))
+               '())))
+
+  (map (match-lambda
+         ((input version) (make-input input version))
+         (input (make-input input #f)))
+       names))
+
 (define (maybe-cargo-inputs package-names)
   (match (package-names->package-inputs package-names)
     (()
diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index d817318a91..8fa017e18f 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -8,6 +8,7 @@
 ;;; Copyright © 2020 Helio Machado <0x2b3bfa0+guix <at> googlemail.com>
 ;;; Copyright © 2020 Martin Becze <mjbecze <at> riseup.net>
 ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> mgsn.dev>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -237,12 +238,10 @@ into a proper sentence and by using two spaces between sentences."
 optional OUTPUT, tries to generate a quoted list of inputs, as suitable to
 use in an 'inputs' field of a package definition."
   (define (make-input input version)
-    (cons* input (list 'unquote (string->symbol
-                                 (if version
-                                     (string-append input "-" version)
-                                     input)))
-           (or (and output (list output))
-               '())))
+    (let ((name (if version (string-append input "-" version) input)))
+      (if output
+          (list (string->symbol name) output)
+          (string->symbol name))))
 
   (map (match-lambda
          ((input version) (make-input input version))
@@ -263,7 +262,7 @@ snippet generated is for regular inputs."
       (()
        '())
       ((package-inputs ...)
-       `((,field-name (,'quasiquote ,package-inputs)))))))
+       `((,field-name (list ,@package-inputs)))))))
 
 (define* (maybe-native-inputs package-names #:optional (output #f))
   "Same as MAYBE-INPUTS, but for native inputs."
diff --git a/tests/go.scm b/tests/go.scm
index 6749f4585f..743cffb023 100644
--- a/tests/go.scm
+++ b/tests/go.scm
@@ -389,7 +389,7 @@ require github.com/kr/pretty v0.2.1
      (arguments
       '(#:import-path "github.com/go-check/check"))
      (propagated-inputs
-      `(("go-github-com-kr-pretty" ,go-github-com-kr-pretty)))
+      (list go-github-com-kr-pretty))
      (home-page "https://github.com/go-check/check")
      (synopsis "Instructions")
      (description "Package check is a rich testing extension for Go's testing \

base-commit: b15c3dd9b0e9cf6858f730e1d46c35ed9ab6a758
-- 
2.31.1





Information forwarded to guix-patches <at> gnu.org:
bug#49531; Package guix-patches. (Wed, 21 Jul 2021 03:04:02 GMT) Full text and rfc822 format available.

Message #35 received at 49531 <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 49531 <at> debbugs.gnu.org
Subject: Re: bug#49531: [PATCH core-updates 0/4] import: {utils, go, crate}:
 Emit new-style package inputs.
Date: Tue, 20 Jul 2021 20:03:41 -0700
Hi,

Ludovic Courtès <ludo <at> gnu.org> writes:

> Ludovic Courtès <ludo <at> gnu.org> skribis:
>
>> Sarah Morgensen <iskarian <at> mgsn.dev> skribis:
>>
>>> * guix/import/utils.scm (package-names->package-inputs)[make-input]:
>>> Return new-style package inputs.
>>> (maybe-inputs): Wrap PACKAGE-INPUTS in 'list' instead of 'quasiquote'.
>>
>> Applied this patch squeezed with patch #2, which adjusts tests/go.scm,
>> because tests should be modified in the same commit (ideally, one should
>> be able to take any commit and be sure that tests pass).
>
> Actually no, I didn’t apply it in the end, because that’s tied to the
> Crate/Cargo changes as well.  :-/
>
> Ludo’.

Apologies for the trouble! I've sent a rebased v2 (in-reply-to the
original patch; forgot to CC you) that just takes care of the go
importer and lets crate continue to live in its own world until we
decide its fate.

--
Sarah




Information forwarded to guix-patches <at> gnu.org:
bug#49531; Package guix-patches. (Wed, 21 Jul 2021 07:51:01 GMT) Full text and rfc822 format available.

Message #38 received at 49531 <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 49531 <at> debbugs.gnu.org, Efraim Flashner <efraim <at> flashner.co.il>
Subject: Re: bug#49531: [PATCH core-updates 0/4] import: {utils, go, crate}:
 Emit new-style package inputs.
Date: Wed, 21 Jul 2021 00:50:53 -0700
[Message part 1 (text/plain, inline)]
Hi all,

Ludovic Courtès <ludo <at> gnu.org> writes:

> And then, how do we handle the transition?  I’m not enthusiastic about
> customizing ‘guix style’ for Rust packages; should we embark on manual
> changes of the 2.4K Rust packages?

I've attached a patch below that's a first pass at handling
#:cargo-inputs in `guix style`. I didn't handle any input modification
shenanigans, but I don't think any packages do that with #:cargo-inputs
& co., or if so it's just a few which can be manually updated.

The result of running it on #:cargo-inputs/#:cargo-development-inputs
packages:

14 files changed, 9424 insertions(+), 12009 deletions(-)
gnu/packages/crates-graphics.scm |  1006 +--
gnu/packages/crates-gtk.scm      |   658 +-
gnu/packages/crates-io.scm       | 17471 ++++++++++++++++---------------------
gnu/packages/crypto.scm          |     4 +-
gnu/packages/gnome.scm           |    90 +-
gnu/packages/rust-apps.scm       |   672 +-
gnu/packages/security-token.scm  |    30 +-
gnu/packages/sequoia.scm         |   124 +-
gnu/packages/shells.scm          |  1088 ++-
gnu/packages/syndication.scm     |    38 +-
gnu/packages/terminals.scm       |    50 +-
gnu/packages/text-editors.scm    |    60 +-
gnu/packages/video.scm           |   100 +-
gnu/packages/web.scm             |    42 +-

--
Sarah

[handle-cargo-inputs.patch (text/x-patch, inline)]
diff --git a/guix/packages.scm b/guix/packages.scm
index d3fa72fd09..26e82050f8 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -108,6 +108,7 @@
             package-superseded
             deprecated-package
             package-field-location
+            package-argument-location
 
             this-package-input
             this-package-native-input
@@ -515,9 +516,9 @@ object."
     (name old-name)
     (properties `((superseded . ,p)))))
 
-(define (package-field-location package field)
-  "Return the source code location of the definition of FIELD for PACKAGE, or
-#f if it could not be determined."
+(define (package-part-location package proc)
+  "Return the source code location of the part of PACKAGE returned by (PROC
+PACKAGE), or #f if it could not be determined."
   (match (package-location package)
     (($ <location> file line column)
      (match (search-path %load-path file)
@@ -530,17 +531,16 @@ object."
                 (go-to-location port line column)
                 (match (read port)
                   (('package inits ...)
-                   (let ((field (assoc field inits)))
-                     (match field
-                       ((_ value)
-                        (let ((loc (and=> (source-properties value)
-                                          source-properties->location)))
-                          (and loc
-                               ;; Preserve the original file name, which may be a
-                               ;; relative file name.
-                               (set-field loc (location-file) file))))
-                       (_
-                        #f))))
+                   (match (proc inits)
+                     (#f
+                      #f)
+                     (value
+                      (let ((loc (and=> (source-properties value)
+                                        source-properties->location)))
+                        (and loc
+                             ;; Preserve the original file name, which may be a
+                             ;; relative file name.
+                             (set-field loc (location-file) file))))))
                   (_
                    #f)))))
           (lambda _
@@ -550,6 +550,29 @@ object."
         #f)))
     (_ #f)))
 
+(define (package-field-location package field)
+  "Return the source code location of the definition of FIELD for PACKAGE, or
+#f if it could not be determined."
+  (package-part-location
+   package
+   (lambda (p)
+     (match (assoc field p)
+       ((_ value) value)
+       (_ #f)))))
+
+(define (package-argument-location package argument)
+  "Return the source code location of the definition of keyword ARGUMENT for
+PACKAGE, or #f if it could not be determined."
+  (package-part-location
+   package
+   (lambda (p)
+     (match (assoc 'arguments p)
+       ((_ ('quasiquote (arguments ..1)))
+        (match (member argument arguments eq?)
+          ((_ value . _) value)
+          (_ #f)))
+       (_ #f)))))
+
 (define (package-input package name)
   "Return the package input NAME of PACKAGE--i.e., an input
 from the ‘inputs’ or ‘propagated-inputs’ field.  Native inputs are not
diff --git a/guix/scripts/style.scm b/guix/scripts/style.scm
index 3c100197a7..19185d924e 100644
--- a/guix/scripts/style.scm
+++ b/guix/scripts/style.scm
@@ -371,7 +371,7 @@ bailing out~%")
                           (delete ,@to-delete)
                           (prepend ,@things)))
         (location-column location))))
-    (('quasiquote (exp ...))
+    ((or ('quasiquote (exp ...)) ((or (exp ...) (? comment? exp)) ...))
      (let/ec return
        (object->string*
         `(list ,@(simplify-expressions exp inputs return))
@@ -389,6 +389,33 @@ POLICY is a symbol that defines whether to simplify inputs; it can one of
 'silent (change only if the resulting derivation is the same), 'safe (change
 only if semantics are known to be unaffected), and 'always (fearlessly
 simplify inputs!)."
+  (define (package-argument package argument)
+    (match (member argument (package-arguments package) eq?)
+      ((_ value . _) value)
+      (_ #f)))
+
+  ;; We know that the cargo build system does not use its special input labels,
+  ;; so it is always safe to simplify, but it will change the derivation. Only
+  ;; proceed if POLICY is 'safe or 'always.
+  (when (member policy '(safe always))
+    (for-each (lambda (argument)
+                (match (package-argument package argument)
+                  (#f
+                   #f)
+                  (inputs
+                   (match (package-argument-location package argument)
+                     (#f
+                      #f)
+                     (location
+                      (edit-expression
+                       (location->source-properties location)
+                       (lambda (str)
+                         (simplify-inputs location
+                                          (package-name package)
+                                          str inputs
+                                          #:label-matches? (const #t)))))))))
+              (list #:cargo-inputs #:cargo-development-inputs)))
+
   (for-each (lambda (field-name field)
               (match (field package)
                 (()

Information forwarded to guix-patches <at> gnu.org:
bug#49531; Package guix-patches. (Thu, 22 Jul 2021 06:47:01 GMT) Full text and rfc822 format available.

Message #41 received at 49531 <at> debbugs.gnu.org (full text, mbox):

From: Efraim Flashner <efraim <at> flashner.co.il>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 49531 <at> debbugs.gnu.org, Sarah Morgensen <iskarian <at> mgsn.dev>
Subject: Re: Removing input labels for Rust #:cargo-inputs & co.?
Date: Thu, 22 Jul 2021 09:44:53 +0300
[Message part 1 (text/plain, inline)]
On Tue, Jul 20, 2021 at 11:29:13PM +0200, Ludovic Courtès wrote:
> Sarah Morgensen <iskarian <at> mgsn.dev> skribis:
> 
> > Sanitize cargo's inputs here since the package field sanitizers don't
> > know about them.
> >
> > * guix/packages.scm (sanitize-inputs): Export procedure.
> > * guix/build-system/cargo.scm (package-cargo-inputs)
> > (package-cargo-development-inputs)
> > (lower): Sanitize inputs before using them.
> 
> So, do we want to do that?  :-)
> 
> I’d say yes, but what do Rust folks think?  (Efraim?)
> 
> Are labels of #:cargo-inputs & co. used at all?  If not, we can probably
> go one step further and have sanitation remove input labels instead of
> adding them.

I haven't done a thorough search, but the only code snippets I could
think of it turns out were fixed when we managed to add snippets to
cargo crates, and most of the logic was moved to the
cargo-build-system.

> And then, how do we handle the transition?  I’m not enthusiastic about
> customizing ‘guix style’ for Rust packages; should we embark on manual
> changes of the 2.4K Rust packages?

based on some of my previous work I would like to try to change 99% of
the cargo-{development-,}inputs to regular-/native-inputs but I think
after the core-updates merge would be a better time to work on that.

-- 
Efraim Flashner   <efraim <at> flashner.co.il>   אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted
[signature.asc (application/pgp-signature, inline)]

Reply sent to Maxim Cournoyer <maxim.cournoyer <at> gmail.com>:
You have taken responsibility. (Sat, 20 Jan 2024 21:07:02 GMT) Full text and rfc822 format available.

Notification sent to Sarah Morgensen <iskarian <at> mgsn.dev>:
bug acknowledged by developer. (Sat, 20 Jan 2024 21:07:02 GMT) Full text and rfc822 format available.

Message #46 received at 49531-done <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: Efraim Flashner <efraim <at> flashner.co.il>
Cc: 49531-done <at> debbugs.gnu.org, Ludovic Courtès <ludo <at> gnu.org>,
 Sarah Morgensen <iskarian <at> mgsn.dev>
Subject: Re: [bug#49531] Removing input labels for Rust #:cargo-inputs & co.?
Date: Sat, 20 Jan 2024 16:06:05 -0500
Hi,

Efraim Flashner <efraim <at> flashner.co.il> writes:

> On Tue, Jul 20, 2021 at 11:29:13PM +0200, Ludovic Courtès wrote:
>> Sarah Morgensen <iskarian <at> mgsn.dev> skribis:
>> 
>> > Sanitize cargo's inputs here since the package field sanitizers don't
>> > know about them.
>> >
>> > * guix/packages.scm (sanitize-inputs): Export procedure.
>> > * guix/build-system/cargo.scm (package-cargo-inputs)
>> > (package-cargo-development-inputs)
>> > (lower): Sanitize inputs before using them.

I've lined up the v2 changes in this series for core-updates.

Closing!

-- 
Thanks,
Maxim




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 18 Feb 2024 12:24:12 GMT) Full text and rfc822 format available.

This bug report was last modified 61 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.