Subject: [PATCH 1/4] gnu: import: Fix memoization in crate-recursive-import.

From: David Elsing <[email-masked]>
Date: Thu, 21 Dec 2023 22:01:49 +0000

* guix/import/crate.scm (crate-recursive-import): Apply memoize outside the
lambda passed to recursive-import in order to actually use the memoization.
---
 guix/import/crate.scm | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index 43823d006e..07874bdb26 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -6,6 +6,7 @@
 ;;; Copyright © 2022 Hartmut Goebel <[email-masked]>
 ;;; Copyright © 2023 Simon Tournier <[email-masked]>
 ;;; Copyright © 2023 Efraim Flashner <[email-masked]>
+;;; Copyright © 2023 David Elsing <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -328,15 +329,17 @@ (define (sort-map-dependencies deps)
       (values #f '())))
 
 (define* (crate-recursive-import crate-name #:key version)
-  (recursive-import crate-name
-                    #:repo->guix-package (lambda* params
-                      ;; download development dependencies only for the top level package
-                      (let ((include-dev-deps? (equal? (car params) crate-name))
-                            (crate->guix-package* (memoize crate->guix-package)))
-                        (apply crate->guix-package*
-                               (append params `(#:include-dev-deps? ,include-dev-deps?)))))
-                    #:version version
-                    #:guix-name crate-name->package-name))
+  (recursive-import
+   crate-name
+   #:repo->guix-package
+   (let ((crate->guix-package* (memoize crate->guix-package)))
+     (lambda* params
+       ;; download development dependencies only for the top level package
+       (let ((include-dev-deps? (equal? (car params) crate-name)))
+         (apply crate->guix-package*
+                (append params `(#:include-dev-deps? ,include-dev-deps?))))))
+   #:version version
+   #:guix-name crate-name->package-name))
 
 (define (guix-package->crate-name package)
   "Return the crate name of PACKAGE."
-- 
2.41.0