From patchwork Mon Feb 17 15:41:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Kubisiak X-Patchwork-Id: 38786 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 58E1F27BBEA; Mon, 17 Feb 2025 15:42:28 +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=ham 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 B37D727BBE2 for ; Mon, 17 Feb 2025 15:42:27 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tk3G3-0006q0-I2; Mon, 17 Feb 2025 10:42: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 1tk3Fz-0006p3-97 for guix-patches@gnu.org; Mon, 17 Feb 2025 10:42:03 -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 1tk3Fy-0004Sg-K7 for guix-patches@gnu.org; Mon, 17 Feb 2025 10:42: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:From:Date:To:In-Reply-To:References:Subject; bh=jmVSgZgAB5blRPek6fQUrYKjolt4RZjTPTPhUFENap4=; b=ENHYwKzMMWFVQybzsIAiLIHmpa3YiatPzC4f9gDOIfPoaq1xm1/pNHO9rpItFI800wVHxh7R/YrG2zjPNVru9QWMovwRM84pLFv6rlQ1QGsBM/xPHGT3hgFiKPl2dKXA/76PZVZC9ohyKonnFUgXrGKOaq6ggu7E0zv1k7TX13H7EeURyn3EXAN7OoadGXNEKPY+rYP7eIqADzfJSsHonUugHd0ETqLbBPTtc4AcPyZNzMlweTyfU6JpSOHsqECHa25qeeMRpUBU3y7yK+Bnm/SaNakD4dJ8F7Nl6tni5jFap1huJqGLBRuheBtMc3Q323je5UIhmtQgFwOZChyFKw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tk3Fy-0007Sv-5P for guix-patches@gnu.org; Mon, 17 Feb 2025 10:42:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#74633] [PATCH v4] ui: Search channels for guix extensions References: <2fc5afe876af28643f8074dd1623640cb314cc5e.1733064752.git.brian@kubisiak.com> In-Reply-To: <2fc5afe876af28643f8074dd1623640cb314cc5e.1733064752.git.brian@kubisiak.com> Resent-From: Brian Kubisiak Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 17 Feb 2025 15:42: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: 74633@debbugs.gnu.org Received: via spool by 74633-submit@debbugs.gnu.org id=B74633.173980691928670 (code B ref 74633); Mon, 17 Feb 2025 15:42:02 +0000 Received: (at 74633) by debbugs.gnu.org; 17 Feb 2025 15:41:59 +0000 Received: from localhost ([127.0.0.1]:47786 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tk3Fu-0007SK-FF for submit@debbugs.gnu.org; Mon, 17 Feb 2025 10:41:58 -0500 Received: from [75.171.110.13] (port=2679 helo=mail.kubisiak.com) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1tk3Fr-0007Rm-UN for 74633@debbugs.gnu.org; Mon, 17 Feb 2025 10:41:56 -0500 dkim-signature: v=1; a=rsa-sha256; d=kubisiak.com; s=s1; c=relaxed/relaxed; q=dns/txt; h=From:Subject:Date:Message-ID:To:MIME-Version:Content-Type; bh=jmVSgZgAB5blRPek6fQUrYKjolt4RZjTPTPhUFENap4=; b=QC20NaubcqQDsk4dw5K8G3hpumHVC1UToAo9ziMhI/kmU2X2llLDiync8rbhKtrocG6uwFTCTwNHftLT1IYf2yqNZH0vqnd8ZG2cYc3002QA6dfEJzcgpAZmT591T9x4IjtvOGV2RMWntwVkhSwUIqsIl6w+OAs7kWjZrvnedb93cON82BuYQAyFAcLC1X5eRUt+6M6i6L6KO5vo+LxzJhLUd86BM0AWIhiK+KVt3T9CLpFnocvYKk8mJg kikwtp4sdrD1Zvxdh58IxdH5zwMF6r4UDdCRXzQ7inPM8b/H/wXAW8gjR3IMiL0OuANS6CtZP/g621TbMe6kaCZjYJYQ== Received: from peregrine (135-180-130-213.dsl.dynamic.sonic.net [135.180.130.213]) (envelope-sender ) by mail.kubisiak.com with ESMTPSA id <6c9bd54fc741c8e31821b1506e261776b0829e43.1739806839.git.brian@kubisiak.com> for <74633@debbugs.gnu.org> (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256) ; Mon, 17 Feb 2025 09:41:48 -0600 Date: Mon, 17 Feb 2025 07:41:46 -0800 From: Brian Kubisiak Message-ID: <6c9bd54fc741c8e31821b1506e261776b0829e43.1739806839.git.brian@kubisiak.com> MIME-Version: 1.0 Content-Disposition: inline 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/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 --- gnu/packages.scm | 7 ++++--- guix/describe.scm | 15 +++++++++++++++ guix/self.scm | 1 + guix/ui.scm | 27 +++++++++++++++++++++++---- 4 files changed, 43 insertions(+), 7 deletions(-) base-commit: 0cd02f5e083abac280f6478cb8fda16a0a02e789 diff --git a/gnu/packages.scm b/gnu/packages.scm index bdd5d21940..ee99dea2ca 100644 --- a/gnu/packages.scm +++ b/gnu/packages.scm @@ -148,15 +148,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. + (append-channels-to-load-path!) (set! %load-path - (append environment %load-path channels-scm)) + (append environment %load-path)) (set! %load-compiled-path - (append environment %load-compiled-path channels-go)) + (append environment %load-compiled-path)) (make-parameter (append environment diff --git a/guix/describe.scm b/guix/describe.scm index a4ca2462f4..819f0fef74 100644 --- a/guix/describe.scm +++ b/guix/describe.scm @@ -28,12 +28,14 @@ (define-module (guix describe) manifest-entry-channel) #:use-module (srfi srfi-1) #:use-module (srfi srfi-34) + #:use-module (srfi srfi-71) #:use-module (ice-9 match) #:export (current-profile current-profile-date current-profile-entries current-channels package-path-entries + append-channels-to-load-path! package-provenance package-channels @@ -190,6 +192,19 @@ (define (package-path-entries) "/site-ccache"))) (current-channel-entries)))) +(define (append-channels-to-load-path!) + "Automatically add channels to Guile's search path. Channels are added to the +end of the path so they don't override Guix' own modules. + +This procedure ensures that channels are only added to the search path once +even if it is called multiple times." + (let ((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))) + (set! append-channels-to-load-path! (lambda () #t))) + (define (package-channels package) "Return the list of channels providing PACKAGE or an empty list if it could not be determined." 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) guile-json) ;for (guix swh) #:guile-for-build guile-for-build)) diff --git a/guix/ui.scm b/guix/ui.scm index 87a448bf72..3cc15b05fc 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -2194,9 +2194,24 @@ (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")))) + ;; 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!))) + (define package-path-entries + (module-ref (resolve-module `(guix describe)) + (symbol-append 'package-path-entries))) + (append-channels-to-load-path!) + (let ((channels (package-path-entries))) + (filter file-exists? + (parse-path + (getenv "GUIX_EXTENSIONS_PATH") + (append + (map (cut string-append <> "/guix/scripts") + channels) + (map (cut string-append <> "/guix/extensions") + channels)))))) (define (commands) "Return the list of commands, alphabetically sorted." @@ -2284,7 +2299,11 @@ (define (run-guix-command command . args) (show-guix-usage))))) (file (load file) - (resolve-interface `(guix extensions ,command))))) + (let ((maybe-extension-path + (format #f "/guix/extensions/~a.scm" command))) + (if (string-suffix? maybe-extension-path file) + (resolve-interface `(guix extensions ,command)) + (resolve-interface `(guix scripts ,command))))))) (let ((command-main (module-ref module (symbol-append 'guix- command))))