From: Simon Tournier <zimon.toutoune@gmail.com>
To: 72266@debbugs.gnu.org
Cc: ludo@gnu.org
Subject: bug#72266: this-package-input for multiple outputs package
Date: Wed, 24 Jul 2024 02:41:39 +0200 [thread overview]
Message-ID: <87plr3ei4c.fsf@gmail.com> (raw)
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.
--8<---------------cut here---------------start------------->8---
$ 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")))))
--8<---------------cut here---------------end--------------->8---
Then, it’s possible to add phases, e.g.,
--8<---------------cut here---------------start------------->8---
(wrap-program (string-append #$output "/bin/hello")
`("STUFF" ":" prefix
(,(string-append #$(this-package-input "git") "/bin")))
--8<---------------cut here---------------end--------------->8---
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,
--8<---------------cut here---------------start------------->8---
$ 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"))
--8<---------------cut here---------------end--------------->8---
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:
--8<---------------cut here---------------start------------->8---
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)))
--8<---------------cut here---------------end--------------->8---
Now we get different labels,
--8<---------------cut here---------------start------------->8---
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"))
--8<---------------cut here---------------end--------------->8---
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,
--8<---------------cut here---------------start------------->8---
(,(string-append #$(this-package-input "git:send-email") "/bin")))
--8<---------------cut here---------------end--------------->8---
Because of the procedure ’lookup-input’ from (guix packages), the
package is correctly identified but the output is still discarded.
Hence this modification:
--8<---------------cut here---------------start------------->8---
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:
--8<---------------cut here---------------start------------->8---
(unquote (string-append #<gexp-input (#<package git@2.45.2 gnu/packages/version-control.scm:243 7b7573de1b00> . "send-email"):out> "/bin"))
--8<---------------cut here---------------end--------------->8---
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:
--8<---------------cut here---------------start------------->8---
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")
--8<---------------cut here---------------end--------------->8---
And thus improving the situation for packages with multiple outputs and
“new style” probably means a world rebuild.
reply other threads:[~2024-07-24 6:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87plr3ei4c.fsf@gmail.com \
--to=zimon.toutoune@gmail.com \
--cc=72266@debbugs.gnu.org \
--cc=ludo@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).