mirror of
https://codeberg.org/guix/guix.git
synced 2025-10-02 02:15:12 +00:00
ui: Allow evaluating multi-expressions strings with read/eval.
This can be useful when evaluating a scheme-file store output for example, which has multiple top level expressions. * guix/ui.scm (read/eval): Also accept a port object as argument. Read and evaluate all expressions from input port or string. Change-Id: I0213706fa4824c3a8ffe5d93f44f263048cb62c2
This commit is contained in:
parent
bc2e923c19
commit
18ed22536d
2 changed files with 43 additions and 9 deletions
|
@ -2,6 +2,7 @@
|
|||
# Copyright © 2012-2014, 2016-2025 Ludovic Courtès <ludo@gnu.org>
|
||||
# Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
|
||||
# Copyright © 2021 Chris Marusich <cmmarusich@gmail.com>
|
||||
# Copyright © 2025 Maxim Cournoyer <maxim.cournoyer@gmail.com>
|
||||
#
|
||||
# This file is part of GNU Guix.
|
||||
#
|
||||
|
@ -420,6 +421,22 @@ then
|
|||
guix build -m <(echo '(specifications->manifest (list "guile"))') -n
|
||||
fi
|
||||
|
||||
# Build a scheme->file object via multiple expressions, and validate it
|
||||
# produces the correct result when evaluated.
|
||||
scheme_file=$(guix build -e \
|
||||
"(use-modules (guix gexp)) \
|
||||
(scheme-file \"mathematics\" \
|
||||
'(begin \
|
||||
(define add +) \
|
||||
(define multiply *) \
|
||||
(add 5 (multiply 2 10)))
|
||||
#:guile (@@ (gnu packages bootstrap) %bootstrap-guile))")
|
||||
guile -c \
|
||||
"(begin \
|
||||
(use-modules (guix ui) (rnrs base) (srfi srfi-26)) \
|
||||
(assert (= 25 (call-with-input-file \"$scheme_file\" \
|
||||
(cut read/eval <>)))))"
|
||||
|
||||
# Using 'GUIX_BUILD_OPTIONS'.
|
||||
GUIX_BUILD_OPTIONS="--dry-run --no-grafts"
|
||||
export GUIX_BUILD_OPTIONS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue