unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Simon Tournier <zimon.toutoune@gmail.com>
To: 68163@debbugs.gnu.org
Cc: antlers <antlers@illucid.net>,
	dev@jpoiret.xyz, othacehe@gnu.org, ludo@gnu.org, me@tobias.gr,
	rekado@elephly.net, david@daviwil.com, guix@cbaines.net
Subject: [bug#68163] [PATCH] gnu: Prevent stale cache use when `%package-module-path' is parameterized.
Date: Thu, 11 Jan 2024 19:24:17 +0100	[thread overview]
Message-ID: <87mstbzq26.fsf@gmail.com> (raw)
In-Reply-To: <b2aaf81a7ae81d47ff5091cb4012764124c6f61c.1704002781.git.antlers@illucid.net>

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@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@gnu.org>
Mon, 08 Jan 2024 23:04:41 +0000
id:21937d23-9a81-4090-979d-584f40880a51@app.fastmail.com
https://issues.guix.gnu.org/68163
https://issues.guix.gnu.org/msgid/21937d23-9a81-4090-979d-584f40880a51@app.fastmail.com
https://yhetil.org/guix/21937d23-9a81-4090-979d-584f40880a51@app.fastmail.com




  parent reply	other threads:[~2024-01-12 12:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

  List information: https://guix.gnu.org/

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

  git send-email \
    --in-reply-to=87mstbzq26.fsf@gmail.com \
    --to=zimon.toutoune@gmail.com \
    --cc=68163@debbugs.gnu.org \
    --cc=antlers@illucid.net \
    --cc=david@daviwil.com \
    --cc=dev@jpoiret.xyz \
    --cc=guix@cbaines.net \
    --cc=ludo@gnu.org \
    --cc=me@tobias.gr \
    --cc=othacehe@gnu.org \
    --cc=rekado@elephly.net \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).