[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#74633] [PATCH] ui: Search channels for guix extensions
From: |
Carlo Zancanaro |
Subject: |
[bug#74633] [PATCH] ui: Search channels for guix extensions |
Date: |
Tue, 03 Dec 2024 22:29:46 +1100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Hi Brian!
As Ludo mentioned, I've recently sent a patch to solve the same problem,
but mine is a bit different. I think your change is better in most ways
to mine, but I'll comment on some things inline below.
On Sun, Dec 01 2024, Brian Kubisiak wrote:
> diff --git a/gnu/packages.scm b/gnu/packages.scm
> index 80c22d1d7f..05b8bf8e6d 100644
> --- a/gnu/packages.scm
> +++ b/gnu/packages.scm
> @@ -147,15 +147,16 @@ (define %package-module-path
> (let* ((not-colon (char-set-complement (char-set #\:)))
> (environment (string-tokenize (or (getenv "GUIX_PACKAGE_PATH") "")
> not-colon))
> - (channels-scm channels-go (package-path-entries)))
> + (channels-scm (package-path-entries)))
> ;; Automatically add channels and items from $GUIX_PACKAGE_PATH to
> Guile's
> ;; search path. For historical reasons, $GUIX_PACKAGE_PATH goes to the
> ;; front; channels go to the back so that they don't override Guix' own
> ;; modules.
This comment should be moved onto add-channels-to-load-path!. Possibly
even as a docstring.
> diff --git a/guix/describe.scm b/guix/describe.scm
> index a4ca2462f4..3bbda15db5 100644
> --- a/guix/describe.scm
> +++ b/guix/describe.scm
> @@ -190,6 +192,17 @@ (define (package-path-entries)
> "/site-ccache")))
> (current-channel-entries))))
>
> +(define add-channels-to-load-path!
> + (let ((promise
> + (delay
> + (let-values (((channels-scm channels-go) (package-path-entries)))
> + (set! %load-path
> + (append %load-path channels-scm))
> + (set! %load-compiled-path
> + (append %load-compiled-path channels-go))))))
> + (lambda ()
> + (force promise))))
I like that this is avoiding adding things to the path multiple times
(which is a problem with my proposed change).
> diff --git a/guix/self.scm b/guix/self.scm
> index 2652688c71..28239d53f5 100644
> --- a/guix/self.scm
> +++ b/guix/self.scm
> @@ -882,6 +882,7 @@ (define* (compiled-guix source #:key
> ,(local-file "../guix/store/schema.sql")))
>
> #:extensions (list guile-gcrypt
> + guile-git ;for (guix git)
I don't know enough to know if this is a problem, but it's a shame to
have to add this, given I don't think this change actually ends up using
any git functionality.
I solved the same issue by lazily resolving the (guix describe) module.
Using an autoload wasn't enough (i.e. it still broke "guix pull"), but
using (@ (guix describe) package-path-entries) worked.
> diff --git a/guix/ui.scm b/guix/ui.scm
> index eba12c8616..28690b22bc 100644
> --- a/guix/ui.scm
> +++ b/guix/ui.scm
> @@ -2192,9 +2193,15 @@ (define* (command-files #:optional directory)
>
> (define (extension-directories)
> "Return the list of directories containing Guix extensions."
> - (filter file-exists?
> - (parse-path
> - (getenv "GUIX_EXTENSIONS_PATH"))))
> + (add-channels-to-load-path!)
> + (let ((channels (package-path-entries)))
> + (filter file-exists?
> + (append
> + (parse-path
> + (getenv "GUIX_EXTENSIONS_PATH"))
> + (map
> + (cut string-append <> "/guix/extensions")
> + channels)))))
I don't think you need the (append ...). According to the manual,
parse-path takes another argument as a "tail" for the resulting list, so
(parse-path (getenv "GUIX_EXTENSIONS_PATH") (map ... channels)) should
be enough here.
Am I right in thinking that this will look inside the channels at
/guix/extensions to try to find things? That is, if I wanted to add a
command "guix foo" I would need to define a module in
$channel_dir/guix/extensions/guix/scripts/foo.scm?
If I'm reading that correctly, this feels unnecessary. Channels can
already specify a directory in their .guix-channel file. In my change it
just looks for $channel_dir/guix/scripts/foo.scm, which seems more
straightforward. (I'm not worried about people accidentally defining
something /guix/scripts/, because the name is pretty obvious.)
All together, I'm proposing simplifying things to:
--8<---------------cut here---------------start------------->8---
(define (extension-directories)
"Return the list of directories containing Guix extensions."
(add-channels-to-load-path!)
(let ((channels (package-path-entries)))
(filter file-exists?
(parse-path (getenv "GUIX_EXTENSIONS_PATH") channels))))
--8<---------------cut here---------------end--------------->8---
We may also want to something into the docstring to mention that it adds
to %load-path.
Carlo