all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#49531] [PATCH core-updates 0/4] import: {utils, go, crate}: Emit new-style package inputs.
@ 2021-07-12  5:35 Sarah Morgensen via Guix-patches via
  2021-07-12  5:48 ` [bug#49531] [PATCH core-updates 1/4] import: utils: " Sarah Morgensen via Guix-patches via
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Sarah Morgensen via Guix-patches via @ 2021-07-12  5:35 UTC (permalink / raw)
  To: 49531

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





^ permalink raw reply	[flat|nested] 14+ messages in thread

* [bug#49531] [PATCH core-updates 1/4] import: utils: Emit new-style package inputs.
  2021-07-12  5:35 [bug#49531] [PATCH core-updates 0/4] import: {utils, go, crate}: Emit new-style package inputs Sarah Morgensen via Guix-patches via
@ 2021-07-12  5:48 ` Sarah Morgensen via Guix-patches via
  2021-07-20 21:22   ` [bug#49531] [PATCH core-updates 0/4] import: {utils, go, crate}: " Ludovic Courtès
  2021-07-12  5:48 ` [bug#49531] [PATCH core-updates 2/4] import: go: " Sarah Morgensen via Guix-patches via
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 14+ messages in thread
From: Sarah Morgensen via Guix-patches via @ 2021-07-12  5:48 UTC (permalink / raw)
  To: 49531

* 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@googlemail.com>
 ;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
 ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@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





^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [bug#49531] [PATCH core-updates 2/4] import: go: Emit new-style package inputs.
  2021-07-12  5:35 [bug#49531] [PATCH core-updates 0/4] import: {utils, go, crate}: Emit new-style package inputs Sarah Morgensen via Guix-patches via
  2021-07-12  5:48 ` [bug#49531] [PATCH core-updates 1/4] import: utils: " Sarah Morgensen via Guix-patches via
@ 2021-07-12  5:48 ` Sarah Morgensen via Guix-patches via
  2021-07-12  5:48 ` [bug#49531] [PATCH core-updates 3/4] import: crate: " Sarah Morgensen via Guix-patches via
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: Sarah Morgensen via Guix-patches via @ 2021-07-12  5:48 UTC (permalink / raw)
  To: 49531

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 1063 bytes --]

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@radiofrance.com>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@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





^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [bug#49531] [PATCH core-updates 3/4] import: crate: Emit new-style package inputs.
  2021-07-12  5:35 [bug#49531] [PATCH core-updates 0/4] import: {utils, go, crate}: Emit new-style package inputs Sarah Morgensen via Guix-patches via
  2021-07-12  5:48 ` [bug#49531] [PATCH core-updates 1/4] import: utils: " Sarah Morgensen via Guix-patches via
  2021-07-12  5:48 ` [bug#49531] [PATCH core-updates 2/4] import: go: " Sarah Morgensen via Guix-patches via
@ 2021-07-12  5:48 ` Sarah Morgensen via Guix-patches via
  2021-07-12 14:41   ` [bug#49531] [PATCH core-updates v2 " Sarah Morgensen via Guix-patches via
  2021-07-12  5:48 ` [bug#49531] [PATCH core-updates 4/4] cargo-build-system: Accept " Sarah Morgensen via Guix-patches via
  2021-07-21  2:59 ` [bug#49531] [PATCH core-updates v2] import: go: Emit new-style package inputs Sarah Morgensen
  4 siblings, 1 reply; 14+ messages in thread
From: Sarah Morgensen via Guix-patches via @ 2021-07-12  5:48 UTC (permalink / raw)
  To: 49531

* 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@gnu.org>
 ;;; Copyright © 2019, 2020 Martin Becze <mjbecze@riseup.net>
 ;;; Copyright © 2021 Nicolas Goaziou <mail@nicolasgoaziou.fr>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@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@craven.ch>
 ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@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





^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [bug#49531] [PATCH core-updates 4/4] cargo-build-system: Accept new-style package inputs.
  2021-07-12  5:35 [bug#49531] [PATCH core-updates 0/4] import: {utils, go, crate}: Emit new-style package inputs Sarah Morgensen via Guix-patches via
                   ` (2 preceding siblings ...)
  2021-07-12  5:48 ` [bug#49531] [PATCH core-updates 3/4] import: crate: " Sarah Morgensen via Guix-patches via
@ 2021-07-12  5:48 ` Sarah Morgensen via Guix-patches via
  2021-07-20 21:29   ` [bug#49531] Removing input labels for Rust #:cargo-inputs & co.? Ludovic Courtès
  2021-07-21  2:59 ` [bug#49531] [PATCH core-updates v2] import: go: Emit new-style package inputs Sarah Morgensen
  4 siblings, 1 reply; 14+ messages in thread
From: Sarah Morgensen via Guix-patches via @ 2021-07-12  5:48 UTC (permalink / raw)
  To: 49531

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@gmail.com>
 ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
 ;;; Copyright © 2021 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@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@fastmail.com>
 ;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2021 Chris Marusich <cmmarusich@gmail.com>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@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





^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [bug#49531] [PATCH core-updates v2 3/4] import: crate: Emit new-style package inputs.
  2021-07-12  5:48 ` [bug#49531] [PATCH core-updates 3/4] import: crate: " Sarah Morgensen via Guix-patches via
@ 2021-07-12 14:41   ` Sarah Morgensen via Guix-patches via
  0 siblings, 0 replies; 14+ messages in thread
From: Sarah Morgensen via Guix-patches via @ 2021-07-12 14:41 UTC (permalink / raw)
  To: 49531

* 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@gnu.org>
 ;;; Copyright © 2019, 2020 Martin Becze <mjbecze@riseup.net>
 ;;; Copyright © 2021 Nicolas Goaziou <mail@nicolasgoaziou.fr>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@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@craven.ch>
 ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@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





^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [bug#49531] [PATCH core-updates 0/4] import: {utils, go, crate}: Emit new-style package inputs.
  2021-07-12  5:48 ` [bug#49531] [PATCH core-updates 1/4] import: utils: " Sarah Morgensen via Guix-patches via
@ 2021-07-20 21:22   ` Ludovic Courtès
  2021-07-20 21:36     ` Ludovic Courtès
  0 siblings, 1 reply; 14+ messages in thread
From: Ludovic Courtès @ 2021-07-20 21:22 UTC (permalink / raw)
  To: Sarah Morgensen; +Cc: 49531

Hi,

Sarah Morgensen <iskarian@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’.




^ permalink raw reply	[flat|nested] 14+ messages in thread

* [bug#49531] Removing input labels for Rust #:cargo-inputs & co.?
  2021-07-12  5:48 ` [bug#49531] [PATCH core-updates 4/4] cargo-build-system: Accept " Sarah Morgensen via Guix-patches via
@ 2021-07-20 21:29   ` Ludovic Courtès
  2021-07-21  7:50     ` [bug#49531] [PATCH core-updates 0/4] import: {utils, go, crate}: Emit new-style package inputs Sarah Morgensen
  2021-07-22  6:44     ` [bug#49531] Removing input labels for Rust #:cargo-inputs & co.? Efraim Flashner
  0 siblings, 2 replies; 14+ messages in thread
From: Ludovic Courtès @ 2021-07-20 21:29 UTC (permalink / raw)
  To: Sarah Morgensen; +Cc: 49531, Efraim Flashner

Sarah Morgensen <iskarian@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@fastmail.com>
>  ;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
>  ;;; Copyright © 2021 Chris Marusich <cmmarusich@gmail.com>
> +;;; Copyright © 2021 Sarah Morgensen <iskarian@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’.




^ permalink raw reply	[flat|nested] 14+ messages in thread

* [bug#49531] [PATCH core-updates 0/4] import: {utils, go, crate}: Emit new-style package inputs.
  2021-07-20 21:22   ` [bug#49531] [PATCH core-updates 0/4] import: {utils, go, crate}: " Ludovic Courtès
@ 2021-07-20 21:36     ` Ludovic Courtès
  2021-07-21  3:03       ` Sarah Morgensen
  0 siblings, 1 reply; 14+ messages in thread
From: Ludovic Courtès @ 2021-07-20 21:36 UTC (permalink / raw)
  To: Sarah Morgensen; +Cc: 49531

Ludovic Courtès <ludo@gnu.org> skribis:

> Sarah Morgensen <iskarian@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’.




^ permalink raw reply	[flat|nested] 14+ messages in thread

* [bug#49531] [PATCH core-updates v2] import: go: Emit new-style package inputs.
  2021-07-12  5:35 [bug#49531] [PATCH core-updates 0/4] import: {utils, go, crate}: Emit new-style package inputs Sarah Morgensen via Guix-patches via
                   ` (3 preceding siblings ...)
  2021-07-12  5:48 ` [bug#49531] [PATCH core-updates 4/4] cargo-build-system: Accept " Sarah Morgensen via Guix-patches via
@ 2021-07-21  2:59 ` Sarah Morgensen
  4 siblings, 0 replies; 14+ messages in thread
From: Sarah Morgensen @ 2021-07-21  2:59 UTC (permalink / raw)
  To: 49531

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@gnu.org>
 ;;; Copyright © 2019, 2020 Martin Becze <mjbecze@riseup.net>
 ;;; Copyright © 2021 Nicolas Goaziou <mail@nicolasgoaziou.fr>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@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@googlemail.com>
 ;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
 ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@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





^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [bug#49531] [PATCH core-updates 0/4] import: {utils, go, crate}: Emit new-style package inputs.
  2021-07-20 21:36     ` Ludovic Courtès
@ 2021-07-21  3:03       ` Sarah Morgensen
  0 siblings, 0 replies; 14+ messages in thread
From: Sarah Morgensen @ 2021-07-21  3:03 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 49531

Hi,

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

> Ludovic Courtès <ludo@gnu.org> skribis:
>
>> Sarah Morgensen <iskarian@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




^ permalink raw reply	[flat|nested] 14+ messages in thread

* [bug#49531] [PATCH core-updates 0/4] import: {utils, go, crate}: Emit new-style package inputs.
  2021-07-20 21:29   ` [bug#49531] Removing input labels for Rust #:cargo-inputs & co.? Ludovic Courtès
@ 2021-07-21  7:50     ` Sarah Morgensen
  2021-07-22  6:44     ` [bug#49531] Removing input labels for Rust #:cargo-inputs & co.? Efraim Flashner
  1 sibling, 0 replies; 14+ messages in thread
From: Sarah Morgensen @ 2021-07-21  7:50 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 49531, Efraim Flashner

[-- Attachment #1: Type: text/plain, Size: 1344 bytes --]

Hi all,

Ludovic Courtès <ludo@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


[-- Attachment #2: handle-cargo-inputs.patch --]
[-- Type: text/x-patch, Size: 5400 bytes --]

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)
                 (()

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [bug#49531] Removing input labels for Rust #:cargo-inputs & co.?
  2021-07-20 21:29   ` [bug#49531] Removing input labels for Rust #:cargo-inputs & co.? Ludovic Courtès
  2021-07-21  7:50     ` [bug#49531] [PATCH core-updates 0/4] import: {utils, go, crate}: Emit new-style package inputs Sarah Morgensen
@ 2021-07-22  6:44     ` Efraim Flashner
  2024-01-20 21:06       ` bug#49531: " Maxim Cournoyer
  1 sibling, 1 reply; 14+ messages in thread
From: Efraim Flashner @ 2021-07-22  6:44 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 49531, Sarah Morgensen

[-- Attachment #1: Type: text/plain, Size: 1540 bytes --]

On Tue, Jul 20, 2021 at 11:29:13PM +0200, Ludovic Courtès wrote:
> Sarah Morgensen <iskarian@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@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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#49531: Removing input labels for Rust #:cargo-inputs & co.?
  2021-07-22  6:44     ` [bug#49531] Removing input labels for Rust #:cargo-inputs & co.? Efraim Flashner
@ 2024-01-20 21:06       ` Maxim Cournoyer
  0 siblings, 0 replies; 14+ messages in thread
From: Maxim Cournoyer @ 2024-01-20 21:06 UTC (permalink / raw)
  To: Efraim Flashner; +Cc: 49531-done, Ludovic Courtès, Sarah Morgensen

Hi,

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

> On Tue, Jul 20, 2021 at 11:29:13PM +0200, Ludovic Courtès wrote:
>> Sarah Morgensen <iskarian@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




^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2024-01-20 21:07 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-12  5:35 [bug#49531] [PATCH core-updates 0/4] import: {utils, go, crate}: Emit new-style package inputs Sarah Morgensen via Guix-patches via
2021-07-12  5:48 ` [bug#49531] [PATCH core-updates 1/4] import: utils: " Sarah Morgensen via Guix-patches via
2021-07-20 21:22   ` [bug#49531] [PATCH core-updates 0/4] import: {utils, go, crate}: " Ludovic Courtès
2021-07-20 21:36     ` Ludovic Courtès
2021-07-21  3:03       ` Sarah Morgensen
2021-07-12  5:48 ` [bug#49531] [PATCH core-updates 2/4] import: go: " Sarah Morgensen via Guix-patches via
2021-07-12  5:48 ` [bug#49531] [PATCH core-updates 3/4] import: crate: " Sarah Morgensen via Guix-patches via
2021-07-12 14:41   ` [bug#49531] [PATCH core-updates v2 " Sarah Morgensen via Guix-patches via
2021-07-12  5:48 ` [bug#49531] [PATCH core-updates 4/4] cargo-build-system: Accept " Sarah Morgensen via Guix-patches via
2021-07-20 21:29   ` [bug#49531] Removing input labels for Rust #:cargo-inputs & co.? Ludovic Courtès
2021-07-21  7:50     ` [bug#49531] [PATCH core-updates 0/4] import: {utils, go, crate}: Emit new-style package inputs Sarah Morgensen
2021-07-22  6:44     ` [bug#49531] Removing input labels for Rust #:cargo-inputs & co.? Efraim Flashner
2024-01-20 21:06       ` bug#49531: " Maxim Cournoyer
2021-07-21  2:59 ` [bug#49531] [PATCH core-updates v2] import: go: Emit new-style package inputs Sarah Morgensen

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.