all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#68163] [PATCH] gnu: Prevent stale cache use when `%package-module-path' is parameterized.
@ 2023-12-31  6:06 antlers via Guix-patches via
  2024-01-08 17:06 ` Ludovic Courtès
  2024-01-11 18:24 ` Simon Tournier
  0 siblings, 2 replies; 8+ messages in thread
From: antlers via Guix-patches via @ 2023-12-31  6:06 UTC (permalink / raw)
  To: 68163; +Cc: antlers, guix, dev, ludo, othacehe, rekado, zimon.toutoune, me

* gnu/packages.scm(find-package-by-name/direct): Convert `delay'-ed cache
construction in closure into a form memoized over `%package-module-path'.

Change-Id: I6e4b4b3fa58082b79aacf307468aec43ec60bf22
---
This enables `specification->package' to be parameterized to resolve packages
from within the module-under-compilation.

I use this to parse my init.el[0] into packages in my guix-home profile, all
in one repo.

 gnu/packages.scm | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/gnu/packages.scm b/gnu/packages.scm
index 80c22d1d7f..b0cc2f7427 100644
--- a/gnu/packages.scm
+++ b/gnu/packages.scm
@@ -281,18 +281,21 @@ (define load-package-cache
                #f
                (apply throw args))))))))
 
-(define find-packages-by-name/direct              ;bypass the cache
-  (let ((packages (delay
-                    (fold-packages (lambda (p r)
-                                     (vhash-cons (package-name p) p r))
-                                   vlist-null)))
+(define find-packages-by-name/direct
+  ;; Bypass pre-built cache, but still memoize over `(%package-module-path)'
+  (let ((packages (lambda ()
+                    ((mlambda (_%package-module-path)
+                       (fold-packages (lambda (p r)
+                                        (vhash-cons (package-name p) p r))
+                                      vlist-null))
+                     (%package-module-path))))
         (version>? (lambda (p1 p2)
                      (version>? (package-version p1) (package-version p2)))))
     (lambda* (name #:optional version)
       "Return the list of packages with the given NAME.  If VERSION is not #f,
 then only return packages whose version is prefixed by VERSION, sorted in
 decreasing version order."
-      (let ((matching (sort (vhash-fold* cons '() name (force packages))
+      (let ((matching (sort (vhash-fold* cons '() name (packages))
                             version>?)))
         (if version
             (filter (lambda (package)

base-commit: 2a242e86379ebddbdddf2927f26e5e27a98fc605
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-01-17  8:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-31  6:06 [bug#68163] [PATCH] gnu: Prevent stale cache use when `%package-module-path' is parameterized antlers via Guix-patches via
2024-01-08 17:06 ` Ludovic Courtès
2024-01-08 23:04   ` antlers via Guix-patches via
2024-01-08 23:56     ` antlers via Guix-patches via
2024-01-11 18:24 ` Simon Tournier
2024-01-13  0:23   ` antlers via Guix-patches via
2024-01-13  4:41     ` antlers via Guix-patches via
2024-01-17  8:32       ` antlers via Guix-patches via

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.