[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#67172] [PATCH 0/2] Turning <gexp-input> into lowerable objects
From: |
Ludovic Courtès |
Subject: |
[bug#67172] [PATCH 0/2] Turning <gexp-input> into lowerable objects |
Date: |
Tue, 14 Nov 2023 14:24:45 +0100 |
Hello there!
These patches address a long-standing issue with gexps: the gexp
writer has full control over the type of references used in the gexp
(they get to choose between ‘ungexp’ and ‘ungexp-native’, they also
choose which output of the file-like to refer to), but whoever passes
a value that ends up in the gexp has no power over the type of
reference.
The goal here is to provide a more control over that, as shown in
this manual excerpt added here:
--8<---------------cut here---------------start------------->8---
-- Procedure: gexp-input OBJ [OUTPUT] [#:native? #f]
Return a “gexp input” record for the given OUTPUT of file-like
object OBJ, with ‘#:native?’ determining whether this is a native
reference (as with ‘ungexp-native’) or not.
This procedure is helpful when you want to pass a reference to a
specific output of an object to some procedure that may not know
about that output. For example, assume you have this procedure,
which takes one file-like object:
(define (make-symlink target)
(computed-file "the-symlink"
#~(symlink #$target #$output)))
Here ‘make-symlink’ can only ever refer to the default output of
TARGET—the ‘"out"’ output (*note Packages with Multiple Outputs::).
To have it refer to, say, the ‘"lib"’ output of the ‘hwloc’
package, you can call it like so:
(make-symlink (gexp-input hwloc "lib"))
You can also compose it like any other file-like object:
(make-symlink
(file-append (gexp-input hwloc "lib") "/lib/libhwloc.so"))
--8<---------------cut here---------------end--------------->8---
Thoughts?
Ludo’.
Ludovic Courtès (2):
gexp: Add compiler for <gexp-input>.
gexp: #:references-graphs accepts and honors <gexp-input> records.
doc/guix.texi | 45 ++++++++++++++++++++++++++++++++++++----
guix/gexp.scm | 31 +++++++++++++++++++++++-----
tests/gexp.scm | 56 +++++++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 122 insertions(+), 10 deletions(-)
base-commit: 08d94fe20eca47b69678b3eced8749dd02c700a4
--
2.41.0
- [bug#67172] [PATCH 0/2] Turning <gexp-input> into lowerable objects,
Ludovic Courtès <=