guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

06/15: squash! build-system: Rewrite using gexps.


From: guix-commits
Subject: 06/15: squash! build-system: Rewrite using gexps.
Date: Tue, 23 Feb 2021 08:34:01 -0500 (EST)

civodul pushed a commit to branch wip-build-systems-gexp
in repository guix.

commit c391919737bd3680bfc941b1c668ca67003f80a7
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Sat Feb 13 22:47:21 2021 +0100

    squash! build-system: Rewrite using gexps.
    
    * guix/build-system/cargo.scm (cargo-build): Change to 'gexp->derivation'.
    * guix/build-system/copy.scm (copy-build): Likewise.
    * guix/build-system/dune.scm (dune-build): Likewise.
    * guix/build-system/guile.scm (guile-build, guile-cross-build):
    Likewise.
    * guix/build-system/meson.scm (meson-build): Likewise.
    * guix/build-system/ocaml.scm (ocaml-build): Likewise.
    * guix/build-system/scons.scm (scons-build): Likewise.
    * guix/build-system/texlive.scm (texlive-build): Likewise.
---
 guix/build-system/cargo.scm   |  72 ++++++++---------
 guix/build-system/copy.scm    |  70 ++++++++--------
 guix/build-system/dune.scm    |  83 +++++++++----------
 guix/build-system/guile.scm   | 181 ++++++++++++++++++------------------------
 guix/build-system/meson.scm   | 115 ++++++++++-----------------
 guix/build-system/ocaml.scm   |  87 +++++++++-----------
 guix/build-system/scons.scm   |  67 +++++++---------
 guix/build-system/texlive.scm |  69 +++++++---------
 8 files changed, 320 insertions(+), 424 deletions(-)

diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
index ed69746..3d0559d 100644
--- a/guix/build-system/cargo.scm
+++ b/guix/build-system/cargo.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013, 2014, 2015, 2016, 2019 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013, 2014, 2015, 2016, 2019, 2021 Ludovic Courtès 
<ludo@gnu.org>
 ;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
 ;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
 ;;; Copyright © 2016 David Craven <david@craven.ch>
@@ -25,7 +25,8 @@
   #:use-module (guix search-paths)
   #:use-module (guix store)
   #:use-module (guix utils)
-  #:use-module (guix derivations)
+  #:use-module (guix gexp)
+  #:use-module (guix monads)
   #:use-module (guix packages)
   #:use-module (guix build-system)
   #:use-module (guix build-system gnu)
@@ -70,8 +71,9 @@ to NAME and VERSION."
     (guix build json)
     ,@%cargo-utils-modules))
 
-(define* (cargo-build store name inputs
+(define* (cargo-build name inputs
                       #:key
+                      source
                       (tests? #t)
                       (test-target #f)
                       (vendor-dir "guix-vendor")
@@ -91,45 +93,35 @@ to NAME and VERSION."
   "Build SOURCE using CARGO, and with INPUTS."
 
   (define builder
-    `(begin
-       (use-modules ,@modules)
-       (cargo-build #:name ,name
-                    #:source ,(match (assoc-ref inputs "source")
-                                (((? derivation? source))
-                                 (derivation->output-path source))
-                                ((source)
-                                 source)
-                                (source
-                                 source))
-                    #:system ,system
-                    #:test-target ,test-target
-                    #:vendor-dir ,vendor-dir
-                    #:cargo-build-flags ,cargo-build-flags
-                    #:cargo-test-flags ,cargo-test-flags
-                    #:features ,features
-                    #:skip-build? ,skip-build?
-                    #:tests? ,(and tests? (not skip-build?))
-                    #:phases ,phases
-                    #:outputs %outputs
-                    #:search-paths ',(map search-path-specification->sexp
-                                          search-paths)
-                    #:inputs %build-inputs)))
+    (with-imported-modules imported-modules
+      #~(begin
+          (use-modules #$@modules)
 
-  (define guile-for-build
-    (match guile
-      ((? package?)
-       (package-derivation store guile system #:graft? #f))
-      (#f                                         ; the default
-       (let* ((distro (resolve-interface '(gnu packages commencement)))
-              (guile  (module-ref distro 'guile-final)))
-         (package-derivation store guile system #:graft? #f)))))
+          (cargo-build #:name #$name
+                       #:source #+source
+                       #:system #$system
+                       #:test-target #$test-target
+                       #:vendor-dir #$vendor-dir
+                       #:cargo-build-flags #$cargo-build-flags
+                       #:cargo-test-flags #$cargo-test-flags
+                       #:features #$features
+                       #:skip-build? #$skip-build?
+                       #:tests? #$(and tests? (not skip-build?))
+                       #:phases #$phases
+                       #:outputs (list #$@(map (lambda (name)
+                                                 #~(cons #$name
+                                                         (ungexp output name)))
+                                               outputs))
+                       #:inputs (map (lambda (tuple)
+                                       (apply cons tuple))
+                                     '#$inputs)
+                       #:search-paths '#$(map search-path-specification->sexp
+                                             search-paths)))))
 
-  (build-expression->derivation store name builder
-                                #:inputs inputs
-                                #:system system
-                                #:modules imported-modules
-                                #:outputs outputs
-                                #:guile-for-build guile-for-build))
+  (gexp->derivation name builder
+                    #:system system
+                    #:target #f
+                    #:guile-for-build guile))
 
 (define (package-cargo-inputs p)
   (apply
diff --git a/guix/build-system/copy.scm b/guix/build-system/copy.scm
index d1bf8fb..ee7091b 100644
--- a/guix/build-system/copy.scm
+++ b/guix/build-system/copy.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2019 Julien Lepiller <julien@lepiller.eu>
 ;;; Copyright © 2020 Pierre Neidhardt <mail@ambrevar.xyz>
+;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -20,7 +21,8 @@
 (define-module (guix build-system copy)
   #:use-module (guix store)
   #:use-module (guix utils)
-  #:use-module (guix derivations)
+  #:use-module (guix gexp)
+  #:use-module (guix monads)
   #:use-module (guix search-paths)
   #:use-module (guix build-system)
   #:use-module (guix build-system gnu)
@@ -75,8 +77,9 @@
     (build copy-build)
     (arguments (strip-keyword-arguments private-keywords arguments))))
 
-(define* (copy-build store name inputs
-                     #:key (guile #f)
+(define* (copy-build name inputs
+                     #:key
+                     guile source
                      (outputs '("out"))
                      (install-plan ''(("." "./")))
                      (search-paths '())
@@ -90,49 +93,38 @@
                      (phases '(@ (guix build copy-build-system)
                                  %standard-phases))
                      (system (%current-system))
+                     (target #f)
                      (imported-modules %copy-build-system-modules)
                      (modules '((guix build copy-build-system)
                                 (guix build utils))))
   "Build SOURCE using INSTALL-PLAN, and with INPUTS."
   (define builder
-    `(begin
-       (use-modules ,@modules)
-       (copy-build #:source ,(match (assoc-ref inputs "source")
-                               (((?  derivation? source))
-                                (derivation->output-path source))
-                               ((source)
-                                source)
-                               (source
-                                source))
-                   #:system ,system
-                   #:outputs %outputs
-                   #:inputs %build-inputs
-                   #:install-plan ,install-plan
-                   #:search-paths ',(map search-path-specification->sexp
-                                         search-paths)
-                   #:phases ,phases
-                   #:out-of-source? ,out-of-source?
-                   #:validate-runpath? ,validate-runpath?
-                   #:patch-shebangs? ,patch-shebangs?
-                   #:strip-binaries? ,strip-binaries?
-                   #:strip-flags ,strip-flags
-                   #:strip-directories ,strip-directories)))
+    (with-imported-modules imported-modules
+      #~(begin
+          (use-modules ,@modules)
 
-  (define guile-for-build
-    (match guile
-      ((? package?)
-       (package-derivation store guile system #:graft? #f))
-      (#f                                         ; the default
-       (let* ((distro (resolve-interface '(gnu packages commencement)))
-              (guile  (module-ref distro 'guile-final)))
-         (package-derivation store guile system #:graft? #f)))))
+          #$(with-build-variables inputs outputs
+              #~(copy-build #:source #+source
+                            #:system #$system
+                            #:outputs %outputs
+                            #:inputs %build-inputs
+                            #:install-plan #$install-plan
+                            #:search-paths '#$(map 
search-path-specification->sexp
+                                                   search-paths)
+                            #:phases #$phases
+                            #:out-of-source? #$out-of-source?
+                            #:validate-runpath? #$validate-runpath?
+                            #:patch-shebangs? #$patch-shebangs?
+                            #:strip-binaries? #$strip-binaries?
+                            #:strip-flags #$strip-flags
+                            #:strip-directories #$strip-directories)))))
 
-  (build-expression->derivation store name builder
-                                #:system system
-                                #:inputs inputs
-                                #:modules imported-modules
-                                #:outputs outputs
-                                #:guile-for-build guile-for-build))
+  (mlet %store-monad ((guile (package->derivation (or guile (default-guile))
+                                                  system #:graft? #f)))
+    (gexp->derivation name builder
+                      #:system system
+                      #:target #f
+                      #:guile-for-build guile)))
 
 (define copy-build-system
   (build-system
diff --git a/guix/build-system/dune.scm b/guix/build-system/dune.scm
index 6a2f3d1..0f54064 100644
--- a/guix/build-system/dune.scm
+++ b/guix/build-system/dune.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2016, 2017, 2018 Julien Lepiller <julien@lepiller.eu>
 ;;; Copyright © 2017 Ben Woodcroft <donttrustben@gmail.com>
+;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -20,7 +21,7 @@
 (define-module (guix build-system dune)
   #:use-module (guix store)
   #:use-module (guix utils)
-  #:use-module (guix derivations)
+  #:use-module (guix gexp)
   #:use-module (guix search-paths)
   #:use-module (guix build-system)
   #:use-module ((guix build-system gnu) #:prefix gnu:)
@@ -80,8 +81,9 @@
            (build dune-build)
            (arguments (strip-keyword-arguments private-keywords arguments))))))
 
-(define* (dune-build store name inputs
-                     #:key (guile #f)
+(define* (dune-build name inputs
+                     #:key
+                     guile source
                      (outputs '("out"))
                      (search-paths '())
                      (build-flags ''())
@@ -107,50 +109,39 @@
   "Build SOURCE using OCAML, and with INPUTS. This assumes that SOURCE
 provides a 'setup.ml' file as its build system."
   (define builder
-    `(begin
-       (use-modules ,@modules)
-       (dune-build #:source ,(match (assoc-ref inputs "source")
-                               (((? derivation? source))
-                                (derivation->output-path source))
-                               ((source)
-                                source)
-                               (source
-                                source))
-                   #:system ,system
-                   #:outputs %outputs
-                   #:inputs %build-inputs
-                   #:search-paths ',(map search-path-specification->sexp
-                                         search-paths)
-                   #:phases ,phases
-                   #:test-flags ,test-flags
-                   #:build-flags ,build-flags
-                   #:out-of-source? ,out-of-source?
-                   #:jbuild? ,jbuild?
-                   #:package ,package
-                   #:tests? ,tests?
-                   #:test-target ,test-target
-                   #:install-target ,install-target
-                   #:validate-runpath? ,validate-runpath?
-                   #:patch-shebangs? ,patch-shebangs?
-                   #:strip-binaries? ,strip-binaries?
-                   #:strip-flags ,strip-flags
-                   #:strip-directories ,strip-directories)))
+    (with-imported-modules imported-modules
+      #~(begin
+          (use-modules ,@modules)
+          (dune-build #:source #$source
+                      #:system ,system
+                      #:outputs (list #$@(map (lambda (name)
+                                                #~(cons #$name
+                                                        (ungexp output name)))
+                                              outputs))
+                      #:inputs (map (lambda (tuple)
+                                      (apply cons tuple))
+                                    '#$inputs)
+                      #:search-paths '#$(map search-path-specification->sexp
+                                             search-paths)
+                      #:phases #$phases
+                      #:test-flags #$test-flags
+                      #:build-flags #$build-flags
+                      #:out-of-source? #$out-of-source?
+                      #:jbuild? #$jbuild?
+                      #:package #$package
+                      #:tests? #$tests?
+                      #:test-target #$test-target
+                      #:install-target #$install-target
+                      #:validate-runpath? #$validate-runpath?
+                      #:patch-shebangs? #$patch-shebangs?
+                      #:strip-binaries? #$strip-binaries?
+                      #:strip-flags #$strip-flags
+                      #:strip-directories #$strip-directories))))
 
-  (define guile-for-build
-    (match guile
-      ((? package?)
-       (package-derivation store guile system #:graft? #f))
-      (#f                                         ; the default
-       (let* ((distro (resolve-interface '(gnu packages commencement)))
-              (guile  (module-ref distro 'guile-final)))
-         (package-derivation store guile system #:graft? #f)))))
-
-  (build-expression->derivation store name builder
-                                #:system system
-                                #:inputs inputs
-                                #:modules imported-modules
-                                #:outputs outputs
-                                #:guile-for-build guile-for-build))
+  (gexp->derivation name builder
+                    #:system system
+                    #:target #f
+                    #:guile-for-build guile))
 
 (define dune-build-system
   (build-system
diff --git a/guix/build-system/guile.scm b/guix/build-system/guile.scm
index 45e735b..fe0bf0b 100644
--- a/guix/build-system/guile.scm
+++ b/guix/build-system/guile.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2018, 2019 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2018, 2019, 2021 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -20,7 +20,8 @@
   #:use-module (guix store)
   #:use-module (guix utils)
   #:use-module (guix packages)
-  #:use-module (guix derivations)
+  #:use-module (guix monads)
+  #:use-module (guix gexp)
   #:use-module (guix search-paths)
   #:use-module (guix build-system)
   #:use-module (guix build-system gnu)
@@ -75,7 +76,7 @@
   ;; denominator between Guile 2.0 and 2.2.
   ''("-Wunbound-variable" "-Warity-mismatch" "-Wformat"))
 
-(define* (guile-build store name inputs
+(define* (guile-build name inputs
                       #:key source
                       (guile #f)
                       (phases '%standard-phases)
@@ -91,47 +92,39 @@
                                  (guix build utils))))
   "Build SOURCE using Guile taken from the native inputs, and with INPUTS."
   (define builder
-    `(begin
-       (use-modules ,@modules)
-       (guile-build #:name ,name
-                    #:source ,(match (assoc-ref inputs "source")
-                                (((? derivation? source))
-                                 (derivation->output-path source))
-                                ((source)
-                                 source)
-                                (source
-                                 source))
-                    #:source-directory ,source-directory
-                    #:scheme-file-regexp ,scheme-file-regexp
-                    #:not-compiled-file-regexp ,not-compiled-file-regexp
-                    #:compile-flags ,compile-flags
-                    #:phases ,phases
-                    #:system ,system
-                    #:outputs %outputs
-                    #:search-paths ',(map search-path-specification->sexp
-                                          search-paths)
-                    #:inputs %build-inputs)))
-
-  (define guile-for-build
-    (match guile
-      ((? package?)
-       (package-derivation store guile system #:graft? #f))
-      (#f                                         ; the default
-       (let* ((distro (resolve-interface '(gnu packages commencement)))
-              (guile  (module-ref distro 'guile-final)))
-         (package-derivation store guile system #:graft? #f)))))
-
-  (build-expression->derivation store name builder
-                                #:inputs inputs
-                                #:system system
-                                #:modules imported-modules
-                                #:outputs outputs
-                                #:guile-for-build guile-for-build))
-
-(define* (guile-cross-build store name
+    (with-imported-modules imported-modules
+      #~(begin
+          (use-modules #$@modules)
+
+          (guile-build #:name #$name
+                       #:source #+source
+                       #:source-directory #$source-directory
+                       #:scheme-file-regexp #$scheme-file-regexp
+                       #:not-compiled-file-regexp #$not-compiled-file-regexp
+                       #:compile-flags #$compile-flags
+                       #:phases #$phases
+                       #:system #$system
+                       #:outputs (list #$@(map (lambda (name)
+                                                 #~(cons #$name
+                                                         (ungexp output name)))
+                                               outputs))
+                       #:inputs (map (lambda (tuple)
+                                       (apply cons tuple))
+                                     '#$inputs)
+                       #:search-paths '#$(map search-path-specification->sexp
+                                              search-paths)))))
+
+  (mlet %store-monad ((guile (package->derivation (or guile (default-guile))
+                                                  system #:graft? #f)))
+    (gexp->derivation name builder
+                      #:system system
+                      #:target #f
+                      #:guile-for-build guile)))
+
+(define* (guile-cross-build name
                             #:key
                             (system (%current-system)) target
-                            native-drvs target-drvs
+                            build-inputs target-inputs host-inputs
                             (guile #f)
                             source
                             (outputs '("out"))
@@ -146,68 +139,48 @@
                             (modules '((guix build guile-build-system)
                                        (guix build utils))))
   (define builder
-    `(begin
-       (use-modules ,@modules)
-
-       (let ()
-         (define %build-host-inputs
-           ',(map (match-lambda
-                    ((name (? derivation? drv) sub ...)
-                     `(,name . ,(apply derivation->output-path drv sub)))
-                    ((name path)
-                     `(,name . ,path)))
-                  native-drvs))
-
-         (define %build-target-inputs
-           ',(map (match-lambda
-                    ((name (? derivation? drv) sub ...)
-                     `(,name . ,(apply derivation->output-path drv sub)))
-                    ((name (? package? pkg) sub ...)
-                     (let ((drv (package-cross-derivation store pkg
-                                                          target system)))
-                       `(,name . ,(apply derivation->output-path drv sub))))
-                    ((name path)
-                     `(,name . ,path)))
-                  target-drvs))
-
-         (guile-build #:source ,(match (assoc-ref native-drvs "source")
-                                  (((? derivation? source))
-                                   (derivation->output-path source))
-                                  ((source)
-                                   source)
-                                  (source
-                                   source))
-                      #:system ,system
-                      #:target ,target
-                      #:outputs %outputs
-                      #:source-directory ,source-directory
-                      #:not-compiled-file-regexp ,not-compiled-file-regexp
-                      #:compile-flags ,compile-flags
-                      #:inputs %build-target-inputs
-                      #:native-inputs %build-host-inputs
-                      #:search-paths ',(map search-path-specification->sexp
-                                            search-paths)
-                      #:native-search-paths ',(map
-                                               search-path-specification->sexp
-                                               native-search-paths)
-                      #:phases ,phases))))
-
-  (define guile-for-build
-    (match guile
-      ((? package?)
-       (package-derivation store guile system #:graft? #f))
-      (#f                                         ; the default
-       (let* ((distro (resolve-interface '(gnu packages commencement)))
-              (guile  (module-ref distro 'guile-final)))
-         (package-derivation store guile system #:graft? #f)))))
-
-  (build-expression->derivation store name builder
-                                #:system system
-                                #:inputs (append native-drvs target-drvs)
-                                #:outputs outputs
-                                #:modules imported-modules
-                                #:substitutable? substitutable?
-                                #:guile-for-build guile-for-build))
+    (with-imported-modules imported-modules
+      #~(begin
+          (use-modules #$@modules)
+
+          (define %build-host-inputs
+            (map (lambda (tuple)
+                   (apply cons tuple))
+                 '#+(append build-inputs target-inputs)))
+
+          (define %build-target-inputs
+            (map (lambda (tuple)
+                   (apply cons tuple))
+                 '#$host-inputs))
+
+          (define %outputs
+            (list #$@(map (lambda (name)
+                            #~(cons #$name
+                                    (ungexp output name)))
+                          outputs)))
+
+          (guile-build #:source #+source
+                       #:system #$system
+                       #:target #$target
+                       #:outputs %outputs
+                       #:source-directory #$source-directory
+                       #:not-compiled-file-regexp #$not-compiled-file-regexp
+                       #:compile-flags #$compile-flags
+                       #:inputs %build-target-inputs
+                       #:native-inputs %build-host-inputs
+                       #:search-paths '#$(map search-path-specification->sexp
+                                              search-paths)
+                       #:native-search-paths '#$(map
+                                                 
search-path-specification->sexp
+                                                 native-search-paths)
+                       #:phases #$phases))))
+
+  (mlet %store-monad ((guile (package->derivation (or guile (default-guile))
+                                                  system #:graft? #f)))
+    (gexp->derivation name builder
+                      #:system system
+                      #:target target
+                      #:guile-for-build guile)))
 
 (define guile-build-system
   (build-system
diff --git a/guix/build-system/meson.scm b/guix/build-system/meson.scm
index e042233..5404e51 100644
--- a/guix/build-system/meson.scm
+++ b/guix/build-system/meson.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2017 Peter Mikkelsen <petermikkelsen10@gmail.com>
 ;;; Copyright © 2018, 2019 Marius Bakke <mbakke@fastmail.com>
+;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -18,9 +19,10 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (guix build-system meson)
-  #:use-module (guix store)
+  #:use-module (guix gexp)
   #:use-module (guix utils)
-  #:use-module (guix derivations)
+  #:use-module (guix store)
+  #:use-module (guix monads)
   #:use-module (guix search-paths)
   #:use-module (guix build-system)
   #:use-module (guix build-system gnu)
@@ -85,8 +87,9 @@
          (build meson-build)
          (arguments (strip-keyword-arguments private-keywords arguments)))))
 
-(define* (meson-build store name inputs
-                      #:key (guile #f)
+(define* (meson-build name inputs
+                      #:key
+                      guile source
                       (outputs '("out"))
                       (configure-flags ''())
                       (search-paths '())
@@ -114,76 +117,46 @@
                       disallowed-references)
   "Build SOURCE using MESON, and with INPUTS, assuming that SOURCE
 has a 'meson.build' file."
-
-  ;; TODO: Copied from build-system/gnu, factorize this!
-  (define canonicalize-reference
-    (match-lambda
-     ((? package? p)
-      (derivation->output-path (package-derivation store p system
-                                                   #:graft? #f)))
-     (((? package? p) output)
-      (derivation->output-path (package-derivation store p system
-                                                   #:graft? #f)
-                               output))
-     ((? string? output)
-      output)))
-
   (define builder
-    `(let ((build-phases (if ,glib-or-gtk?
-                             ,phases
-                             (modify-phases ,phases
-                               (delete 'glib-or-gtk-compile-schemas)
-                               (delete 'glib-or-gtk-wrap)))))
-       (use-modules ,@modules)
-       (meson-build #:source ,(match (assoc-ref inputs "source")
-                                (((? derivation? source))
-                                 (derivation->output-path source))
-                                ((source)
-                                 source)
-                                (source
-                                 source))
-                    #:system ,system
-                    #:outputs %outputs
-                    #:inputs %build-inputs
-                    #:search-paths ',(map search-path-specification->sexp
-                                          search-paths)
-                    #:phases build-phases
-                    #:configure-flags ,configure-flags
-                    #:build-type ,build-type
-                    #:tests? ,tests?
-                    #:test-target ,test-target
-                    #:parallel-build? ,parallel-build?
-                    #:parallel-tests? ,parallel-tests?
-                    #:validate-runpath? ,validate-runpath?
-                    #:patch-shebangs? ,patch-shebangs?
-                    #:strip-binaries? ,strip-binaries?
-                    #:strip-flags ,strip-flags
-                    #:strip-directories ,strip-directories
-                    #:elf-directories ,elf-directories)))
+    (with-imported-modules imported-modules
+      #~(let ((build-phases #$(if glib-or-gtk?
+                                  phases
+                                  #~(modify-phases #$phases
+                                      (delete 'glib-or-gtk-compile-schemas)
+                                      (delete 'glib-or-gtk-wrap)))))
+
+          (use-modules ,@modules)
 
-  (define guile-for-build
-    (match guile
-      ((? package?)
-       (package-derivation store guile system #:graft? #f))
-      (#f                                         ; the default
-       (let* ((distro (resolve-interface '(gnu packages commencement)))
-              (guile  (module-ref distro 'guile-final)))
-         (package-derivation store guile system #:graft? #f)))))
+          #$(with-build-variables inputs outputs
+              #~(meson-build #:source #+source
+                             #:system #$system
+                             #:outputs %outputs
+                             #:inputs %build-inputs
+                             #:search-paths '#$(map 
search-path-specification->sexp
+                                                    search-paths)
+                             #:phases build-phases
+                             #:configure-flags #$configure-flags
+                             #:build-type #$build-type
+                             #:tests? #$tests?
+                             #:test-target #$test-target
+                             #:parallel-build? #$parallel-build?
+                             #:parallel-tests? #$parallel-tests?
+                             #:validate-runpath? #$validate-runpath?
+                             #:patch-shebangs? #$patch-shebangs?
+                             #:strip-binaries? #$strip-binaries?
+                             #:strip-flags #$strip-flags
+                             #:strip-directories #$strip-directories
+                             #:elf-directories #$elf-directories)))))
 
-  (build-expression->derivation store name builder
-                                #:system system
-                                #:inputs inputs
-                                #:modules imported-modules
-                                #:outputs outputs
-                                #:guile-for-build guile-for-build
-                                #:allowed-references
-                                (and allowed-references
-                                     (map canonicalize-reference
-                                          allowed-references))
-                                #:disallowed-references
-                                (and disallowed-references
-                                     (map canonicalize-reference
-                                          disallowed-references))))
+  (mlet %store-monad ((guile (package->derivation (or guile (default-guile))
+                                                  system #:graft? #f)))
+    (gexp->derivation name builder
+                      #:system system
+                      #:target #f
+                      #:substitutable? substitutable?
+                      #:allowed-references allowed-references
+                      #:disallowed-references disallowed-references
+                      #:guile-for-build guile)))
 
 (define meson-build-system
   (build-system
diff --git a/guix/build-system/ocaml.scm b/guix/build-system/ocaml.scm
index 5513216..9d0e9ff 100644
--- a/guix/build-system/ocaml.scm
+++ b/guix/build-system/ocaml.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2016, 2017, 2018 Julien Lepiller <julien@lepiller.eu>
 ;;; Copyright © 2017 Ben Woodcroft <donttrustben@gmail.com>
+;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -19,7 +20,7 @@
 (define-module (guix build-system ocaml)
   #:use-module (guix store)
   #:use-module (guix utils)
-  #:use-module (guix derivations)
+  #:use-module (guix gexp)
   #:use-module (guix search-paths)
   #:use-module (guix build-system)
   #:use-module (guix build-system gnu)
@@ -226,8 +227,9 @@ pre-defined variants."
          (build ocaml-build)
          (arguments (strip-keyword-arguments private-keywords arguments)))))
 
-(define* (ocaml-build store name inputs
-                      #:key (guile #f)
+(define* (ocaml-build name inputs
+                      #:key
+                      guile source
                       (outputs '("out")) (configure-flags ''())
                       (search-paths '())
                       (make-flags ''())
@@ -253,51 +255,40 @@ pre-defined variants."
   "Build SOURCE using OCAML, and with INPUTS. This assumes that SOURCE
 provides a 'setup.ml' file as its build system."
   (define builder
-    `(begin
-       (use-modules ,@modules)
-       (ocaml-build #:source ,(match (assoc-ref inputs "source")
-                                (((? derivation? source))
-                                 (derivation->output-path source))
-                                ((source)
-                                 source)
-                                (source
-                                 source))
-                    #:system ,system
-                    #:outputs %outputs
-                    #:inputs %build-inputs
-                    #:search-paths ',(map search-path-specification->sexp
-                                          search-paths)
-                    #:phases ,phases
-                    #:configure-flags ,configure-flags
-                    #:test-flags ,test-flags
-                    #:make-flags ,make-flags
-                    #:build-flags ,build-flags
-                    #:out-of-source? ,out-of-source?
-                    #:use-make? ,use-make?
-                    #:tests? ,tests?
-                    #:test-target ,test-target
-                    #:install-target ,install-target
-                    #:validate-runpath? ,validate-runpath?
-                    #:patch-shebangs? ,patch-shebangs?
-                    #:strip-binaries? ,strip-binaries?
-                    #:strip-flags ,strip-flags
-                    #:strip-directories ,strip-directories)))
-
-  (define guile-for-build
-    (match guile
-      ((? package?)
-       (package-derivation store guile system #:graft? #f))
-      (#f                                         ; the default
-       (let* ((distro (resolve-interface '(gnu packages commencement)))
-              (guile  (module-ref distro 'guile-final)))
-         (package-derivation store guile system #:graft? #f)))))
-
-  (build-expression->derivation store name builder
-                                #:system system
-                                #:inputs inputs
-                                #:modules imported-modules
-                                #:outputs outputs
-                                #:guile-for-build guile-for-build))
+    (with-imported-modules imported-modules
+      #~(begin
+          (use-modules #$@modules)
+          (ocaml-build #:source #$source
+                       #:system #$system
+                       #:outputs (list #$@(map (lambda (name)
+                                                 #~(cons #$name
+                                                         (ungexp output name)))
+                                               outputs))
+                       #:inputs (map (lambda (tuple)
+                                       (apply cons tuple))
+                                     '#$inputs)
+                       #:search-paths '#$(map search-path-specification->sexp
+                                              search-paths)
+                       #:phases #$phases
+                       #:configure-flags #$configure-flags
+                       #:test-flags #$test-flags
+                       #:make-flags #$make-flags
+                       #:build-flags #$build-flags
+                       #:out-of-source? #$out-of-source?
+                       #:use-make? #$use-make?
+                       #:tests? #$tests?
+                       #:test-target #$test-target
+                       #:install-target #$install-target
+                       #:validate-runpath? #$validate-runpath?
+                       #:patch-shebangs? #$patch-shebangs?
+                       #:strip-binaries? #$strip-binaries?
+                       #:strip-flags #$strip-flags
+                       #:strip-directories #$strip-directories))))
+
+  (gexp->derivation name builder
+                    #:system system
+                    #:target #f
+                    #:guile-for-build guile))
 
 (define ocaml-build-system
   (build-system
diff --git a/guix/build-system/scons.scm b/guix/build-system/scons.scm
index aad455c..7e4a540 100644
--- a/guix/build-system/scons.scm
+++ b/guix/build-system/scons.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net>
+;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -19,7 +20,8 @@
 (define-module (guix build-system scons)
   #:use-module (guix utils)
   #:use-module (guix packages)
-  #:use-module (guix derivations)
+  #:use-module (guix monads)
+  #:use-module (guix gexp)
   #:use-module (guix search-paths)
   #:use-module (guix build-system)
   #:use-module (guix build-system gnu)
@@ -72,8 +74,9 @@
          (build scons-build)
          (arguments (strip-keyword-arguments private-keywords arguments)))))
 
-(define* (scons-build store name inputs
+(define* (scons-build name inputs
                       #:key
+                      (source #f)
                       (tests? #t)
                       (scons-flags ''())
                       (build-targets ''())
@@ -91,43 +94,33 @@
   "Build SOURCE using SCons, and with INPUTS.  This assumes that SOURCE
 provides a 'SConstruct' file as its build system."
   (define builder
-    `(begin
-       (use-modules ,@modules)
-       (scons-build #:name ,name
-                    #:source ,(match (assoc-ref inputs "source")
-                                (((? derivation? source))
-                                 (derivation->output-path source))
-                                ((source)
-                                 source)
-                                (source
-                                 source))
-                    #:scons-flags ,scons-flags
-                    #:system ,system
-                    #:build-targets ,build-targets
-                    #:test-target ,test-target
-                    #:tests? ,tests?
-                    #:install-targets ,install-targets
-                    #:phases ,phases
-                    #:outputs %outputs
-                    #:search-paths ',(map search-path-specification->sexp
-                                          search-paths)
-                    #:inputs %build-inputs)))
+    (with-imported-modules imported-modules
+      #~(begin
+          (use-modules #$@modules)
 
-  (define guile-for-build
-    (match guile
-      ((? package?)
-       (package-derivation store guile system #:graft? #f))
-      (#f                                         ; the default
-       (let* ((distro (resolve-interface '(gnu packages commencement)))
-              (guile  (module-ref distro 'guile-final)))
-         (package-derivation store guile system #:graft? #f)))))
+          (scons-build #:name ,name
+                       #:source #+source
+                       #:scons-flags #$scons-flags
+                       #:system #$system
+                       #:build-targets #$build-targets
+                       #:test-target #$test-target
+                       #:tests? #$tests?
+                       #:install-targets #$install-targets
+                       #:phases #$phases
+                       #:outputs (list #$@(map (lambda (name)
+                                                 #~(cons #$name
+                                                         (ungexp output name)))
+                                               outputs))
+                       #:inputs (map (lambda (tuple)
+                                       (apply cons tuple))
+                                     '#$inputs)
+                       #:search-paths '#$(map search-path-specification->sexp
+                                              search-paths)))))
 
-  (build-expression->derivation store name builder
-                                #:inputs inputs
-                                #:system system
-                                #:modules imported-modules
-                                #:outputs outputs
-                                #:guile-for-build guile-for-build))
+  (gexp->derivation name builder
+                    #:system system
+                    #:target #f
+                    #:guile-for-build guile))
 
 (define scons-build-system
   (build-system
diff --git a/guix/build-system/texlive.scm b/guix/build-system/texlive.scm
index a854575..1c2f7e6 100644
--- a/guix/build-system/texlive.scm
+++ b/guix/build-system/texlive.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -20,7 +21,8 @@
   #:use-module (guix store)
   #:use-module (guix utils)
   #:use-module (guix packages)
-  #:use-module (guix derivations)
+  #:use-module (guix monads)
+  #:use-module (guix gexp)
   #:use-module (guix search-paths)
   #:use-module (guix build-system)
   #:use-module (guix build-system gnu)
@@ -120,8 +122,9 @@ level package ID."
     (build texlive-build)
     (arguments (strip-keyword-arguments private-keywords arguments))))
 
-(define* (texlive-build store name inputs
+(define* (texlive-build name inputs
                         #:key
+                        source
                         (tests? #f)
                         tex-directory
                         (build-targets #f)
@@ -139,43 +142,31 @@ level package ID."
                                    (guix build utils))))
   "Build SOURCE with INPUTS."
   (define builder
-    `(begin
-       (use-modules ,@modules)
-       (texlive-build #:name ,name
-                      #:source ,(match (assoc-ref inputs "source")
-                                       (((? derivation? source))
-                                        (derivation->output-path source))
-                                       ((source)
-                                        source)
-                                       (source
-                                        source))
-                      #:tex-directory ,tex-directory
-                      #:build-targets ,build-targets
-                      #:tex-format ,tex-format
-                      #:system ,system
-                      #:tests? ,tests?
-                      #:phases ,phases
-                      #:outputs %outputs
-                      #:search-paths ',(map search-path-specification->sexp
-                                            search-paths)
-                      #:inputs %build-inputs)))
-
-  (define guile-for-build
-    (match guile
-      ((? package?)
-       (package-derivation store guile system #:graft? #f))
-      (#f                               ; the default
-       (let* ((distro (resolve-interface '(gnu packages commencement)))
-              (guile  (module-ref distro 'guile-final)))
-         (package-derivation store guile system #:graft? #f)))))
-
-  (build-expression->derivation store name builder
-                                #:inputs inputs
-                                #:system system
-                                #:modules imported-modules
-                                #:outputs outputs
-                                #:guile-for-build guile-for-build
-                                #:substitutable? substitutable?))
+    (with-imported-modules imported-modules
+      #~(begin
+          (use-modules #$@modules)
+          (texlive-build #:name ,name
+                         #:source #+source
+                         #:tex-directory #$tex-directory
+                         #:build-targets #$build-targets
+                         #:tex-format #$tex-format
+                         #:system #$system
+                         #:tests? #$tests?
+                         #:phases #$phases
+                         #:outputs (list #$@(map (lambda (name)
+                                                   #~(cons #$name
+                                                           (ungexp output 
name)))
+                                                 outputs))
+                         #:inputs (map (lambda (tuple)
+                                         (apply cons tuple))
+                                       '#$inputs)
+                         #:search-paths '#$(map search-path-specification->sexp
+                                                search-paths)))))
+
+  (gexp->derivation name builder
+                    #:system system
+                    #:target #f
+                    #:substitutable? substitutable?))
 
 (define texlive-build-system
   (build-system



reply via email to

[Prev in Thread] Current Thread [Next in Thread]