From: "Ludovic Courtès" <ludo@gnu.org>
To: 67172@debbugs.gnu.org
Cc: "Ludovic Courtès" <ludo@gnu.org>,
"Christopher Baines" <guix@cbaines.net>,
"Josselin Poiret" <dev@jpoiret.xyz>,
"Ludovic Courtès" <ludo@gnu.org>,
"Mathieu Othacehe" <othacehe@gnu.org>,
"Ricardo Wurmus" <rekado@elephly.net>,
"Simon Tournier" <zimon.toutoune@gmail.com>,
"Tobias Geerinckx-Rice" <me@tobias.gr>
Subject: [bug#67172] [PATCH 2/2] gexp: #:references-graphs accepts and honors <gexp-input> records.
Date: Tue, 14 Nov 2023 14:35:48 +0100 [thread overview]
Message-ID: <f41f063d67ae58e94d242881f3c4923b7ce7122c.1699967900.git.ludo@gnu.org> (raw)
In-Reply-To: <cover.1699967900.git.ludo@gnu.org>
* guix/gexp.scm (lower-reference-graphs)[tuple->gexp-input]: Add
‘gexp-input?’ case.
(gexp->derivation): Update docstring.
* doc/guix.texi (G-Expressions): Adjust accordingly.
* tests/gexp.scm ("references-file, non-default output"): New test.
Change-Id: I595cb75da0867ab8ab44552887dc06ed1d23315e
---
doc/guix.texi | 7 +++----
guix/gexp.scm | 12 ++++++++----
tests/gexp.scm | 30 ++++++++++++++++++++++++++++++
3 files changed, 41 insertions(+), 8 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 8492f0ada3..5f90ec6eb4 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -12213,10 +12213,9 @@ G-Expressions
following forms:
@example
-(@var{file-name} @var{package})
-(@var{file-name} @var{package} @var{output})
-(@var{file-name} @var{derivation})
-(@var{file-name} @var{derivation} @var{output})
+(@var{file-name} @var{obj})
+(@var{file-name} @var{obj} @var{output})
+(@var{file-name} @var{gexp-input})
(@var{file-name} @var{store-item})
@end example
diff --git a/guix/gexp.scm b/guix/gexp.scm
index a7f4256d24..29819878fa 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -934,6 +934,11 @@ (define* (lower-reference-graphs graphs #:key system target)
corresponding <derivation-input> or store item."
(define tuple->gexp-input
(match-lambda
+ (((? gexp-input? input))
+ ;; This case lets users specify the output of interest more
+ ;; conveniently, for instance by passing (gexp-input hwloc "lib") to
+ ;; the 'references-file' procedure.
+ input)
((thing)
(%gexp-input thing "out" (not target)))
((thing output)
@@ -1152,10 +1157,9 @@ (define* (gexp->derivation name exp
When REFERENCES-GRAPHS is true, it must be a list of tuples of one of the
following forms:
- (FILE-NAME PACKAGE)
- (FILE-NAME PACKAGE OUTPUT)
- (FILE-NAME DERIVATION)
- (FILE-NAME DERIVATION OUTPUT)
+ (FILE-NAME OBJ)
+ (FILE-NAME OBJ OUTPUT)
+ (FILE-NAME GEXP-INPUT)
(FILE-NAME STORE-ITEM)
The right-hand-side of each element of REFERENCES-GRAPHS is automatically made
diff --git a/tests/gexp.scm b/tests/gexp.scm
index a3147405d7..481755138e 100644
--- a/tests/gexp.scm
+++ b/tests/gexp.scm
@@ -1651,6 +1651,36 @@ (define shebang
read)
refs)))))))
+(test-assertm "references-file, non-default output"
+ (let* ((exp #~(begin
+ (mkdir #$output)
+ (symlink #$%bootstrap-guile #$output:extra)))
+ (computed (computed-file "computed" exp
+ #:guile %bootstrap-guile))
+ (refs1 (references-file computed
+ #:guile %bootstrap-guile))
+ ;; Wrap COMPUTE in 'gexp-input' to get the "extra" output.
+ (refs2 (references-file (gexp-input computed "extra")
+ #:guile %bootstrap-guile)))
+ (mlet* %store-monad ((drv0 (lower-object %bootstrap-guile))
+ (drv1 (lower-object computed))
+ (drv2 (lower-object refs2))
+ (drv3 (lower-object refs1)))
+ (mbegin %store-monad
+ (built-derivations (list drv2 drv3))
+ (mlet %store-monad ((refs ((store-lift requisites)
+ (list (derivation->output-path
+ drv1 "extra")))))
+ (return
+ (and (lset= string=?
+ (call-with-input-file (derivation->output-path drv2)
+ read)
+ refs)
+ (lset= string=?
+ (call-with-input-file (derivation->output-path drv3)
+ read)
+ (list (derivation->output-path drv1))))))))))
+
(test-assert "lower-object & gexp-input-error?"
(guard (c ((gexp-input-error? c)
(gexp-error-invalid-input c)))
--
2.41.0
next prev parent reply other threads:[~2023-11-14 13:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-14 13:24 [bug#67172] [PATCH 0/2] Turning <gexp-input> into lowerable objects Ludovic Courtès
2023-11-14 13:35 ` [bug#67172] [PATCH 1/2] gexp: Add compiler for <gexp-input> Ludovic Courtès
2023-12-04 1:59 ` Maxim Cournoyer
2023-11-14 13:35 ` Ludovic Courtès [this message]
2023-12-04 2:05 ` [bug#67172] [PATCH 2/2] gexp: #:references-graphs accepts and honors <gexp-input> records Maxim Cournoyer
2023-12-21 23:38 ` bug#67172: " Ludovic Courtès
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=f41f063d67ae58e94d242881f3c4923b7ce7122c.1699967900.git.ludo@gnu.org \
--to=ludo@gnu.org \
--cc=67172@debbugs.gnu.org \
--cc=dev@jpoiret.xyz \
--cc=guix@cbaines.net \
--cc=me@tobias.gr \
--cc=othacehe@gnu.org \
--cc=rekado@elephly.net \
--cc=zimon.toutoune@gmail.com \
/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).