From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id EAlQMs40r2HtrgAAgWs5BA (envelope-from ) for ; Tue, 07 Dec 2021 11:17:50 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id +JZRLs40r2H+bAAA1q6Kng (envelope-from ) for ; Tue, 07 Dec 2021 10:17:50 +0000 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 EA9BC32DFD for ; Tue, 7 Dec 2021 11:17:49 +0100 (CET) Received: from localhost ([::1]:37024 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1muXXf-0000JL-SG for larch@yhetil.org; Tue, 07 Dec 2021 05:17:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muXV1-0005ah-Lg for guix-patches@gnu.org; Tue, 07 Dec 2021 05:15:06 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:53092) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1muXV0-0006BC-7W for guix-patches@gnu.org; Tue, 07 Dec 2021 05:15:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1muXV0-00048r-20 for guix-patches@gnu.org; Tue, 07 Dec 2021 05:15:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#51845] Using =?UTF-8?Q?=E2=80=98native-inputs=E2=80=99?= and =?UTF-8?Q?=E2=80=98inputs=E2=80=99?= for Cargo packages? Resent-From: Efraim Flashner Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 07 Dec 2021 10:15:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51845 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 51845@debbugs.gnu.org Received: via spool by 51845-submit@debbugs.gnu.org id=B51845.163887206215856 (code B ref 51845); Tue, 07 Dec 2021 10:15:01 +0000 Received: (at 51845) by debbugs.gnu.org; 7 Dec 2021 10:14:22 +0000 Received: from localhost ([127.0.0.1]:36404 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1muXUK-00047e-Hv for submit@debbugs.gnu.org; Tue, 07 Dec 2021 05:14:22 -0500 Received: from flashner.co.il ([178.62.234.194]:52988) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1muXUG-00047Q-UR for 51845@debbugs.gnu.org; Tue, 07 Dec 2021 05:14:18 -0500 Received: from localhost (unknown [94.230.83.253]) by flashner.co.il (Postfix) with ESMTPSA id F2632402DB; Tue, 7 Dec 2021 10:14:10 +0000 (UTC) Date: Tue, 7 Dec 2021 12:11:04 +0200 From: Efraim Flashner Message-ID: Mail-Followup-To: Efraim Flashner , Ludovic =?UTF-8?Q?Court=C3=A8s?= , 51845@debbugs.gnu.org References: <87zgpend04.fsf@gnu.org> <87wnkhlmfb.fsf@gnu.org> <405F2D9A-C0E6-42EC-9F81-F52F305B723C@flashner.co.il> <878rwxl6no.fsf_-_@gnu.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="GpTSFCB6c8EdULoH" Content-Disposition: inline In-Reply-To: <878rwxl6no.fsf_-_@gnu.org> X-PGP-Key-ID: 0x41AAE7DCCA3D8351 X-PGP-Key: https://flashner.co.il/~efraim/efraim_flashner.asc X-PGP-Fingerprint: A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 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" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1638872270; 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; bh=decAR2pVSEmKBmHuZZnxUoHY4/OnBe376xEklxLlxCw=; b=kt+15t6FQvYrpTIttKyeY8fnD4VgAJDdxik8reTon+0zx3Y4uzWyXL0nxliNqAE2OSr33V 1Q8kTJc7fiq4N2Tr2ur0yymfpc0vP37QHneNdzhhjE03vREZlJMvoLhCKKPZinUJ5bSZi6 s5baRJUl/jvAKv/eVOs5sfgG79TosAUgflKFAJ2YpV2cZA98GJDZaWy9NGSoiOA1btOrDL yJDmq4KCSYtXNm4NBnJrbO+7tB+95XjZmL2ScJpNAG432R2N6WcJR9tHoVXz1XqxbvmHZe J5jcaZV7Awngqxx7CaIIJmiFR9vO3FvFG4adPxJgoMk8IzbO/VK/V6NdtMb99Q== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1638872270; a=rsa-sha256; cv=none; b=R+5xbwGTpy8pxFyrYpibMMaHF5HifGSIsMv28z8DdN5Bb1DiBqzyFs76bDM8XBg1iHkwSL 3OAIrbiA0yd70DfLoQRAy6wgySWMvaNwYh6u2KAxYWlNn8P5mh8I/bpUy1atkGXE1FFF47 /x9rRsHg+PK0jB8oxD9RSE2nqIxEFd1In+1AHdC+qXhFLLxwuZ9n03zKESnrfmHa7PS6yU BvSVN6dAO4wHWVEi0kEE7pmaMKT9Jqp8IxWqODejTSjxbZdszriwDi+38lT1Lmty+FAkJC eumuV7WJuhxqISPY4gAKQJx1ZgBrkTBf3WhoPx7fgf5zkaXDXBaBhiWhHwL54g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; 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" X-Migadu-Spam-Score: -3.54 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; 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" X-Migadu-Queue-Id: EA9BC32DFD X-Spam-Score: -3.54 X-Migadu-Scanner: scn0.migadu.com X-TUID: ioLRX2qS9xGi --GpTSFCB6c8EdULoH Content-Type: multipart/mixed; boundary="3XNKIioCZ2QNyaQn" Content-Disposition: inline --3XNKIioCZ2QNyaQn Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Dec 06, 2021 at 11:17:47PM +0100, Ludovic Court=C3=A8s wrote: > Efraim Flashner skribis: >=20 > > On December 6, 2021 4:37:12 PM UTC, "Ludovic Court=C3=A8s" wrote: >=20 > [...] >=20 > >>Thinking out loud=E2=80=A6 would it work to change: > >> > >> (arguments '(#:cargo-inputs X #:cargo-development-inputs Y)) > >> > >>to: > >> > >> (native-inputs (map package-source Y)) > >> (inputs (map package-source X)) > >> > >>? >=20 > [...] >=20 > > Then we lose the transitive package sources, which is how we ended up w= here we are today. >=20 > True. >=20 > With the minimal changes to (guix build-system cargo) below, one can use > either the current style or pass =E2=80=9Cdevelopment inputs=E2=80=9D as = =E2=80=98native-inputs=E2=80=99 > and other dependencies as =E2=80=98inputs=E2=80=99. Source transitivity = is preserved > but you can write packages the normal way. >=20 > I modified some of the dependencies of librsvg to use > native-inputs/inputs and you can see when applying this part of the > patch that the librsvg derivation is unchanged. Good thing is that > =E2=80=98guix graph=E2=80=99 and =E2=80=98guix refresh -l=E2=80=99 work f= or these packages. >=20 > Is this a direction we want to take? I like the way it works out, and has Guix do the magic to give us the crates in the graph. On the other hand I tried changing the cargo-inputs =66rom librsvg to regular inputs, and after 2.5 minutes of trying to run `guix show librsvg` I still wasn't seeing the dependencies and my RAM usage was still increasing. Also gnu/packages/gnome.scm didn't fail to compile, so there was no notice of the loop. I changed some more packages which are transitive inputs of rust-encoding@0.2 and didn't see any slowdown. I was worried that this would affect a future use of `guix shell -D rust-app` not pulling in any of the crates but it still seems to work. I tried with rust-encoding@0.2 and got the crates for the packages I expected (only the ones I changed). (ins)efraim@3900XT ~/workspace/guix-core-updates$ ./pre-inst-env guix shell= -D rust-encoding@0.2 (ins)efraim@3900XT ~/workspace/guix-core-updates [env]$ ls $GUIX_ENVIRONMEN= T/share/cargo/registry/ | col cc-1.0.66.crate compiler_builtins-0.1.26.crate encoding-index-japanese-1.20141219.5.crate encoding-index-korean-1.20141219.5.crate encoding-index-simpchinese-1.20141219.5.crate encoding-index-singlebyte-1.20141219.5.crate encoding_index_tests-0.1.4.crate encoding-index-tradchinese-1.20141219.5.crate getopts-0.2.21.crate log-0.3.9.crate rustc-std-workspace-core-1.0.0.crate rustc-std-workspace-std-1.0.1.crate unicode-width-0.1.9.crate So to summarize, between your diff to treat inputs built using cargo-build-system as cargo-inputs and my changes to save previous crates for the next input we reach a place where we can start to change the crates over to use inputs and native-inputs instead of cargo-inputs and cargo-development-inputs without needing to flip everything at once. So I'd go with it's good, but I'm not sure it directly works to fix the problem we're having with librsvg. > If so, we can have =E2=80=98guix style=E2=80=99 automate transformations. >=20 > Thanks, > Ludo=E2=80=99. >=20 I've added some inline comments in the diff (and removed a bunch of lines) > diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm > index 60c35eed07..b2d97beb2f 100644 > --- a/guix/build-system/cargo.scm > +++ b/guix/build-system/cargo.scm > @@ -125,17 +125,21 @@ (define builder > #:target #f > #:guile-for-build guile)) > =20 > +(define (cargo-input? input) > + (match input > + ((label (? package? p)) > + (eq? cargo-build-system (package-build-system p))) > + (_ #f))) > + I would've sorted based on the name starting with 'rust-'. I can't think of an example quickly where it would happen, but take librsvg, which we currently build with cargo-build-system. If we need it as an input for pango (or some other library) and we also build that with the cargo-build-system then we'll just get the rust inputs, not the actual library. Can we check the arguments field for `#:install-source? #f` and use it as a regular {propagated-,native-,}input in that case? Then we could have cbindgen and rust-cbindgen, depending on if we needed the binary or the sources. > (define (package-cargo-inputs p) > - (apply > - (lambda* (#:key (cargo-inputs '()) #:allow-other-keys) > - cargo-inputs) > - (package-arguments p))) > + (match (member #:cargo-inputs (package-arguments p)) > + (#f (filter cargo-input? (package-inputs p))) > + ((_ inputs . _) inputs))) > =20 > (define (package-cargo-development-inputs p) > - (apply > - (lambda* (#:key (cargo-development-inputs '()) #:allow-other-keys) > - cargo-development-inputs) > - (package-arguments p))) > + (match (member #:cargo-development-inputs (package-arguments p)) > + (#f (filter cargo-input? (package-native-inputs p))) > + ((_ inputs . _) inputs))) I see we don't get rid of #:cargo-inputs or #:cargo-development-inputs. So even if applying the style change to all the crates causes circular dependency problems we can fall back to the current method. I ran into problems once I hit all the rust-bindgen crates. > =20 > (define (crate-closure inputs) > "Return the closure of INPUTS when considering the 'cargo-inputs' and > @@ -235,8 +239,8 @@ (define (expand-crate-sources cargo-inputs cargo-deve= lopment-inputs) > (define* (lower name > #:key source inputs native-inputs outputs system target > (rust (default-rust)) > - (cargo-inputs '()) > - (cargo-development-inputs '()) > + (cargo-inputs (filter cargo-input? inputs)) > + (cargo-development-inputs (filter cargo-input? native-in= puts)) I tried commenting the cargo-development-inputs out, but it only caused problems for me when trying to compile rust-encoding@0.2. > #:allow-other-keys > #:rest arguments) > "Return a bag for NAME." > @@ -260,7 +264,9 @@ (define private-keywords > (build-inputs `(("cargo" ,rust "cargo") > ("rustc" ,rust) > ,@(expand-crate-sources cargo-inputs cargo-deve= lopment-inputs) > - ,@native-inputs)) > + ,@(if (eq? native-inputs cargo-development-inpu= ts) > + '() > + native-inputs))) > (outputs outputs) > (build cargo-build) > (arguments (strip-keyword-arguments private-keywords arguments)= )))) > diff --git a/guix/packages.scm b/guix/packages.scm > index b3c5a00011..275cc3675c 100644 > --- a/guix/packages.scm > +++ b/guix/packages.scm > @@ -660,7 +660,8 @@ (define (deprecated-package old-name p) > (name old-name) > (properties `((superseded . ,p))))) > =20 > -(define (package-field-location package field) > +(define* (package-field-location package field > + #:key (value-location? #t)) > "Return the source code location of the definition of FIELD for PACKAG= E, or > #f if it could not be determined." > (match (package-location package) > @@ -678,7 +679,10 @@ (define (package-field-location package field) > (let ((field (assoc field inits))) > (match field > ((_ value) > - (let ((loc (and=3D> (source-properties value) > + (let ((loc (and=3D> (source-properties > + (if value-location? > + value > + field)) > source-properties->location))) > (and loc > ;; Preserve the original file name, which= may be a > diff --git a/guix/scripts/style.scm b/guix/scripts/style.scm > index 86a46f693c..dccc20d880 100644 > --- a/guix/scripts/style.scm > +++ b/guix/scripts/style.scm > @@ -29,6 +29,7 @@ > =20 > (define-module (guix scripts style) > #:autoload (gnu packages) (specification->package fold-packages) > + #:autoload (guix build-system cargo) (cargo-build-system) > #:use-module (guix scripts) > #:use-module ((guix scripts build) #:select (%standard-build-options)) > #:use-module (guix combinators) > @@ -212,6 +213,21 @@ (define (object->string* obj indent) > (pretty-print-with-comments port obj > #:indent indent)))) > =20 > +(define (object-list->string lst indent) > + (call-with-output-string > + (lambda (port) > + (let loop ((lst lst)) > + (match lst > + ((obj) > + (pretty-print-with-comments port obj > + #:indent indent)) > + ((obj rest ...) > + (pretty-print-with-comments port obj > + #:indent indent) > + (newline port) > + (display (make-string indent #\space) port) > + (loop rest))))))) > + > =0C > ;;; > ;;; Simplifying input expressions. > @@ -441,6 +457,49 @@ (define matches? > (list package-inputs package-native-inputs > package-propagated-inputs))) > =20 > +=0C > +;;; > +;;; Crates, Cargo, Rust, and all that. > +;;; > + > +(define* (rewrite-cargo-inputs package > + #:key (policy 'silent) > + (edit-expression edit-expression)) > + (when (eq? (package-build-system package) cargo-build-system) > + (match (package-field-location package 'arguments > + #:value-location? #f) > + (#f #f) > + (location > + (let* ((indent (location-column location))) > + (edit-expression > + (pk 'loc (location->source-properties location)) > + (lambda (str) > + (define arguments > + (call-with-input-string (pk 'str str) read-with-comments)) > + > + (match arguments > + (('arguments ('quasiquote lst)) > + (let ((inputs (match (member #:cargo-inputs lst) > + (#f '()) > + ((_ inputs . _) inputs))) > + (native (match (member #:cargo-development-inputs l= st) > + (#f '()) > + ((_ inputs . _) inputs))) > + (rest (strip-keyword-arguments > + '(#:cargo-inputs #:cargo-development-inputs) > + lst))) > + (object-list->string > + `(,@(if (null? rest) > + '() > + `((arguments ,(list 'quasiquote rest)))) > + ,@(if (null? native) > + '() > + `((native-inputs ,(list 'quasiquote native)))) > + ,@(if (null? inputs) > + '() > + `((inputs ,(list 'quasiquote inputs))))) > + indent))))))))))) > + > (define (package-location "Return true if P1's location is \"before\" P2's." > (let ((loc1 (package-location p1)) > @@ -536,7 +595,7 @@ (define (parse-options) > edit-expression)) > (policy (assoc-ref opts 'input-simplification-policy))) > (for-each (lambda (package) > - (simplify-package-inputs package #:policy policy > + (rewrite-cargo-inputs package #:policy policy > #:edit-expression edit)) > ;; Sort package by source code location so that we start e= diting > ;; files from the bottom and going upward. That way, the --=20 Efraim Flashner =D7=A8=D7=A0=D7=A9=D7=9C=D7=A4 = =D7=9D=D7=99=D7=A8=D7=A4=D7=90 GPG key =3D A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 Confidentiality cannot be guaranteed on emails sent or received unencrypted --3XNKIioCZ2QNyaQn Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename=rust-changes-c-u-f Content-Transfer-Encoding: quoted-printable diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm index b8c4c7bd39..ae717645d8 100644 --- a/gnu/packages/crates-io.scm +++ b/gnu/packages/crates-io.scm @@ -5728,18 +5728,18 @@ (define-public rust-bitflags-1.3 (file-name (string-append name "-" version ".tar.gz")) (sha256 (base32 "12ki6w8gn1ldq7yz9y680llwk5gmrhrzszaa17g1sbrw2r2qvwxy")))) - (arguments - `(#:tests? #f ; Tests require rust-1.46 or newer. - #:cargo-inputs - (("rust-compiler-builtins" ,rust-compiler-builtins-0.1) - ("rust-rustc-std-workspace-core" ,rust-rustc-std-workspace-core-1)) - #:cargo-development-inputs - (("rust-rustversion" ,rust-rustversion-1) + (arguments `(#:tests? #f ; Tests require rust-1.46 or newer. + )) + (native-inputs + `(("rust-rustversion" ,rust-rustversion-1) ("rust-serde" ,rust-serde-1) ("rust-serde-derive" ,rust-serde-derive-1) ("rust-serde-json" ,rust-serde-json-1) ("rust-trybuild" ,rust-trybuild-1) - ("rust-walkdir" ,rust-walkdir-2)))))) + ("rust-walkdir" ,rust-walkdir-2))) + (inputs + `(("rust-compiler-builtins" ,rust-compiler-builtins-0.1) + ("rust-rustc-std-workspace-core" ,rust-rustc-std-workspace-core-1)= )))) =20 (define-public rust-bitflags-0.9 (package @@ -8391,12 +8391,9 @@ (define-public rust-cast-0.2 (base32 "1c5z7zryj0zwnhdgs6rw5dfvnlwc1vm19jzrlgx5055alnwk952b")))) (build-system cargo-build-system) - (arguments - `(#:skip-build? #t - #:cargo-inputs - (("rust-rustc-version" ,rust-rustc-version-0.2)) - #:cargo-development-inputs - (("rust-quickcheck" ,rust-quickcheck-0.9)))) + (arguments `(#:skip-build? #t)) + (native-inputs `(("rust-quickcheck" ,rust-quickcheck-0.9))) + (inputs `(("rust-rustc-version" ,rust-rustc-version-0.2))) (home-page "https://github.com/japaric/cast.rs") (synopsis "Ergonomic, checked cast functions for primitive types") @@ -8434,7 +8431,7 @@ (define-public rust-cc-1 (origin (method url-fetch) (uri (crate-uri "cc" version)) - (file-name (string-append name "-" version ".crate")) + (file-name (string-append name "-" version ".tar.gz")) (sha256 (base32 "0j7d7h4n81z5f22l3v8ggjvvw8m64636nlaqax4x1y44da1rc12c")))) @@ -8596,7 +8593,7 @@ (define-public rust-cfg-if-0.1 (origin (method url-fetch) (uri (crate-uri "cfg-if" version)) - (file-name (string-append name "-" version ".crate")) + (file-name (string-append name "-" version ".tar.gz")) (sha256 (base32 "08h80ihs74jcyp24cd75wwabygbbdgl05k6p5dmq8akbr78vv1a7")))) @@ -10052,16 +10049,17 @@ (define-public rust-compiler-builtins-0.1 (origin (method url-fetch) (uri (crate-uri "compiler_builtins" version)) - (file-name (string-append name "-" version ".crate")) + (file-name (string-append name "-" version ".tar.gz")) (sha256 (base32 "1rhj6ccmfkh9gcxnxgjq4fg257yi4f9325nfzsphbmxwkrg06sq3")))) (build-system cargo-build-system) (arguments `(#:skip-build? #t - #:cargo-inputs - (("rust-rustc-std-workspace-core" ,rust-rustc-std-workspace-core-1) - ("rust-cc" ,rust-cc-1)))) + )) + (inputs + `(("rust-rustc-std-workspace-core" ,rust-rustc-std-workspace-core-1) + ("rust-cc" ,rust-cc-1))) (home-page "https://github.com/rust-lang/compiler-builtins") (synopsis "Compiler intrinsics used by the Rust compiler") (description @@ -12459,10 +12457,9 @@ (define-public rust-cssparser-0.28 (sha256 (base32 "1h924c5g2rwlmgk8hllciyky3ih3z9vf04xz3xsp3cv1jyd5kf0x")))) (build-system cargo-build-system) - (arguments - `(#:skip-build? #t - #:cargo-inputs - (("rust-cssparser-macros" ,rust-cssparser-macros-0.6) + (arguments `(#:skip-build? #t)) + (inputs + `(("rust-cssparser-macros" ,rust-cssparser-macros-0.6) ("rust-dtoa-short" ,rust-dtoa-short-0.3) ("rust-itoa" ,rust-itoa-0.4) ("rust-matches" ,rust-matches-0.1) @@ -12471,7 +12468,7 @@ (define-public rust-cssparser-0.28 ("rust-quote" ,rust-quote-1) ("rust-serde" ,rust-serde-1) ("rust-smallvec" ,rust-smallvec-1) - ("rust-syn" ,rust-syn-1)))) + ("rust-syn" ,rust-syn-1))) (home-page "https://github.com/servo/rust-cssparser") (synopsis "Rust implementation of CSS Syntax Level 3") (description @@ -13601,13 +13598,11 @@ (define-public rust-data-url-0.1 (base32 "176wa1n8h71iwyaxhar4sqwrgrvb5sxk26az0fy88vnxrsffjgyk")))) (build-system cargo-build-system) - (arguments - `(#:cargo-inputs - (("rust-matches" ,rust-matches-0.1)) - #:cargo-development-inputs - (("rust-rustc-test" ,rust-rustc-test-0.3) + (native-inputs + `(("rust-rustc-test" ,rust-rustc-test-0.3) ("rust-serde" ,rust-serde-1) - ("rust-serde-json" ,rust-serde-json-1)))) + ("rust-serde-json" ,rust-serde-json-1))) + (inputs `(("rust-matches" ,rust-matches-0.1))) (home-page "https://github.com/servo/rust-url") (synopsis "Processing of data: URL according to WHATWG's Fetch Standar= d") (description @@ -16334,23 +16329,24 @@ (define-public rust-encoding-0.2 (string-append name "-" version ".tar.gz")) (sha256 (base32 - "1v1ndmkarh9z3n5hk53da4z56hgk9wa5kcsm7cnx345raqw983bb")))) + "1v1ndmkarh9z3n5hk53da4z56hgk9wa5kcsm7cnx345raqw983bb")) + (modules '((guix build utils))) + (snippet + '(begin + (substitute* "Cargo.toml" + (("path.*") "")))))) (build-system cargo-build-system) (arguments - `(#:skip-build? #t - #:cargo-inputs - (("rust-encoding-index-japanese" - ,rust-encoding-index-japanese-1.20141219) - ("rust-encoding-index-korean" - ,rust-encoding-index-korean-1.20141219) - ("rust-encoding-index-simpchinese" - ,rust-encoding-index-simpchinese-1.20141219) - ("rust-encoding-index-singlebyte" - ,rust-encoding-index-singlebyte-1.20141219) - ("rust-encoding-index-tradchinese" - ,rust-encoding-index-tradchinese-1.20141219)) - #:cargo-development-inputs - (("rust-getopts" ,rust-getopts-0.2)))) + `(;#:skip-build? #t + #:tests? #f + )) + (native-inputs `(("rust-getopts" ,rust-getopts-0.2))) + (inputs + `(("rust-encoding-index-japanese" ,rust-encoding-index-japanese-1.20= 141219) + ("rust-encoding-index-korean" ,rust-encoding-index-korean-1.201412= 19) + ("rust-encoding-index-simpchinese" ,rust-encoding-index-simpchines= e-1.20141219) + ("rust-encoding-index-singlebyte" ,rust-encoding-index-singlebyte-= 1.20141219) + ("rust-encoding-index-tradchinese" ,rust-encoding-index-tradchines= e-1.20141219))) (home-page "https://github.com/lifthrasiir/rust-encoding") (synopsis "Character encoding support for Rust") @@ -16374,8 +16370,9 @@ (define-public rust-encoding-index-japanese-1.20141= 219 (build-system cargo-build-system) (arguments `(#:skip-build? #t - #:cargo-inputs - (("rust-encoding-index-tests" ,rust-encoding-index-tests-0.1)))) + )) + (inputs + `(("rust-encoding-index-tests" ,rust-encoding-index-tests-0.1))) (home-page "https://github.com/lifthrasiir/rust-encoding") (synopsis "Index tables for Japanese character encodings") (description @@ -16398,8 +16395,9 @@ (define-public rust-encoding-index-korean-1.20141219 (build-system cargo-build-system) (arguments `(#:skip-build? #t - #:cargo-inputs - (("rust-encoding-index-tests" ,rust-encoding-index-tests-0.1)))) + )) + (inputs + `(("rust-encoding-index-tests" ,rust-encoding-index-tests-0.1))) (home-page "https://github.com/lifthrasiir/rust-encoding") (synopsis "Index tables for Korean character encodings") (description @@ -16422,8 +16420,9 @@ (define-public rust-encoding-index-simpchinese-1.20= 141219 (build-system cargo-build-system) (arguments `(#:skip-build? #t - #:cargo-inputs - (("rust-encoding-index-tests" ,rust-encoding-index-tests-0.1)))) + )) + (inputs + `(("rust-encoding-index-tests" ,rust-encoding-index-tests-0.1))) (home-page "https://github.com/lifthrasiir/rust-encoding") (synopsis "Index tables for simplified Chinese character encodings") (description @@ -16446,8 +16445,9 @@ (define-public rust-encoding-index-singlebyte-1.201= 41219 (build-system cargo-build-system) (arguments `(#:skip-build? #t - #:cargo-inputs - (("rust-encoding-index-tests" ,rust-encoding-index-tests-0.1)))) + )) + (inputs + `(("rust-encoding-index-tests" ,rust-encoding-index-tests-0.1))) (home-page "https://github.com/lifthrasiir/rust-encoding") (synopsis "Index tables for various single-byte character encodings") (description @@ -16493,8 +16493,9 @@ (define-public rust-encoding-index-tradchinese-1.20= 141219 (build-system cargo-build-system) (arguments `(#:skip-build? #t - #:cargo-inputs - (("rust-encoding-index-tests" ,rust-encoding-index-tests-0.1)))) + )) + (inputs + `(("rust-encoding-index-tests" ,rust-encoding-index-tests-0.1))) (home-page "https://github.com/lifthrasiir/rust-encoding") (synopsis "Index tables for traditional Chinese character encodings") (description @@ -18388,8 +18389,7 @@ (define-public rust-float-cmp-0.8 (base32 "1i56hnzjn5pmrcm47fwkmfxiihk7wz5vvcgpb0kpfhzkqi57y9p1")))) (build-system cargo-build-system) - (arguments - `(#:cargo-inputs (("rust-num-traits" ,rust-num-traits-0.2)))) + (inputs `(("rust-num-traits" ,rust-num-traits-0.2))) (home-page "https://github.com/mikedilger/float-cmp") (synopsis "Floating point approximate comparison traits") (description @@ -20542,18 +20542,17 @@ (define-public rust-getopts-0.2 (origin (method url-fetch) (uri (crate-uri "getopts" version)) - (file-name (string-append name "-" version ".crate")) + (file-name (string-append name "-" version ".tar.gz")) (sha256 (base32 "1mgb3qvivi26gs6ihqqhh8iyhp3vgxri6vwyrwg28w0xqzavznql")))) (build-system cargo-build-system) - (arguments - `(#:cargo-inputs - (("rust-unicode-width" ,rust-unicode-width-0.1) + (inputs + `(("rust-unicode-width" ,rust-unicode-width-0.1) ("rust-rustc-std-workspace-core" ,rust-rustc-std-workspace-core-1) - ("rust-rustc-std-workspace-std" ,rust-rustc-std-workspace-std-1)) - #:cargo-development-inputs - (("rust-log" ,rust-log-0.3)))) + ("rust-rustc-std-workspace-std" ,rust-rustc-std-workspace-std-1))) + (native-inputs + `(("rust-log" ,rust-log-0.4))) (home-page "https://github.com/rust-lang/getopts") (synopsis "Rust library for option parsing for CLI utilities") (description "This library provides getopts-like option parsing.") @@ -26818,11 +26817,8 @@ (define-public rust-libm-0.2 (base32 "0akh56sh51adhagmk9l84dyrlz60gv8ri05xhr13i1b18czkpmy7")))) (build-system cargo-build-system) - (arguments - `(#:cargo-inputs - (("rust-rand" ,rust-rand-0.6)) - #:cargo-development-inputs - (("rust-no-panic" ,rust-no-panic-0.1)))) + (native-inputs `(("rust-no-panic" ,rust-no-panic-0.1))) + (inputs `(("rust-rand" ,rust-rand-0.6))) (home-page "https://github.com/rust-lang/libm") (synopsis "Libm in pure Rust") (description "This package provides an implementation of libm in pure = Rust.") @@ -27685,7 +27681,7 @@ (define-public rust-log-0.4 (origin (method url-fetch) (uri (crate-uri "log" version)) - (file-name (string-append name "-" version ".crate")) + (file-name (string-append name "-" version ".tar.gz")) (sha256 (base32 "04175hv0v62shd82qydq58a48k3bjijmk54v38zgqlbxqkkbpfai")))) (build-system cargo-build-system) @@ -44102,7 +44098,7 @@ (define-public rust-rustc-std-workspace-core-1 (origin (method url-fetch) (uri (crate-uri "rustc-std-workspace-core" version)) - (file-name (string-append name "-" version ".crate")) + (file-name (string-append name "-" version ".tar.gz")) (sha256 (base32 "1309xhwyai9xpz128xrfjqkmnkvgjwddznmj7brbd8i8f58zamhr")))) @@ -58950,11 +58946,10 @@ (define-public rust-unicode-width-0.1 (base32 "0wq9wl69wlp6zwlxp660g9p4hm5gk91chwk14dp1gl9bxba45mry")))) (build-system cargo-build-system) - (arguments - `(#:cargo-inputs - (("rust-compiler-builtins" ,rust-compiler-builtins-0.1) + (inputs + `(("rust-compiler-builtins" ,rust-compiler-builtins-0.1) ("rust-rustc-std-workspace-core" ,rust-rustc-std-workspace-core-1) - ("rust-rustc-std-workspace-std" ,rust-rustc-std-workspace-std-1)))) + ("rust-rustc-std-workspace-std" ,rust-rustc-std-workspace-std-1))) (home-page "https://github.com/unicode-rs/unicode-width") (synopsis "Determine displayed width according to Unicode rules") (description "This crate allows you to determine displayed width of diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm index 2037ab9369..389b53eef0 100644 --- a/gnu/packages/gnome.scm +++ b/gnu/packages/gnome.scm @@ -3479,43 +3479,6 @@ (define-public librsvg ((guix build cargo-build-system) (guix build utils) ((guix build gnu-build-system) #:prefix gnu:)) - #:cargo-inputs - (("rust-bitflags" ,rust-bitflags-1) - ("rust-cairo-rs" ,rust-cairo-rs-0.8) - ("rust-cairo-sys-rs" ,rust-cairo-sys-rs-0.9) - ("rust-cast" ,rust-cast-0.2) - ("rust-cssparser" ,rust-cssparser-0.27) - ("rust-data-url" ,rust-data-url-0.1) - ("rust-encoding" ,rust-encoding-0.2) - ("rust-float-cmp" ,rust-float-cmp-0.8) - ("rust-gdk-pixbuf" ,rust-gdk-pixbuf-0.8) - ("rust-gdk-pixbuf-sys" ,rust-gdk-pixbuf-sys-0.9) - ("rust-gio" ,rust-gio-0.8) - ("rust-gio-sys" ,rust-gio-sys-0.9) - ("rust-glib" ,rust-glib-0.9) - ("rust-glib-sys" ,rust-glib-sys-0.9) - ("rust-gobject-sys" ,rust-gobject-sys-0.9) - ("rust-itertools" ,rust-itertools-0.9) - ("rust-language-tags" ,rust-language-tags-0.2) - ("rust-libc" ,rust-libc-0.2) - ("rust-locale-config" ,rust-locale-config-0.3) - ("rust-markup5ever" ,rust-markup5ever-0.10) - ("rust-nalgebra" ,rust-nalgebra-0.21) - ("rust-num-traits" ,rust-num-traits-0.2) - ("rust-once-cell" ,rust-once-cell-1) - ("rust-pkg-config" ,rust-pkg-config-0.3) - ("rust-pango" ,rust-pango-0.8) - ("rust-pango-sys" ,rust-pango-sys-0.9) - ("rust-pangocairo" ,rust-pangocairo-0.9) - ("rust-rayon" ,rust-rayon-1) - ("rust-rctree" ,rust-rctree-0.3) - ("rust-rgb" ,rust-rgb-0.8) - ("rust-regex" ,rust-regex-1) - ("rust-selectors" ,rust-selectors-0.22) - ("rust-string-cache" ,rust-string-cache-0.8) - ("rust-tinyvec" ,rust-tinyvec-0.3) - ("rust-url" ,rust-url-2) - ("rust-xml5ever" ,rust-xml5ever-0.16)) #:cargo-development-inputs (("rust-assert-cmd" ,rust-assert-cmd-1) ("rust-cairo-rs" ,rust-cairo-rs-0.8) @@ -3621,7 +3584,43 @@ (define-public librsvg libcroco libgsf libxml2 - pango)) + pango + rust-bitflags-1 + rust-cairo-rs-0.8 + rust-cairo-sys-rs-0.9 + rust-cast-0.2 + rust-cssparser-0.27 + rust-data-url-0.1 + rust-encoding-0.2 + rust-float-cmp-0.8 + rust-gdk-pixbuf-0.8 + rust-gdk-pixbuf-sys-0.9 + rust-gio-0.8 + rust-gio-sys-0.9 + rust-glib-0.9 + rust-glib-sys-0.9 + rust-gobject-sys-0.9 + rust-itertools-0.9 + rust-language-tags-0.2 + rust-libc-0.2 + rust-locale-config-0.3 + rust-markup5ever-0.10 + rust-nalgebra-0.21 + rust-num-traits-0.2 + rust-once-cell-1 + rust-pkg-config-0.3 + rust-pango-0.8 + rust-pango-sys-0.9 + rust-pangocairo-0.9 + rust-rayon-1 + rust-rctree-0.3 + rust-rgb-0.8 + rust-regex-1 + rust-selectors-0.22 + rust-string-cache-0.8 + rust-tinyvec-0.3 + rust-url-2 + rust-xml5ever-0.16)) (propagated-inputs (list cairo gdk-pixbuf glib)) (synopsis "SVG rendering library") diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm index 60c35eed07..b2d97beb2f 100644 --- a/guix/build-system/cargo.scm +++ b/guix/build-system/cargo.scm @@ -125,17 +125,21 @@ (define builder #:target #f #:guile-for-build guile)) =20 +(define (cargo-input? input) + (match input + ((label (? package? p)) + (eq? cargo-build-system (package-build-system p))) + (_ #f))) + (define (package-cargo-inputs p) - (apply - (lambda* (#:key (cargo-inputs '()) #:allow-other-keys) - cargo-inputs) - (package-arguments p))) + (match (member #:cargo-inputs (package-arguments p)) + (#f (filter cargo-input? (package-inputs p))) + ((_ inputs . _) inputs))) =20 (define (package-cargo-development-inputs p) - (apply - (lambda* (#:key (cargo-development-inputs '()) #:allow-other-keys) - cargo-development-inputs) - (package-arguments p))) + (match (member #:cargo-development-inputs (package-arguments p)) + (#f (filter cargo-input? (package-native-inputs p))) + ((_ inputs . _) inputs))) =20 (define (crate-closure inputs) "Return the closure of INPUTS when considering the 'cargo-inputs' and @@ -235,8 +239,8 @@ (define (expand-crate-sources cargo-inputs cargo-develo= pment-inputs) (define* (lower name #:key source inputs native-inputs outputs system target (rust (default-rust)) - (cargo-inputs '()) - (cargo-development-inputs '()) + (cargo-inputs (filter cargo-input? inputs)) + (cargo-development-inputs (filter cargo-input? native-inpu= ts)) #:allow-other-keys #:rest arguments) "Return a bag for NAME." @@ -260,7 +264,9 @@ (define private-keywords (build-inputs `(("cargo" ,rust "cargo") ("rustc" ,rust) ,@(expand-crate-sources cargo-inputs cargo-develo= pment-inputs) - ,@native-inputs)) + ,@(if (eq? native-inputs cargo-development-inputs) + '() + native-inputs))) (outputs outputs) (build cargo-build) (arguments (strip-keyword-arguments private-keywords arguments)))= )) diff --git a/guix/packages.scm b/guix/packages.scm index b3c5a00011..275cc3675c 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -660,7 +660,8 @@ (define (deprecated-package old-name p) (name old-name) (properties `((superseded . ,p))))) =20 -(define (package-field-location package field) +(define* (package-field-location package field + #:key (value-location? #t)) "Return the source code location of the definition of FIELD for PACKAGE,= or #f if it could not be determined." (match (package-location package) @@ -678,7 +679,10 @@ (define (package-field-location package field) (let ((field (assoc field inits))) (match field ((_ value) - (let ((loc (and=3D> (source-properties value) + (let ((loc (and=3D> (source-properties + (if value-location? + value + field)) source-properties->location))) (and loc ;; Preserve the original file name, which m= ay be a diff --git a/guix/scripts/style.scm b/guix/scripts/style.scm index 86a46f693c..dccc20d880 100644 --- a/guix/scripts/style.scm +++ b/guix/scripts/style.scm @@ -29,6 +29,7 @@ =20 (define-module (guix scripts style) #:autoload (gnu packages) (specification->package fold-packages) + #:autoload (guix build-system cargo) (cargo-build-system) #:use-module (guix scripts) #:use-module ((guix scripts build) #:select (%standard-build-options)) #:use-module (guix combinators) @@ -212,6 +213,21 @@ (define (object->string* obj indent) (pretty-print-with-comments port obj #:indent indent)))) =20 +(define (object-list->string lst indent) + (call-with-output-string + (lambda (port) + (let loop ((lst lst)) + (match lst + ((obj) + (pretty-print-with-comments port obj + #:indent indent)) + ((obj rest ...) + (pretty-print-with-comments port obj + #:indent indent) + (newline port) + (display (make-string indent #\space) port) + (loop rest))))))) + =0C ;;; ;;; Simplifying input expressions. @@ -441,6 +457,49 @@ (define matches? (list package-inputs package-native-inputs package-propagated-inputs))) =20 +=0C +;;; +;;; Crates, Cargo, Rust, and all that. +;;; + +(define* (rewrite-cargo-inputs package + #:key (policy 'silent) + (edit-expression edit-expression)) + (when (eq? (package-build-system package) cargo-build-system) + (match (package-field-location package 'arguments + #:value-location? #f) + (#f #f) + (location + (let* ((indent (location-column location))) + (edit-expression + (pk 'loc (location->source-properties location)) + (lambda (str) + (define arguments + (call-with-input-string (pk 'str str) read-with-comments)) + + (match arguments + (('arguments ('quasiquote lst)) + (let ((inputs (match (member #:cargo-inputs lst) + (#f '()) + ((_ inputs . _) inputs))) + (native (match (member #:cargo-development-inputs lst) + (#f '()) + ((_ inputs . _) inputs))) + (rest (strip-keyword-arguments + '(#:cargo-inputs #:cargo-development-inputs) + lst))) + (object-list->string + `(,@(if (null? rest) + '() + `((arguments ,(list 'quasiquote rest)))) + ,@(if (null? native) + '() + `((native-inputs ,(list 'quasiquote native)))) + ,@(if (null? inputs) + '() + `((inputs ,(list 'quasiquote inputs))))) + indent))))))))))) + (define (package-location