summaryrefslogtreecommitdiff
path: root/guix/gexp.scm
diff options
context:
space:
mode:
Diffstat (limited to 'guix/gexp.scm')
-rw-r--r--guix/gexp.scm19
1 files changed, 18 insertions, 1 deletions
diff --git a/guix/gexp.scm b/guix/gexp.scm
index 0fe4f1c98a..a7f4256d24 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2014-2022 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2014-2023 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org>
;;; Copyright © 2018 Jan Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2019, 2020 Mathieu Othacehe <m.othacehe@gmail.com>
@@ -775,6 +775,23 @@ x86_64-linux when COREUTILS is lowered."
whether this should be considered a \"native\" input or not."
(%gexp-input thing output native?))
+;; Allow <gexp-input>s to be used within gexps. This is useful when willing
+;; to force a specific reference to an object, as in (gexp-input hwloc "bin"),
+;; which forces a reference to the "bin" output of 'hwloc' instead of leaving
+;; it up to the recipient to pick the right output.
+(define-gexp-compiler gexp-input-compiler <gexp-input>
+ compiler => (lambda (obj system target)
+ (match obj
+ (($ <gexp-input> thing output native?)
+ (lower-object thing system
+ #:target (and (not native?) target)))))
+ expander => (lambda (obj lowered output/ignored)
+ (match obj
+ (($ <gexp-input> thing output native?)
+ (let ((expand (or (lookup-expander thing)
+ (lookup-expander lowered))))
+ (expand thing lowered output))))))
+
;; Reference to one of the derivation's outputs, for gexps used in
;; derivations.
(define-record-type <gexp-output>