From patchwork Mon Nov 18 22:26:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Carlo Zancanaro X-Patchwork-Id: 70510 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 700A327BBE9; Mon, 18 Nov 2024 22:32:30 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id EBAB427BBE2 for ; Mon, 18 Nov 2024 22:32:27 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tDAHw-0000F3-9S; Mon, 18 Nov 2024 17:32:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tDAHt-0000DD-NG for guix-patches@gnu.org; Mon, 18 Nov 2024 17:32:06 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tDAHs-0000qV-2s; Mon, 18 Nov 2024 17:32:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=Vhrp4Krewb2kkOi42o0mrt2OOUKtcqejlGmj7U1iq1o=; b=TSPvSKntlifCXLCT7X6GMkLwI8EvuCjBXB/7nCf7uVRfB5TGMs5Ji15Zf6pl0zaip2OP3ZKPB/P+R7fyXOseik2kGAIotiACe3NcIr5i3g6jGydqXe7byeKsf8SySyg/LuW/6q2Yesa04jWaS3NalQiZx9rkr21B+H5FVPIBNDThnTNFLqlO/7Ep6ljh50cKM35V5kmV5/3WnqWitiismWW6VH1mmeW7URRRd1tiT7XA+przWLYwxaafMuhfgB0GhHs1WXGclVQQZUBaw53bOHmAIheDLD7KxcVthRJdnYQ9ZYW12113QEz5hCRwCr0oJrJLOFZ02y0J0kq4HHOPRQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tDAHq-0006ZQ-JU; Mon, 18 Nov 2024 17:32:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#74425] [PATCH] ui: Include channels in load path before searching for commands. Resent-From: Carlo Zancanaro Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Mon, 18 Nov 2024 22:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 74425 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74425@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by submit@debbugs.gnu.org id=B.173196911225233 (code B ref -1); Mon, 18 Nov 2024 22:32:02 +0000 Received: (at submit) by debbugs.gnu.org; 18 Nov 2024 22:31:52 +0000 Received: from localhost ([127.0.0.1]:39521 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tDAHf-0006Yv-FN for submit@debbugs.gnu.org; Mon, 18 Nov 2024 17:31:51 -0500 Received: from lists.gnu.org ([209.51.188.17]:59936) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tDAHd-0006Yk-2O for submit@debbugs.gnu.org; Mon, 18 Nov 2024 17:31:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tDAHY-0000Bh-Lh for guix-patches@gnu.org; Mon, 18 Nov 2024 17:31:46 -0500 Received: from voltorb.zancanaro.id.au ([45.77.50.64]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tDAHV-0000oD-JW; Mon, 18 Nov 2024 17:31:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=k1; bh=Vhrp4Krewb2kkOi 42o0mrt2OOUKtcqejlGmj7U1iq1o=; h=date:subject:cc:to:from; d=zancanaro.id.au; b=GWwEdzRzOdFvMTwCJVSXDk1HATODB6IW9sILlx2OubQXdoUpr zaDAm5osVECqngy357w1DXE7NUk67kNLWNZq3OvIQRKvIBsJ2OMdz1T94oI5piB9DCdjkT e/6IMqrAK85PXiViivunrdjj+k9COZSJiy11ZInO6cm7+dOTCWpk= Received: by voltorb.zancanaro.id.au (OpenSMTPD) with ESMTPSA id bf58f6aa (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 18 Nov 2024 22:30:49 +0000 (UTC) From: Carlo Zancanaro Date: Tue, 19 Nov 2024 09:26:37 +1100 Message-ID: X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Received-SPF: pass client-ip=45.77.50.64; envelope-from=carlo@zancanaro.id.au; helo=voltorb.zancanaro.id.au X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * 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 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(-) base-commit: 23cbbe6860782c5d4a0ba599ea1cda0642e91661 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 ;;; Copyright © 2022 Taiju HIGASHI ;;; Copyright © 2022 Liliana Marie Prikler +;;; Copyright © 2024 Carlo Zancanaro ;;; ;;; 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."