diff mbox

[bug#49169,00/11] Removing input labels from package definitions

Message ID 868s2ekbw5.fsf_-_@mgsn.dev
State Accepted
Headers show

Commit Message

Sarah Morgensen July 10, 2021, 4:53 a.m. UTC
Hello :)

This is a wonderful direction! I am always happy to see boilerplate
evaporate.

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

>   • I changed a few importers to emit simplified package inputs.
>     We’ll have to take care of the other importers eventually.

I found one more easy change to make in the importers. I just gave it a
quick smoke test with the Go importer, nothing exhaustive; and I'm not
sure which other importers use it. I've attached the patch below.

>  doc/guix.texi          | 208 ++++++++++++++--

In the manual, you added:

> Each element of these lists is either a package, origin, or other
> ``file-like object'' [...]

How should a file input like this be handled?

  ("some.patch" (search-patch "some.patch"))

If I had to guess, I'd try some gexp like...

  #$(local-file (search-patch "some.patch"))

But I really have no idea!

>  guix/scripts/style.scm | 527 +++++++++++++++++++++++++++++++++++++++++
>  tests/style.scm        | 366 ++++++++++++++++++++++++++++
>  23 files changed, 1643 insertions(+), 298 deletions(-)

The style script makes up fully half of the patch! Wow.

--
Sarah

Comments

Ludovic Courtès July 10, 2021, 1:45 p.m. UTC | #1
Hello!

Sarah Morgensen <iskarian@mgsn.dev> skribis:

> This is a wonderful direction! I am always happy to see boilerplate
> evaporate.

Heh thanks, I agree!

> Ludovic Courtès <ludo@gnu.org> writes:
>
>>   • I changed a few importers to emit simplified package inputs.
>>     We’ll have to take care of the other importers eventually.
>
> I found one more easy change to make in the importers. I just gave it a
> quick smoke test with the Go importer, nothing exhaustive; and I'm not
> sure which other importers use it. I've attached the patch below.

Awesome, I’ll apply this patch on your behalf.

> In the manual, you added:
>
>> Each element of these lists is either a package, origin, or other
>> ``file-like object'' [...]
>
> How should a file input like this be handled?
>
>   ("some.patch" (search-patch "some.patch"))
>
> If I had to guess, I'd try some gexp like...
>
>   #$(local-file (search-patch "some.patch"))

Exactly, or:

  (local-file "patches/some.patch")

>>  guix/scripts/style.scm | 527 +++++++++++++++++++++++++++++++++++++++++
>>  tests/style.scm        | 366 ++++++++++++++++++++++++++++
>>  23 files changed, 1643 insertions(+), 298 deletions(-)
>
> The style script makes up fully half of the patch! Wow.

Yes, but the patch resulting from running ‘guix style’ will be an order
of magnitude bigger.  :-)

Now that ‘core-updates’ is in a better shape, I feel safer pushing this
patch series.  Let’s see…

Thanks!

Ludo’.
Ludovic Courtès July 10, 2021, 11:15 p.m. UTC | #2
Hi again,

Sarah Morgensen <iskarian@mgsn.dev> skribis:

> diff --git a/guix/import/utils.scm b/guix/import/utils.scm
> index d817318a91..5075e5c491 100644
> --- a/guix/import/utils.scm
> +++ b/guix/import/utils.scm
> @@ -237,12 +237,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 +261,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."

On closer inspection, it seems that this change would affect the Crate
importer.  Unfortunately, Crate packages live in their own world and are
unaffected by package input simplification.

This is unfortunate, also because they probably never even use input
labels that can be seen in #:cargo-development-inputs and the likes.

That said, it would be good to simplify that too, and I’m open to
suggestions on how to achieve that!

Ludo’.
Sarah Morgensen July 12, 2021, 6:15 a.m. UTC | #3
Hi!

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

> On closer inspection, it seems that this change would affect the Crate
> importer.  Unfortunately, Crate packages live in their own world and are
> unaffected by package input simplification.

Well, that was an interesting code dive :) They really do live in their
own world...

>
> This is unfortunate, also because they probably never even use input
> labels that can be seen in #:cargo-development-inputs and the likes.
>
> That said, it would be good to simplify that too, and I’m open to
> suggestions on how to achieve that!

I have submitted a patchset [0] which just has the crate importer use
the same sanitizer as package inputs, which should be good enough until
we get rid of input labels in the internals.

In the longer term, perhaps we would benefit from some way of indicating
inputs which are just source? Something like

  (package ... (source-inputs ...))

where the listed packages only provide their source instead of any
outputs, and only transitively include other packages via source-inputs.
This would bypass any patching done in phases, but I don't think that's
common enough in these "source" packages that it would be onerous to use
origin patches/snippets instead. This would be useful for any build
system which does not (re)use artifacts from a package's dependencies
(such as cargo and go).

[0] https://issues.guix.gnu.org/49531

--
Sarah
Ludovic Courtès July 12, 2021, 8:47 a.m. UTC | #4
Hi!

Sarah Morgensen <iskarian@mgsn.dev> skribis:

> I have submitted a patchset [0] which just has the crate importer use
> the same sanitizer as package inputs, which should be good enough until
> we get rid of input labels in the internals.

Excellent, I’ll take a look.

> In the longer term, perhaps we would benefit from some way of indicating
> inputs which are just source? Something like
>
>   (package ... (source-inputs ...))
>
> where the listed packages only provide their source instead of any
> outputs, and only transitively include other packages via source-inputs.
> This would bypass any patching done in phases, but I don't think that's
> common enough in these "source" packages that it would be onerous to use
> origin patches/snippets instead. This would be useful for any build
> system which does not (re)use artifacts from a package's dependencies
> (such as cargo and go).

Yeah, I really don’t know.  I thought we could just as well say that
‘inputs’ means “source inputs” for those packages (and indeed that’s
what happens for Go packages), but I always fail to wrap my head around
the specific needs and constraints of Cargo and Go.

Thanks,
Ludo’.
diff mbox

Patch

diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index d817318a91..5075e5c491 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -237,12 +237,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 +261,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."