Subject: [PATCH 48/48] build-system: trivial: Redefine trivial-build functions.

From: Nicolas Graves <[email-masked]>
Date: Mon, 8 Jan 2024 09:03:20 +0100

* guix/build-system/trivial.scm
(trivial-build): Monadic procedure returns a gexp instead of a derivation.
(trivial-cross-build): Monadic procedure returns a gexp instead of a derivation.

Change-Id: I261d5d5ae027a174eafa972e4f598afdc394caa3
---
 guix/build-system/trivial.scm | 41 ++++++++++++++---------------------
 1 file changed, 16 insertions(+), 25 deletions(-)

diff --git a/guix/build-system/trivial.scm b/guix/build-system/trivial.scm
index e08884baf1..bc71c94132 100644
--- a/guix/build-system/trivial.scm
+++ b/guix/build-system/trivial.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012, 2013, 2014, 2015, 2018, 2021 Ludovic Courtès <[email-masked]>
+;;; Copyright © 2024 Nicolas Graves <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -51,18 +52,13 @@ (define* (trivial-build name inputs
                         search-paths allowed-references)
   "Run build expression BUILDER, an expression, for SYSTEM.  SOURCE is
 ignored."
-  (mlet %store-monad ((guile (package->derivation (or guile (default-guile))
-                                                  system #:graft? #f))
-                      (builder -> (if (pair? builder)
-                                      (sexp->gexp builder)
-                                      builder)))
-    (gexp->derivation name (with-build-variables inputs outputs builder)
-                      #:system system
-                      #:target #f
-                      #:graft? #f
-                      #:modules modules
-                      #:allowed-references allowed-references
-                      #:guile-for-build guile)))
+  (mlet* %store-monad ((builder -> (if (pair? builder)
+                                       (sexp->gexp builder)
+                                       builder)))
+    (return (with-imported-modules modules
+              #~(begin
+                  (use-modules #$@(sexp->gexp modules))
+                  #$(with-build-variables inputs outputs builder))))))
 
 (define* (trivial-cross-build name
                               #:key
@@ -73,21 +69,16 @@ (define* (trivial-cross-build name
                               allowed-references)
   "Run build expression BUILDER, an expression, for SYSTEM.  SOURCE is
 ignored."
-  (mlet %store-monad  ((guile (package->derivation (or guile (default-guile))
-                                                   system #:graft? #f))
-                       (builder -> (if (pair? builder)
+  (mlet* %store-monad ((builder -> (if (pair? builder)
                                        (sexp->gexp builder)
                                        builder)))
-    (gexp->derivation name (with-build-variables
-                               (append build-inputs target-inputs host-inputs)
-                               outputs
-                             builder)
-                      #:system system
-                      #:target target
-                      #:graft? #f
-                      #:modules modules
-                      #:allowed-references allowed-references
-                      #:guile-for-build guile)))
+    (return (with-imported-modules modules
+              #~(begin
+                  (use-modules #$@(sexp->gexp modules))
+                  #$(with-build-variables
+                        (append build-inputs target-inputs host-inputs)
+                        outputs
+                      builder))))))
 
 (define trivial-build-system
   (build-system
-- 
2.41.0