From patchwork Wed Jul 21 07:50:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sarah Morgensen X-Patchwork-Id: 31546 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 2EC7127BC78; Wed, 21 Jul 2021 09:04:40 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id A49CF27BC6B for ; Wed, 21 Jul 2021 09:04:39 +0100 (BST) Received: from localhost ([::1]:50190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m67Da-0002R8-Hc for patchwork@mira.cbaines.net; Wed, 21 Jul 2021 04:04:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53400) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m670Q-0008DS-52 for guix-patches@gnu.org; Wed, 21 Jul 2021 03:51:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:52768) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m670P-0004Fz-Ni for guix-patches@gnu.org; Wed, 21 Jul 2021 03:51:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m670P-00069D-IP for guix-patches@gnu.org; Wed, 21 Jul 2021 03:51:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49531] [PATCH core-updates 0/4] import: {utils, go, crate}: Emit new-style package inputs. Resent-From: Sarah Morgensen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 21 Jul 2021 07:51:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49531 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?utf-8?q?Court=C3=A8s?= Cc: 49531@debbugs.gnu.org, Efraim Flashner Received: via spool by 49531-submit@debbugs.gnu.org id=B49531.162685386023624 (code B ref 49531); Wed, 21 Jul 2021 07:51:01 +0000 Received: (at 49531) by debbugs.gnu.org; 21 Jul 2021 07:51:00 +0000 Received: from localhost ([127.0.0.1]:36081 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m670N-00068y-Sv for submit@debbugs.gnu.org; Wed, 21 Jul 2021 03:51:00 -0400 Received: from out2.migadu.com ([188.165.223.204]:33368) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m670K-00068p-Um for 49531@debbugs.gnu.org; Wed, 21 Jul 2021 03:50:58 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mgsn.dev; s=key1; t=1626853855; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=uEGWv3hff4kFlZWWIpz0Im3CotvodbLXUtL/DfgcLAA=; b=EKt8ef5c48nwDgckBPmpPs7vq+VrY7/l0pu0EMeZGJX6o6haVV7/pvfFTJ5LpHPGWFvviF 2F7k75eKmmSha/Bqe522kz/RGkSCsOn51RjznxyRB8ROU+xxZwi9FMG0oXYbGPGJe9y/cY 9N1MgwtJ6BcHU3SuHaXheZ+3nuG03gw= From: Sarah Morgensen References: <598b53d80d66a229502d235507047a7717a15e8d.1626067919.git.iskarian@mgsn.dev> <87lf60isie.fsf_-_@gnu.org> Date: Wed, 21 Jul 2021 00:50:53 -0700 In-Reply-To: <87lf60isie.fsf_-_@gnu.org> ("Ludovic =?utf-8?q?Court=C3=A8s?= "'s message of "Tue, 20 Jul 2021 23:29:13 +0200") Message-ID: <864kcot89u.fsf_-_@mgsn.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: iskarian@mgsn.dev 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" X-getmail-retrieved-from-mailbox: Patches Hi all, Ludovic Courtès writes: > And then, how do we handle the transition? I’m not enthusiastic about > customizing ‘guix style’ for Rust packages; should we embark on manual > changes of the 2.4K Rust packages? I've attached a patch below that's a first pass at handling #:cargo-inputs in `guix style`. I didn't handle any input modification shenanigans, but I don't think any packages do that with #:cargo-inputs & co., or if so it's just a few which can be manually updated. The result of running it on #:cargo-inputs/#:cargo-development-inputs packages: 14 files changed, 9424 insertions(+), 12009 deletions(-) gnu/packages/crates-graphics.scm | 1006 +-- gnu/packages/crates-gtk.scm | 658 +- gnu/packages/crates-io.scm | 17471 ++++++++++++++++--------------------- gnu/packages/crypto.scm | 4 +- gnu/packages/gnome.scm | 90 +- gnu/packages/rust-apps.scm | 672 +- gnu/packages/security-token.scm | 30 +- gnu/packages/sequoia.scm | 124 +- gnu/packages/shells.scm | 1088 ++- gnu/packages/syndication.scm | 38 +- gnu/packages/terminals.scm | 50 +- gnu/packages/text-editors.scm | 60 +- gnu/packages/video.scm | 100 +- gnu/packages/web.scm | 42 +- --- Sarah diff --git a/guix/packages.scm b/guix/packages.scm index d3fa72fd09..26e82050f8 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -108,6 +108,7 @@ package-superseded deprecated-package package-field-location + package-argument-location this-package-input this-package-native-input @@ -515,9 +516,9 @@ object." (name old-name) (properties `((superseded . ,p))))) -(define (package-field-location package field) - "Return the source code location of the definition of FIELD for PACKAGE, or -#f if it could not be determined." +(define (package-part-location package proc) + "Return the source code location of the part of PACKAGE returned by (PROC +PACKAGE), or #f if it could not be determined." (match (package-location package) (($ file line column) (match (search-path %load-path file) @@ -530,17 +531,16 @@ object." (go-to-location port line column) (match (read port) (('package inits ...) - (let ((field (assoc field inits))) - (match field - ((_ value) - (let ((loc (and=> (source-properties value) - source-properties->location))) - (and loc - ;; Preserve the original file name, which may be a - ;; relative file name. - (set-field loc (location-file) file)))) - (_ - #f)))) + (match (proc inits) + (#f + #f) + (value + (let ((loc (and=> (source-properties value) + source-properties->location))) + (and loc + ;; Preserve the original file name, which may be a + ;; relative file name. + (set-field loc (location-file) file)))))) (_ #f))))) (lambda _ @@ -550,6 +550,29 @@ object." #f))) (_ #f))) +(define (package-field-location package field) + "Return the source code location of the definition of FIELD for PACKAGE, or +#f if it could not be determined." + (package-part-location + package + (lambda (p) + (match (assoc field p) + ((_ value) value) + (_ #f))))) + +(define (package-argument-location package argument) + "Return the source code location of the definition of keyword ARGUMENT for +PACKAGE, or #f if it could not be determined." + (package-part-location + package + (lambda (p) + (match (assoc 'arguments p) + ((_ ('quasiquote (arguments ..1))) + (match (member argument arguments eq?) + ((_ value . _) value) + (_ #f))) + (_ #f))))) + (define (package-input package name) "Return the package input NAME of PACKAGE--i.e., an input from the ‘inputs’ or ‘propagated-inputs’ field. Native inputs are not diff --git a/guix/scripts/style.scm b/guix/scripts/style.scm index 3c100197a7..19185d924e 100644 --- a/guix/scripts/style.scm +++ b/guix/scripts/style.scm @@ -371,7 +371,7 @@ bailing out~%") (delete ,@to-delete) (prepend ,@things))) (location-column location)))) - (('quasiquote (exp ...)) + ((or ('quasiquote (exp ...)) ((or (exp ...) (? comment? exp)) ...)) (let/ec return (object->string* `(list ,@(simplify-expressions exp inputs return)) @@ -389,6 +389,33 @@ POLICY is a symbol that defines whether to simplify inputs; it can one of 'silent (change only if the resulting derivation is the same), 'safe (change only if semantics are known to be unaffected), and 'always (fearlessly simplify inputs!)." + (define (package-argument package argument) + (match (member argument (package-arguments package) eq?) + ((_ value . _) value) + (_ #f))) + + ;; We know that the cargo build system does not use its special input labels, + ;; so it is always safe to simplify, but it will change the derivation. Only + ;; proceed if POLICY is 'safe or 'always. + (when (member policy '(safe always)) + (for-each (lambda (argument) + (match (package-argument package argument) + (#f + #f) + (inputs + (match (package-argument-location package argument) + (#f + #f) + (location + (edit-expression + (location->source-properties location) + (lambda (str) + (simplify-inputs location + (package-name package) + str inputs + #:label-matches? (const #t))))))))) + (list #:cargo-inputs #:cargo-development-inputs))) + (for-each (lambda (field-name field) (match (field package) (()