this-package-input for multiple outputs package

  • Open
  • quality assurance status badge
Details
One participant
  • Simon Tournier
Owner
unassigned
Submitted by
Simon Tournier
Severity
normal
S
S
Simon Tournier wrote on 24 Jul 02:41 +0200
(address . bug-guix@gnu.org)
87plr3ei4c.fsf@gmail.com
Hi,

For the good or the bad, we have package with multiple outputs. For
instance, see ’git’ with ’git:send-email’ and others.

However, it’s not always easy to work with them using the “new style”.

For a concrete example: https://issues.guix.gnu.org/66704#4.


A minimal example.

Toggle snippet (15 lines)
$ cat /tmp/pkgs/pkgs.scm
(define-module (pkgs)
#:use-module (guix packages)
#:use-module (gnu packages base)
#:use-module (gnu packages version-control))

(define-public salut
(package
(inherit hello)
(name "bye")
(inputs
(list git
`(,git "send-email")))))

Then, it’s possible to add phases, e.g.,

Toggle snippet (5 lines)
(wrap-program (string-append #$output "/bin/hello")
`("STUFF" ":" prefix
(,(string-append #$(this-package-input "git") "/bin")))

All fine!

However, from my understanding, it does not seem possible to access
using this “new style” way to other outputs than “out”. Because, the
inputs reads,

Toggle snippet (19 lines)
$ guix repl -q -L /tmp/pkgs
GNU Guile 3.0.9
Copyright (C) 1995-2023 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guix-user)> ,use(guix packages)
scheme@(guix-user)> ,use(pkgs)
scheme@(guix-user)> ,pp (package-inputs salut)
$1 = (("git"
#<package git@2.45.2 gnu/packages/version-control.scm:243 73a06a652580>)
("git"
#<package git@2.45.2 gnu/packages/version-control.scm:243 73a06a652580>
"send-email"))

Other said, both outputs have the same label – here “git”.

Then, the procedure ’this-package-input’ – under the hood via
lookup-package-input and then lookup-input from (guix packages) – calls:

(assoc-ref (package-inputs some-package) some-string)

Therefore, since “some-string” is the same here, bang!


A first proposal for fixing the issue.

It’s easy to tweak how ’sanitize-inputs’ works. For instance using this
patch:

Toggle snippet (15 lines)
1 file changed, 1 insertion(+), 1 deletion(-)
guix/packages.scm | 2 +-

modified guix/packages.scm
@@ -667,7 +667,7 @@ (define (add-input-label input)
((? package? package)
(list (package-name package) package))
(((? package? package) output) ;XXX: ugly?
- (list (package-name package) package output))
+ (list (string-append (package-name package) ":" output) package output))
((? gexp-input?) ;XXX: misplaced because 'native?' field is ignored?
(let ((obj (gexp-input-thing input))
(output (gexp-input-output input)))

Now we get different labels,

Toggle snippet (8 lines)
scheme@(guix-user)> ,pp (package-inputs salut)
$1 = (("git"
#<package git@2.45.2 gnu/packages/version-control.scm:243 72f31b35de70>)
("git:send-email"
#<package git@2.45.2 gnu/packages/version-control.scm:243 72f31b35de70>
"send-email"))

So far, so good! Please note that some packages then need some
adjustment; e.g., see below.


Next, let add to the package definition this snippet for more wrapping,

Toggle snippet (3 lines)
(,(string-append #$(this-package-input "git:send-email") "/bin")))

Because of the procedure ’lookup-input’ from (guix packages), the
package is correctly identified but the output is still discarded.
Hence this modification:

Toggle snippet (17 lines)
1 file changed, 1 insertion(+)
guix/packages.scm | 1 +

modified guix/packages.scm
@@ -1213,6 +1213,7 @@ (define (lookup-input inputs name)
;; check package names.
(match (assoc-ref inputs name)
((obj) obj)
+ ((obj (? string? out)) (cons obj out))
((obj _) obj)
(#f #f)))
--8<---------------cut here---------------end--------------->8---

But then it is still incorrect. For instance, we check using
’package-arguments’ and the interesting part reads:

(unquote (string-append #<gexp-input (#<package git@2.45.2 gnu/packages/version-control.scm:243 7b7573de1b00> . "send-email"):out> "/bin"))
Toggle snippet (17 lines)
Ok, this is incorrect and it will error when trying to build. Well, the
G-exp compiler needs to be updated in agreement with ’lookup-input’ as
above. What I would expect is something like:

#<gexp-input #<package git@2.45.2 gnu/packages/version-control.scm:243 7b7573de1b00>:send-email>


All in all, I am a bit lost inside the module (guix gexp). :-) To be continued…

Cheers,
simon


Some adjustments here or there:

1 file changed, 1 insertion(+), 1 deletion(-)
gnu/packages/backup.scm | 2 +-

modified gnu/packages/backup.scm
@@ -318,7 +318,7 @@ (define-public libarchive
(libxml2 (assoc-ref inputs "libxml2"))
(xz (assoc-ref inputs "xz"))
(zlib (assoc-ref inputs "zlib"))
- (zstd (assoc-ref inputs "zstd"))
+ (zstd (assoc-ref inputs "zstd:lib"))
(bzip2 (assoc-ref inputs "bzip2")))
;; Embed absolute references to these inputs to avoid propagation.
(substitute* (list (string-append lib "/pkgconfig/libarchive.pc")
Toggle snippet (4 lines)
And thus improving the situation for packages with multiple outputs and
“new style” probably means a world rebuild.
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 72266@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 72266
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch