guix_mirror_bot pushed a commit to branch ocaml-team
in repository guix.

commit bc81fa332547918c6547423b711a75c01795a98d
Author: Jason Conroy <[email protected]>
AuthorDate: Sat Nov 29 09:03:00 2025 -0500

    guix: dune-build-system: Define `lower` in terms of a higher-order function.
    
    * guix/build-system/dune.scm:
    (make-lower): New variable.
    (lower): Define in terms of `make-lower`.
    
    Change-Id: I33586023237e7a7a852196c6ec7607aa5f3c00b6
    Signed-off-by: Julien Lepiller <[email protected]>
---
 guix/build-system/dune.scm | 82 +++++++++++++++++++++++++---------------------
 1 file changed, 44 insertions(+), 38 deletions(-)

diff --git a/guix/build-system/dune.scm b/guix/build-system/dune.scm
index f172f0b9cb..8bd72c242c 100644
--- a/guix/build-system/dune.scm
+++ b/guix/build-system/dune.scm
@@ -45,47 +45,49 @@
   `((guix build dune-build-system)
     ,@ocaml:%ocaml-build-system-modules))
 
-(define* (lower name
-                #:key source inputs native-inputs outputs system target
-                (dune (ocaml:default-dune))
-                (ocaml (ocaml:default-ocaml))
-                (findlib (ocaml:default-findlib))
-                #:allow-other-keys
-                #:rest arguments)
-  "Return a bag for NAME."
+(define (make-lower default-ocaml default-findlib default-dune)
+  (lambda* (name
+            #:key source inputs native-inputs outputs system target
+            (dune (default-dune))
+            (ocaml (default-ocaml))
+            (findlib (default-findlib))
+            #:allow-other-keys
+            #:rest arguments)
+    "Return a bag for NAME."
 
-  ;; Flags that put dune into reproducible build mode.
-  (define dune-release-flags
-    (if (version>=? (package-version dune) "2.5.0")
-        ;; For dune >= 2.5.0 this is just --release.
-        ''("--release")
-        ;; --release does not exist before 2.5.0.  Replace with flags 
compatible
-        ;; with our old ocaml4.07-dune (1.11.3)
-        ''("--root" "." "--ignore-promoted-rules" "--no-config"
-           "--profile" "release")))
+    ;; Flags that put dune into reproducible build mode.
+    (define dune-release-flags
+      (if (version>=? (package-version dune) "2.5.0")
+          ;; For dune >= 2.5.0 this is just --release.
+          ''("--release")
+          ;; --release does not exist before 2.5.0.  Replace with flags 
compatible
+          ;; with our old ocaml4.07-dune (1.11.3)
+          ''("--root" "." "--ignore-promoted-rules" "--no-config"
+             "--profile" "release")))
 
-  (define private-keywords
-    '(#:target #:dune #:findlib #:ocaml #:inputs #:native-inputs))
+    (define private-keywords
+      '(#:target #:dune #:findlib #:ocaml #:inputs #:native-inputs))
 
-  (and (not target)                               ;XXX: no cross-compilation
-       (let ((base (ocaml:lower name
-                                #:source source
-                                #:inputs inputs
-                                #:native-inputs native-inputs
-                                #:outputs outputs
-                                #:system system
-                                #:target target
-                                #:ocaml ocaml
-                                #:findlib findlib
-                                arguments)))
-         (bag
-           (inherit base)
-           (build-inputs `(("dune" ,dune)
-                           ,@(bag-build-inputs base)))
-           (build dune-build)
-           (arguments (append
-                       `(#:dune-release-flags ,dune-release-flags)
-                       (strip-keyword-arguments private-keywords 
arguments)))))))
+    (and (not target)                   ;XXX: no cross-compilation
+         (let ((base (ocaml:lower
+                      name
+                      #:source source
+                      #:inputs inputs
+                      #:native-inputs native-inputs
+                      #:outputs outputs
+                      #:system system
+                      #:target target
+                      #:ocaml ocaml
+                      #:findlib findlib
+                      arguments)))
+           (bag
+             (inherit base)
+             (build-inputs `(("dune" ,dune)
+                             ,@(bag-build-inputs base)))
+             (build dune-build)
+             (arguments (append
+                         `(#:dune-release-flags ,dune-release-flags)
+                         (strip-keyword-arguments private-keywords 
arguments))))))))
 
 (define* (dune-build name inputs
                      #:key
@@ -151,6 +153,10 @@ provides a 'setup.ml' file as its build system."
                     #:graft? #f
                     #:guile-for-build guile))
 
+(define lower (make-lower ocaml:default-ocaml
+                          ocaml:default-findlib
+                          ocaml:default-dune))
+
 (define dune-build-system
   (build-system
     (name 'dune)

Reply via email to