diff mbox series

[bug#57704,v3] guix: Filter unspecified inputs when sanitizing.

Message ID 1b98ce69769d0366503c7fb7f956da7fa9ec5132.camel@gmail.com
State New
Headers show
Series [bug#57704,v3] guix: Filter unspecified inputs when sanitizing. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git-branch success View Git branch
cbaines/applying patch success
cbaines/issue success View issue
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. 10, 2022, 7:41 a.m. UTC
* guix/packages.scm (sanitize-inputs): Filter inputs which are unspecified?
rather than adding a label.
---
 guix/packages.scm | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

M Sept. 10, 2022, 10:19 a.m. UTC | #1
> Am Samstag, dem 10.09.2022 um 02:33 +0200 schrieb Maxime Devos:
>> The docstring is nice, but with documentation, I meant the manual, 
>> presumably in ‘(guix)package Reference’, maybe also in the packaging 
>> tutorial in the cookbook.
> I don't see the current practice documented, so I think we're actually
> good on this front.

That sounds bad to me -- the undocumented surface should be decreased, 
not increased.  Also, it is actually documented a little:

      ‘inputs’ (default: ‘'()’)
      ‘native-inputs’ (default: ‘'()’)
      ‘propagated-inputs’ (default: ‘'()’)
           These fields list dependencies of the package.  Each element
           of these lists is either a package, origin, or other
           “file-like object” (*note G-Expressions::); [...]

#false (or, in this case, *unspecified*) is neither a package, origin or 
other file-like object.  Maybe you can add that #false is also allowed 
but ignored?

On 10-09-2022 09:41, Liliana Marie Prikler wrote:
>            inputs)
> -        (else (map add-input-label inputs))))
> +        (else (filter-map (lambda (input)
> +                            (if (unspecified? input) #f
> +                                (add-input-label input)))
> +                          inputs))))

(when cond ...) / (unless cond ...) returning *unspecified* when (not 
cond)/cond is an implementation detail:

   * The return values(s) when (not cond)/cond is not documented in
     (guile)Conditionals
   * maybe: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=56799#17

     There is an interest in letting it return zero values instead of
     *unspecified*, see e.g. 
https://scheme-reports.scheme-reports.narkive.com/QSQtJSAh/unspecified-values
     and a ‘bug’ on bugs.gnu.org I cannot find anymore about actually
     doing this change.

     By assuming that when/unless returns *unspecified* here, an
     additional backwards-compatibility concern is introduced.

As such, I don't think relying on this to be a good idea.

Alternative proposal: instead of (when cond package), maybe
(and cond package)?

Greetings,
Maxime
diff mbox series

Patch

diff --git a/guix/packages.scm b/guix/packages.scm
index 94e464cd01..0975002c13 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -429,12 +429,15 @@  (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."
+not already the case and removing unspecified inputs."
   (cond ((null? inputs) inputs)
         ((and (pair? (car inputs))
               (string? (caar inputs)))
          inputs)
-        (else (map add-input-label inputs))))
+        (else (filter-map (lambda (input)
+                            (if (unspecified? input) #f
+                                (add-input-label input)))
+                          inputs))))
 
 (define-syntax current-location-vector
   (lambda (s)