Subject: [bug#73073] [PATCH 0/6] Allow origin with label as inputs.

From: Ludovic Courtès <[email-masked]>
Date: Fri, 06 Sep 2024 23:45:04 +0200

Hello,

Simon Tournier <[email-masked]> skribis:

> The reason is because ’sanitize-inputs’; see module (guix packages).
>
>     ((_ (list args ...))
>      (add-input-labels args ...))
>     ((_ inputs)
>      (maybe-add-input-labels inputs))))

[...]

> The procedure ’maybe-add-input-labels’ reads: if the first element of
> the ’inputs’ record field is using the “old style“ then return all
> as-is, assuming all are “old style”.  Else apply to all the ’inputs’
> elements the procedure ’add-input-label’.

Yes: as an optimization, we just check the first element or even just
the syntax (whether the value starts with (list …)).

This is one reason why I’d rather avoid the change you’re suggesting.
But more importantly: I think we should avoid polymorphic lists for
clarity (the principle is followed in most of the code), and
reintroducing labels would be a step backwards.

To be clear, I understand the current situation is not perfect, but I
would rather look for solutions that do not involve undoing what’s taken
this long to do.

The main issue we want to address here is origins being hidden from
‘package-direct-sources’, right?

What if we could do this:

diff --git a/guix/packages.scm b/guix/packages.scm
index f373136d22..624d3d8c45 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -1320,7 +1320,16 @@ (define (package-direct-sources package)
                    ((_ (? origin? orig) _ ...)
                     orig)
                    (_ #f))
-                  (package-direct-inputs package))))
+                  (package-direct-inputs package))
+    (match (assoc #:phases (package-arguments package))
+      ((#:phases (? gexp? phases) . _)
+       (filter-map (lambda (input)
+                     (match (gexp-input-thing input)
+                       ((? origin? o) o)
+                       (_ #f)))
+                   (gexp-inputs phases)))
+      (_
+       '()))))
 
 (define (package-transitive-sources package)
   "Return PACKAGE's direct sources, and their direct sources, recursively."

?  (Currently we can’t because ‘gexp-inputs’ is private.)

Or, alternatively, we’d have origins without labels in inputs, with
this:

diff --git a/guix/packages.scm b/guix/packages.scm
index f373136d22..8b08f0d379 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -676,6 +676,8 @@ (define (add-input-label input)
               "_")
          ,obj
          ,@(if (string=? output "out") '() (list output)))))
+    ((? origin? origin)
+     (list (or (origin-actual-file-name origin) "_") origin))
     (x
      `("_" ,x))))

… meaning we could write (this-package-input "git-manpages.tar.gz") or
similar.  (This particular change would need tweaks in a few packages
such as ‘tzdata’ to avoid a full rebuild.)

WDYT?

Thanks,
Ludo’.