From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id 0DedI9vrTmcMeAEAe85BDQ:P1 (envelope-from ) for ; Tue, 03 Dec 2024 11:30:35 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id 0DedI9vrTmcMeAEAe85BDQ (envelope-from ) for ; Tue, 03 Dec 2024 12:30:35 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=kds5uj8A; dkim=fail ("headers rsa verify failed") header.d=zancanaro.id.au header.s=k1 header.b=nSFbjENG; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=zancanaro.id.au (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1733225435; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=wThLffGQysgTKYtoJD5NB+dPBNaE9aWpUVHJlIcSxCE=; b=j8RrrJTP2Mah+nY7gLWHGz68Gbm7Lqlyz7aDPl9KCcLdMkxHIsJHeSVk8aqz1R2XkaD7kV xdkEhyC+AOm//bmeiX6sULlYYzEFk8EAAT3snVue5y0IFfXqJfaiNr+j5HZ2EBPbH2a5gR FlNWHWVl/J02fMzpVAx0COOQnquG+2cuv+bVre0PdfEEJ9O1pXdMVe50FPAfUOrgTFZWYb MO/KUc7avtphQ2bZXKZg/pJDBiZE0SXKsm5TVpgLhDrh3hle0j70aqpTwukNkE+QWrybzH 8DWGjWYdGL5E44cj1nXGwFZBBjCzmxF8jPtLI1u/RHZlHUJohWkxubVLLyeEww== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=kds5uj8A; dkim=fail ("headers rsa verify failed") header.d=zancanaro.id.au header.s=k1 header.b=nSFbjENG; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=zancanaro.id.au (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1733225435; a=rsa-sha256; cv=none; b=Za1Cq1bNXuf5FEyW2tT57T7y2FjT/uMyx+gBaxlONRUfQoZvad3vVf+YPscSTTKVKHZgrY cuK1M6P1oFVNWohKv2qhaRTlCCcQoN9UTq+npdSyLHWcyT4nEdTBuiZ9/MVtaSq6CXq6o8 Vx+NCc30GJN0iOgSExVONRe6ULa2jE0ffCwocWQyknGDkPdG2OlR+07vZFGQEw8mWgs+2Q zXh7qrqwcBpfga5bgNxtso4kMY8+fEz2236HYFmLLUg4LpWhECnsz+rcZsbpKuAfmPRkM7 tzwtacbU6p/koN6CJxx8yX/fQvS0fsF9vQUi66a4vrO5T9Xh3lKeVbjzLB427g== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 5D0157F17F for ; Tue, 03 Dec 2024 12:30:35 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIR6V-0008GC-A0; Tue, 03 Dec 2024 06:30:07 -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 1tIR6R-0008E4-OP for guix-patches@gnu.org; Tue, 03 Dec 2024 06:30:04 -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 1tIR6R-0000HR-Bn for guix-patches@gnu.org; Tue, 03 Dec 2024 06:30:03 -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:References:In-Reply-To:From:To:Subject; bh=wThLffGQysgTKYtoJD5NB+dPBNaE9aWpUVHJlIcSxCE=; b=kds5uj8AWo8CfcdSKdYB+ZC9xMUMgzWX3PUFs4IWSPoMrOk+7pT7ThlBkcgIXxBXJ+P03l/Hl9UBBvD9zZGK1v+iUbC+MV4rSMmYayZsLC0Gk2Oc30ZWQjStRWQZ0xVTGFieO1QL41tdNHyIGo3AQDigVOltdLMCToe9Idcd4PbeS3TAR1YRCyEUCN+1oE/QuVoBqKvQHf3Io/kWIaRQStlxvURbNbKqhEDrT+/WnRLyIh6OZOewem11evKUXv7w6ufu9a8uJ4uivFBQdfKeDVP8dxls1vBzYJIFxz4KixzyggqUkcQj5L48kY71nj1q/aTsQQqwHjWPV+q3rXN7MQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tIR6Q-0000Zj-Ta for guix-patches@gnu.org; Tue, 03 Dec 2024 06:30:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#74633] [PATCH] ui: Search channels for guix extensions Resent-From: Carlo Zancanaro Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 03 Dec 2024 11:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74633 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Brian Kubisiak Cc: 74633@debbugs.gnu.org Received: via spool by 74633-submit@debbugs.gnu.org id=B74633.17332254002172 (code B ref 74633); Tue, 03 Dec 2024 11:30:02 +0000 Received: (at 74633) by debbugs.gnu.org; 3 Dec 2024 11:30:00 +0000 Received: from localhost ([127.0.0.1]:58447 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tIR6N-0000Yy-9g for submit@debbugs.gnu.org; Tue, 03 Dec 2024 06:29:59 -0500 Received: from voltorb.zancanaro.id.au ([45.77.50.64]:54190) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tIR6K-0000Ye-Nx for 74633@debbugs.gnu.org; Tue, 03 Dec 2024 06:29:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=k1; bh=wThLffGQysgTKYt oJD5NB+dPBNaE9aWpUVHJlIcSxCE=; h=date:references:in-reply-to:subject: cc:to:from; d=zancanaro.id.au; b=nSFbjENGtTcwsYn+Bna0iS7i0ftTc9BYOYUCM qL1ku7P4/+JB6pRtlSzU/NfXAFT00U1J2CBPM846vadO4/gaH45aJ/cbpzftg+qZuoHN4r 8SUmCfrotIfRgySLGq2BrkgC/wUMIGofO9s95FD2Q7RAx7HOrEkeX+qBq7VChPsk= Received: by voltorb.zancanaro.id.au (OpenSMTPD) with ESMTPSA id 8d4ae4dc (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 3 Dec 2024 11:29:06 +0000 (UTC) From: Carlo Zancanaro In-Reply-To: <2fc5afe876af28643f8074dd1623640cb314cc5e.1733064752.git.brian@kubisiak.com> (Brian Kubisiak's message of "Sun, 1 Dec 2024 06:53:03 -0800") References: <2fc5afe876af28643f8074dd1623640cb314cc5e.1733064752.git.brian@kubisiak.com> Date: Tue, 03 Dec 2024 22:29:46 +1100 Message-ID: <87mshdknrp.fsf@zancanaro.id.au> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain 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+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Scanner: mx11.migadu.com X-Migadu-Spam-Score: -0.72 X-Spam-Score: -0.72 X-Migadu-Queue-Id: 5D0157F17F X-TUID: iQIWvOxjtsC/ 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