From 0159dc10cd7fee8f953bcfd46d79be970a6a873a Mon Sep 17 00:00:00 2001 From: Tomas Volf <~@wolfsden.cz> Date: Mon, 6 Oct 2025 01:49:00 +0200 Subject: [PATCH] monad-repl: Add "build-options" command. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There currently was no way to disable build offload for ,build from inside the REPL. Since offloaded builds sometimes do not error report entirely correctly, it is useful to be able to switch to local builds. This commit adds new ,build-options meta command, which allows to specify build options, including #:offload?. * guix/monad-repl.scm (%build-options): New variable. (evaluate/print-with-store, package-argument-command): Use it. (build-options): New meta command to set it. * doc/guix.texi (Using Guix Interactively): Document it. Signed-off-by: Ludovic Courtès --- doc/guix.texi | 10 ++++++++++ guix/monad-repl.scm | 34 ++++++++++++++++++++++++++-------- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 0c002113078..29ededf831a 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -13204,6 +13204,16 @@ Lower @var{object} and build it if it's not already built, returning its output file name(s). @end deffn +@deffn {REPL command} build-options @var{options} +Set build options for rest of the REPL commands to @var{options}. Must +be a list of keywords with values accepted by procedure +@code{(@@ (guix store) set-build-options)}. An example would be: + +@example +,build-options '(#:offload? #f) +@end example +@end deffn + @deffn {REPL command} lower @var{object} Lower @var{object} into a derivation or store file name and return it. @end deffn diff --git a/guix/monad-repl.scm b/guix/monad-repl.scm index d6b39112b77..db4fe3c699c 100644 --- a/guix/monad-repl.scm +++ b/guix/monad-repl.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2014-2016, 2022-2023 Ludovic Courtès +;;; Copyright © 2025 Tomas Volf <~@wolfsden.cz> ;;; ;;; This file is part of GNU Guix. ;;; @@ -81,13 +82,18 @@ ;; Current build verbosity level. 1) +(define %build-options + ;; Additional build options. + '()) + (define* (evaluate/print-with-store mvalue #:key build?) "Run monadic value MVALUE in the store monad and print its value." (with-store store - (set-build-options store - #:print-build-trace #t - #:print-extended-build-trace? #t - #:multiplexed-build-output? #t) + (apply set-build-options store + #:print-build-trace #t + #:print-extended-build-trace? #t + #:multiplexed-build-output? #t + %build-options) (with-status-verbosity %build-verbosity (let* ((guile (or (%guile-for-build) (default-guile-derivation store))) @@ -130,6 +136,17 @@ Lower OBJECT and build it, returning its output file name(s)." (evaluate/print-with-store (lower-object (repl-eval repl form)) #:build? #t)) +(define-meta-command ((build-options guix) repl (opts)) + "build-options OPTIONS +Set build options to OPTIONS. Print previous value (to allow easy restore). + +Must be a list of keywords with values accepted by procedure +(@ (guix store) set-build-options). An example would be: + + ,build-options '(#:offload? #f)" + (repl-print repl %build-options) + (set! %build-options (repl-eval repl opts))) + (define-meta-command ((enter-store-monad guix) repl) "enter-store-monad Enter a REPL for values in the store monad." @@ -172,10 +189,11 @@ missing from those arguments." (define phases (parameterize ((%graft? #f)) (with-store store - (set-build-options store - #:print-build-trace #t - #:print-extended-build-trace? #t - #:multiplexed-build-output? #t) + (apply set-build-options store + #:print-build-trace #t + #:print-extended-build-trace? #t + #:multiplexed-build-output? #t + %build-options) (run-with-store store (mlet %store-monad ((exp (bag->derivation bag*))) (if (gexp? exp)