all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: antlers via Guix-patches via <guix-patches@gnu.org>
To: 68163@debbugs.gnu.org
Cc: antlers <antlers@illucid.net>,
	guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org,
	othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com,
	me@tobias.gr
Subject: [bug#68163] [PATCH] gnu: Prevent stale cache use when `%package-module-path' is parameterized.
Date: Sun, 31 Dec 2023 06:06:21 +0000	[thread overview]
Message-ID: <b2aaf81a7ae81d47ff5091cb4012764124c6f61c.1704002781.git.antlers@illucid.net> (raw)

* 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





             reply	other threads:[~2023-12-31  6:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-31  6:06 antlers via Guix-patches via [this message]
2024-01-08 17:06 ` [bug#68163] [PATCH] gnu: Prevent stale cache use when `%package-module-path' is parameterized 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b2aaf81a7ae81d47ff5091cb4012764124c6f61c.1704002781.git.antlers@illucid.net \
    --to=guix-patches@gnu.org \
    --cc=68163@debbugs.gnu.org \
    --cc=antlers@illucid.net \
    --cc=dev@jpoiret.xyz \
    --cc=guix@cbaines.net \
    --cc=ludo@gnu.org \
    --cc=me@tobias.gr \
    --cc=othacehe@gnu.org \
    --cc=rekado@elephly.net \
    --cc=zimon.toutoune@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.