diff mbox series

[bug#49531,core-updates,4/4] cargo-build-system: Accept new-style package inputs.

Message ID 598b53d80d66a229502d235507047a7717a15e8d.1626067919.git.iskarian@mgsn.dev
State New
Headers show
Series import: {utils, go, crate}: Emit new-style package inputs. | expand

Commit Message

Sarah Morgensen July 12, 2021, 5:48 a.m. UTC
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(-)

Comments

Ludovic Courtès July 20, 2021, 9:29 p.m. UTC | #1
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’.
Efraim Flashner July 22, 2021, 6:44 a.m. UTC | #2
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.
diff mbox series

Patch

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