Subject: [bug#74425] [PATCH] ui: Include channels in load path before searching for commands.

From: Ludovic Courtès <[email-masked]>
Date: Thu, 21 Nov 2024 13:14:00 +0100

Hello,

Carlo Zancanaro <[email-masked]> skribis:

> * guix/ui.scm (extension-directories): Add channel directories to load path,
> compiled load path, and returned list of directories.
>
> Co-authored-by: Ludovic Courtès <[email-masked]>
> Change-Id: I3063cbf7164a065b2c6c2a5c6473df79ce8cbe9b

Nice, thanks for looking into it!

>  (define (extension-directories)
>    "Return the list of directories containing Guix extensions."
> -  (filter file-exists?
> -          (parse-path
> -           (getenv "GUIX_EXTENSIONS_PATH"))))
> +  (define package-path-entries
> +    ;; We need to resolve this lazily, because even using an #:autoload is too
> +    ;; much and breaks compilation during "guix pull".
> +    (module-ref (resolve-module `(guix describe))
> +                (symbol-append 'package-path-entries)))
> +  (let ((scm-path go-path (package-path-entries)))
> +    (set! %load-path (append %load-path scm-path))
> +    (set! %load-compiled-path (append %load-compiled-path go-path))
> +    (filter file-exists?
> +            (parse-path (getenv "GUIX_EXTENSIONS_PATH") scm-path))))

I think you could do:

  #:autoload (guix describe) (package-path-entries)

instead of doing the trick above.

Two things:

  1. The ‘%load-path’ and ‘%load-compiled-path’ modifications can now be
     removed from (gnu packages), after checking that GUIX_PACKAGE_PATH
     still takes precedence.

  2. The performance impact of this change must be tested, in particular
     the startup time of ‘guix’ commands since they’ll now be loading
     (guix channels) & co. unconditionally.

     One way to do that might be:

       PROFILE=$(guix time-machine -q --url=/path/to/checkout)
       guix shell time -- time $PROFILE/bin/guix build --help
       strace -c $PROFILE/bin/guix build --help
     
Could you give it a try?

Ludo’.