diff mbox series

[bug#57704,core-updates] guix: packages: Remove #f from inputs when sanitizing.

Message ID b1b6504d725df23dc910cb04591a203979cdca7b.camel@gmail.com
State New
Headers show
Series [bug#57704,core-updates] guix: packages: Remove #f from inputs when sanitizing. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git-branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Liliana Marie Prikler Sept. 9, 2022, 3:56 p.m. UTC
This makes it so that new-style inputs can be optional using regular Guile
patterns, e.g. (and (target-x86-64?) rust).

* guix/packages.scm (sanitize-inputs): Filter inputs by identity before adding
labels.
---
Note that this patch was prepared using master, but since it affects the
package record, it needs to go to core-updates.  I don' think there should
be a merge conflict here.

 guix/packages.scm | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

M Sept. 9, 2022, 6:54 p.m. UTC | #1
On 09-09-2022 17:56, Liliana Marie Prikler wrote:
> This makes it so that new-style inputs can be optional using regular Guile
> patterns, e.g. (and (target-x86-64?) rust).

Seems useful.

> * guix/packages.scm (sanitize-inputs): Filter inputs by identity before adding
> labels.

Documentation is missing.

> ---
> Note that this patch was prepared using master, but since it affects the
> package record, it needs to go to core-updates.  I don' think there should
> be a merge conflict here.

It does affect the package record, but it doesn't cause any rebuilds, so 
master should be fine:

* There aren't any current uses of #false:

(use-modules (guix packages) (gnu packages))
(package
   (inherit (specification->package "hello"))
   (inputs (list #false)))
;; guix build -f [...] --> package ‘hello@2.12.1’ has an invalid input

* In the absence of #false, the behaviour remains unchanged.

* guix/packages.scm is not used by any derivation
   (except for "guix pull" and the guix package)

As a test, I applied the patch and did
‘make && ./pre-inst-env guix build -n libreoffice’,
and it turned out I already have it installed.

Greetings,
Maxime.
Ludovic Courtès Sept. 26, 2022, 8:51 p.m. UTC | #2
Hi Liliana,

Liliana Marie Prikler <liliana.prikler@gmail.com> skribis:

> This makes it so that new-style inputs can be optional using regular Guile
> patterns, e.g. (and (target-x86-64?) rust).

I’d rather avoid that and make sure input lists are just plain lists,
remaining strict, and keeping the sanitize procedure simple (notably so
it can be optimized in common cases).

That means we have to live with idioms like:

  (append (list x y z)
          (if (target-x86-64?) (list rust) '()))

The ‘openmpi’ package has sugar to make that more concise.

Thoughts?

Thanks,
Ludo’.
Maxim Cournoyer Jan. 20, 2024, 8:43 p.m. UTC | #3
Hi Liliana,

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

> Hi Liliana,
>
> Liliana Marie Prikler <liliana.prikler@gmail.com> skribis:
>
>> This makes it so that new-style inputs can be optional using regular Guile
>> patterns, e.g. (and (target-x86-64?) rust).
>
> I’d rather avoid that and make sure input lists are just plain lists,
> remaining strict, and keeping the sanitize procedure simple (notably so
> it can be optimized in common cases).
>
> That means we have to live with idioms like:
>
>   (append (list x y z)
>           (if (target-x86-64?) (list rust) '()))
>
> The ‘openmpi’ package has sugar to make that more concise.
>
> Thoughts?

Any plans to revisit this, or should we close it?
diff mbox series

Patch

diff --git a/guix/packages.scm b/guix/packages.scm
index 94e464cd01..5bb2e81e18 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -430,11 +430,12 @@  (define %cuirass-supported-systems
 (define-inlinable (sanitize-inputs inputs)
   "Sanitize INPUTS by turning it into a list of name/package tuples if it's
 not already the case."
-  (cond ((null? inputs) inputs)
-        ((and (pair? (car inputs))
-              (string? (caar inputs)))
-         inputs)
-        (else (map add-input-label inputs))))
+  (let ((inputs (filter identity inputs)))
+    (cond ((null? inputs) inputs)
+          ((and (pair? (car inputs))
+                (string? (caar inputs)))
+           inputs)
+          (else (map add-input-label inputs)))))
 
 (define-syntax current-location-vector
   (lambda (s)