summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/guix.texi7
-rw-r--r--guix/monad-repl.scm36
2 files changed, 33 insertions, 10 deletions
diff --git a/doc/guix.texi b/doc/guix.texi
index 05eac9bda96..6bf2ca4f1ad 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -123,7 +123,7 @@ Copyright @copyright{} 2023 Foundation Devices, Inc.@*
123Copyright @copyright{} 2023 Thomas Ieong@* 123Copyright @copyright{} 2023 Thomas Ieong@*
124Copyright @copyright{} 2023 Saku Laesvuori@* 124Copyright @copyright{} 2023 Saku Laesvuori@*
125Copyright @copyright{} 2023 Graham James Addis@* 125Copyright @copyright{} 2023 Graham James Addis@*
126Copyright @copyright{} 2023-2025 Tomas Volf@* 126Copyright @copyright{} 2023-2026 Tomas Volf@*
127Copyright @copyright{} 2024-2026 Herman Rimm@* 127Copyright @copyright{} 2024-2026 Herman Rimm@*
128Copyright @copyright{} 2024 Matthew Trzcinski@* 128Copyright @copyright{} 2024 Matthew Trzcinski@*
129Copyright @copyright{} 2024 Richard Sent@* 129Copyright @copyright{} 2024 Richard Sent@*
@@ -13735,9 +13735,12 @@ $7 = "/gnu/store/@dots{}-x"
13735The full list of REPL commands can be seen by typing @code{,help guix} 13735The full list of REPL commands can be seen by typing @code{,help guix}
13736and is given below for reference. 13736and is given below for reference.
13737 13737
13738@deffn {REPL command} build @var{object} 13738@deffn {REPL command} build @var{object} [@var{build-mode}]
13739Lower @var{object} and build it if it's not already built, returning its 13739Lower @var{object} and build it if it's not already built, returning its
13740output file name(s). 13740output file name(s).
13741
13742@var{build-mode} defaults to @code{normal}. Other valid build modes are
13743@code{check} and @code{repair}.
13741@end deffn 13744@end deffn
13742 13745
13743@deffn {REPL command} build-options @var{options} 13746@deffn {REPL command} build-options @var{options}
diff --git a/guix/monad-repl.scm b/guix/monad-repl.scm
index dcb00988fe8..7c27765954a 100644
--- a/guix/monad-repl.scm
+++ b/guix/monad-repl.scm
@@ -1,6 +1,6 @@
1;;; GNU Guix --- Functional package management for GNU 1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2014-2016, 2022-2023 Ludovic Courtès <ludo@gnu.org> 2;;; Copyright © 2014-2016, 2022-2023 Ludovic Courtès <ludo@gnu.org>
3;;; Copyright © 2025 Tomas Volf <~@wolfsden.cz> 3;;; Copyright © 2025-2026 Tomas Volf <~@wolfsden.cz>
4;;; 4;;;
5;;; This file is part of GNU Guix. 5;;; This file is part of GNU Guix.
6;;; 6;;;
@@ -86,7 +86,10 @@
86 ;; Additional build options. 86 ;; Additional build options.
87 '()) 87 '())
88 88
89(define* (evaluate/print-with-store mvalue #:key build?) 89(define* (evaluate/print-with-store mvalue
90 #:key
91 build?
92 (build-mode (build-mode normal)))
90 "Run monadic value MVALUE in the store monad and print its value." 93 "Run monadic value MVALUE in the store monad and print its value."
91 (with-store store 94 (with-store store
92 (apply set-build-options store 95 (apply set-build-options store
@@ -102,7 +105,7 @@
102 (mlet %store-monad ((obj mvalue)) 105 (mlet %store-monad ((obj mvalue))
103 (if (derivation? obj) 106 (if (derivation? obj)
104 (mbegin %store-monad 107 (mbegin %store-monad
105 (built-derivations (list obj)) 108 (built-derivations (list obj) build-mode)
106 (return 109 (return
107 (match (derivation->output-paths obj) 110 (match (derivation->output-paths obj)
108 (((_ . files) ...) files)))) 111 (((_ . files) ...) files))))
@@ -132,11 +135,28 @@ Change build verbosity to LEVEL.
132Lower OBJECT into a derivation or store file and return it." 135Lower OBJECT into a derivation or store file and return it."
133 (evaluate/print-with-store (lower-object (repl-eval repl form)))) 136 (evaluate/print-with-store (lower-object (repl-eval repl form))))
134 137
135(define-meta-command ((build guix) repl (form)) 138(define-meta-command ((build guix) repl (form) . args)
136 "build OBJECT 139 "build OBJECT [BUILD-MODE]
137Lower OBJECT and build it, returning its output file name(s)." 140Lower OBJECT and build it, returning its output file name(s).
138 (evaluate/print-with-store (lower-object (repl-eval repl form)) 141
139 #:build? #t)) 142Build mode defaults to 'normal. If expression is provided, it must evaluate
143to one of the following symbols: normal, check, repair."
144 (let ((build-mode (match args
145 ((mode)
146 (match mode
147 ((or 'normal ''normal) (build-mode normal))
148 ((or 'check ''check) (build-mode check))
149 ((or 'repair ''repair) (build-mode repair))
150 ((or 'normal ''normal) (build-mode normal))
151 (_
152 (format #t ";; ERROR: Invalid build mode.~%")
153 #f)))
154 (()
155 (build-mode normal)))))
156 (when build-mode
157 (evaluate/print-with-store (lower-object (repl-eval repl form))
158 #:build? #t
159 #:build-mode build-mode))))
140 160
141(define-meta-command ((build-options guix) repl (opts)) 161(define-meta-command ((build-options guix) repl (opts))
142 "build-options OPTIONS 162 "build-options OPTIONS