GNU bug report logs - #68163
[PATCH] gnu: Prevent stale cache use when `%package-module-path' is parameterized.

Previous Next

Package: guix-patches;

Reported by: antlers <antlers <at> illucid.net>

Date: Sun, 31 Dec 2023 06:25:02 UTC

Severity: normal

Tags: patch

Full log


Message #17 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Simon Tournier <zimon.toutoune <at> gmail.com>
To: antlers via Guix-patches via <guix-patches <at> gnu.org>, 68163 <at> debbugs.gnu.org
Cc: antlers <antlers <at> illucid.net>, dev <at> jpoiret.xyz, othacehe <at> gnu.org,
 ludo <at> gnu.org, me <at> tobias.gr, rekado <at> elephly.net, david <at> daviwil.com,
 guix <at> cbaines.net
Subject: Re: [bug#68163] [PATCH] gnu: Prevent stale cache use when
 `%package-module-path' is parameterized.
Date: Thu, 11 Jan 2024 19:24:17 +0100
Hi,

(For what it is worth, I have also read the rest of the thread. :-))

On Sun, 31 Dec 2023 at 06:06, antlers via Guix-patches via <guix-patches <at> gnu.org> wrote:

> -(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))))

I am not sure by this change.

 1. Instead, I would push to ’extract-emacs-packages’ the bits.
 2. I miss what makes your use case fails.

First, about #1.

Somehow, ’fold-packages’ accepts a list of modules as argument and it
would be the way you should go: in addition to the argument ’file-path’,
you should also pass to ’extract-emacs-packages’ another argument
capturing this locally extended %package-module-path.

Concretely, considering your example [1]: extract the list of packages
based on Emacs configuration (use-package) to then pass for “building
your home” using Guix.  From my understanding, the core reads:

--8<---------------cut here---------------start------------->8---
antlers/home/extract-emacs-packages.scm[2]:
``` scheme
(define extact-emacs-packages (file-path)
  [...]) ; this is not polished code, you don't wanna see it: just imagine
;; => (list #<package [...]> ...)
```

antlers/home.scm:
``` scheme
(simple-service 'emacs-packages home-profile-service-type
  ;; Add `(antlers packages)' to `specification->package' PATH
  (parameterize ((%package-module-path
                   (cons `(,(dirname (dirname (module-filename (current-module))))
                           . "antlers/packages")
                         (%package-module-path))))
    (append (extract-emacs-packages "./home/files/emacs/init.el")
            (extract-emacs-packages "./home/files/emacs/early-init.el"))))
```
--8<---------------cut here---------------end--------------->8---

I guess, the procedure ’extract-emacs-packages’ extracts the package
name represented as string from ’use-package’ keyword ’:guix’ and then
passes it to ’specification->package’ in order to build a list of
’<package>’ records.  Right?

If yes, I suggest to tweak that part instead of
’specification->package’.  When doing this conversion, from string to
<package>, it seems doable to:

 a) Pass a list of all modules to ’fold-packages’, i.e., get all the
 packages, included your custom ones;
 
 b) Filter based on package name (and/or other information tracked under
 use-package keyword :guix).

Somehow, do not rely on ’specification->package’ in
’extract-emacs-packages’.


Last, about #2.

What I do not understand is why is required: « This enables
`specification->package' to be parameterized to resolve packages from
within the module-under-compilation. »

When you run “guix pull”, it builds the Guix channel and all the other
custom channels, therefore all the packages should be visible from
’specification->package’.  Aren’t they?

Then, when running “guix home …”, I miss why it fails.

Other said,

 i)  Could you provide some details about the tree of your channel?

 ii) Could you explain when it fails exactly and running which Guix
     command-line?


Cheers,
simon

1: [bug#68163] [PATCH] gnu: Prevent stale cache use when `%package-module-path' is parameterized.
antlers via Guix-patches via <guix-patches <at> gnu.org>
Mon, 08 Jan 2024 23:04:41 +0000
id:21937d23-9a81-4090-979d-584f40880a51 <at> app.fastmail.com
https://issues.guix.gnu.org/68163
https://issues.guix.gnu.org/msgid/21937d23-9a81-4090-979d-584f40880a51 <at> app.fastmail.com
https://yhetil.org/guix/21937d23-9a81-4090-979d-584f40880a51 <at> app.fastmail.com




This bug report was last modified 1 year and 154 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.