diff options
author | Ludovic Courtès <ludo@gnu.org> | 2023-11-12 22:47:43 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2023-12-22 00:31:40 +0100 |
commit | d9190abbd20f15ea5b55abdd51e1376f05055850 (patch) | |
tree | 295c14c1542f402a581df51b7489441ef1d1b2eb /guix/gexp.scm | |
parent | 4771960e5d559d2f3911fd24fd648fa5e97bdf39 (diff) |
gexp: Add compiler for <gexp-input>.
* guix/gexp.scm (gexp-input-compiler): New procedure.
* tests/gexp.scm ("gexp references non-existent output")
("gexp-input, as first-class input"): New tests.
* doc/guix.texi (G-Expressions): Document it.
Reviewed-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Change-Id: I95b58d6e4d77a54364026b4324fbb00125a9402e
Diffstat (limited to 'guix/gexp.scm')
-rw-r--r-- | guix/gexp.scm | 19 |
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> |