Subject: [PATCH 1/2] profiles: Add #:build? argument to lower-manifest-entry.

From: [email-masked]
Date: Sat, 18 Jan 2025 19:41:58 +0800

From: 宋文武 <[email-masked]>

* guix/profiles.scm (lower-manifest-entry): Add #:build? keyword argument.

Change-Id: Iab2832d1bac1b28f6124e0c4e78e9284daf9a2ea
---
 guix/profiles.scm | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/guix/profiles.scm b/guix/profiles.scm
index a28cf872cf..a05b90d685 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -308,9 +308,10 @@ (define (manifest-entry-lookup manifest)
       ((_ . entry) entry)
       (#f          #f))))
 
-(define* (lower-manifest-entry entry system #:key target)
+(define* (lower-manifest-entry entry system #:key target
+                               (build? #f))
   "Lower ENTRY for SYSTEM and TARGET such that its 'item' field is a store
-file name."
+file name.  When BUILD? is true, build the entry before returning."
   (define (recurse entry)
     (mapm/accumulate-builds (lambda (entry)
                               (lower-manifest-entry entry system
@@ -319,12 +320,19 @@ (define* (lower-manifest-entry entry system #:key target)
 
   (let ((item (manifest-entry-item entry)))
     (if (string? item)
-        (with-monad %store-monad
+        (mbegin %store-monad
+          (if (build?)
+              (build (list item))
+              (return #f))
           (return entry))
-        (mlet %store-monad ((drv (lower-object item system
+        (mlet* %store-monad ((drv (lower-object item system
                                                #:target target))
+
                             (dependencies (recurse entry))
-                            (output -> (manifest-entry-output entry)))
+                            (output -> (manifest-entry-output entry))
+                            (built (if build?
+                                       (built-derivations (list (cons drv output)))
+                                       (return #f))))
           (return (manifest-entry
                     (inherit entry)
                     (item (derivation->output-path drv output))
-- 
2.47.1