Subject: bug#74425: closed (Re: [bug#74633] [PATCH v4] ui: Search channels for guix extensions)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 08 Mar 2025 16:40:03 +0000

Your bug report

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

which was filed against the guix-patches package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
74633: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=74633
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: [bug#74633] [PATCH v4] ui: Search channels for guix extensions
From: Ludovic Courtès <[email-masked]>
To: Brian Kubisiak <[email-masked]>
Cc: [email-masked]
Date: Sat, 08 Mar 2025 17:39:03 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi Brian,

Brian Kubisiak <[email-masked]> skribis:

> * guix/describe.scm (append-channels-to-load-path!): New function.
> * gnu/packages.scm (%package-module-path): Call new function. Remove
> the code that the function call replaces.
> * guix/ui.scm (extension-directories): Call new function. Search
> channels for guix extensions.
> * guix/self.scm (compiled-guix)[*core-modules*]: Add 'guile-git' to
> the list of extensions.
>
> Change-Id: I53af828dc554485ca28389c9e2653ea6b4fb6b7e

Finally applied, with the cosmetic changes below.

Thanks!

Ludo’.

diff --git a/guix/ui.scm b/guix/ui.scm
index 3cc15b05fc..d462f7133e 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -2197,11 +2197,12 @@ (define (extension-directories)
   ;; We need to resolve these lazily, because even using an #:autoload is too
   ;; much and breaks compilation during "guix pull".
   (define append-channels-to-load-path!
-    (module-ref (resolve-module `(guix describe))
-                (symbol-append 'append-channels-to-load-path!)))
+    (module-ref (resolve-interface '(guix describe))
+                'append-channels-to-load-path!))
   (define package-path-entries
-    (module-ref (resolve-module `(guix describe))
-                (symbol-append 'package-path-entries)))
+    (module-ref (resolve-interface '(guix describe))
+                'package-path-entries))
+
   (append-channels-to-load-path!)
   (let ((channels (package-path-entries)))
     (filter file-exists?

Subject: [PATCH] ui: Include channels in load path before searching for commands.
From: Carlo Zancanaro <[email-masked]>
To: [email-masked]
Cc: Ludovic Courtès <[email-masked]>
Date: Tue, 19 Nov 2024 09:26:37 +1100
List-Id: <debbugs-submit.debbugs.gnu.org>

* 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
---

This patch allows extensions in channels to be found by the Guix
CLI. Most notably, this means that a script can define commands by
defining an appropriate (guix scripts X) module, with a guix-X
function.

This is a slight modification to a diff that Ludovic sent through IRC.

I've tested that it works when I use "guix time-machine". Guix is able
to find a command that I define in a channel.

I haven't specifically tested that it finds commands when run through
"guix pull", but I have tested that this change does not break "guix
pull".

 guix/ui.scm | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/guix/ui.scm b/guix/ui.scm
index 447550635c..a702b6f3f8 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -19,6 +19,7 @@
 ;;; Copyright © 2018 Steve Sprang <[email-masked]>
 ;;; Copyright © 2022 Taiju HIGASHI <[email-masked]>
 ;;; Copyright © 2022 Liliana Marie Prikler <[email-masked]>
+;;; Copyright © 2024 Carlo Zancanaro <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -73,6 +74,7 @@ (define-module (guix ui)                       ;import in user interfaces only
   #:use-module (srfi srfi-31)
   #:use-module (srfi srfi-34)
   #:use-module (srfi srfi-35)
+  #:use-module (srfi srfi-71)
   #:autoload   (ice-9 ftw)  (scandir)
   #:use-module (ice-9 match)
   #:use-module (ice-9 format)
@@ -2192,9 +2194,16 @@ (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"))))
+  (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))))
 
 (define (commands)
   "Return the list of commands, alphabetically sorted."

base-commit: 23cbbe6860782c5d4a0ba599ea1cda0642e91661
-- 
2.46.0