From patchwork Fri Oct 6 16:52:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Sergio_Pastor_P=C3=A9rez?= X-Patchwork-Id: 54532 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 A1C8527BBEA; Fri, 6 Oct 2023 18:23:02 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI,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 E002D27BBE2 for ; Fri, 6 Oct 2023 18:23:00 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qooXI-0000Dg-6S; Fri, 06 Oct 2023 13:22:48 -0400 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 1qooXD-0000DP-7f for guix-patches@gnu.org; Fri, 06 Oct 2023 13:22:43 -0400 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 1qooXC-00045g-W2 for guix-patches@gnu.org; Fri, 06 Oct 2023 13:22:43 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qooXV-0000FE-Rl for guix-patches@gnu.org; Fri, 06 Oct 2023 13:23:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#66376] [PATCH] fix: correct emacs-guix not finding packages from user channels Resent-From: Sergio Pastor =?utf-8?b?UMOpcmV6?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 06 Oct 2023 17:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 66376 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 66376@debbugs.gnu.org Cc: Sergio Pastor =?utf-8?b?UMOpcmV6?= X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.1696612943893 (code B ref -1); Fri, 06 Oct 2023 17:23:01 +0000 Received: (at submit) by debbugs.gnu.org; 6 Oct 2023 17:22:23 +0000 Received: from localhost ([127.0.0.1]:52556 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qooWs-0000EJ-QH for submit@debbugs.gnu.org; Fri, 06 Oct 2023 13:22:23 -0400 Received: from lists.gnu.org ([2001:470:142::17]:42482) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qooWq-0000E7-Sk for submit@debbugs.gnu.org; Fri, 06 Oct 2023 13:22:21 -0400 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 1qooWS-0008KK-L6 for guix-patches@gnu.org; Fri, 06 Oct 2023 13:21:56 -0400 Received: from mail-he1eur04olkn2070.outbound.protection.outlook.com ([40.92.73.70] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qooWQ-0003y0-Pb for guix-patches@gnu.org; Fri, 06 Oct 2023 13:21:56 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bJDogBVWTE/S0tDiErN51TKRR2Y3a8Y3aGGCyvs5zrbZdlZwVG5WvLBc4ACz+tSE6QvTDvWySJcKnjYcrdOcKyX2rvTmfpCpKZhNupTUcC6kQWt61/C7ZJbGS5RIBm9wB8vuGwNxFs5dpY1LgE6cBkhwGMCi0pb88Ke3zjSy7BRNDbUa8BvIPEZl2e8OPCRKeWfhRKZ1ynjuCdjWLAd6/3JsajiP3KDr0BlYX85aiziNtaCtjSZ744cCZCI59DxOfKgqcn6qgsiE0hDlQStnnd8Z0W8KZFaseBuFdbWII5mslxmG7ZWJQk9AcB+mOv2thi8B1ERc305dcuHCqVvBMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yXUbx75bi9LHNaV4ubpmgkuPgKqfcesRPab60YvioKI=; b=avD6jPWPAFnrNDeK+WoDYVQkCClV3tamyA1xWngfzV0c9wB4O6SekflYnTY2rnxBdY8AatrwTL+ABon+7G3dGFV0cAXQkdeMYDMOAhR78gNS5KOh5urfIcSkdAJOJxIH9rz6zc0FyT1An/FtiWX1B2fSgj1g3lnZd9lEPzCGnJjRDWu6HTJHKJrLiPe6jj90GLmtyqhJHWpwzGlKmDQLarF5Bunl6j9AncVk0V/nD8hbWokJVXCVjR7h9JBvjNiHntXKiqd+sOD8o2jT+qunKGaLp2I7KYLhmv2Kx1Ulk2Bg1fLXIurYDAMl1i7sEiXPg6yWrn+9PIuJviPskUR3pg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from DU2P193MB2132.EURP193.PROD.OUTLOOK.COM (2603:10a6:10:2f8::9) by DB9P193MB1259.EURP193.PROD.OUTLOOK.COM (2603:10a6:10:23f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.38; Fri, 6 Oct 2023 17:21:52 +0000 Received: from DU2P193MB2132.EURP193.PROD.OUTLOOK.COM ([fe80::5693:2d5:c58c:e127]) by DU2P193MB2132.EURP193.PROD.OUTLOOK.COM ([fe80::5693:2d5:c58c:e127%4]) with mapi id 15.20.6838.033; Fri, 6 Oct 2023 17:21:52 +0000 From: Sergio Pastor =?utf-8?b?UMOpcmV6?= Date: Fri, 6 Oct 2023 18:52:54 +0200 Message-ID: X-Mailer: git-send-email 2.41.0 X-TMN: [6NtpojrsX6QAt4AQI6bS1X9sVFRoi8d0] X-ClientProxiedBy: MR2P264CA0186.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501::25) To DU2P193MB2132.EURP193.PROD.OUTLOOK.COM (2603:10a6:10:2f8::9) X-Microsoft-Original-Message-ID: <20231006172116.22755-1-sergio.pastorperez@outlook.es> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2P193MB2132:EE_|DB9P193MB1259:EE_ X-MS-Office365-Filtering-Correlation-Id: fb32caf1-7e28-442b-9c33-08dbc690bafc X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4bDsMwabFZvHtJ98Qdrm69L9QgGxKlVg6zwOUUWXsFuxDfxVv+Rj8cCDWyNbnmWPK8vdlwWmyG4hki3VVl2Qw+1CGafVPdbwrxOASXdi3WI+oDqPYhS+biAPHlylt2A97wuJkz9iRP/Z0J22jGbuEDwnK4NJIQ/qG/hemBCty5wsH+FfFm1/sySJqZLSEWChPW65K7ML0zwCFP5OXbt6YFpZh2et6fR9UhnDkpyjhBD7ZIoCmQlX9N26klgKAkWt7HkeA+v+21kyjBSBkQlXqjjf3/ZFIWwgFW5IFeINK9luzHTRXi9HMR+1AivbN5EapZCH0uq9tx9QgW1RqPVVbPkR/pLxsTXxfQBJUR8Jvh8jHOJmbfy4gwMcrH1+fKrD3u8NJnu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1Hu60iFx1JWAJgfilgonG5/DEAvMcyyq/Vz207zNOlcU23EyBZFONVwzPa2UGGjVKpj6G4g8zfxljkyY1NCVvwDpgbB9u72MhD0NpIh5yW/RxhLWZ/oQyd2oWPqJZ38vhcWKUeTMYT4hWOCG1fF+SuZAIy3QN1qrI64ENLpCa1XEqfcQg6gQaAQ3g/dDONUzhzjjazPU6aduplyawBVzluEDWsu8wJaot2DlOSAeNgc8Y21Fsgl5gi05Ir42mx6w/HxV+fSjFJiDiXw9J7dtp8Ituc730yuYQAjWN9netgWGYfc3jzFMt/a9tY4+n/I25r/qRAbuurg7PkfG3k0/oPiJ+1ZhiTEW+fi5zmZEWKcCYFLoc/TSuc4s76df9BTZbVx8oGR8TKnRsf+bqoB9W+jOmRbACg9vc4m99DOwjIFLYxl7DSqcD5qiN9jBf1vwVJDVGqbctOkKJ4D4KtE= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-80ceb.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: fb32caf1-7e28-442b-9c33-08dbc690bafc X-MS-Exchange-CrossTenant-AuthSource: DU2P193MB2132.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2023 17:21:52.0436 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9P193MB1259 Received-SPF: pass client-ip=40.92.73.70; envelope-from=sergio.pastorperez@outlook.es; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.499, SPF_HELO_PASS=-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 --- Hi. I've noticed that `emacs-guix' is not able to fetch packages from user channels. This is a quick fix that could be implemented much easier with some help. As you can see, there is lots of redundant code from modules of the guix core, such as: 'gnu/packages.scm' as well as 'guix/describe.scm'. The issue is that neither of the functions exposed, which are used on the call hierarchy, accept a parameter for targeting a profile so all this functions need to be reimplemented to change the lowest function on the call hierarchy. I thought of using: --8<---------------cut here---------------start------------->8--- (module-define! (resolve-module '(guix describe)) 'current-profile (lambda () "Return the profile (created by 'guix pull') the calling process lives in, or #f if this is not applicable." (find (lambda (str) (string-contains str "current-guix")) (user-profiles)))) --8<---------------cut here---------------end--------------->8--- But this is not possible since most of the functions up in the call hierarchy are memoized with `mlambda'. For now this is what I'm using for myself. I submit this patch hopping that someone will have a more elegant solution. Will it be okay to redefine the functions from the guix core into generic ones that accept a profile as a parameter? The ones we have could just call the more generic one with a specific parameter so they will be the 'curried' versions. What do you think? Any ideas? Have a nice day, Sergio. scheme/emacs-guix/packages.scm | 14 ++++-- scheme/emacs-guix/profiles.scm | 79 +++++++++++++++++++++++++++++++++- 2 files changed, 88 insertions(+), 5 deletions(-) diff --git a/scheme/emacs-guix/packages.scm b/scheme/emacs-guix/packages.scm index aba04d8..928a99d 100644 --- a/scheme/emacs-guix/packages.scm +++ b/scheme/emacs-guix/packages.scm @@ -338,6 +340,7 @@ See `fold-packages' for the meaning of SELECT?." (cons pkg res) res)) '() + all-current-guix-package-modules #:select? select?)) (define (filter-packages-by-output packages output) @@ -783,7 +786,8 @@ get information with all available parameters, which are: 'id', 'name', "Return a list of names of available packages." (fold-packages (lambda (pkg res) (cons (package-name pkg) res)) - '())) + '() + all-current-guix-package-modules)) (define (package-names*) "Return to emacs side a list of names of available packages." @@ -792,7 +796,8 @@ get information with all available parameters, which are: 'id', 'name', (define (number-of-packages) "Return the number of available packages." (fold-packages (lambda (_ sum) (1+ sum)) - 0)) + 0 + all-current-guix-package-modules)) ;;; Package locations @@ -809,7 +814,8 @@ get information with all available parameters, which are: 'id', 'name', (let ((file (location-file (package-location package)))) (vhash-cons file package table))) - vlist-null))) + vlist-null + all-current-guix-package-modules))) (files (delay (vhash-fold (lambda (file _ result) (if (member file result) diff --git a/scheme/emacs-guix/profiles.scm b/scheme/emacs-guix/profiles.scm index 4792b25..5c9b224 100644 --- a/scheme/emacs-guix/profiles.scm +++ b/scheme/emacs-guix/profiles.scm @@ -27,6 +27,12 @@ (define-module (emacs-guix profiles) #:use-module (ice-9 match) #:use-module (srfi srfi-1) + #:use-module (srfi srfi-71) + #:use-module ((gnu packages) + #:select (%default-package-module-path)) + #:use-module ((guix discovery) + #:select (all-modules)) + #:use-module (guix memoization) #:use-module (guix profiles) #:use-module (guix search-paths) #:use-module ((guix scripts package) @@ -39,7 +45,8 @@ manifest-entry-dependencies-file-names search-paths-specifications search-paths - user-profiles)) + user-profiles + all-current-guix-package-modules)) ;;; Manifest entries @@ -154,4 +161,74 @@ Each specification is (VARIABLE SEPARATOR PATH) list." (generation-profile root))) (gc-roots)))) +(define current-guix-profile + (mlambda () + "Return the profile (created by 'guix pull') the calling process lives in, +or #f if this is not applicable." + (find (lambda (str) + (string-contains str "current-guix")) + (user-profiles)))) + +(define current-guix-profile-entries + (mlambda () + "Return the list of entries in the 'guix pull' profile the calling process +lives in, or the empty list if this is not applicable." + (match (current-guix-profile) + (#f '()) + (profile + (let ((manifest (profile-manifest profile))) + (manifest-entries manifest)))))) + +(define current-guix-channel-entries + (mlambda () + "Return manifest entries corresponding to extra channels--i.e., not the +'guix' channel." + (remove (lambda (entry) + (or (string=? (manifest-entry-name entry) "guix") + + ;; If ENTRY lacks the 'source' property, it's not an entry + ;; from 'guix pull'. See . + (not (assq 'source (manifest-entry-properties entry))))) + (current-guix-profile-entries)))) + +(define (current-guix-package-path-entries) + "Return two values: the list of package path entries to be added to the +package search path, and the list to be added to %LOAD-COMPILED-PATH. These +entries are taken from the 'guix pull' profile the calling process lives in, +when applicable." + ;; Filter out Guix itself. + (unzip2 (map (lambda (entry) + (list (string-append (manifest-entry-item entry) + "/share/guile/site/" + (effective-version)) + (string-append (manifest-entry-item entry) + "/lib/guile/" (effective-version) + "/site-ccache"))) + (current-guix-channel-entries)))) + +(define %current-guix-package-module-path + ;; Search path for package modules. Each item must be either a directory + ;; name or a pair whose car is a directory and whose cdr is a sub-directory + ;; to narrow the search. + (let* ((not-colon (char-set-complement (char-set #\:))) + (environment (string-tokenize (or (getenv "GUIX_PACKAGE_PATH") "") + not-colon)) + (channels-scm channels-go (current-guix-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. + (set! %load-path + (append environment %load-path channels-scm)) + (set! %load-compiled-path + (append environment %load-compiled-path channels-go)) + + (make-parameter + (append environment + %default-package-module-path + channels-scm)))) + +(define all-current-guix-package-modules + (all-modules (%current-guix-package-module-path))) + ;;; profiles.scm ends here