GNU bug report logs - #77093
[PATCH rust-team 00/18] New Rust packaging workflow based on lockfile importer.

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix-patches; Reported by: Hilton Chain <hako@HIDDEN>; Keywords: patch; dated Tue, 18 Mar 2025 07:18:02 UTC; Maintainer for guix-patches is guix-patches@HIDDEN.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 12 Apr 2025 12:58:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Apr 12 08:58:26 2025
Received: from localhost ([127.0.0.1]:54410 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1u3aRE-0005qR-Vd
	for submit <at> debbugs.gnu.org; Sat, 12 Apr 2025 08:58:26 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:43488)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <ludo@HIDDEN>) id 1u3aR9-0005oa-AU
 for 77093 <at> debbugs.gnu.org; Sat, 12 Apr 2025 08:58:21 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1u3aR2-0002We-2z; Sat, 12 Apr 2025 08:58:12 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To:
 From; bh=jiTX33Z29l0tFPv+nw7qJLfd37JvAbkqBkV9vZXXqUE=; b=Kxfx986XDz/WIiTnlmXP
 bbBGb4zytqTugxc2SqzABhNEH92nHeG0mX3SMtFLm7EeGyFobXGLwDyPuLIQIcWXn+cp2M5APpA5x
 q23I5OepoRmIUTp/Ja5DvacM5Tnh7U1tR+FS6tegiNrDz5370FXdzdLNJlR7UIHKlIVp8TGpHwjSc
 KnpcSAKTrgZRaGUVNoQQRqA8D05QvswgTp0Ncv1xBLCQiJkuxgp9qYrYSWmB6gW+G1yPbZ1MQlDHD
 DmM27wYcCYoBozIPCuKWh95X5XRkXaTJw/Bzai4GrdjszhiuAS8UrtxsOHYmPy6cEy/+axzTOJW/E
 famV4Gxla63T9w==;
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Hilton Chain <hako@HIDDEN>
Subject: Re: [PATCH rust-team v3 00/17] New Rust packaging workflow based on
 lockfile importer.
In-Reply-To: <87zfgl7hiz.wl-hako@HIDDEN> (Hilton Chain's message of
 "Sat, 12 Apr 2025 19:20:36 +0800")
References: <cover.1742713356.git.hako@HIDDEN>
 <87r027xqs2.wl-hako@HIDDEN>
 <87zfgl7hiz.wl-hako@HIDDEN>
User-Agent: mu4e 1.12.9; emacs 29.4
X-URL: https://people.bordeaux.inria.fr/lcourtes/
X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4  0CFB 090B 1199 3D9A EBB5
X-OS: x86_64-pc-linux-gnu
X-Revolutionary-Date: Tridi 23 Germinal an 233 de la =?utf-8?Q?R=C3=A9volu?=
 =?utf-8?Q?tion=2C?= jour du Marronnier
Date: Sat, 12 Apr 2025 14:58:08 +0200
Message-ID: <875xj9fsf3.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 77093
Cc: Maxim Cournoyer <maxim.cournoyer@HIDDEN>,
 Steve George <steve@HIDDEN>, 77093 <at> debbugs.gnu.org,
 Divya Ranjan Pattanaik <divya@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hello,

Hilton Chain <hako@HIDDEN> skribis:

> I'll set a deadline (1 year?) to remove #:cargo-inputs support from
> cargo-build-sytem.  Here're remaining users in our codebase:

I think you could add an entry in =E2=80=98etc/news.scm=E2=80=99 and mentio=
n this plan.
(Perhaps a blog post explaining the rationale and strategy would be in
order, too! :-))

Kudos for all this work!

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 12 Apr 2025 11:20:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Apr 12 07:20:50 2025
Received: from localhost ([127.0.0.1]:54262 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1u3Yun-0003tW-L4
	for submit <at> debbugs.gnu.org; Sat, 12 Apr 2025 07:20:50 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:38014)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1u3Yuk-0003tK-R6
 for 77093 <at> debbugs.gnu.org; Sat, 12 Apr 2025 07:20:47 -0400
Date: Sat, 12 Apr 2025 19:20:36 +0800
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1744456845;
 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=ck1B0p1+htNJKMQWYCfUwaST9bDj/3crCJAUexOGIOY=;
 b=bz/0DCJ/QLkedvLHm3k389HodWN4IShl2hvyM9fTUVir/mcl5GhKznZ9OfCPO6fb2RKFUc
 p6gaC/62axvUf/prB/TQBobTf2Kq0eHyMfdnfohYt9ED3Ffgt5n+xEwlrXsk+ZlxwFwZZd
 O6qHB8YqKouwiFGpZhtzXrzzfnuffa9p22przx1exyO2f1Bgh6zvwJMBemx8F1REnfFaOo
 aviFybOmjjFdzJ4/Yshasz8tSWpihuyAHUSRx2tggTX46XEcCUOpA1AIuilYXMjfrxF9zc
 x+H50iTnUp0QJXPLqyO+XTUvLIBVR8OqgNi+8K5guDwaVhDzqAGFufant1XClg==
Message-ID: <87zfgl7hiz.wl-hako@HIDDEN>
From: Hilton Chain <hako@HIDDEN>
To: 77093 <at> debbugs.gnu.org
Subject: Re: [PATCH rust-team v3 00/17] New Rust packaging workflow based on
 lockfile importer.
In-Reply-To: <87r027xqs2.wl-hako@HIDDEN>
References: <cover.1742713356.git.hako@HIDDEN>
 <87r027xqs2.wl-hako@HIDDEN>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=US-ASCII
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Ludovic =?ISO-8859-1?Q?Court=E8s?= <ludo@HIDDEN>,
 Maxim Cournoyer <maxim.cournoyer@HIDDEN>, Steve George <steve@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>,
 Divya Ranjan Pattanaik <divya@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Sat, 05 Apr 2025 10:53:33 +0800,
Hilton Chain wrote:
>
> On Sun, 23 Mar 2025 15:23:04 +0800,
> Hilton Chain wrote:
> >
> I'll apply this series (except the documentation change, which will be tracked
> here separately) to rust-team when I have checked an initial set of packages.
>
> In case it's useful, I'm using this script to get a list of unstaged crates to
> look through:
> --8<---------------cut here---------------start------------->8---
> for i in $(git diff gnu/packages/rust-crates.scm | grep -E '^\+\(define rust-' | cut -f2 -d' ')
> do
>     guix build -e "(@@ (gnu packages rust-crates) $i)" -v0
> done
> --8<---------------cut here---------------end--------------->8---

Adjusted this script to open editor automatically until all files have been
opened:
--8<---------------cut here---------------start------------->8---
for i in $(git diff gnu/packages/rust-crates.scm | grep -E '^\+\(define rust-' | cut -f2 -d' ')
do
    file="$(guix build -e "(@@ (gnu packages rust-crates) $i)" -v0 2>/dev/null)"
    if [[ -n $file ]]; then
        $EDITOR $file
    fi
done
--8<---------------cut here---------------end--------------->8---

I use this script for an extra check, after addressing files reported by
check-for-pregenerated-files phase first.

The phase can't check source, a large number of pregenerated bindings exist and
are included as before.  Some crates are specificially made for this purpose as
well, I think we should have a clear policy for them.

I'll set a deadline (1 year?) to remove #:cargo-inputs support from
cargo-build-sytem.  Here're remaining users in our codebase:
--8<---------------cut here---------------start------------->8---
$ git grep -wc '#:cargo-.*inputs' gnu/packages
gnu/packages/bioinformatics.scm:3        wait python-team merge
gnu/packages/crates-apple.scm:84         dependencies
gnu/packages/crates-audio.scm:68         ...
gnu/packages/crates-check.scm:42         ...
gnu/packages/crates-compression.scm:115  ...
gnu/packages/crates-crypto.scm:355       ...
gnu/packages/crates-database.scm:80      ...
gnu/packages/crates-graphics.scm:346     ...
gnu/packages/crates-gtk.scm:348          ...
gnu/packages/crates-io.scm:5234          ...
gnu/packages/crates-shell.scm:51         ...
gnu/packages/crates-tls.scm:130          ...
gnu/packages/crates-vcs.scm:429          ...
gnu/packages/crates-web.scm:404          ...
gnu/packages/crates-windows.scm:146      ...
gnu/packages/crypto.scm:3                ...
gnu/packages/machine-learning.scm:11     wait python-team merge
gnu/packages/python-compression.scm:1    ...
gnu/packages/python-crypto.scm:1         ...
gnu/packages/python-science.scm:1        ...
gnu/packages/python-web.scm:1            ...
gnu/packages/python-xyz.scm:8            ...
gnu/packages/rust-apps.scm:96            TODO
gnu/packages/sequoia.scm:46              TODO
--8<---------------cut here---------------end--------------->8---

I have rebased rust-team to a recent master, this issue (#77093) will be an
extra blocker for merging the branch.

Don't keep too many changes to rust-crates.scm locally :)




Information forwarded to guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 5 Apr 2025 02:57:22 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Apr 04 22:57:22 2025
Received: from localhost ([127.0.0.1]:40868 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1u0tij-0002ST-RW
	for submit <at> debbugs.gnu.org; Fri, 04 Apr 2025 22:57:22 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:44376)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1u0tid-0002SC-BV
 for 77093 <at> debbugs.gnu.org; Fri, 04 Apr 2025 22:57:18 -0400
Date: Sat, 05 Apr 2025 10:53:33 +0800
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1743821833;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=Qv8tON6hpT9EfHJkzmVBIylIdEjajwpqVZD0J9MY33c=;
 b=JoyZfjjlk8AhD1nKyNFb7pA0UQUu+O53VeZCllONSHIADUtS6YcZpCvJDwdQdyPCNBGTcY
 7WKX5Bse72TfnSBD9K779Bw+lw2sN7sAn5X5cNfBpJ6WMadB1g1ue0gj8fo09RgnEVs0Fp
 5lY77Q9RtCvTcfqTlePmB5iVQDk+Y/9stlVxRv1/UNneVtAqDxbHziJsCnjWZtBVM8sEMi
 OAgP02IsfGqo1Uj0u3wDc3DOikTTCiwfIUOkafPY1VELM9lW8tMVUcbAjEHO1ZOpn2Evbd
 1+0fPWTtNMqIVbor/wZFv40qOuHqqPtRSZ940wXLENXHM+dmaYm9QC+l48IbGw==
Message-ID: <87r027xqs2.wl-hako@HIDDEN>
From: Hilton Chain <hako@HIDDEN>
To: 77093 <at> debbugs.gnu.org
Subject: Re: [PATCH rust-team v3 00/17] New Rust packaging workflow based on
 lockfile importer.
In-Reply-To: <cover.1742713356.git.hako@HIDDEN>
References: <cover.1742713356.git.hako@HIDDEN>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=ISO-8859-7
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Ludovic =?ISO-8859-1?Q?Court=E8s?= <ludo@HIDDEN>,
 Maxim Cournoyer <maxim.cournoyer@HIDDEN>, Steve George <steve@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>,
 Divya Ranjan Pattanaik <divya@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Sun, 23 Mar 2025 15:23:04 +0800,
Hilton Chain wrote:
>
> V2 -> V3:
> * Add Efraim's etc/teams/rust/audit-rust-crates script.
> * Add (guix import crate cargo-lock) to Rust team's scope.
> * =A1definer=A2 -> =A1define-prefix=A2
> * Adjust documentation and move examples to Guix Cookbook.
> * Document =A1cargo-inputs=A2 and remove mentioning of files under etc/te=
ams/rust.
>
> Diff inserted at end.
>
> Efraim Flashner (1):
>   build/cargo: Don't try to unpack sanity-check.py.
>
> Hilton Chain (16):
>   build/cargo: Pass =A1--offline=A2 to cargo.
>   build/cargo: Print out all non-empty binary files.
>   build-system: cargo: Support packaging Cargo workspace.
>   build-system: cargo: Support installing Cargo workspace.
>   build/cargo: Set default value of arguments for build phases.
>   build/cargo: Support non-workspace directory source inputs.
>   scripts: import: Document argument for =A1--insert=A2 option in help
>     message.
>   scripts: import: Add two newlines for =A1--insert=A2 option.
>   scripts: import: Support expressions defined by 'define.
>   scripts: import: Pass "--insert" to importers.
>   scripts: import: Skip existing definition for =A1--insert=A2 option.
>   import: crate: crate-name->package-name: Move to (guix build-system
>     cargo).
>   build-system: cargo: Add =A1cargo-inputs=A2.
>   import: crate: Add Cargo.lock parser.
>   import: crate: Add =A1--lockfile=A2 option.
>   doc: Document lockfile importer based Rust packaging workflow.
>
>  Makefile.am                       |   1 +
>  doc/contributing.texi             |  91 +++++---
>  doc/guix-cookbook.texi            | 352 ++++++++++++++++++++++++++++++
>  doc/guix.texi                     |  24 ++
>  etc/teams.scm                     |   1 +
>  etc/teams/rust/audit-rust-crates  |  70 ++++++
>  etc/teams/rust/cleanup-crates.sh  |  37 ++++
>  etc/teams/rust/rust-crates.tmpl   |  42 ++++
>  gnu/local.mk                      |   2 +
>  gnu/packages/rust-crates.scm      |  42 ++++
>  gnu/packages/rust-sources.scm     |  29 +++
>  guix/build-system/cargo.scm       |  59 ++++-
>  guix/build/cargo-build-system.scm | 150 +++++++++----
>  guix/import/crate.scm             |  81 ++++++-
>  guix/import/crate/cargo-lock.scm  | 105 +++++++++
>  guix/scripts/import.scm           |  54 +++--
>  guix/scripts/import/crate.scm     |  58 ++++-
>  guix/utils.scm                    |  29 ++-
>  tests/crate.scm                   |  88 ++++++++
>  19 files changed, 1209 insertions(+), 106 deletions(-)
>  create mode 100755 etc/teams/rust/audit-rust-crates
>  create mode 100755 etc/teams/rust/cleanup-crates.sh
>  create mode 100644 etc/teams/rust/rust-crates.tmpl
>  create mode 100644 gnu/packages/rust-crates.scm
>  create mode 100644 gnu/packages/rust-sources.scm
>  create mode 100644 guix/import/crate/cargo-lock.scm

I'll apply this series (except the documentation change, which will be trac=
ked
here separately) to rust-team when I have checked an initial set of package=
s.

In case it's useful, I'm using this script to get a list of unstaged crates=
 to
look through:
--8<---------------cut here---------------start------------->8---
for i in $(git diff gnu/packages/rust-crates.scm | grep -E '^\+\(define rus=
t-' | cut -f2 -d' ')
do
    guix build -e "(@@ (gnu packages rust-crates) $i)" -v0
done
--8<---------------cut here---------------end--------------->8---

Thanks




Information forwarded to guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 25 Mar 2025 09:23:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 25 05:23:03 2025
Received: from localhost ([127.0.0.1]:36261 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tx0Ux-0001ms-6f
	for submit <at> debbugs.gnu.org; Tue, 25 Mar 2025 05:23:03 -0400
Received: from hera.aquilenet.fr ([185.233.100.1]:45248)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <ludo@HIDDEN>) id 1tx0Uv-0001m9-9L
 for 77093 <at> debbugs.gnu.org; Tue, 25 Mar 2025 05:23:02 -0400
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 7DBEC490;
 Tue, 25 Mar 2025 10:22:54 +0100 (CET)
Authentication-Results: hera.aquilenet.fr;
	none
X-Virus-Scanned: Debian amavis at hera.aquilenet.fr
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavis, port 10024) with ESMTP
 id 5pbkBigXwHWr; Tue, 25 Mar 2025 10:22:53 +0100 (CET)
Received: from ribbon (unknown [193.50.110.142])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id E7F1D63F;
 Tue, 25 Mar 2025 10:22:52 +0100 (CET)
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Hilton Chain <hako@HIDDEN>
Subject: Re: [bug#77093] [PATCH rust-team 00/18] New Rust packaging workflow
 based on lockfile importer.
In-Reply-To: <cover.1742281797.git.hako@HIDDEN> (Hilton Chain's
 message of "Tue, 18 Mar 2025 15:16:05 +0800")
References: <cover.1742281797.git.hako@HIDDEN>
X-URL: http://www.fdn.fr/~lcourtes/
X-Revolutionary-Date: Quintidi 5 Germinal an 233 de la =?utf-8?Q?R=C3=A9vo?=
 =?utf-8?Q?lution=2C?= jour de la Poule
X-PGP-Key-ID: 0x090B11993D9AEBB5
X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc
X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4  0CFB 090B 1199 3D9A EBB5
X-OS: x86_64-pc-linux-gnu
Date: Tue, 25 Mar 2025 10:22:51 +0100
Message-ID: <87zfh9o45w.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Rspamd-Queue-Id: 7DBEC490
X-Spamd-Result: default: False [4.45 / 15.00]; SPAM_FLAG(5.00)[];
 BAYES_HAM(-3.00)[99.99%]; NEURAL_SPAM(2.55)[0.851];
 MIME_GOOD(-0.10)[text/plain]; TO_DN_SOME(0.00)[];
 FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2];
 RCVD_TLS_ALL(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[];
 TAGGED_RCPT(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[];
 RCVD_VIA_SMTP_AUTH(0.00)[]; MID_RHS_MATCH_FROM(0.00)[];
 FROM_HAS_DN(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com];
 RCPT_COUNT_THREE(0.00)[3];
 FREEMAIL_CC(0.00)[debbugs.gnu.org,gmail.com]
X-Spam-Level: ****
X-Rspamd-Action: no action
X-Spamd-Bar: ++++
X-Rspamd-Server: hera
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 77093
Cc: 77093 <at> debbugs.gnu.org, Maxim Cournoyer <maxim.cournoyer@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

Hi Hilton,

Hilton Chain <hako@HIDDEN> skribis:

> This series:
> * integrates cargo2guix (https://git.sr.ht/~look/cargo2guix) as a crate i=
mporter
>   option, =E2=80=98-f / --lockfile=3D=E2=80=99.
>
> * adds Cargo workspace support to cargo-build-system, via two new argumen=
ts:
>   #:cargo-package-crates and #:cargo-install-paths.
>
> * introduces a new Rust packaging workflow, as described in contributing.=
texi
>   change.

I hadn=E2=80=99t noticed this patch series but I=E2=80=99m really happy you=
=E2=80=99re working
on it, I think it can help make Rust packaging more sustainable. =F0=9F=91=
=8D

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:32:23 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 23 03:32:23 2025
Received: from localhost ([127.0.0.1]:47444 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twFoe-0004jV-HM
	for submit <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:32:23 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:54550)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1twFmJ-0004ET-UH
 for 77093 <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:29:55 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742714991;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=JiNwbKUrl7zsfQSvHZddejGeZQwk+CVEvwtXC14pCdk=;
 b=I39DQxxgZtDTKDE5TR92ggTTyDrG4NieIxzSDs+X/5ae5Cuwn1MaalaJS8EA7iGAdbUYSu
 wG0E2phwmhWzwj+3qO87rncyVIR40o5wDfTk6tw46p4By6VHWwBpzflGyRGTPbZWNUp9zA
 0ZrjMNwY70NiSx0uNE6/m1BXfWOL+iULG2nGK/Zuh+lnWoP9fHVoLd1kqbrdEAL2QFtjzU
 4T2iUIcWWl03TIxhsxlXk31HAiHF5Wpdyq+k6fqLdHbIMW6soY8IePC3bKwBqZ7YSqO6ph
 puDBipMUd130LAjuyEVdGUvkHH6FI9LSOmEIJkclztdYU/kvRyg75OHKZAwlEw==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v3 17/17] doc: Document lockfile importer based Rust
 packaging workflow.
Date: Sun, 23 Mar 2025 15:28:39 +0800
Message-ID: <71cbf5b40992439fd6e7f52daac0b63d61edf1d4.1742713356.git.hako@HIDDEN>
In-Reply-To: <cover.1742713356.git.hako@HIDDEN>
References: <cover.1742713356.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Ludovic Courtès <ludo@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.7 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.3 (/)

* doc/contributing.texi (Packaging Guidelines)[Rust Crates]: Update
documentation.
* doc/guix-cookbook.texi (Packaging)[Packaging Workflow]: New section.

Change-Id: Ic0c6378cf5f5df97d6f8bdd040b486be62c7bddc
---
 doc/contributing.texi  |  91 ++++++++---
 doc/guix-cookbook.texi | 352 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 418 insertions(+), 25 deletions(-)

diff --git a/doc/contributing.texi b/doc/contributing.texi
index ab4f30d54b..17f22390d5 100644
--- a/doc/contributing.texi
+++ b/doc/contributing.texi
@@ -1600,34 +1600,75 @@ Rust Crates
 @subsection Rust Crates
 
 @cindex rust
-Rust programs standing for themselves are named as any other package, using the
-lowercase upstream name.
+Rust programs (binary crates) and dependencies (library crates) are treated
+separately.  We put our main efforts into programs and only package Rust
+dependencies as sources, utilizing automation with a manual focus on unbundling
+vendored dependencies.  The following paragraphs will explain them and give
+several examples.
 
-To prevent namespace collisions we prefix all other Rust packages with the
-@code{rust-} prefix.  The name should be changed to lowercase as appropriate and
-dashes should remain in place.
+Rust programs are treated like any other package and named using the lowercase
+upstream name.  When using the Cargo build system (@pxref{Build Systems,
+@code{cargo-build-system}}), Rust programs should have @code{#:install-source?}
+argument set to @code{#f}, as this argument only makes sense for dependencies.
+When the package source is a Cargo workspace, @code{#:cargo-install-paths} must
+be set to enable relevant support.
+
+Rust dependencies are managed in two modules:
+
+@enumerate
+@item
+@code{(gnu packages rust-crates)}, storing source definitions imported from Rust
+programs' @file{Cargo.lock} via the lockfile importer (@pxref{Invoking guix
+import, @code{crate}, @code{--lockfile=@var{file}}}).
+
+Imported definitions must be checked and have vendored sources unbundled before
+being contributed to Guix.  This module is managed by the Rust team
+(@pxref{Teams}).
+
+@item
+@code{(gnu packages rust-sources)}, storing more complex definitions that need
+to be full packages.  This includes Rust dependencies requiring external inputs
+to unbundle and Cargo workspaces.
+
+These dependencies should have the @code{#:skip-build?} argument set to
+@code{#t}.  For Cargo workspaces, @code{#:cargo-package-crates} must be set.
+
+Since they are added manually, the following naming convention applies:
+
+To prevent namespace collisions they are named with @code{rust-} prefix.  The
+name should be changed to lowercase as appropriate and dashes should remain in
+place.
 
 In the rust ecosystem it is common for multiple incompatible versions of a
-package to be used at any given time, so all package definitions should have a
-versioned suffix.  The versioned suffix is the left-most non-zero digit (and
-any leading zeros, of course).  This follows the ``caret'' version scheme
-intended by Cargo.  Examples@: @code{rust-clap-2}, @code{rust-rand-0.6}.
-
-Because of the difficulty in reusing rust packages as pre-compiled inputs for
-other packages the Cargo build system (@pxref{Build Systems,
-@code{cargo-build-system}}) presents the @code{#:cargo-inputs} and
-@code{cargo-development-inputs} keywords as build system arguments.  It would be
-helpful to think of these as similar to @code{propagated-inputs} and
-@code{native-inputs}.  Rust @code{dependencies} and @code{build-dependencies}
-should go in @code{#:cargo-inputs}, and @code{dev-dependencies} should go in
-@code{#:cargo-development-inputs}.  If a Rust package links to other libraries
-then the standard placement in @code{inputs} and the like should be used.
-
-Care should be taken to ensure the correct version of dependencies are used; to
-this end we try to refrain from skipping the tests or using @code{#:skip-build?}
-when possible.  Of course this is not always possible, as the package may be
-developed for a different Operating System, depend on features from the Nightly
-Rust compiler, or the test suite may have atrophied since it was released.
+package to be used at any given time, so all dependencies should have a
+versioned suffix.  The versioned suffix is the left-most non-zero digit (and any
+leading zeros, of course).  This follows the ``caret'' version scheme intended
+by Cargo.  Examples@: @code{rust-clap-2}, @code{rust-rand-0.6}.
+
+In practice we are usually packaging development snapshots of Rust dependencies
+specifically for some Rust programs, and can't simply identity them by version.
+In this case we can use a @code{for-@var{program}} suffix, for example,
+@code{rust-pipewire-for-niri} and @code{rust-pubgrub-for-uv}.
+@end enumerate
+
+Rust dependencies are not referenced directly.  @code{(guix build-sytem cargo)}
+provides a @code{cargo-inputs} procedure to create an input list, in combination
+with the lockfile importer.
+
+@cindex cargo-inputs
+@deffn {Procedure} cargo-inputs @var{name} @
+       [#:crates-module '(gnu packages rust-crates)] @
+       [#:sources-module '(gnu packages rust-sources)]
+Given symbol @code{'@var{name}}, resolve variable
+@code{@var{name}-cargo-inputs}, an input list, in @var{crates-module}, return
+its copy with @code{#f} removed and symbols resolved to variables defined in
+@var{sources-module} if the input list exists, otherwise return an empty list.
+
+@var{name} must be consistent with the one used in lockfile importer invocation.
+@end deffn
+
+For a more detailed packaging workflow, @pxref{Packaging Rust Crates,,,
+guix-cookbook, GNU Guix Cookbook}.
 
 
 @node Elm Packages
diff --git a/doc/guix-cookbook.texi b/doc/guix-cookbook.texi
index d9b98a2ab3..1f0e5eee54 100644
--- a/doc/guix-cookbook.texi
+++ b/doc/guix-cookbook.texi
@@ -103,6 +103,7 @@ Top
 Packaging
 
 * Packaging Tutorial::          A tutorial on how to add packages to Guix.
+* Packaging Workflows::         Real life examples on working with specific build systems.
 
 Packaging Tutorial
 
@@ -127,6 +128,16 @@ Top
 * Automatic update::
 * Inheritance::
 
+Packaging Workflows
+
+* Packaging Rust Crates::
+
+Packaging Rust Crates
+
+* Common Workflow for Packaging Rust Crates::
+* Development Snapshots and Cargo Workspaces::
+* Rust Programs With Mixed Build Systems::
+
 System Configuration
 
 * Auto-Login to a Specific TTY::  Automatically Login a User to a Specific TTY
@@ -514,6 +525,7 @@ Packaging
 
 @menu
 * Packaging Tutorial::          A tutorial on how to add packages to Guix.
+* Packaging Workflows::         Real life examples on working with specific build systems.
 @end menu
 
 @node Packaging Tutorial
@@ -1593,6 +1605,346 @@ References
 @uref{https://www.gnu.org/software/guix/guix-ghm-andreas-20130823.pdf, ``GNU Guix: Package without a scheme!''}, by Andreas Enge
 @end itemize
 
+@node Packaging Workflows
+@section Packaging Workflows
+
+The following sections are real life examples on working with specific build
+systems, serving as extensions to the concise packaging guidelines
+(@pxref{Packaging Guidelines,,, guix, GNU Guix Reference Manual}).
+
+@menu
+* Packaging Rust Crates::
+@end menu
+
+@node Packaging Rust Crates
+@subsection Packaging Rust Crates
+
+In preparation, add the following packages to our environment:
+
+@example
+$ guix shell rust rust:cargo cargo-audit cargo-license
+@end example
+
+@menu
+* Common Workflow for Packaging Rust Crates::
+* Development Snapshots and Cargo Workspaces::
+* Rust Programs With Mixed Build Systems::
+@end menu
+
+@node Common Workflow for Packaging Rust Crates
+@subsubsection Common Workflow for Packaging Rust Crates
+
+In this example, we'll package @code{cargo-audit}, which is published on the
+@uref{https://crates.io, crates.io} Rust package repository.  All its
+dependencies are on crates.io as well.
+
+@enumerate
+@item
+Since @code{cargo-audit} is available on crates.io, We can generate a draft
+definition via the crates.io importer (@pxref{Invoking guix import,,, guix, GNU
+Guix Reference Manual}).  In the end we'll have the following definiton:
+
+@lisp
+(define-public cargo-audit
+  (package
+    (name "cargo-audit")
+    (version "0.21.2")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (crate-uri "cargo-audit" version))
+       (file-name (string-append name "-" version ".tar.gz"))
+       (sha256
+        (base32 "1a00yqpckkw86zh2hg7ra82c5fx0ird5766dyynimbvqiwg2ps0n"))))
+    (build-system cargo-build-system)
+    (arguments (list #:install-source? #f))
+    (inputs (cargo-inputs 'cargo-audit))
+    (home-page "https://rustsec.org/")
+    (synopsis "Audit Cargo.lock for crates with security vulnerabilities")
+    (description
+     "This package provides a Cargo subcommand, @@command@{cargo audit@}, to
+audit @@file@{Cargo.lock@} for crates with security vulnerabilities.")
+    (license (list license:asl2.0 license:expat))))
+@end lisp
+
+The symbol used in @code{cargo-inputs}, @code{'cargo-audit} here, must be a
+unique identifier, usually matching the variable name of the package.
+
+@item
+Unpack package source and navigate to the unpacked directory, then execute the
+following commands:
+
+@example
+$ cargo generate-lockfile
+$ cargo audit
+$ cargo license
+@end example
+
+@command{cargo generate-lockfile} updates dependencies to compatible versions,
+@command{cargo audit} checks known vulnerabilities and @command{cargo license}
+checks licenses of all dependencies.
+
+We must have an acceptable output of @command{cargo audit} and ensure all
+dependencies are licensed with our supported licenses (@pxref{Defining
+Packages,,, guix, GNU Guix Reference Manual}).
+
+@item
+Import dependencies from previously generated lockfile:
+
+@example
+$ guix import --insert=gnu/packages/rust-crates.scm \
+      crate --lockfile=/path/to/Cargo.lock cargo-audit
+@end example
+
+@code{cargo-audit} used here must be consistent with the identifier used for
+@code{cargo-inputs}.
+
+At this stage, package @code{cargo-audit} is buildable.
+
+@item
+Finally we'll unbundle vendored sources.  The lockfile importer inserts
+@code{TODO:} comments to dependencies with high probability of bundled sources.
+@code{cargo-build-system} also performs additional check in its
+@code{check-for-pregenerated-files} phase:
+
+@example
+$ ./pre-inst-env guix build cargo-audit
+@dots{}
+starting phase `check-for-pregenerated-files'
+Searching for binary files...
+./guix-vendor/rust-addr2line-0.21.0.tar.gz/rustfmt.toml
+./guix-vendor/rust-arc-swap-1.7.1.tar.gz/rustfmt.toml
+./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/dictionary-rust
+./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/dictionary-rust-other
+./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/lib.rs.zst
+./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/long-window-size-lib.rs.zst
+@dots{}
+@end example
+
+Although dependencies in @code{(gnu packages rust-crates)} are not exported, we
+can still select them via the Guix command-line interface through expression:
+
+@example
+$ guix build --expression='(@@@@ (gnu packages rust-crates) rust-ring-0.17.14)'
+@end example
+
+For most dependencies, a snippet is sufficient:
+
+@lisp
+(define rust-bzip2-sys-0.1.13+1.0.8
+  (crate-source "bzip2-sys" "0.1.13+1.0.8"
+                "056c39pgjh4272bdslv445f5ry64xvb0f7nph3z7860ln8rzynr2"
+                #:snippet
+                '(begin
+                   (delete-file-recursively "bzip2-1.0.8")
+                   (delete-file "build.rs")
+                   ;; Inspired by Debian's patch.
+                   (with-output-to-file "build.rs"
+                     (lambda _
+                       (format #t "fn main() @{~@@
+                        println!(\"cargo:rustc-link-lib=bz2\");~@@
+                        @}~%"))))))
+@end lisp
+
+In a more complex case, where unbundling one dependency requires other packages,
+we should package the dependency in @code{(gnu packages rust-sources)} first and
+reference it by a symbol in the imported definition.
+
+For example we have defined a @code{rust-ring-0.17} in @code{(gnu packages
+rust-sources)}, then the imported definition in @code{(gnu packages
+rust-crates)} should be modified to a matching symbol.
+
+@lisp
+(define rust-ring-0.17.14 'rust-ring-0.17)
+@end lisp
+
+When one dependency can be safely removed, modify it to @code{#f}.
+
+@lisp
+(define rust-openssl-src-300.4.2+3.4.1 #f)
+@end lisp
+@end enumerate
+
+@node Development Snapshots and Cargo Workspaces
+@subsubsection Development Snapshots and Cargo Workspaces
+
+In this example, we'll package @code{niri}, which depends on development
+snapshots (also Cargo workspaces here).
+
+As we can't ensure compatibility of a development snapshot, before executing
+@command{cargo generate-lockfile}, we should modify @file{Cargo.toml} to pin it
+to a known working revision.
+
+To use our packaged development snapshots, it's also necessary to modify
+@file{Cargo.toml} in a build phase, with a package-specific substitution
+pattern.
+
+@lisp
+(define-public niri
+  (package
+   (name "niri")
+   (version "25.02")
+   (source (origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/YaLTeR/niri")
+                   (commit (string-append "v" version))))
+             (file-name (git-file-name name version))
+             (sha256
+              (base32
+               "0vzskaalcz6pcml687n54adjddzgf5r07gggc4fhfsa08h1wfd4r"))))
+   (build-system cargo-build-system)
+   (arguments
+    (list #:install-source? #f
+          #:phases
+          #~(modify-phases %standard-phases
+              (add-after 'unpack 'use-guix-vendored-dependencies
+                (lambda _
+                  (substitute* "Cargo.toml"
+                    (("# version =.*")
+                     "version = \"*\"")
+                    (("git.*optional")
+                     "version = \"*\", optional")
+                    (("^git = .*")
+                     "")))))))
+   (native-inputs
+    (list pkg-config))
+   (inputs
+    (cons* clang
+           libdisplay-info
+           libinput-minimal
+           libseat
+           libxkbcommon
+           mesa
+           pango
+           pipewire
+           wayland
+           (cargo-inputs 'niri)))
+   (home-page "https://github.com/YaLTeR/niri")
+   (synopsis "Scrollable-tiling Wayland compositor")
+   (description
+    "Niri is a scrollable-tiling Wayland compositor which arranges windows in a
+scrollable format.  It is considered stable for daily use and performs most
+functions expected of a Wayland compositor.")
+   (license license:gpl3+)))
+@end lisp
+
+@code{niri} has Cargo workspace dependencies.  When packaging a Cargo workspace,
+argument @code{#:cargo-package-crates} is required.
+
+@lisp
+(define-public rust-pipewire-for-niri
+  (let ((commit "fd3d8f7861a29c2eeaa4c393402e013578bb36d9")
+        (revision "0"))
+    (package
+      (name "rust-pipewire")
+      (version (git-version "0.8.0" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://gitlab.freedesktop.org/pipewire/pipewire-rs.git")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32 "1hzyhz7xg0mz8a5y9j6yil513p1m610q3j9pzf6q55vdh5mcn79v"))))
+      (build-system cargo-build-system)
+      (arguments
+       (list #:skip-build? #t
+             #:cargo-package-crates
+             ''("libspa-sys" "libspa" "pipewire-sys" "pipewire")))
+      (inputs (cargo-inputs 'rust-pipewire-for-niri))
+      (home-page "https://pipewire.org/")
+      (synopsis "Rust bindings for PipeWire")
+      (description "This package provides Rust bindings for PipeWire.")
+      (license license:expat))))
+@end lisp
+
+Don't forget to modify all workspace members in @code{(gnu packages
+rust-crates)}:
+
+@lisp
+(define rust-pipewire-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
+(define rust-pipewire-sys-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
+@dots{}
+(define rust-libspa-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
+(define rust-libspa-sys-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
+@end lisp
+
+@node Rust Programs With Mixed Build Systems
+@subsubsection Rust Programs With Mixed Build Systems
+
+In this example, we'll package @code{fish}, which combines two build systems.
+
+When building Rust packages in other build systems, we need to add @code{rust}
+and @code{rust:cargo} to @code{native-inputs}, import and use modules from both
+build systems, and apply necessary build phases from @code{cargo-build-system}.
+
+@lisp
+(define-public fish
+  (package
+    (name "fish")
+    (version "4.0.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://github.com/fish-shell/fish-shell/"
+                           "releases/download/" version "/"
+                           "fish-" version ".tar.xz"))
+       (sha256
+        (base32 "1wv9kjwg6ax8m2f85i58l9f9cndshn1f15n8skc68w1mf3cmpnig"))))
+    (build-system cmake-build-system)
+    (inputs
+     (cons* fish-foreign-env ncurses pcre2
+            python                    ;for fish_config and manpage completions
+            (cargo-inputs 'fish)))
+    (native-inputs
+     (list doxygen groff                ;for 'fish --help'
+           pkg-config
+           procps                       ;for the test suite
+           rust
+           `(,rust "cargo")))
+    (arguments
+     (list #:imported-modules
+           (append %cargo-build-system-modules
+                   %cmake-build-system-modules)
+           #:modules
+           (((guix build cargo-build-system) #:prefix cargo:)
+            (guix build cmake-build-system)
+            (guix build utils))
+           #:phases
+           #~(modify-phases %standard-phases
+               (add-after 'unpack 'use-guix-vendored-dependencies
+                 (lambda _
+                   (substitute* "Cargo.toml"
+                     (("git.*tag.*,")
+                      "version = \"*\","))))
+               (add-after 'unpack 'prepare-cargo-build-system
+                 (lambda args
+                   (for-each
+                    (lambda (phase)
+                      (format #t "Running cargo phase: ~a~%" phase)
+                      (apply (assoc-ref cargo:%standard-phases phase)
+                             args))
+                    '(unpack-rust-crates
+                      configure
+                      check-for-pregenerated-files
+                      patch-cargo-checksums)))))))
+    (synopsis "The friendly interactive shell")
+    (description
+     "Fish (friendly interactive shell) is a shell focused on interactive use,
+discoverability, and friendliness.  Fish has very user-friendly and powerful
+tab-completion, including descriptions of every completion, completion of
+strings with wildcards, and many completions for specific commands.  It also
+has extensive and discoverable help.  A special @@command@{help@} command gives
+access to all the fish documentation in your web browser.  Other features
+include smart terminal handling based on terminfo, an easy to search history,
+and syntax highlighting.")
+    (home-page "https://fishshell.com/")
+    (license license:gpl2)))
+@end lisp
+
+
 @c *********************************************************************
 @node System Configuration
 @chapter System Configuration
-- 
2.49.0





Information forwarded to ludo@HIDDEN, maxim.cournoyer@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:30:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 23 03:30:11 2025
Received: from localhost ([127.0.0.1]:47368 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twFma-0004Jn-Da
	for submit <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:30:11 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:40062)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1twFmI-0004EA-2l
 for 77093 <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:29:50 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742714989;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=sLJzYPGfO+QkRVtxgTvXJbYwUKaAeoBjRxGqIariPi0=;
 b=R6IyhD+OlTa8VCB2/0Pzzddok9Rt6Z7FtSSrY9zHAMtfhWdoVmxpm8QIdK9ibN/AnSSc2m
 NikQtlly/ro2mtdvRe3719bSSGGW1NqIF8UTz0XMaNcVIJjuGVSUELTRCZLbMHbtFNtTT+
 NHuUjg5QgVH9mchnaRYyi6CNiHoTJI9CuT8tWSS5rCy3L+WSdUMbn7g7zgUosgBP9PbfVP
 niWFsIbe/UujIHy8fYLzsKlLJR6BwSyHyBPF7j7DSZBJgUUnSxHQwHqsEKceGs2TMruVZ6
 38X1pswhScvVMc3FSp3Blyk/X2rw6y4DWTVVurGTkTNrjeZIUp6T+e2ngbW9/g==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v3 16/17] =?UTF-8?q?import:=20crate:=20Add=20?=
 =?UTF-8?q?=E2=80=98--lockfile=E2=80=99=20option.?=
Date: Sun, 23 Mar 2025 15:28:38 +0800
Message-ID: <81adafb3ac10a3b522c2e1949a91351f34216a9e.1742713356.git.hako@HIDDEN>
In-Reply-To: <cover.1742713356.git.hako@HIDDEN>
References: <cover.1742713356.git.hako@HIDDEN>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
X-Debbugs-Cc: Christopher Baines <guix@HIDDEN>, Divya Ranjan Pattanaik <divya@HIDDEN>, Efraim Flashner <efraim@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Steve George <steve@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/scripts/import/crate.scm (%options): Add ‘--lockfile’ option.
* guix/scripts/import/crate.scm (show-help): Add it.
(guix-import-crate): Use it.
* doc/guix.texi (Invoking guix import): Document it.
* tests/crate.scm (temp-file): New variable.
("crate-lockfile-import"): New test.

Change-Id: I291478e04adf9f2df0bf216425a5e8aeba0bedd9
---
 doc/guix.texi                 | 14 ++++++
 guix/scripts/import/crate.scm | 58 +++++++++++++++++++----
 tests/crate.scm               | 88 +++++++++++++++++++++++++++++++++++
 3 files changed, 150 insertions(+), 10 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 7fa986b4b9..218c2ba630 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -14703,6 +14703,20 @@ Invoking guix import
 If a crate dependency is not (yet) packaged, make the corresponding
 input in @code{#:cargo-inputs} or @code{#:cargo-development-inputs} into
 a comment.
+@item --lockfile=@var{file}
+@itemx -f @var{file}
+When @option{--lockfile} is specified, the importer will ignore other options
+and won't output package definitions, instead generating source definitions for
+all dependencies in @var{file}, a @file{Cargo.lock} file.  For example:
+
+@example
+guix import crate --lockfile=/path/to/Cargo.lock my-package
+@end example
+
+generates sources from @file{/path/to/Cargo.lock} and a list
+@code{my-package-cargo-inputs} referencing these sources.  The generated list is
+intended for the package's @code{inputs}, replacing @code{#:cargo-inputs} and
+@code{#:cargo-development-inputs}.
 @end table
 
 @item elm
diff --git a/guix/scripts/import/crate.scm b/guix/scripts/import/crate.scm
index 723cbb3665..3b536e135a 100644
--- a/guix/scripts/import/crate.scm
+++ b/guix/scripts/import/crate.scm
@@ -25,11 +25,13 @@
 (define-module (guix scripts import crate)
   #:use-module (guix ui)
   #:use-module (guix utils)
+  #:use-module (guix read-print)
   #:use-module (guix scripts)
   #:use-module (guix import crate)
   #:use-module (guix scripts import)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-11)
+  #:use-module (srfi srfi-26)
   #:use-module (srfi srfi-37)
   #:use-module (ice-9 match)
   #:use-module (ice-9 format)
@@ -60,6 +62,9 @@ (define (show-help)
                          sufficient package exists for it"))
   (newline)
   (display (G_ "
+  -f, --lockfile=FILE    import dependencies from FILE, a 'Cargo.lock' file"))
+  (newline)
+  (display (G_ "
   -h, --help             display this help and exit"))
   (display (G_ "
   -V, --version          display version information and exit"))
@@ -87,6 +92,9 @@ (define %options
          (option '("mark-missing") #f #f
                  (lambda (opt name arg result)
                    (alist-cons 'mark-missing #t result)))
+         (option '(#\f "lockfile") #f #t
+                 (lambda (opt name arg result)
+                   (alist-cons 'lockfile arg result)))
          %standard-import-options))
 
 
@@ -101,6 +109,8 @@ (define (guix-import-crate . args)
                         #:build-options? #f))
 
   (let* ((opts (parse-options))
+         (lockfile (assoc-ref opts 'lockfile))
+         (file-to-insert (assoc-ref opts 'file-to-insert))
          (args (filter-map (match-lambda
                              (('argument . value)
                               value)
@@ -111,16 +121,44 @@ (define (guix-import-crate . args)
        (define-values (name version)
          (package-name->name+version spec))
 
-       (match (if (assoc-ref opts 'recursive)
-                  (crate-recursive-import
-                   name #:version version
-                   #:recursive-dev-dependencies?
-                   (assoc-ref opts 'recursive-dev-dependencies)
-                   #:allow-yanked? (assoc-ref opts 'allow-yanked))
-                  (crate->guix-package
-                   name #:version version #:include-dev-deps? #t
-                   #:allow-yanked? (assoc-ref opts 'allow-yanked)
-                   #:mark-missing? (assoc-ref opts 'mark-missing)))
+       (match (cond
+               ((and=> lockfile
+                       (lambda (file)
+                         (or (file-exists? file)
+                             (leave (G_ "file '~a' does not exist~%") file))))
+                (let-values (((crate-definitions input-list)
+                              (cargo-lock->definitions lockfile name)))
+                  (if file-to-insert
+                      ;; Adjusted from ‘--insert’ option of guix-import.
+                      (let ((term (second input-list)))
+                        (begin
+                          ;; Remove existing input list definition.
+                          (and=> (find-definition-location file-to-insert term)
+                                 delete-expression)
+                          ;; Insert input list alphabetically.
+                          (or (and=> (find-definition-insertion-location
+                                      file-to-insert term)
+                                     (cut insert-expression <> input-list))
+                              (let ((port (open-file file-to-insert "a")))
+                                (newline port)
+                                (pretty-print-with-comments port input-list)
+                                (newline port)
+                                (newline port)
+                                (close-port port))))
+                        crate-definitions)
+                      `(,@crate-definitions
+                        ,input-list))))
+               ((assoc-ref opts 'recursive)
+                (crate-recursive-import
+                 name #:version version
+                 #:recursive-dev-dependencies?
+                 (assoc-ref opts 'recursive-dev-dependencies)
+                 #:allow-yanked? (assoc-ref opts 'allow-yanked)))
+               (else
+                (crate->guix-package
+                 name #:version version #:include-dev-deps? #t
+                 #:allow-yanked? (assoc-ref opts 'allow-yanked)
+                 #:mark-missing? (assoc-ref opts 'mark-missing))))
          ((or #f '())
           (leave (G_ "failed to download meta-data for package '~a'~%")
                  (if version
diff --git a/tests/crate.scm b/tests/crate.scm
index d0dc779cd2..9b7066c3b1 100644
--- a/tests/crate.scm
+++ b/tests/crate.scm
@@ -34,6 +34,7 @@ (define-module (test-crate)
   #:use-module (gnu packages)
   #:use-module (ice-9 iconv)
   #:use-module (ice-9 match)
+  #:use-module (srfi srfi-11)
   #:use-module (srfi srfi-64))
 
 
@@ -476,6 +477,9 @@ (define rust-leaf-bob-3.0.2-yanked
     (description #f)
     (license #f)))
 
+(define temp-file
+  (string-append "t-crate-" (number->string (getpid))))
+
 
 (test-begin "crate")
 
@@ -1178,4 +1182,88 @@ (define rust-leaf-bob-3.0.2-yanked
           (x
            (pk 'fail (pretty-print-with-comments (current-output-port) x) #f)))))
 
+
+(test-assert "crate-lockfile-import"
+  (begin
+    (call-with-output-file temp-file
+      (lambda (port)
+        (display "\
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = \"adler2\"
+version = \"2.0.0\"
+source = \"registry+https://github.com/rust-lang/crates.io-index\"
+checksum = \"512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627\"
+
+[[package]]
+name = \"aho-corasick\"
+version = \"1.1.3\"
+source = \"registry+https://github.com/rust-lang/crates.io-index\"
+checksum = \"8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916\"
+dependencies = [
+ \"memchr\",
+]
+
+[[package]]
+name = \"smithay\"
+version = \"0.4.0\"
+source = \"git+https://github.com/Smithay/smithay.git?rev=\
+0cd3345c59f7cb139521f267956a1a4e33248393#\
+0cd3345c59f7cb139521f267956a1a4e33248393\"
+dependencies = [
+ \"appendlist\",
+]
+
+[[package]]
+name = \"test\"
+version = \"25.2.0\"\n" port)))
+    (mock
+     ((guix scripts download) guix-download
+      (lambda _
+        (format #t "~a~%~a~%"
+                "/gnu/store/in056fyrz6nvy3jpxrxglgj30g0lwniv-smithay-0cd3345"
+                "191h87bpzg0l1ihfb4hmx00b86pfb5mwwc6s8i49al0vigc14l37")))
+     (let-values
+         (((crates-definitions input-list)
+           (cargo-lock->definitions temp-file "test")))
+       (and
+        (match crates-definitions
+          (((define 'rust-adler2-2.0.0
+              (crate-source
+               "adler2" "2.0.0"
+               "09r6drylvgy8vv8k20lnbvwq8gp09h7smfn6h1rxsy15pgh629si"))
+            (define 'rust-aho-corasick-1.1.3
+              (crate-source
+               "aho-corasick" "1.1.3"
+               "05mrpkvdgp5d20y2p989f187ry9diliijgwrs254fs9s1m1x6q4f"))
+            (define 'rust-smithay-0.4.0.0cd3345
+              ($ <comment>
+                 ";; TODO: Define standalone package if this is a workspace.\n"
+                 #f)
+              (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/Smithay/smithay.git")
+                      (commit "0cd3345c59f7cb139521f267956a1a4e33248393")))
+                (file-name (git-file-name "rust-smithay" "0.4.0.0cd3345"))
+                (sha256
+                 (base32
+                  "191h87bpzg0l1ihfb4hmx00b86pfb5mwwc6s8i49al0vigc14l37")))))
+           #t)
+          (x
+           (pk 'fail (pretty-print-with-comments (current-output-port) x) #f)))
+        (match input-list
+          ((define-public 'test-cargo-inputs
+             (list rust-adler2-2.0.0
+                   rust-aho-corasick-1.1.3
+                   rust-smithay-0.4.0.0cd3345))
+           #t)
+          (x
+           (pk 'fail x #f))))))))
+
 (test-end "crate")
+
+(false-if-exception (delete-file temp-file))
-- 
2.49.0





Information forwarded to guix@HIDDEN, divya@HIDDEN, efraim@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, maxim.cournoyer@HIDDEN, zimon.toutoune@HIDDEN, steve@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:30:08 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 23 03:30:08 2025
Received: from localhost ([127.0.0.1]:47361 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twFmW-0004I0-Oh
	for submit <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:30:08 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:40058)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1twFmG-0004Du-8c
 for 77093 <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:29:49 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742714987;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=aVHLOZmV4I/qcACy1bMCS4p3weOyVcxLn/v5Effmdss=;
 b=Cz814f2WlHfmTMNma8tZqVkAG5bA+4Sb7HAqCbVLABqt5M0ltYta9/Hv6LcR7ui1FhyUO7
 DeD26FQaRyStjOVtAedQ4IEtdsT3M7M++4zWLvtbNK9S+hd9xp0KACFzdrgRrwDb9bc40D
 Qx/yXIjrpL0/zckEyHEN1K5hjRtH65Fzi2xA5uSuY6Xpk3gCC3/XVmU7IiA+57YyIZbahi
 cKf+zCbaMPZTg+q3+Sp1hgFbc5fntgZgutwNvIIK+P6FMGWG/L5hYDM/rDRdZZ1xn0LqeE
 rAXmYc6w4us/vkBzncQVPbfjWOoKzwlgsAA1/nc8Tqevz9wUQZB8tkKdkcD3Yg==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v3 15/17] import: crate: Add Cargo.lock parser.
Date: Sun, 23 Mar 2025 15:28:37 +0800
Message-ID: <52f74fa07c2b1671769f33aadd28037732062d79.1742713356.git.hako@HIDDEN>
In-Reply-To: <cover.1742713356.git.hako@HIDDEN>
References: <cover.1742713356.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Divya Ranjan Pattanaik <divya@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>, Steve George <steve@HIDDEN>
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Murilo <murilo@HIDDEN>, Hilton Chain <hako@HIDDEN>,
 Luis Guilherme Coelho <lgcoelho@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/import/crate/cargo-lock.scm: New file.
* Makefile.am (MODULES): Regisiter it.
* etc/teams.scm (rust)[#:scope]: Add it.
* guix/import/crate.scm (cargo-lock->definitions): New procedure.

Co-authored-by: Murilo <murilo@HIDDEN>
Co-authored-by: Luis Guilherme Coelho <lgcoelho@HIDDEN>
Change-Id: I95421e9e2ba11a671b4bc4e1323c6d31a1b012c5
---
 Makefile.am                      |   1 +
 etc/teams.scm                    |   1 +
 guix/import/crate.scm            |  78 +++++++++++++++++++++++
 guix/import/crate/cargo-lock.scm | 105 +++++++++++++++++++++++++++++++
 4 files changed, 185 insertions(+)
 create mode 100644 guix/import/crate/cargo-lock.scm

diff --git a/Makefile.am b/Makefile.am
index 4091a52387..a04e461ea8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -295,6 +295,7 @@ MODULES =					\
   guix/import/cpan.scm				\
   guix/import/cran.scm				\
   guix/import/crate.scm				\
+  guix/import/crate/cargo-lock.scm		\
   guix/import/egg.scm   			\
   guix/import/elm.scm				\
   guix/import/elpa.scm   			\
diff --git a/etc/teams.scm b/etc/teams.scm
index 6bddbd91fa..c4bee8d3d9 100755
--- a/etc/teams.scm
+++ b/etc/teams.scm
@@ -389,6 +389,7 @@ (define-team rust
                       "guix/build/cargo-utils.scm"
                       "guix/build-system/cargo.scm"
                       "guix/import/crate.scm"
+                      "guix/import/crate/cargo-lock.scm"
                       "guix/scripts/import/crate.scm"
                       "tests/crate.scm")))
 
diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index a6f247bbae..ef3a6d0b4b 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -9,6 +9,9 @@
 ;;; Copyright © 2023, 2024 David Elsing <david.elsing@HIDDEN>
 ;;; Copyright © 2024 Maxim Cournoyer <maxim.cournoyer@HIDDEN>
 ;;; Copyright © 2025 Herman Rimm <herman@HIDDEN>
+;;; Copyright © 2024 Murilo <murilo@HIDDEN>
+;;; Copyright © 2024-2025 Luis Guilherme Coelho <lgcoelho@HIDDEN>
+;;; Copyright © 2025 Hilton Chain <hako@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -26,12 +29,14 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (guix import crate)
+  #:use-module (guix base16)
   #:use-module (guix base32)
   #:use-module ((guix build-system cargo) #:hide (crate-source))
   #:use-module (guix diagnostics)
   #:use-module (gcrypt hash)
   #:use-module (guix http-client)
   #:use-module (guix i18n)
+  #:use-module (guix import crate cargo-lock)
   #:use-module (guix import json)
   #:use-module (guix import utils)
   #:use-module (guix memoization)
@@ -39,9 +44,11 @@ (define-module (guix import crate)
   #:use-module (guix read-print)
   #:use-module (guix upstream)
   #:use-module (guix utils)
+  #:use-module (guix scripts download)
   #:use-module (gnu packages)
   #:use-module (ice-9 match)
   #:use-module (ice-9 regex)
+  #:use-module (ice-9 textual-ports)
   #:use-module (json)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-2)
@@ -52,6 +59,7 @@ (define-module (guix import crate)
             guix-package->crate-name
             string->license
             crate-recursive-import
+            cargo-lock->definitions
             %crate-updater))
 
 
@@ -481,6 +489,76 @@ (define (guix-package->crate-name package)
     (match parts
       ((name _ ...) name))))
 
+
+;;;
+;;; Convert ‘Cargo.lock’ to Guix sources.
+;;;
+
+(define (cargo-lock->definitions lockfile package-name)
+  "Given LOCKFILE, a 'Cargo.lock' file, convert its content into source
+definitions.  Return a list of sources and 'PACKAGE-NAME-cargo-inputs', an input
+list referencing all imported sources."
+  (define (crate->definition crate)
+    (match crate
+      (('crate
+        ('crate-name name)
+        ('crate-version version)
+        ('crate-source _)
+        ('crate-checksum checksum))
+       `(define
+          ,(string->symbol
+            (string-append (crate-name->package-name name) "-" version))
+          ,@(if (or (string-suffix? "src" name)
+                    (string-suffix? "sys" name))
+                (list (comment ";; TODO: Check bundled sources.\n" #f))
+                '())
+          (crate-source ,name ,version
+                        ,(bytevector->nix-base32-string
+                          (base16-string->bytevector checksum)))))
+      ;; Git snapshot.
+      (('crate
+        ('crate-name name)
+        ('crate-version version)
+        ('crate-source source))
+       (begin
+         (let* ((src (string-split source (char-set #\+ #\? #\#)))
+                (url (second src))
+                (commit (last src))
+                (version (string-append version "." (string-take commit 7)))
+                (checksum
+                 (second
+                  (string-split
+                   (with-output-to-string
+                     (lambda _
+                       (guix-download "-g" url
+                                      (string-append "--commit=" commit))))
+                   #\newline))))
+           `(define
+              ,(string->symbol
+                (string-append (crate-name->package-name name) "-" version))
+              ,(comment
+                ";; TODO: Define standalone package if this is a workspace.\n"
+                #f)
+              (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url ,url)
+                      (commit ,commit)))
+                (file-name
+                 (git-file-name ,(crate-name->package-name name) ,version))
+                (sha256 (base32 ,checksum)))))))
+      ;; Workspace member.
+      (else #f)))
+
+  (let ((definitions
+          (filter-map crate->definition
+                      (cargo-lock-string->scm
+                       (call-with-input-file lockfile get-string-all)))))
+    (values definitions
+            `(define-public
+               ,(string->symbol (string-append package-name "-cargo-inputs"))
+               (list ,@(map second definitions))))))
+
 
 ;;;
 ;;; Updater
diff --git a/guix/import/crate/cargo-lock.scm b/guix/import/crate/cargo-lock.scm
new file mode 100644
index 0000000000..b8a6ab20c0
--- /dev/null
+++ b/guix/import/crate/cargo-lock.scm
@@ -0,0 +1,105 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2024 Murilo <murilo@HIDDEN>
+;;; Copyright © 2024 Luis Guilherme Coelho <lgcoelho@HIDDEN>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix import crate cargo-lock)
+  #:use-module (ice-9 peg)
+  #:export (cargo-lock-string->scm
+
+            crate-name
+            crate-version
+            crate-source
+            crate-checksum
+            crate-dependencies
+            cargo-lock))
+
+;;;
+;;; PEG parser for ‘Cargo.lock’.
+;;;
+
+(define (cargo-lock-string->scm str)
+  (peg:tree (search-for-pattern cargo-lock str)))
+
+;; Auxiliar peg patterns
+(define-peg-pattern numeric-char body
+  (range #\0 #\9))
+
+(define-peg-pattern lowercase-char body
+  (range #\a #\z))
+
+(define-peg-pattern uppercase-char body
+  (range #\A #\Z))
+
+(define-peg-pattern alphabetic-char body
+  (or lowercase-char uppercase-char))
+
+(define-peg-pattern alphanumeric-char body
+  (or alphabetic-char numeric-char))
+
+;; name
+(define-peg-pattern crate-name all
+  (+ (or "-" alphabetic-char
+         "_" numeric-char)))
+
+;; version
+(define-peg-pattern non-negative-integer body
+  (+ numeric-char))
+
+(define-peg-pattern crate-version all
+  (and non-negative-integer "."
+       non-negative-integer "."
+       non-negative-integer
+       (? (+ (or "-" lowercase-char
+                 "." uppercase-char
+                 "+" numeric-char "_")))))
+
+;; source
+(define-peg-pattern crate-source all
+  (and (or "registry" "git")
+       "+https://"
+       (+ (or "/" "." "?" "=" "-" "#" "_"
+              alphanumeric-char))))
+
+;; checksum
+(define-peg-pattern crate-checksum all
+  (+ (or lowercase-char numeric-char)))
+
+;; dependency specification
+(define-peg-pattern dependency-specification all
+  (and crate-name (? (and (ignore " ") crate-version))))
+
+;; dependencies
+(define-peg-pattern crate-dependencies all
+  (and (ignore "[\n")
+       (+ (and (ignore " \"")
+               (capture dependency-specification)
+               (ignore "\",\n")))
+       (ignore "]")))
+
+;; crates
+(define-peg-pattern crate all
+  (and (ignore "[[package]]\n")
+       (ignore "name = \"") (capture crate-name) (ignore "\"\n")
+       (ignore "version = \"") (capture crate-version) (ignore "\"\n")
+       (? (and (ignore "source = \"") (capture crate-source) (ignore "\"\n")))
+       (? (and (ignore "checksum = \"") (capture crate-checksum) (ignore "\"\n")))
+       (? (ignore (and "dependencies = " crate-dependencies "\n")))))
+
+;; Cargo.lock
+(define-peg-pattern cargo-lock all
+  (+ (and (ignore "\n") crate)))
-- 
2.49.0





Information forwarded to divya@HIDDEN, efraim@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:30:05 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 23 03:30:04 2025
Received: from localhost ([127.0.0.1]:47355 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twFmT-0004Gr-OI
	for submit <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:30:04 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:54540)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1twFmD-0004Db-E8
 for 77093 <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:29:47 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742714984;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=QK3ReL2BAsFZjCPBVH7S/b7tT3dQsc5umNUoNod7fPw=;
 b=AjmzaVM+bYz5GvqkuGo+cvCQEO4hIqh3wI+4S2tC7QTvfeaBZhTmmcqHBAVlsVj89h8iwc
 Uj01FInoEPqJonm/70ujiFZI2rro9tqhNGmDynu598DRSorTjguwDv7ecoKN8LHQzFqkIh
 51YmePIzzqNmjeQ4+rz3hAmjfWnOrTKrx2q5TO2/EdQogsOExa4lSarw+K4Lk4PdfkCJJS
 OEFGiEBSdFeq7efMnaSC2pmSZsuWtfYhUIwPjjXasQeJCEwAu/D1ABlS86Si0+ZiJIme7b
 4/gbex1y4enyKSbAJyUR7nc3EjUah0yd9AO4qoO+aoa6y+OILbxn8NYdxUbycg==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v3 14/17] =?UTF-8?q?build-system:=20cargo:=20Add?=
 =?UTF-8?q?=20=E2=80=98cargo-inputs=E2=80=99.?=
Date: Sun, 23 Mar 2025 15:28:36 +0800
Message-ID: <8fccd6705884ef7fae492cd6649060544f06bb0b.1742713356.git.hako@HIDDEN>
In-Reply-To: <cover.1742713356.git.hako@HIDDEN>
References: <cover.1742713356.git.hako@HIDDEN>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
X-Debbugs-Cc: Divya Ranjan Pattanaik <divya@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>, Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* gnu/packages/rust-crates.scm: New file.
* gnu/packages/rust-sources.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Regisiter them.
* guix/build-system/cargo.scm (crate-source,cargo-inputs): New procedures.
* guix/import/crate.scm: Hide ‘crate-source’ from (guix build-system cargo).
* etc/teams/rust/audit-rust-crates: New file.
* etc/teams/rust/cleanup-crates.sh: New file.
* etc/teams/rust/rust-crates.tmpl: New file.

Change-Id: I2f2d705a3e376ed3c646f31b824052a2278d4fb3
---
 etc/teams/rust/audit-rust-crates | 70 ++++++++++++++++++++++++++++++++
 etc/teams/rust/cleanup-crates.sh | 37 +++++++++++++++++
 etc/teams/rust/rust-crates.tmpl  | 42 +++++++++++++++++++
 gnu/local.mk                     |  2 +
 gnu/packages/rust-crates.scm     | 42 +++++++++++++++++++
 gnu/packages/rust-sources.scm    | 29 +++++++++++++
 guix/build-system/cargo.scm      | 47 ++++++++++++++++++++-
 guix/import/crate.scm            |  2 +-
 8 files changed, 269 insertions(+), 2 deletions(-)
 create mode 100755 etc/teams/rust/audit-rust-crates
 create mode 100755 etc/teams/rust/cleanup-crates.sh
 create mode 100644 etc/teams/rust/rust-crates.tmpl
 create mode 100644 gnu/packages/rust-crates.scm
 create mode 100644 gnu/packages/rust-sources.scm

diff --git a/etc/teams/rust/audit-rust-crates b/etc/teams/rust/audit-rust-crates
new file mode 100755
index 0000000000..d5546fd1e1
--- /dev/null
+++ b/etc/teams/rust/audit-rust-crates
@@ -0,0 +1,70 @@
+#!/usr/bin/env -S gawk -f
+# GNU Guix --- Functional package management for GNU
+# Copyright © 2025 Efraim Flashner <efraim@HIDDEN>
+#
+# This file is part of GNU Guix.
+#
+# GNU Guix is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or (at
+# your option) any later version.
+#
+# GNU Guix is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+# To run:
+# ./etc/teams/rust/audit-rust-crates ./path/to/file.scm
+# Prints the output of cargo-audit to the shell.
+
+# Make sure we have cargo-audit in our PATH
+BEGIN {
+    if (system("which cargo-audit 1> /dev/null"))
+        exit 1;
+    # Parse a record at a time.
+    RS = "\n\n"
+    cargoAudit = "cargo-audit audit --file -"
+}
+
+# Check the crate-source origin-only inputs
+/crate-source/ {
+    for(i=3; i <= NF-2; i++) {
+        if($i == "(crate-source") {
+            cargoLock = cargoLock "[[package]]\nname = " $(i+1) "\nversion = " $(i+2) "\n"
+            next
+        }
+    }
+}
+
+# Check the crates packaged from crates.io tarballs
+/crate-uri/ {
+    for(i=3; i <= NF; i++) {
+        if($i == "(version")
+           crateVersion = $(i+1)
+        if($i == "(crate-uri")
+           crateName = $(i+1)
+    }
+    gsub(/)/, "", crateVersion)
+    cargoLock = cargoLock "[[package]]\nname = " crateName "\nversion = " crateVersion "\n"
+}
+
+# The xxxx-cargo-input variables have a set style
+# TODO: Replace the last dash between the name and the version with a space!
+# This doesn't take into account swapping between "-" and "_" so we skip it.
+#( $2 ~ /-cargo-inputs/ ) {
+#    sub(/-cargo-inputs/, "", $2)
+#    gsub(/)/, "", $0)
+#    gsub(/rust-/, "", $0)
+#    #gensub(/([[:alpha:]])-([[:digit:]]+)/, "\\1 \\2", "g", $i)
+#    print "[[package]]\nname = \"" $2 "\"\nversion = \"1.0.0\"\ndependencies = ["
+#    for (i = 4; i <= NF; i++) {
+#        print "\"" $i "\","
+#    }
+#    print "]"
+#}
+
+END { print cargoLock | cargoAudit }
diff --git a/etc/teams/rust/cleanup-crates.sh b/etc/teams/rust/cleanup-crates.sh
new file mode 100755
index 0000000000..eca37ca00c
--- /dev/null
+++ b/etc/teams/rust/cleanup-crates.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+# GNU Guix --- Functional package management for GNU
+# Copyright © 2025 Hilton Chain <hako@HIDDEN>
+#
+# This file is part of GNU Guix.
+#
+# GNU Guix is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or (at
+# your option) any later version.
+#
+# GNU Guix is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+FILE=gnu/packages/rust-crates.scm
+PATTERN='^(define rust-'
+
+grep "$PATTERN" $FILE | cut -d' ' -f2 | while IFS= read -r crate
+do
+    if [ "$(grep -wc "$crate" $FILE)" -eq 1 ]; then
+        echo "\
+(begin
+  (use-modules (guix utils))
+  (let ((source-properties
+         (find-definition-location \"$FILE\" '$crate #:define-prefix 'define)))
+    (and=> source-properties delete-expression)))" |
+            guix repl -t machine
+    fi
+done
+
+# Delete extra newlines.
+sed --in-place ':a;N;$!ba;s/\n\n\+/\n\n/g' $FILE
diff --git a/etc/teams/rust/rust-crates.tmpl b/etc/teams/rust/rust-crates.tmpl
new file mode 100644
index 0000000000..98053b7151
--- /dev/null
+++ b/etc/teams/rust/rust-crates.tmpl
@@ -0,0 +1,42 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2025 Hilton Chain <hako@HIDDEN>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages rust-crates)
+  #:use-module (guix gexp)
+  #:use-module (guix packages)
+  #:use-module (guix download)
+  #:use-module (guix git-download)
+  #:use-module (guix build-system cargo))
+
+;;;
+;;; This file is managed by ‘guix import’.  DO NOT add definitions manually.
+;;;
+
+;;;
+;;; Rust dependencies fetched from crates.io and non-workspace development
+;;; snapshots.
+;;;
+
+(define qqqq-separator 'begin-of-crates)
+
+(define ssss-separator 'end-of-crates)
+
+
+;;;
+;;; Cargo inputs.
+;;;
diff --git a/gnu/local.mk b/gnu/local.mk
index 02de02e65f..8d8bd6ebbe 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -616,6 +616,8 @@ GNU_SYSTEM_MODULES =				\
   %D%/packages/rush.scm				\
   %D%/packages/rust.scm				\
   %D%/packages/rust-apps.scm			\
+  %D%/packages/rust-crates.scm			\
+  %D%/packages/rust-sources.scm			\
   %D%/packages/samba.scm			\
   %D%/packages/sagemath.scm			\
   %D%/packages/sawfish.scm			\
diff --git a/gnu/packages/rust-crates.scm b/gnu/packages/rust-crates.scm
new file mode 100644
index 0000000000..98053b7151
--- /dev/null
+++ b/gnu/packages/rust-crates.scm
@@ -0,0 +1,42 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2025 Hilton Chain <hako@HIDDEN>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages rust-crates)
+  #:use-module (guix gexp)
+  #:use-module (guix packages)
+  #:use-module (guix download)
+  #:use-module (guix git-download)
+  #:use-module (guix build-system cargo))
+
+;;;
+;;; This file is managed by ‘guix import’.  DO NOT add definitions manually.
+;;;
+
+;;;
+;;; Rust dependencies fetched from crates.io and non-workspace development
+;;; snapshots.
+;;;
+
+(define qqqq-separator 'begin-of-crates)
+
+(define ssss-separator 'end-of-crates)
+
+
+;;;
+;;; Cargo inputs.
+;;;
diff --git a/gnu/packages/rust-sources.scm b/gnu/packages/rust-sources.scm
new file mode 100644
index 0000000000..bf9b91a671
--- /dev/null
+++ b/gnu/packages/rust-sources.scm
@@ -0,0 +1,29 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2025 Hilton Chain <hako@HIDDEN>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages rust-sources)
+  #:use-module (guix gexp)
+  #:use-module (guix packages)
+  #:use-module (guix download)
+  #:use-module (guix git-download)
+  #:use-module (guix build-system cargo))
+
+;;;
+;;; Cargo workspaces and Rust dependencies requiring external inputs to
+;;; unbundle.
+;;;
diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
index 7a07003262..bbfa2f933b 100644
--- a/guix/build-system/cargo.scm
+++ b/guix/build-system/cargo.scm
@@ -31,6 +31,7 @@ (define-module (guix build-system cargo)
   #:use-module (guix gexp)
   #:use-module (guix monads)
   #:use-module (guix packages)
+  #:use-module (guix download)
   #:use-module (guix platform)
   #:use-module (guix build-system)
   #:use-module (guix build-system gnu)
@@ -45,7 +46,9 @@ (define-module (guix build-system cargo)
             crate-url
             crate-url?
             crate-uri
-            crate-name->package-name))
+            crate-name->package-name
+            crate-source
+            cargo-inputs))
 
 (define %crate-base-url
   (make-parameter "https://crates.io"))
@@ -62,6 +65,48 @@ (define (crate-uri name version)
 (define (crate-name->package-name name)
   (downstream-package-name "rust-" name))
 
+(define* (crate-source name version hash #:key (patches '()) (snippet #f))
+  (origin
+    (method url-fetch)
+    (uri (crate-uri name version))
+    (file-name
+     (string-append (crate-name->package-name name) "-" version ".tar.gz"))
+    (sha256 (base32 hash))
+    (modules '((guix build utils)))
+    (patches patches)
+    (snippet snippet)))
+
+(define* (cargo-inputs name #:key (crates-module '(gnu packages rust-crates))
+                       (sources-module '(gnu packages rust-sources)))
+
+  "Given symbol NAME, resolve variable 'NAME-cargo-inputs', an input list, in
+CRATES-MODULE, return its copy with #f removed and symbols resolved to
+variables defined in SOURCES-MODULE if the input list exists, otherwise return
+an empty list."
+  (let loop ((inputs
+              (catch #t
+                (lambda ()
+                  (module-ref (resolve-interface crates-module)
+                              (symbol-append name '-cargo-inputs)))
+                (const '())))
+             (result '()))
+    (if (null? inputs)
+        result
+        (match inputs
+          ((input . rest)
+           (loop rest
+                 (cond
+                  ;; #f, remove it.
+                  ((not input)
+                   result)
+                  ;; Symbol, resolve it in SOURCES-MODULE.
+                  ((symbol? input)
+                   (cons (module-ref (resolve-interface sources-module) input)
+                         result))
+                  ;; Else: keep it.
+                  (else
+                   (cons input result)))))))))
+
 (define (default-rust target)
   "Return the default Rust package."
   ;; Lazily resolve the binding to avoid a circular dependency.
diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index 14e6e28c5b..a6f247bbae 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -27,7 +27,7 @@
 
 (define-module (guix import crate)
   #:use-module (guix base32)
-  #:use-module (guix build-system cargo)
+  #:use-module ((guix build-system cargo) #:hide (crate-source))
   #:use-module (guix diagnostics)
   #:use-module (gcrypt hash)
   #:use-module (guix http-client)
-- 
2.49.0





Information forwarded to divya@HIDDEN, efraim@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:30:02 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 23 03:30:01 2025
Received: from localhost ([127.0.0.1]:47353 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twFmS-0004GN-V2
	for submit <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:30:01 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:54524)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1twFmB-0004D3-3w
 for 77093 <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:29:44 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742714982;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=Wekb04LgqEYpO0enGWr410xsI+L8Mevkj8GM+wk2izw=;
 b=WA3v9qqN0kE60tiPzOECy1X9NzPnnEx3HGN6qhsUAibEWz7gUKwA3Nj8uFvfneVR6NVxW5
 9YzruVwK9EoFtMCvn/uTmPVr5jC+56mejnwr9sNmF8GHXOD45TYylFMRlGscc1UtNVvdCy
 ofZeJnYfRbIDClZnKUkDPe19v6sepd0FiXtc9Rl8oWawuHW55Nk1w0EQMpaHzXYwg1CXX7
 PQ92hZUvVrKROjQOsQVZZazGR6C3pFloLoPWjVEA11FqrHQxAicvYKychoFgNbZib9s92Y
 nowWQH1pj40QGvn46rTzBfhGjA0kb3M/URG9qKwelZ+KgQXDorWueHHhqg0FMw==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v3 13/17] import: crate: crate-name->package-name:
 Move to (guix build-system cargo).
Date: Sun, 23 Mar 2025 15:28:35 +0800
Message-ID: <3e476eb8a81e416358acc9fc5cfbd6df0605dd21.1742713356.git.hako@HIDDEN>
In-Reply-To: <cover.1742713356.git.hako@HIDDEN>
References: <cover.1742713356.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Divya Ranjan Pattanaik <divya@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>, Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/import/crate.scm (crate-name->package-name): Move to...
* guix/build-system/cargo.scm (crate-name->package-name): ...here and export.

Change-Id: Ie9813179d6c40d159956cc1e2ae59a74dea0a42d
---
 guix/build-system/cargo.scm | 6 +++++-
 guix/import/crate.scm       | 5 -----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
index 4486c706a1..7a07003262 100644
--- a/guix/build-system/cargo.scm
+++ b/guix/build-system/cargo.scm
@@ -44,7 +44,8 @@ (define-module (guix build-system cargo)
             %crate-base-url
             crate-url
             crate-url?
-            crate-uri))
+            crate-uri
+            crate-name->package-name))
 
 (define %crate-base-url
   (make-parameter "https://crates.io"))
@@ -58,6 +59,9 @@ (define (crate-uri name version)
 to NAME and VERSION."
   (string-append crate-url name "/" version "/download"))
 
+(define (crate-name->package-name name)
+  (downstream-package-name "rust-" name))
+
 (define (default-rust target)
   "Return the default Rust package."
   ;; Lazily resolve the binding to avoid a circular dependency.
diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index 5a8caeb3e1..14e6e28c5b 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -481,10 +481,6 @@ (define (guix-package->crate-name package)
     (match parts
       ((name _ ...) name))))
 
-(define (crate-name->package-name name)
-  (downstream-package-name "rust-" name))
-
-
 
 ;;;
 ;;; Updater
@@ -528,4 +524,3 @@ (define %crate-updater
    (description "Updater for crates.io packages")
    (pred crate-package?)
    (import import-release)))
-
-- 
2.49.0





Information forwarded to divya@HIDDEN, efraim@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:30:01 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 23 03:30:00 2025
Received: from localhost ([127.0.0.1]:47351 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twFmS-0004GE-DE
	for submit <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:30:00 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:48284)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1twFm8-0004CY-V9
 for 77093 <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:29:42 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742714979;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=rrhSfMRParvnEoPsd8PRNLNnCpGJ1AEC4RVTgfshvK8=;
 b=LPnH+aIrc6AAC52yIAYOvvWD8T4BotIa0TG1Ve17I7cZkFtbGs4P57Q5bGAscqWlFyAd2L
 Xd4cV7RsW5jkeJQkJs2Rz8NtWCEd73hUHRO4dlAX12LNeGGs4sd4GMxth4lgvwzEtk3vO6
 8kZ+7gcqro9Cc9y0SioNfgXQyRzkBVLxnSMvgtKx1qANINHgrm9Zxvo7Duvxt9r5PHAmm6
 7Ho+YD7Y5jefo+dzw2DRc6O+8gZfq8G/V4HINZVJfxoT2Rrj3ME8Pxcth0hKTxR4+cTZlN
 lPoL8A7Gf7Q3pbSqNePKkHk543URjjo8oG/zlC75gCHj+OOtMVbqWwTCf1/lCg==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v3 12/17] =?UTF-8?q?scripts:=20import:=20Skip=20?=
 =?UTF-8?q?existing=20definition=20for=20=E2=80=98--insert=E2=80=99=20opti?=
 =?UTF-8?q?on.?=
Date: Sun, 23 Mar 2025 15:28:34 +0800
Message-ID: <b9bdd880118e28e326894853d65d357cc6334953.1742713356.git.hako@HIDDEN>
In-Reply-To: <cover.1742713356.git.hako@HIDDEN>
References: <cover.1742713356.git.hako@HIDDEN>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
X-Debbugs-Cc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/scripts/import.scm (guix-import): Skip existing definition for
‘--insert’ option.

Change-Id: I2c4242669f974b263a018ab0cf56538bd7c81d06
---
 guix/scripts/import.scm | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index 38349bff3a..1bddac15c6 100644
--- a/guix/scripts/import.scm
+++ b/guix/scripts/import.scm
@@ -136,16 +136,19 @@ (define-command (guix-import . args)
              (lambda (expr)
                (match expr
                  (((? define-prefix? define-prefix) term _ ...)
-                  (let ((source-properties
-                         (find-definition-insertion-location
-                          file term #:define-prefix define-prefix)))
-                    (if source-properties
-                      (insert-expression source-properties expr)
-                      (let ((port (open-file file "a")))
-                        (pretty-print-with-comments port expr)
-                        (newline port)
-                        (newline port)
-                        (close-port port)))))))))
+                  ;; Skip existing definition.
+                  (unless (find-definition-location
+                           file term #:define-prefix define-prefix)
+                    (let ((source-properties
+                           (find-definition-insertion-location
+                            file term #:define-prefix define-prefix)))
+                      (if source-properties
+                          (insert-expression source-properties expr)
+                          (let ((port (open-file file "a")))
+                            (pretty-print-with-comments port expr)
+                            (newline port)
+                            (newline port)
+                            (close-port port))))))))))
        (import-as-definitions importer
                               (cons (string-append "--file-to-insert=" file)
                                     args)
-- 
2.49.0





Information forwarded to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:30:00 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 23 03:30:00 2025
Received: from localhost ([127.0.0.1]:47349 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twFmR-0004G4-TR
	for submit <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:30:00 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:48278)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1twFm7-0004CK-1k
 for 77093 <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:29:39 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742714977;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=KhWp5HomxdIJw2k6eeh7hBQ+zY/Mq1YRWj1Fvj0R1go=;
 b=DglK9qV7ynnb7nB4FXJsewfUIGLyJWFMSliL0xRWcWUvxlgxQdnmpA2Hw+XO0TnqnleYb4
 QTxp1Wd/YDsZet3IoHAL1jOV9rUuC+ShT69lOGMLawrjvz9d5b1nIlrKQsdIZJ6HzEhA41
 cn+ARbRYdpa90UFQJKOdGZalEDKJL/envdX7GCTSMqzZqZUXYBdFXUR7Zp87gqhlWt3afb
 KFsyRp6A19vlvdwpbMgUKj7eSY0kfWpIJsOdqkIvt9FRNChqj+8FJu2S57dtYH76dnBJ1D
 W1zgkX+5ahWEW7riT9LkBv2qcDEHUjFsp3WsDPbR3I3dDArW331V38P8H3lLqQ==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v3 11/17] scripts: import: Pass "--insert" to
 importers.
Date: Sun, 23 Mar 2025 15:28:33 +0800
Message-ID: <8484c437247c8527b4dea8cdda1f3c43bb981611.1742713356.git.hako@HIDDEN>
In-Reply-To: <cover.1742713356.git.hako@HIDDEN>
References: <cover.1742713356.git.hako@HIDDEN>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
X-Debbugs-Cc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

So that importers can adjust the file before inserting.

* guix/scripts/import.scm (%standard-import-options): Add ‘--file-to-insert’.
(guix-import): Pass it to importers when ‘--insert’ is set.

Change-Id: I8e7a18ee8e0f96d7fc5688a207a7a5390ad2fa30
---
 guix/scripts/import.scm | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index 6f6354928e..38349bff3a 100644
--- a/guix/scripts/import.scm
+++ b/guix/scripts/import.scm
@@ -31,6 +31,7 @@ (define-module (guix scripts import)
   #:use-module (guix utils)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
+  #:use-module (srfi srfi-37)
   #:use-module (ice-9 format)
   #:use-module (ice-9 match)
   #:export (%standard-import-options
@@ -41,7 +42,12 @@ (define-module (guix scripts import)
 ;;; Command line options.
 ;;;
 
-(define %standard-import-options '())
+(define %standard-import-options
+  (list
+   ;; Hidden option for importer-specific file preprocessing.
+   (option '("file-to-insert") #f #t
+           (lambda (opt name arg result)
+             (alist-cons 'file-to-insert arg result)))))
 
 
 ;;;
@@ -140,7 +146,10 @@ (define-command (guix-import . args)
                         (newline port)
                         (newline port)
                         (close-port port)))))))))
-       (import-as-definitions importer args find-and-insert)))
+       (import-as-definitions importer
+                              (cons (string-append "--file-to-insert=" file)
+                                    args)
+                              find-and-insert)))
     ((importer args ...)
      (let ((print (lambda (expr)
                     (leave-on-EPIPE
-- 
2.49.0





Information forwarded to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:30:00 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 23 03:29:59 2025
Received: from localhost ([127.0.0.1]:47347 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twFmR-0004Fu-6i
	for submit <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:29:59 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:54430)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1twFm5-0004C5-4W
 for 77093 <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:29:38 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742714976;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=p3wLcBT+ZuzStmxt7XCA9mvvWfKLGl3I0jdiYr76vbc=;
 b=D+TTar/4Q7i7A98/cdw95/la5YMy+qdfsYroy+b20tAQ1xhan2+Z3TPvf9F57GdxPj4DWk
 +/7ApXXBAc2uyQPAIM8GIdlR9282RDvYLaN1KAlarjH0/zZr31L/0FMbjgrPc6+2USYDoq
 3NVUhzWxWPiBNLK0lkKNo1Qr2M7UrzDInEhvBR3k3ymCZ5Ye2jIvR9KW7u3vE9/SUj0Gi4
 YHS8LDbi/kqhFxtnBLNf5eftKnCYyrgX4ypxyApHyDjn7u027lkttBYtTjU3II0HxXSXUt
 mn3PHOyOtqzXAkj9J5tnQ7PIg2vgPa/55VKQBnf1R5wElZkKIXQ7Kj7PrXY7/g==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v3 10/17] scripts: import: Support expressions
 defined by 'define.
Date: Sun, 23 Mar 2025 15:28:32 +0800
Message-ID: <00ffa2da7f970ea1c54cf3bd36574381cae5fd23.1742713356.git.hako@HIDDEN>
In-Reply-To: <cover.1742713356.git.hako@HIDDEN>
References: <cover.1742713356.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/utils.scm (find-definition-location): New procedure.
(find-definition-insertion-location): Define with it.
* guix/scripts/import.scm (import-as-definitions, guix-import): Support
expressions defined by 'define.

Change-Id: I03118e1a3372028b4f0530964aba871b4a1a4d25
---
 guix/scripts/import.scm | 21 +++++++++++++++------
 guix/utils.scm          | 29 +++++++++++++++++++++--------
 2 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index 58a84d0db7..6f6354928e 100644
--- a/guix/scripts/import.scm
+++ b/guix/scripts/import.scm
@@ -30,6 +30,7 @@ (define-module (guix scripts import)
   #:use-module (guix read-print)
   #:use-module (guix utils)
   #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-26)
   #:use-module (ice-9 format)
   #:use-module (ice-9 match)
   #:export (%standard-import-options
@@ -83,7 +84,8 @@ (define (import-as-definitions importer args proc)
         ((and expr (or ('package _ ...)
                        ('let _ ...)))
          (proc (package->definition expr)))
-        ((and expr ('define-public _ ...))
+        ((and expr (or ('define-public _ ...)
+                       ('define _ ...)))
          (proc expr))
         ((expressions ...)
          (for-each (lambda (expr)
@@ -91,7 +93,8 @@ (define (import-as-definitions importer args proc)
                        ((and expr (or ('package _ ...)
                                       ('let _ ...)))
                         (proc (package->definition expr)))
-                       ((and expr ('define-public _ ...))
+                       ((and expr (or ('define-public _ ...)
+                                      ('define _ ...)))
                         (proc expr))))
                    expressions))
         (x
@@ -117,13 +120,19 @@ (define-command (guix-import . args)
      (show-version-and-exit "guix import"))
     ((or ("-i" file importer args ...)
          ("--insert" file importer args ...))
-     (let ((find-and-insert
+     (let* ((define-prefixes
+             `(,@(if (member importer '("crate"))
+                     '(define)
+                     '())
+               define-public))
+            (define-prefix? (cut member <> define-prefixes))
+            (find-and-insert
              (lambda (expr)
                (match expr
-                 (('define-public term _ ...)
+                 (((? define-prefix? define-prefix) term _ ...)
                   (let ((source-properties
-                          (find-definition-insertion-location
-                            file term)))
+                         (find-definition-insertion-location
+                          file term #:define-prefix define-prefix)))
                     (if source-properties
                       (insert-expression source-properties expr)
                       (let ((port (open-file file "a")))
diff --git a/guix/utils.scm b/guix/utils.scm
index c7c23d9d5b..3f85320845 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -154,6 +154,7 @@ (define-module (guix utils)
             edit-expression
             delete-expression
             insert-expression
+            find-definition-location
             find-definition-insertion-location
 
             filtered-port
@@ -520,24 +521,36 @@ (define (insert-expression source-properties expr)
                    (string-append expr "\n\n" str))))
     (edit-expression source-properties insert)))
 
-(define (find-definition-insertion-location file term)
-  "Search in FILE for a top-level public definition whose defined term
-alphabetically succeeds TERM. Return the location if found, or #f
-otherwise."
-  (let ((search-term (symbol->string term)))
+(define* (find-definition-location file term
+                                   #:key (define-prefix 'define-public)
+                                   (pred string=))
+  "Search in FILE for a top-level definition defined by DEFINE-PREFIX with
+defined term comparing to TERM through PRED.  Return the location if PRED
+returns #t, or #f otherwise."
+  (let ((search-term (symbol->string term))
+        (define-prefix? (cut eq? define-prefix <>)))
     (call-with-input-file file
       (lambda (port)
         (do ((syntax (read-syntax port)
                      (read-syntax port)))
           ((match (syntax->datum syntax)
-             (('define-public current-term _ ...)
-              (string> (symbol->string current-term)
-                       search-term))
+             (((? define-prefix?) current-term _ ...)
+              (pred (symbol->string current-term)
+                    search-term))
              ((? eof-object?) #t)
              (_ #f))
            (and (not (eof-object? syntax))
                 (syntax-source syntax))))))))
 
+(define* (find-definition-insertion-location file term
+                                             #:key
+                                             (define-prefix 'define-public))
+  "Search in FILE for a top-level definition defined by DEFINE-PREFIX with
+defined term alphabetically succeeds TERM. Return the location if found, or #f
+otherwise."
+  (find-definition-location
+   file term #:define-prefix define-prefix #:pred string>))
+
 
 ;;;
 ;;; Keyword arguments.
-- 
2.49.0





Information forwarded to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:29:59 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 23 03:29:59 2025
Received: from localhost ([127.0.0.1]:47345 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twFmQ-0004Fn-Tp
	for submit <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:29:59 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:48276)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1twFm2-0004Be-Sd
 for 77093 <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:29:35 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742714973;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=fqhu2l56Odr9Ir4ZOodrxtGElOfLeWWRB8i95e+2gYA=;
 b=YX5XDe4TAQCmsiqa/20tQrikMHVKpxLmXgPagxvWbnQYTFfPIeieVJ5jIc6w9mMGeLOVkL
 hpyRr8dK6yh7NvnqpthmEHn0uSQ20zSDJUUYjYkaSArvvZgWhYyk3Y1JvuzDBVtcDDM/eF
 U+l7K8/CItkswUYAP1xJYgn4tbOkIitwFI0DJ1XqipbKFk8BAmdXLrxfiFoUpgtmxlL1CO
 HwFXzltPG1wACNZ/27istn767KCrPgGNo5VtrxPzxbfwTapuR9uPfwMumJo8iCbC1qqlOe
 sSjV/nWSxDQ7FHgEWoH3COr159gn2G8Rw0UoxQIUF4X2Uk2jpxq0Y6wJdml9Ow==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v3 09/17] =?UTF-8?q?scripts:=20import:=20Add=20t?=
 =?UTF-8?q?wo=20newlines=20for=20=E2=80=98--insert=E2=80=99=20option.?=
Date: Sun, 23 Mar 2025 15:28:31 +0800
Message-ID: <80044c949ed949f57b3f76190f53e13c139cf442.1742713356.git.hako@HIDDEN>
In-Reply-To: <cover.1742713356.git.hako@HIDDEN>
References: <cover.1742713356.git.hako@HIDDEN>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
X-Debbugs-Cc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

For consistency with ‘insert-expression’.

* guix/scripts/import.scm (guix-import): Add two newlines when inserting.

Change-Id: I55b45ca137d175fdf6ee5c0bb2b6b1ca8385750d
---
 guix/scripts/import.scm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index 4fad329cd3..58a84d0db7 100644
--- a/guix/scripts/import.scm
+++ b/guix/scripts/import.scm
@@ -129,6 +129,7 @@ (define-command (guix-import . args)
                       (let ((port (open-file file "a")))
                         (pretty-print-with-comments port expr)
                         (newline port)
+                        (newline port)
                         (close-port port)))))))))
        (import-as-definitions importer args find-and-insert)))
     ((importer args ...)
-- 
2.49.0





Information forwarded to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:29:59 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 23 03:29:58 2025
Received: from localhost ([127.0.0.1]:47343 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twFmQ-0004Fg-JF
	for submit <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:29:58 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:48270)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1twFm1-0004BS-0M
 for 77093 <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:29:33 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742714971;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=nZMSP3IJmGH8bvNCHSTc4l/woXGuccB1OsC88I5gVRM=;
 b=DaVxxs1B31NSYgnxj0tFGgplNkmJbzhJClDUOsHYZxznTVzW6hCnAjx+EYS4ZW1tltMwRi
 eD/Ykl8Z82EAgs0KobJg/GT4TRnuEiNgZxiR29jOdIASjHIr0UqtT5xvYSV/cTJobHZ+8+
 s9I5Kj/ZhcYLchlwVScgTXNamWN3PTc7EB1ESB2CXW4mD1mNIQalc2fm+s25rMyC4p4wki
 P4wqNrfz+A+g+18eMEX6g8iQLraiUCYpEuQt1elEkdSeJOZiGFqv0XQH6L6DGbGeVEyQJL
 y+M9Z9OfpQmrpUHWcG+WEu1gTEvMgjrRsbj1SHLGFq7Q5L2RAyIG5Cf0MsLrog==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v3 08/17] =?UTF-8?q?scripts:=20import:=20Documen?=
 =?UTF-8?q?t=20argument=20for=20=E2=80=98--insert=E2=80=99=20option=20in?=
 =?UTF-8?q?=20help=20message.?=
Date: Sun, 23 Mar 2025 15:28:30 +0800
Message-ID: <b698494ecb08e57dfad47ea6d0a933e557f8054c.1742713356.git.hako@HIDDEN>
In-Reply-To: <cover.1742713356.git.hako@HIDDEN>
References: <cover.1742713356.git.hako@HIDDEN>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
X-Debbugs-Cc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/scripts/import.scm (show-help): Add missing ‘FILE’.

Change-Id: I540d5feae3fe49c00e9bd6f7a8649ffe0d6e006d
---
 guix/scripts/import.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index bbf31baa15..4fad329cd3 100644
--- a/guix/scripts/import.scm
+++ b/guix/scripts/import.scm
@@ -69,7 +69,7 @@ (define (show-help)
   (display (G_ "
   -h, --help             display this help and exit"))
   (display (G_ "
-  -i, --insert           insert packages into file alphabetically"))
+  -i, --insert=FILE      insert packages into FILE alphabetically"))
   (display (G_ "
   -V, --version          display version information and exit"))
   (newline)
-- 
2.49.0





Information forwarded to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:29:58 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 23 03:29:58 2025
Received: from localhost ([127.0.0.1]:47341 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twFmQ-0004FY-0k
	for submit <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:29:58 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:34824)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1twFlz-0004BF-7g
 for 77093 <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:29:32 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742714970;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=h3Vgf4tjTqkYBWyagpTXL5ZNIhW4KaLaVkwkrFdGnws=;
 b=CKmFZltJGcsXqX+jLqACViuNcMfaLg06AKlE2pV9nmG7cw1To/DDON4Dg/JoT44Jp0d0Cu
 MKbXW11B5iQyTp/H7KtJi3lx9qHkpkk5xH3d2Q60RUQ4fmgbooLubsyz2xYVqFKhX8Ls8g
 ew4d/5MGBodQinW/8Nv0nrgZ+wsTO9/WtRkIZiQcF4szBDUC2UwBdXDBIT5hpMqipJmEG/
 yEugDt+FAhv4Eqc/RPhjfwSNBlZrb9E3Zjq204XEX/EgUKkeKF11UN4TEh932CjcgWVhhI
 fBLcd2pBpg5IxmTZsWlfND+hFZ/rEiNnsZx+VfU3CG2pPdpGPWaYrxbYz/jSCA==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v3 07/17] build/cargo: Support non-workspace
 directory source inputs.
Date: Sun, 23 Mar 2025 15:28:29 +0800
Message-ID: <4c0ba403c7eac57f45425e2372cc7ba5e0c08af5.1742713356.git.hako@HIDDEN>
In-Reply-To: <cover.1742713356.git.hako@HIDDEN>
References: <cover.1742713356.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Divya Ranjan Pattanaik <divya@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>, Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/build/cargo-build-system.scm (single-crate?): New procedure.
(crate-src?): Support non-workspace directory source inputs.
(configure): Likewise.

Change-Id: If2bd318b44ed765baec69309f25d320edceee116
---
 guix/build/cargo-build-system.scm | 60 ++++++++++++++++++++-----------
 1 file changed, 39 insertions(+), 21 deletions(-)

diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index f2a7323748..1012d7f401 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -33,6 +33,7 @@ (define-module (guix build cargo-build-system)
   #:use-module (ice-9 ftw)
   #:use-module (ice-9 format)
   #:use-module (ice-9 match)
+  #:use-module (ice-9 textual-ports)
   #:use-module (ice-9 threads)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
@@ -60,22 +61,35 @@ (define (has-executable-target?)
          (bin-dep? (lambda (dep) (find bin? (get-kinds dep)))))
     (find bin-dep? (manifest-targets))))
 
+(define (single-crate? dir)
+  "Check if directory DIR contains 'Cargo.toml' and is not a workspace."
+  (let ((manifest-file (in-vicinity dir "Cargo.toml")))
+    (and (file-exists? manifest-file)
+         (not (string-contains
+               (call-with-input-file manifest-file get-string-all)
+               "[workspace]")))))
+
 (define (crate-src? path)
   "Check if PATH refers to a crate source, namely a gzipped tarball with a
 Cargo.toml file present at its root."
-    (and (not (directory-exists? path)) ; not a tarball
-         (not (string-suffix? "py" path))   ; sanity-check.py
-         ;; First we print out all file names within the tarball to see if it
-         ;; looks like the source of a crate. However, the tarball will include
-         ;; an extra path component which we would like to ignore (since we're
-         ;; interested in checking if a Cargo.toml exists at the root of the
-         ;; archive, but not nested anywhere else). We do this by cutting up
-         ;; each output line and only looking at the second component. We then
-         ;; check if it matches Cargo.toml exactly and short circuit if it does.
-         (apply invoke (list "sh" "-c"
-                             (string-append "tar -tf " path
-                                            " | cut -d/ -f2"
-                                            " | grep -q '^Cargo.toml$'")))))
+  (if (directory-exists? path)
+      ;; The build system only handles sources containing single crate.
+      ;; Workspaces should be packaged into crates (via 'package phase)
+      ;; and used in inputs.
+      (single-crate? path)
+      (and (not (string-suffix? "py" path)) ;sanity-check.py
+           ;; First we print out all file names within the tarball to see
+           ;; if it looks like the source of a crate. However, the tarball
+           ;; will include an extra path component which we would like to
+           ;; ignore (since we're interested in checking if a Cargo.toml
+           ;; exists at the root of the archive, but not nested anywhere
+           ;; else). We do this by cutting up each output line and only
+           ;; looking at the second component. We then check if it matches
+           ;; Cargo.toml exactly and short circuit if it does.
+           (invoke "sh" "-c"
+                   (string-append "tar -tf " path
+                                  " | cut -d/ -f2"
+                                  " | grep -q '^Cargo.toml$'")))))
 
 (define* (unpack-rust-crates #:key inputs (vendor-dir "guix-vendor")
                              #:allow-other-keys)
@@ -159,14 +173,18 @@ (define* (configure #:key inputs
          (and (crate-src? path)
               ;; Gracefully handle duplicate inputs
               (not (file-exists? crate-dir))
-              (mkdir-p crate-dir)
-              ;; Cargo crates are simply gzipped tarballs but with a .crate
-              ;; extension. We expand the source to a directory name we control
-              ;; so that we can generate any cargo checksums.
-              ;; The --strip-components argument is needed to prevent creating
-              ;; an extra directory within `crate-dir`.
-              (format #t "Unpacking ~a~%" name)
-              (invoke "tar" "xf" path "-C" crate-dir "--strip-components" "1")))))
+              (if (directory-exists? path)
+                  (copy-recursively path crate-dir)
+                  (begin
+                    (mkdir-p crate-dir)
+                    ;; Cargo crates are simply gzipped tarballs but with a
+                    ;; .crate extension. We expand the source to a directory
+                    ;; name we control so that we can generate any cargo
+                    ;; checksums.  The --strip-components argument is needed to
+                    ;; prevent creating an extra directory within `crate-dir`.
+                    (format #t "Unpacking ~a~%" name)
+                    (invoke "tar" "xf" path "-C" crate-dir
+                            "--strip-components" "1")))))))
     inputs)
 
   ;; For cross-building
-- 
2.49.0





Information forwarded to divya@HIDDEN, efraim@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:29:58 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 23 03:29:58 2025
Received: from localhost ([127.0.0.1]:47339 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twFmP-0004FP-Cu
	for submit <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:29:57 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:54426)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1twFlx-0004Ap-Aj
 for 77093 <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:29:30 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742714968;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=tG2XNZs5GS0JQumnYtWu0WyDueTXJUyWLXF2tuIKzIg=;
 b=hGVxaFxcjYmWBUdoiB1zoGd+Y1gkELx9r8UYHrsvFIA4yhXLp7+Vb0Dkyw9nmCMpjdoa2b
 WKPub2Y8KInZU6wSe6MlL4ZCwcEcbSAoV2AKOiyFxaoyFaXZUQ2OewXyPJWapvNm/WbdSq
 dyLavvvfRtvVntve+YYbkzOdoEXq0fy/Ja33KPPXGzLSQPAlBR2mB2GXxUBaqDMARCrecf
 3awbBdj0B5h/2cpfIidenxJji6aGf8KWgn0T60RuspdEtlZw2uu5ZjYhGHs1qwiebohf0e
 eD0YXCoGrhvCbj5ch7mQO+yBlXtgQJCmcDCH19BXj2FjEfzRhSVPwYKqvoRnJA==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v3 06/17] build/cargo: Don't try to unpack
 sanity-check.py.
Date: Sun, 23 Mar 2025 15:28:28 +0800
Message-ID: <66d29a621b80ab17ec6125e9877e365dce174ce0.1742713356.git.hako@HIDDEN>
In-Reply-To: <cover.1742713356.git.hako@HIDDEN>
References: <cover.1742713356.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Divya Ranjan Pattanaik <divya@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>, Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Efraim Flashner <efraim@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

From: Efraim Flashner <efraim@HIDDEN>

* guix/build/cargo-build-system.scm (crate-src?): Also don't try to
check python scripts for Cargo.toml.

Change-Id: I001a89b83d2e472706b1263007be45d1153c140f
---
 guix/build/cargo-build-system.scm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index 15eda8396c..f2a7323748 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -64,6 +64,7 @@ (define (crate-src? path)
   "Check if PATH refers to a crate source, namely a gzipped tarball with a
 Cargo.toml file present at its root."
     (and (not (directory-exists? path)) ; not a tarball
+         (not (string-suffix? "py" path))   ; sanity-check.py
          ;; First we print out all file names within the tarball to see if it
          ;; looks like the source of a crate. However, the tarball will include
          ;; an extra path component which we would like to ignore (since we're
-- 
2.49.0





Information forwarded to divya@HIDDEN, efraim@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:29:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 23 03:29:57 2025
Received: from localhost ([127.0.0.1]:47337 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twFmO-0004FG-Ss
	for submit <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:29:57 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:34822)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1twFlv-0004AT-Io
 for 77093 <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:29:29 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742714966;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=7cHC5JaE/yoaTiqjZnZGmW/1emw8eox9nVLO4naCJAM=;
 b=ApCgR0mgdF8PWkSEali2i8PUKxS6TdtQD1ZPC256GCtum00Krl1iimHrv3kOgmTQEt2aIk
 8S0MNrVJLovo2BV1YSqHrDi16WmYkrkTbRbf8Ul/WJY3pCaSk3WeUEq7JvnYk6W2xAIwMr
 fX5r6ecvVKlslSmStfl5kD1WyMfNw/ItzAqAGiuxHmWiYM2q+rzeffVJlhAE/VjGryXmpz
 iFyMZ9kdf5v/Jc3/4ZgcNW1VKP9qXTisHVDXN0xCJGedr2wt0xmyYw5SyOukE1GCZmLzuX
 TgjTK3p9Hh7U7mbAv3IEIB2QmkQ3qsLN0IXPGyBxyVVfWfhw/+aMyviiF9XYgQ==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v3 05/17] build/cargo: Set default value of
 arguments for build phases.
Date: Sun, 23 Mar 2025 15:28:27 +0800
Message-ID: <6bb7dff08560eab1521f718dde1ee870b41cd323.1742713356.git.hako@HIDDEN>
In-Reply-To: <cover.1742713356.git.hako@HIDDEN>
References: <cover.1742713356.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Divya Ranjan Pattanaik <divya@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>, Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

This makes it easier to use these phases in other bulid systems.

* guix/build/cargo-build-system.scm (unpack-rust-crates,configure,build,package)
(install): Set default value of arguments.

Change-Id: I1dde1b063d8eee57967903abd2fce94574211a0a
---
 guix/build/cargo-build-system.scm | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index 67311fc850..15eda8396c 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -76,7 +76,8 @@ (define (crate-src? path)
                                             " | cut -d/ -f2"
                                             " | grep -q '^Cargo.toml$'")))))
 
-(define* (unpack-rust-crates #:key inputs vendor-dir #:allow-other-keys)
+(define* (unpack-rust-crates #:key inputs (vendor-dir "guix-vendor")
+                             #:allow-other-keys)
   (define (inputs->rust-inputs inputs)
     "Filter using the label part from INPUTS."
     (filter (lambda (input)
@@ -139,7 +140,7 @@ (define* (check-for-pregenerated-files #:key parallel-build? #:allow-other-keys)
 
 (define* (configure #:key inputs
                     target system
-                    cargo-target
+                    (cargo-target #f)
                     (vendor-dir "guix-vendor")
                     #:allow-other-keys)
   "Vendor Cargo.toml dependencies as guix inputs."
@@ -258,7 +259,7 @@ (define* (patch-cargo-checksums #:key
 
 (define* (build #:key
                 parallel-build?
-                skip-build?
+                (skip-build? #f)
                 (features '())
                 (cargo-build-flags '("--release"))
                 #:allow-other-keys)
@@ -298,8 +299,8 @@ (define* (check #:key
 
 (define* (package #:key
                   source
-                  skip-build?
-                  install-source?
+                  (skip-build? #f)
+                  (install-source? #t)
                   (cargo-package-crates '())
                   (cargo-package-flags '("--no-metadata" "--no-verify"))
                   (vendor-dir "guix-vendor")
@@ -374,9 +375,9 @@ (define* (package #:key
 (define* (install #:key
                   inputs
                   outputs
-                  skip-build?
-                  install-source?
-                  features
+                  (skip-build? #f)
+                  (install-source? #t)
+                  (features '())
                   (cargo-install-paths '())
                   #:allow-other-keys)
   "Install a given Cargo package."
-- 
2.49.0





Information forwarded to divya@HIDDEN, efraim@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:29:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 23 03:29:56 2025
Received: from localhost ([127.0.0.1]:47335 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twFmO-0004F5-1T
	for submit <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:29:56 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:34810)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1twFlt-0004A3-14
 for 77093 <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:29:27 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742714964;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=23lhd6o6dULzhofljL9UaScmfBPSTipNmygrpe7uEkk=;
 b=Wmtbz+/rrm4HpUwSE7fE+E820iYO1Hh97di0T1ktBGuuGx50ZsW+8CaEXZoFAnynhgo6r8
 IoZti3i8s90C/Su0iLxLewfS5Wwn31xUyM7XK+qT7wjuGaDIady34ZfUw+0SSgJrXLg7xE
 icRzc8+gJZv6MMqgibDdIUyMH24Ul8Jm5bqbF0sNjafn4k0VQzE9W5h2FJF8HXsxLmDcT6
 UrCwGBd+6AISfnIJ2EfE+9RNCGNNWLvT9WRy2Nj5cEFCZ5eBNQ1vpqUC67ZTpNXRCYHo98
 r7WZfne1pnNZl2lYzS9ylcQ6ctNhOkalOMotTXiI4zrpma+cIcjoXS6uBBnwIA==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v3 04/17] build-system: cargo: Support installing
 Cargo workspace.
Date: Sun, 23 Mar 2025 15:28:26 +0800
Message-ID: <d361c46719773763ac0938fc61f2f6c25af134f3.1742713356.git.hako@HIDDEN>
In-Reply-To: <cover.1742713356.git.hako@HIDDEN>
References: <cover.1742713356.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Divya Ranjan Pattanaik <divya@HIDDEN>, Efraim Flashner <efraim@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>, Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

*guix/build-system/cargo.scm (cargo-build,cargo-cross-build)
[#:cargo-install-paths]: New argument.
* guix/build/cargo-build-system.scm (install): Use it.
* doc/guix.texi (Build Systems)[cargo-build-system]: Document it.

Change-Id: I74ed1972a5716da05afeac8edb2b0e4b6834bf40
---
 doc/guix.texi                     |  5 ++++-
 guix/build-system/cargo.scm       |  4 ++++
 guix/build/cargo-build-system.scm | 17 +++++++++++++----
 3 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 0089f9e60f..7fa986b4b9 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -9369,7 +9369,10 @@ Build Systems
 library crates to package in the @code{package} phase.  Specified crates are
 packaged from left to right, in case there's dependency among them.  For
 example, specifying @code{''("pcre2-sys" "pcre2")} will package
-@code{"pcre2-sys"} first and then @code{"pcre2"}.
+@code{"pcre2-sys"} first and then @code{"pcre2"}.  Parameter
+@code{#:cargo-install-paths} (default: @code{''()}) allows specifying paths of
+binary crates to install in the @code{install} phase, @code{''("crates/atuin")},
+for example.
 @end defvar
 
 @defvar chicken-build-system
diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
index 4f6d46e70c..4486c706a1 100644
--- a/guix/build-system/cargo.scm
+++ b/guix/build-system/cargo.scm
@@ -96,6 +96,7 @@ (define* (cargo-build name inputs
                       (cargo-test-flags ''())
                       (cargo-package-crates ''())
                       (cargo-package-flags ''("--no-metadata" "--no-verify"))
+                      (cargo-install-paths ''())
                       (features ''())
                       (skip-build? #f)
                       (parallel-build? #t)
@@ -125,6 +126,7 @@ (define* (cargo-build name inputs
                        #:cargo-test-flags #$(sexp->gexp cargo-test-flags)
                        #:cargo-package-crates #$(sexp->gexp cargo-package-crates)
                        #:cargo-package-flags #$(sexp->gexp cargo-package-flags)
+                       #:cargo-install-paths #$(sexp->gexp cargo-install-paths)
                        #:cargo-target #$(cargo-triplet system)
                        #:features #$(sexp->gexp features)
                        #:skip-build? #$skip-build?
@@ -158,6 +160,7 @@ (define* (cargo-cross-build name
                             (cargo-test-flags ''())
                             (cargo-package-crates ''())
                             (cargo-package-flags ''("--no-metadata" "--no-verify"))
+                            (cargo-install-paths ''())
                             (cargo-target (cargo-triplet (or target system)))
                             (features ''())
                             (skip-build? #f)
@@ -190,6 +193,7 @@ (define* (cargo-cross-build name
                        #:cargo-test-flags #$(sexp->gexp cargo-test-flags)
                        #:cargo-package-crates #$(sexp->gexp cargo-package-crates)
                        #:cargo-package-flags #$(sexp->gexp cargo-package-flags)
+                       #:cargo-install-paths #$(sexp->gexp cargo-install-paths)
                        #:cargo-target #$(cargo-triplet (or target system))
                        #:features #$(sexp->gexp features)
                        #:skip-build? #$skip-build?
diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index 51a45b4eab..67311fc850 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -377,6 +377,7 @@ (define* (install #:key
                   skip-build?
                   install-source?
                   features
+                  (cargo-install-paths '())
                   #:allow-other-keys)
   "Install a given Cargo package."
   (let* ((out      (assoc-ref outputs "out"))
@@ -391,10 +392,18 @@ (define* (install #:key
     ;; Only install crates which include binary targets,
     ;; otherwise cargo will raise an error.
     (or skip-build?
-        (not (has-executable-target?))
-        (invoke "cargo" "install" "--offline" "--no-track"
-                "--path" "." "--root" out
-                "--features" (string-join features)))
+        ;; NOTE: Cargo workspace installation support:
+        ;; #:skip-build? #f + #:cargo-install-paths.
+        (and (null? cargo-install-paths)
+             (not (has-executable-target?)))
+        (for-each
+         (lambda (path)
+           (invoke "cargo" "install" "--offline" "--no-track"
+                   "--path" path "--root" out
+                   "--features" (string-join features)))
+         (if (null? cargo-install-paths)
+             '(".")
+             cargo-install-paths)))
 
     (when install-source?
       ;; Install crate tarballs and unpacked sources for later use.
-- 
2.49.0





Information forwarded to divya@HIDDEN, efraim@HIDDEN, ludo@HIDDEN, maxim.cournoyer@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:29:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 23 03:29:56 2025
Received: from localhost ([127.0.0.1]:47333 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twFmM-0004Ek-Fe
	for submit <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:29:55 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:34802)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1twFlr-00049h-Dq
 for 77093 <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:29:26 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742714962;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=TsqMeoEPxrWTz5BuoP/adKMehqeUtbJe5HaI+Gmux8I=;
 b=LEd1cTtZU5ZvfaAHvj5XcnuR24WWPz/nJup1v+iKlBRYUp9Xq3xLENrv8t7DagXXpNPCAw
 ixzT1V1B4UGjCbERhCRlYbqa4p31UN2M2kx22foOAA8v4+nfWenk9nzGnIZ9EOiKO52zwn
 B8kbhHiee3me/ZALZ0acICl6lrCDQgVSy61DBJTU8D5kbcj6G7YTD++gkUVcNgJlFA6ETR
 Ebfm9mOrctr72qOvGRElh2VqlIEDRiIhMNSvvgBw+WOwQQh6hO0SH+bqnswzOVAYhy93eK
 V6sIHqJLq4O4a2dy4V5IhYbvWxReMzRB8AckEFeIpiwp1l4euQp+NY1YImkrkg==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v3 03/17] build-system: cargo: Support packaging
 Cargo workspace.
Date: Sun, 23 Mar 2025 15:28:25 +0800
Message-ID: <9118bb6e582587547a1d0530d9b4db917cadca6a.1742713356.git.hako@HIDDEN>
In-Reply-To: <cover.1742713356.git.hako@HIDDEN>
References: <cover.1742713356.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Divya Ranjan Pattanaik <divya@HIDDEN>, Efraim Flashner <efraim@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>, Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/build-system/cargo.scm (cargo-build,cargo-cross-build)
[#:cargo-package-crates]: New argument.
* guix/build/cargo-build-system.scm (package): Use it.
* doc/guix.texi (Build Systems)[cargo-build-system]: Document it.

Change-Id: I45ccd95e90827d47127015cb0bda2d41f792335b
---
 doc/guix.texi                     |  7 +++++++
 guix/build-system/cargo.scm       |  4 ++++
 guix/build/cargo-build-system.scm | 21 +++++++++++++++++++--
 3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 0ca109a214..0089f9e60f 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -9363,6 +9363,13 @@ Build Systems
 the binaries defined by the crate.  Unless @code{install-source? #f} is
 defined it will also install a source crate repository of itself and unpacked
 sources, to ease in future hacking on rust packages.
+
+This build system supports cargo workspaces.  Parameter
+@code{#:cargo-package-crates} (default: @code{''()}) allows specifying names of
+library crates to package in the @code{package} phase.  Specified crates are
+packaged from left to right, in case there's dependency among them.  For
+example, specifying @code{''("pcre2-sys" "pcre2")} will package
+@code{"pcre2-sys"} first and then @code{"pcre2"}.
 @end defvar
 
 @defvar chicken-build-system
diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
index 452f7f78d0..4f6d46e70c 100644
--- a/guix/build-system/cargo.scm
+++ b/guix/build-system/cargo.scm
@@ -94,6 +94,7 @@ (define* (cargo-build name inputs
                       (vendor-dir "guix-vendor")
                       (cargo-build-flags ''("--release"))
                       (cargo-test-flags ''())
+                      (cargo-package-crates ''())
                       (cargo-package-flags ''("--no-metadata" "--no-verify"))
                       (features ''())
                       (skip-build? #f)
@@ -122,6 +123,7 @@ (define* (cargo-build name inputs
                        #:vendor-dir #$vendor-dir
                        #:cargo-build-flags #$(sexp->gexp cargo-build-flags)
                        #:cargo-test-flags #$(sexp->gexp cargo-test-flags)
+                       #:cargo-package-crates #$(sexp->gexp cargo-package-crates)
                        #:cargo-package-flags #$(sexp->gexp cargo-package-flags)
                        #:cargo-target #$(cargo-triplet system)
                        #:features #$(sexp->gexp features)
@@ -154,6 +156,7 @@ (define* (cargo-cross-build name
                             (vendor-dir "guix-vendor")
                             (cargo-build-flags ''("--release"))
                             (cargo-test-flags ''())
+                            (cargo-package-crates ''())
                             (cargo-package-flags ''("--no-metadata" "--no-verify"))
                             (cargo-target (cargo-triplet (or target system)))
                             (features ''())
@@ -185,6 +188,7 @@ (define* (cargo-cross-build name
                        #:vendor-dir #$vendor-dir
                        #:cargo-build-flags #$(sexp->gexp cargo-build-flags)
                        #:cargo-test-flags #$(sexp->gexp cargo-test-flags)
+                       #:cargo-package-crates #$(sexp->gexp cargo-package-crates)
                        #:cargo-package-flags #$(sexp->gexp cargo-package-flags)
                        #:cargo-target #$(cargo-triplet (or target system))
                        #:features #$(sexp->gexp features)
diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index 58238992b8..51a45b4eab 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -300,11 +300,16 @@ (define* (package #:key
                   source
                   skip-build?
                   install-source?
+                  (cargo-package-crates '())
                   (cargo-package-flags '("--no-metadata" "--no-verify"))
+                  (vendor-dir "guix-vendor")
                   #:allow-other-keys)
   "Run 'cargo-package' for a given Cargo package."
   (if install-source?
-    (if skip-build?
+    ;; NOTE: Cargo workspace packaging support:
+    ;; #:install-source? #t + #:cargo-package-crates.
+    (if (and (null? cargo-package-crates)
+             skip-build?)
       (begin
         (install-file source "target/package")
         (with-directory-excursion "target/package"
@@ -322,7 +327,19 @@ (define* (package #:key
         ;;error: invalid inclusion of reserved file name Cargo.toml.orig in package source
         (when (file-exists? "Cargo.toml.orig")
           (delete-file "Cargo.toml.orig"))
-        (apply invoke `("cargo" "package" "--offline" ,@cargo-package-flags))
+
+        (if (null? cargo-package-crates)
+            (apply invoke `("cargo" "package" "--offline" ,@cargo-package-flags))
+            (for-each
+             (lambda (pkg)
+               (apply invoke "cargo" "package" "--offline" "--package" pkg
+                      cargo-package-flags)
+               (for-each
+                (lambda (crate)
+                  (invoke "tar" "xzf" crate "-C" vendor-dir))
+                (find-files "target/package" "\\.crate$"))
+               (patch-cargo-checksums #:vendor-dir vendor-dir))
+             cargo-package-crates))
 
         ;; Then unpack the crate, reset the timestamp of all contained files, and
         ;; repack them.  This is necessary to ensure that they are reproducible.
-- 
2.49.0





Information forwarded to divya@HIDDEN, efraim@HIDDEN, ludo@HIDDEN, maxim.cournoyer@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:29:43 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 23 03:29:43 2025
Received: from localhost ([127.0.0.1]:47326 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twFm9-0004Cl-I1
	for submit <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:29:43 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:59754)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1twFlo-000491-Rf
 for 77093 <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:29:23 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742714959;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=4dyk8EhTBpU4zaPXLxseyoCZCVCVNbObU/8XSgx1X8g=;
 b=WyxGqEy5SqwyjF2dmxB1Vu6X3xv/AUkdkTXVZwdZyVL5IcjjG+g+Qy9T83m0175KlE5fTi
 T+DuwuaDKcPtNnaVdb1VHrHQ82Jqifc+IEDhSJUbYbNCAhh2KDchW8Fv9icPzE6fynV/5E
 kSPubc/sh/V3XpQ9cmQbHTJy5D6z/YkiQd+FS+nhBcn1cfxA+0r1hRj3iG3J05KFjumPcd
 3WmVsC6Kz/lGsNYY1FY47RLKuXHHYYEtemGB1oUVwJ0+QsfkatYDtuOf7dB//4ARPLSWR8
 GIqEcP5MyaJMxLSyLS6Y9TqYOcGJteSbGYtT08wCtHBpI5NUaaz1vBEJZD8aMQ==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v3 02/17] build/cargo: Print out all non-empty
 binary files.
Date: Sun, 23 Mar 2025 15:28:24 +0800
Message-ID: <eae23e0485704990b9a27df8b02bfaaf4190eff1.1742713356.git.hako@HIDDEN>
In-Reply-To: <cover.1742713356.git.hako@HIDDEN>
References: <cover.1742713356.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Divya Ranjan Pattanaik <divya@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>, Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/build/cargo-build-system.scm (%standard-phases): Move
'unpack-rust-crates after 'unpack.
Move 'check-for-pregenerated-files after 'configure.
(check-for-pregenerated-files): Only check non-empty files.
Print out binary files.
Run in parallel.
Don't fail to keep compatibility for phase order change.

Change-Id: I0a332fe843e97687324bd908fa111422a63e475d
---
 guix/build/cargo-build-system.scm | 31 +++++++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index 41f54f42b7..58238992b8 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -29,9 +29,11 @@ (define-module (guix build cargo-build-system)
   #:use-module ((guix build utils) #:hide (delete))
   #:use-module (ice-9 popen)
   #:use-module (ice-9 rdelim)
+  #:use-module (ice-9 regex)
   #:use-module (ice-9 ftw)
   #:use-module (ice-9 format)
   #:use-module (ice-9 match)
+  #:use-module (ice-9 threads)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
   #:export (%standard-phases
@@ -111,12 +113,29 @@ (define* (unpack-rust-crates #:key inputs vendor-dir #:allow-other-keys)
 (define (rust-package? name)
   (string-prefix? "rust-" name))
 
-(define* (check-for-pregenerated-files #:rest _)
+(define* (check-for-pregenerated-files #:key parallel-build? #:allow-other-keys)
   "Check the source code for files which are known to generally be bundled
 libraries or executables."
-  (let ((pregenerated-files (find-files "." "\\.(a|dll|dylib|exe|lib)$")))
-    (when (not (null-list? pregenerated-files))
-      (error "Possible pre-generated files found:" pregenerated-files))))
+  (format #t "Searching for binary files...~%")
+  (let ((known-pattern (make-regexp "\\.(a|dll|dylib|exe|lib)$"))
+        (empty-file?
+         (lambda (filename)
+           (call-with-ascii-input-file filename
+             (lambda (p)
+               (eqv? #\0 (read-char p)))))))
+    (n-par-for-each
+     (if parallel-build?
+         (parallel-job-count)
+         1)
+     (lambda (file)
+       (unless (empty-file? file)
+         ;; Print out binary files.
+         (false-if-exception (invoke "grep" "-IL" "." file))
+         ;; Warn about known pre-generated files.
+         ;; Not failing here for compatibility with existing packages.
+         (when (regexp-exec known-pattern file)
+           (format #t "error: Possible pre-generated file found: ~a~%" file))))
+     (find-files "."))))
 
 (define* (configure #:key inputs
                     target system
@@ -380,8 +399,8 @@ (define %standard-phases
     (replace 'check check)
     (replace 'install install)
     (add-after 'build 'package package)
-    (add-after 'unpack 'check-for-pregenerated-files check-for-pregenerated-files)
-    (add-after 'check-for-pregenerated-files 'unpack-rust-crates unpack-rust-crates)
+    (add-after 'unpack 'unpack-rust-crates unpack-rust-crates)
+    (add-after 'configure 'check-for-pregenerated-files check-for-pregenerated-files)
     (add-after 'patch-generated-file-shebangs 'patch-cargo-checksums patch-cargo-checksums)))
 
 (define* (cargo-build #:key inputs (phases %standard-phases)
-- 
2.49.0





Information forwarded to divya@HIDDEN, efraim@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:29:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 23 03:29:41 2025
Received: from localhost ([127.0.0.1]:47321 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twFm4-0004C1-3a
	for submit <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:29:41 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:41786)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1twFlk-00048k-Jb
 for 77093 <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:29:20 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742714955;
 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:
 content-transfer-encoding:content-transfer-encoding;
 bh=uykQ3f9snLl0Jk8YahIOIV0raQ2+niRJWypqAqTgSSI=;
 b=FaWhL01nxpO9kNULL3Qgq4WpiLYPRy4PjwGhNjbvy8fkkfwnL30IydgBK7Is+uqTu9Uf4Z
 mz/c/CMoYTOgYNfaTABzKEm/fjJmfZq7HW1NnuLiF0KsQl9c3IWACThqyhZukbjCeggXEs
 k8HTAbPIMQHBsNg1KDsI0cwZq3+zlFeTubjVBwliRCNgvUOFeaTnLp2dUeC+mVQPkcFTqH
 IWaB+GDO3uO+GliodA6wAY0OAyWaZYAM2lFJvFPzi9DLkI4u+ixzaPzWiWoC9JmocS+iXZ
 nRq0zLSqC+NDR80xa5iVt7CwM4mymT8L7/rsp6rKn3KUL5ykRz0mT+YfOm7LXg==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v3 00/17] New Rust packaging workflow based on
 lockfile importer.
Date: Sun, 23 Mar 2025 15:28:22 +0800
Message-ID: <cover.1742713356.git.hako@HIDDEN>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
X-Debbugs-Cc: Divya Ranjan Pattanaik <divya@HIDDEN>, Efraim Flashner <efraim@HIDDEN>, Steve George <steve@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>
X-Debbugs-Cc: Ludovic Courtès <ludo@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.7 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.3 (/)

V2 -> V3:
* Add Efraim's etc/teams/rust/audit-rust-crates script.
* Add (guix import crate cargo-lock) to Rust team's scope.
* ‘definer’ -> ‘define-prefix’
* Adjust documentation and move examples to Guix Cookbook.
* Document ‘cargo-inputs’ and remove mentioning of files under etc/teams/rust.

Diff inserted at end.

Efraim Flashner (1):
  build/cargo: Don't try to unpack sanity-check.py.

Hilton Chain (16):
  build/cargo: Pass ‘--offline’ to cargo.
  build/cargo: Print out all non-empty binary files.
  build-system: cargo: Support packaging Cargo workspace.
  build-system: cargo: Support installing Cargo workspace.
  build/cargo: Set default value of arguments for build phases.
  build/cargo: Support non-workspace directory source inputs.
  scripts: import: Document argument for ‘--insert’ option in help
    message.
  scripts: import: Add two newlines for ‘--insert’ option.
  scripts: import: Support expressions defined by 'define.
  scripts: import: Pass "--insert" to importers.
  scripts: import: Skip existing definition for ‘--insert’ option.
  import: crate: crate-name->package-name: Move to (guix build-system
    cargo).
  build-system: cargo: Add ‘cargo-inputs’.
  import: crate: Add Cargo.lock parser.
  import: crate: Add ‘--lockfile’ option.
  doc: Document lockfile importer based Rust packaging workflow.

 Makefile.am                       |   1 +
 doc/contributing.texi             |  91 +++++---
 doc/guix-cookbook.texi            | 352 ++++++++++++++++++++++++++++++
 doc/guix.texi                     |  24 ++
 etc/teams.scm                     |   1 +
 etc/teams/rust/audit-rust-crates  |  70 ++++++
 etc/teams/rust/cleanup-crates.sh  |  37 ++++
 etc/teams/rust/rust-crates.tmpl   |  42 ++++
 gnu/local.mk                      |   2 +
 gnu/packages/rust-crates.scm      |  42 ++++
 gnu/packages/rust-sources.scm     |  29 +++
 guix/build-system/cargo.scm       |  59 ++++-
 guix/build/cargo-build-system.scm | 150 +++++++++----
 guix/import/crate.scm             |  81 ++++++-
 guix/import/crate/cargo-lock.scm  | 105 +++++++++
 guix/scripts/import.scm           |  54 +++--
 guix/scripts/import/crate.scm     |  58 ++++-
 guix/utils.scm                    |  29 ++-
 tests/crate.scm                   |  88 ++++++++
 19 files changed, 1209 insertions(+), 106 deletions(-)
 create mode 100755 etc/teams/rust/audit-rust-crates
 create mode 100755 etc/teams/rust/cleanup-crates.sh
 create mode 100644 etc/teams/rust/rust-crates.tmpl
 create mode 100644 gnu/packages/rust-crates.scm
 create mode 100644 gnu/packages/rust-sources.scm
 create mode 100644 guix/import/crate/cargo-lock.scm


base-commit: 127e1e89a83785f4ad8362bdc76b0d850279cf2f
--
2.49.0

diff --git a/doc/contributing.texi b/doc/contributing.texi
index 837074dead..17f22390d5 100644
--- a/doc/contributing.texi
+++ b/doc/contributing.texi
@@ -1600,12 +1600,6 @@ Rust Crates
 @subsection Rust Crates

 @cindex rust
-As currently there's no achievable way to reuse Rust packages as pre-compiled
-inputs for other packages at a distribution scale, and our previous approach on
-making all Rust dependencies as full packages doesn't cope well with Rust
-ecosystem thus causing issues on both contribution and maintenance sides, we
-have switched to a different packaging model.
-
 Rust programs (binary crates) and dependencies (library crates) are treated
 separately.  We put our main efforts into programs and only package Rust
 dependencies as sources, utilizing automation with a manual focus on unbundling
@@ -1625,19 +1619,11 @@ Rust Crates
 @item
 @code{(gnu packages rust-crates)}, storing source definitions imported from Rust
 programs' @file{Cargo.lock} via the lockfile importer (@pxref{Invoking guix
-import, crate, @code{--lockfile=@var{file}}}).
+import, @code{crate}, @code{--lockfile=@var{file}}}).

 Imported definitions must be checked and have vendored sources unbundled before
-contributing to Guix.  Naturally, this module serves as a store for both sources
-and unbundling strategies.
-
-This module is managed by the Rust team (@pxref{Teams}) to ensure there's always
-one version containing all changes from other branches, so that the maintained
-version can be used directly in case of merge conflicts, thus coordination is
-required for other committers to modify it.
-
-Guix source ships template @file{etc/teams/rust/rust-crates.tmpl} and cleanup
-script @file{etc/teams/rust/cleanup-crates.sh} for this module.
+being contributed to Guix.  This module is managed by the Rust team
+(@pxref{Teams}).

 @item
 @code{(gnu packages rust-sources)}, storing more complex definitions that need
@@ -1661,338 +1647,28 @@ Rust Crates

 In practice we are usually packaging development snapshots of Rust dependencies
 specifically for some Rust programs, and can't simply identity them by version.
-In this case we can use a @code{for-@var{program}} suffix.  Examples@:
-@code{rust-pipewire-for-niri}, @code{rust-pubgrub-for-uv}.
-@end enumerate
-
-Let's demonstrate the packaging workflow by examples, note that package-specific
-issues are not involved here.
-
-In preparation, we'll add the following packages to our environment:
-
-@example
-guix shell rust rust:cargo cargo-audit cargo-license
-@end example
-
-Example 1: @code{cargo-audit}, which is published on the crates.io Rust package
-repository @uref{https://crates.io, crates.io}.
-
-@enumerate
-@item
-We can generate a draft definition via the crates.io importer (@pxref{Invoking
-guix import, crate}).  In the end we'll have the following definiton:
-
-@lisp
-(define-public cargo-audit
-  (package
-    (name "cargo-audit")
-    (version "0.21.2")
-    (source
-     (origin
-       (method url-fetch)
-       (uri (crate-uri "cargo-audit" version))
-       (file-name (string-append name "-" version ".tar.gz"))
-       (sha256
-        (base32 "1a00yqpckkw86zh2hg7ra82c5fx0ird5766dyynimbvqiwg2ps0n"))))
-    (build-system cargo-build-system)
-    (arguments (list #:install-source? #f))
-    (inputs (cargo-inputs 'cargo-audit))
-    (home-page "https://rustsec.org/")
-    (synopsis "Audit Cargo.lock for crates with security vulnerabilities")
-    (description
-     "This package provides a Cargo subcommand, @@command@{cargo audit@}, to
-audit @@file@{Cargo.lock@} for crates with security vulnerabilities.")
-    (license (list license:asl2.0 license:expat))))
-@end lisp
-
-@code{cargo-inputs} is a procedure defined in @code{guix build-system cargo},
-facilitating dependency modification.  @code{'cargo-audit} used here must be a
-unique identifier, usually same to the program's variable name.
-
-@item
-Unpack package source and navigate to the unpacked directory, then execute the
-following commands:
-
-@example
-cargo generate-lockfile
-cargo audit
-cargo license
-@end example
-
-@command{cargo generate-lockfile} updates dependencies to compatible versions,
-@command{cargo audit} checks known vulnerabilities and @command{cargo license}
-checks licenses of all dependencies.
-
-We must have an acceptable output of @command{cargo audit} and ensure all
-dependencies are licensed with our supported licenses (@pxref{Defining Packages,
-@code{license}}).
-
-@item
-Import dependencies from previously generated lockfile:
-
-@example
-guix import --insert=gnu/packages/rust-crates.scm \
-    crate --lockfile=/path/to/Cargo.lock cargo-audit
-@end example
-
-@code{cargo-audit} used here must be consistent with the identifier used for
-@code{cargo-inputs}.
-
-At this stage, @code{cargo-audit} is buildable.
-
-@item
-Finally we'll unbundle vendored sources.  The lockfile importer inserts
-@code{TODO:} comments to dependencies with high probability of bundled sources.
-@code{cargo-build-system} also performs additional check in its
-@code{check-for-pregenerated-files} phase:
-
-@example
-$ ./pre-inst-env guix build cargo-audit
-@dots{}
-starting phase `check-for-pregenerated-files'
-Searching for binary files...
-./guix-vendor/rust-addr2line-0.21.0.tar.gz/rustfmt.toml
-./guix-vendor/rust-arc-swap-1.7.1.tar.gz/rustfmt.toml
-./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/dictionary-rust
-./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/dictionary-rust-other
-./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/lib.rs.zst
-./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/long-window-size-lib.rs.zst
-@dots{}
-@end example
-
-Although dependencies in @code{(gnu packages rust-crates)} are not exported, we
-can still select them in Guix command-line interface through expression:
-
-@example
-guix build --expression='(@@@@ (gnu packages rust-crates) rust-ring-0.17.14)'
-@end example
-
-For most dependencies, a snippet is sufficient:
-
-@lisp
-(define rust-bzip2-sys-0.1.13+1.0.8
-  (crate-source "bzip2-sys" "0.1.13+1.0.8"
-                "056c39pgjh4272bdslv445f5ry64xvb0f7nph3z7860ln8rzynr2"
-                #:snippet
-                '(begin
-                   (delete-file-recursively "bzip2-1.0.8")
-                   (delete-file "build.rs")
-                   ;; Inspired by Debian's patch.
-                   (with-output-to-file "build.rs"
-                     (lambda _
-                       (format #t "fn main() @{~@@
-                        println!(\"cargo:rustc-link-lib=bz2\");~@@
-                        @}~%"))))))
-@end lisp
-
-In a more complex case, where unbundling one dependency requires other packages,
-we should package the dependency in @code{(gnu packages rust-sources)} first and
-point the imported definition to a symbol with the same name.
-
-For example we have defined a @code{rust-ring-0.17} in @code{(gnu packages
-rust-sources)}, then the imported definition in @code{(gnu packages
-rust-crates)} should be modified to point to it:
-
-@lisp
-(define rust-ring-0.17.14 'rust-ring-0.17)
-@end lisp
-
-When one dependency can be safely removed, modify it to @code{#f}.
-
-@lisp
-(define rust-openssl-src-300.4.2+3.4.1 #f)
-@end lisp
-
-Such modifications are processed by @code{cargo-inputs} procedure.
-
-@code{cargo-inputs} can also be configured by keywoard arguments
-@code{#:crates-module} (default: @code{(gnu packages rust-crates)}, module to
-resolve imported definitions) and @code{#:sources-module} (default: @code{(gnu
-packages rust-sources)}, module to resolve modified symbols), which are useful
-to maintain an independent channel.
+In this case we can use a @code{for-@var{program}} suffix, for example,
+@code{rust-pipewire-for-niri} and @code{rust-pubgrub-for-uv}.
 @end enumerate

-Example 2: @code{niri}, which is not available on crates.io and depends on
-development snapshots (also Cargo workspaces in this example).
+Rust dependencies are not referenced directly.  @code{(guix build-sytem cargo)}
+provides a @code{cargo-inputs} procedure to create an input list, in combination
+with the lockfile importer.

-@enumerate
-@item
-As we can't ensure compatibility of a development snapshot, before executing
-@command{cargo generate-lockfile}, we should modify @file{Cargo.toml} to pin it
-in a known working revision.
+@cindex cargo-inputs
+@deffn {Procedure} cargo-inputs @var{name} @
+       [#:crates-module '(gnu packages rust-crates)] @
+       [#:sources-module '(gnu packages rust-sources)]
+Given symbol @code{'@var{name}}, resolve variable
+@code{@var{name}-cargo-inputs}, an input list, in @var{crates-module}, return
+its copy with @code{#f} removed and symbols resolved to variables defined in
+@var{sources-module} if the input list exists, otherwise return an empty list.

-To use our packaged development snapshots, it's also necessary to modify
-@file{Cargo.toml} in build environment, the substitution pattern is
-package-specific.
-
-@code{cargo-inputs} returns a list, all list operations apply to it too.
-
-@lisp
-(define-public niri
-  (package
-   (name "niri")
-   (version "25.02")
-   (source (origin
-             (method git-fetch)
-             (uri (git-reference
-                   (url "https://github.com/YaLTeR/niri")
-                   (commit (string-append "v" version))))
-             (file-name (git-file-name name version))
-             (sha256
-              (base32
-               "0vzskaalcz6pcml687n54adjddzgf5r07gggc4fhfsa08h1wfd4r"))))
-   (build-system cargo-build-system)
-   (arguments
-    (list #:install-source? #f
-          #:phases
-          #~(modify-phases %standard-phases
-              (add-after 'unpack 'use-guix-vendored-dependencies
-                (lambda _
-                  (substitute* "Cargo.toml"
-                    (("# version =.*")
-                     "version = \"*\"")
-                    (("git.*optional")
-                     "version = \"*\", optional")
-                    (("^git = .*")
-                     "")))))))
-   (native-inputs
-    (list pkg-config))
-   (inputs
-    (cons* clang
-           libdisplay-info
-           libinput-minimal
-           libseat
-           libxkbcommon
-           mesa
-           pango
-           pipewire
-           wayland
-           (cargo-inputs 'niri)))
-   (home-page "https://github.com/YaLTeR/niri")
-   (synopsis "Scrollable-tiling Wayland compositor")
-   (description
-    "Niri is a scrollable-tiling Wayland compositor which arranges windows in a
-scrollable format.  It is considered stable for daily use and performs most
-functions expected of a Wayland compositor.")
-   (license license:gpl3)))
-@end lisp
-
-@item
-@code{niri} also has Cargo workspace dependencies.  When packaging a Cargo
-workspace, build argument @code{#:cargo-package-crates} is required.
-
-@lisp
-(define-public rust-pipewire-for-niri
-  (let ((commit "fd3d8f7861a29c2eeaa4c393402e013578bb36d9")
-        (revision "0"))
-    (package
-      (name "rust-pipewire")
-      (version (git-version "0.8.0" revision commit))
-      (source
-       (origin
-         (method git-fetch)
-         (uri (git-reference
-               (url "https://gitlab.freedesktop.org/pipewire/pipewire-rs.git")
-               (commit commit)))
-         (file-name (git-file-name name version))
-         (sha256
-          (base32 "1hzyhz7xg0mz8a5y9j6yil513p1m610q3j9pzf6q55vdh5mcn79v"))))
-      (build-system cargo-build-system)
-      (arguments
-       (list #:skip-build? #t
-             #:cargo-package-crates
-             ''("libspa-sys" "libspa" "pipewire-sys" "pipewire")))
-      (inputs (cargo-inputs 'rust-pipewire-for-niri))
-      (home-page "https://pipewire.org/")
-      (synopsis "Rust bindings for PipeWire")
-      (description "This package provides Rust bindings for PipeWire.")
-      (license license:expat))))
-@end lisp
-
-Don't forget to modify all workspace members in @code{(gnu packages
-rust-crates)}:
-
-@lisp
-(define rust-pipewire-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
-(define rust-pipewire-sys-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
-@dots{}
-(define rust-libspa-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
-(define rust-libspa-sys-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
-@end lisp
-@end enumerate
-
-Example 3: @code{fish}, which combines two build systems.
-
-@enumerate
-@item
-When building Rust packages in other build systems, we need to add @code{rust}
-and @code{rust:cargo} to @code{native-inputs}, import and use modules from both
-build systems, and apply necessary build phases from @code{cargo-build-system}.
+@var{name} must be consistent with the one used in lockfile importer invocation.
+@end deffn

-@lisp
-(define-public fish
-  (package
-    (name "fish")
-    (version "4.0.0")
-    (source
-     (origin
-       (method url-fetch)
-       (uri (string-append "https://github.com/fish-shell/fish-shell/"
-                           "releases/download/" version "/"
-                           "fish-" version ".tar.xz"))
-       (sha256
-        (base32 "1wv9kjwg6ax8m2f85i58l9f9cndshn1f15n8skc68w1mf3cmpnig"))))
-    (build-system cmake-build-system)
-    (inputs
-     (cons* fish-foreign-env ncurses pcre2
-            python                    ;for fish_config and manpage completions
-            (cargo-inputs 'fish)))
-    (native-inputs
-     (list doxygen groff                ;for 'fish --help'
-           pkg-config
-           procps                       ;for the test suite
-           rust
-           `(,rust "cargo")))
-    (arguments
-     (list #:imported-modules
-           (append %cargo-build-system-modules
-                   %cmake-build-system-modules)
-           #:modules
-           (((guix build cargo-build-system) #:prefix cargo:)
-            (guix build cmake-build-system)
-            (guix build utils))
-           #:phases
-           #~(modify-phases %standard-phases
-               (add-after 'unpack 'use-guix-vendored-dependencies
-                 (lambda _
-                   (substitute* "Cargo.toml"
-                     (("git.*tag.*,")
-                      "version = \"*\","))))
-               (add-after 'unpack 'prepare-cargo-build-system
-                 (lambda args
-                   (for-each
-                    (lambda (phase)
-                      (format #t "Running cargo phase: ~a~%" phase)
-                      (apply (assoc-ref cargo:%standard-phases phase)
-                             args))
-                    '(unpack-rust-crates
-                      configure
-                      check-for-pregenerated-files
-                      patch-cargo-checksums)))))))
-    (synopsis "The friendly interactive shell")
-    (description
-     "Fish (friendly interactive shell) is a shell focused on interactive use,
-discoverability, and friendliness.  Fish has very user-friendly and powerful
-tab-completion, including descriptions of every completion, completion of
-strings with wildcards, and many completions for specific commands.  It also
-has extensive and discoverable help.  A special @@command@{help@} command gives
-access to all the fish documentation in your web browser.  Other features
-include smart terminal handling based on terminfo, an easy to search history,
-and syntax highlighting.")
-    (home-page "https://fishshell.com/")
-    (license license:gpl2)))
-@end lisp
-@end enumerate
+For a more detailed packaging workflow, @pxref{Packaging Rust Crates,,,
+guix-cookbook, GNU Guix Cookbook}.


 @node Elm Packages
diff --git a/doc/guix-cookbook.texi b/doc/guix-cookbook.texi
index d9b98a2ab3..1f0e5eee54 100644
--- a/doc/guix-cookbook.texi
+++ b/doc/guix-cookbook.texi
@@ -103,6 +103,7 @@ Top
 Packaging

 * Packaging Tutorial::          A tutorial on how to add packages to Guix.
+* Packaging Workflows::         Real life examples on working with specific build systems.

 Packaging Tutorial

@@ -127,6 +128,16 @@ Top
 * Automatic update::
 * Inheritance::

+Packaging Workflows
+
+* Packaging Rust Crates::
+
+Packaging Rust Crates
+
+* Common Workflow for Packaging Rust Crates::
+* Development Snapshots and Cargo Workspaces::
+* Rust Programs With Mixed Build Systems::
+
 System Configuration

 * Auto-Login to a Specific TTY::  Automatically Login a User to a Specific TTY
@@ -514,6 +525,7 @@ Packaging

 @menu
 * Packaging Tutorial::          A tutorial on how to add packages to Guix.
+* Packaging Workflows::         Real life examples on working with specific build systems.
 @end menu

 @node Packaging Tutorial
@@ -1593,6 +1605,346 @@ References
 @uref{https://www.gnu.org/software/guix/guix-ghm-andreas-20130823.pdf, ``GNU Guix: Package without a scheme!''}, by Andreas Enge
 @end itemize

+@node Packaging Workflows
+@section Packaging Workflows
+
+The following sections are real life examples on working with specific build
+systems, serving as extensions to the concise packaging guidelines
+(@pxref{Packaging Guidelines,,, guix, GNU Guix Reference Manual}).
+
+@menu
+* Packaging Rust Crates::
+@end menu
+
+@node Packaging Rust Crates
+@subsection Packaging Rust Crates
+
+In preparation, add the following packages to our environment:
+
+@example
+$ guix shell rust rust:cargo cargo-audit cargo-license
+@end example
+
+@menu
+* Common Workflow for Packaging Rust Crates::
+* Development Snapshots and Cargo Workspaces::
+* Rust Programs With Mixed Build Systems::
+@end menu
+
+@node Common Workflow for Packaging Rust Crates
+@subsubsection Common Workflow for Packaging Rust Crates
+
+In this example, we'll package @code{cargo-audit}, which is published on the
+@uref{https://crates.io, crates.io} Rust package repository.  All its
+dependencies are on crates.io as well.
+
+@enumerate
+@item
+Since @code{cargo-audit} is available on crates.io, We can generate a draft
+definition via the crates.io importer (@pxref{Invoking guix import,,, guix, GNU
+Guix Reference Manual}).  In the end we'll have the following definiton:
+
+@lisp
+(define-public cargo-audit
+  (package
+    (name "cargo-audit")
+    (version "0.21.2")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (crate-uri "cargo-audit" version))
+       (file-name (string-append name "-" version ".tar.gz"))
+       (sha256
+        (base32 "1a00yqpckkw86zh2hg7ra82c5fx0ird5766dyynimbvqiwg2ps0n"))))
+    (build-system cargo-build-system)
+    (arguments (list #:install-source? #f))
+    (inputs (cargo-inputs 'cargo-audit))
+    (home-page "https://rustsec.org/")
+    (synopsis "Audit Cargo.lock for crates with security vulnerabilities")
+    (description
+     "This package provides a Cargo subcommand, @@command@{cargo audit@}, to
+audit @@file@{Cargo.lock@} for crates with security vulnerabilities.")
+    (license (list license:asl2.0 license:expat))))
+@end lisp
+
+The symbol used in @code{cargo-inputs}, @code{'cargo-audit} here, must be a
+unique identifier, usually matching the variable name of the package.
+
+@item
+Unpack package source and navigate to the unpacked directory, then execute the
+following commands:
+
+@example
+$ cargo generate-lockfile
+$ cargo audit
+$ cargo license
+@end example
+
+@command{cargo generate-lockfile} updates dependencies to compatible versions,
+@command{cargo audit} checks known vulnerabilities and @command{cargo license}
+checks licenses of all dependencies.
+
+We must have an acceptable output of @command{cargo audit} and ensure all
+dependencies are licensed with our supported licenses (@pxref{Defining
+Packages,,, guix, GNU Guix Reference Manual}).
+
+@item
+Import dependencies from previously generated lockfile:
+
+@example
+$ guix import --insert=gnu/packages/rust-crates.scm \
+      crate --lockfile=/path/to/Cargo.lock cargo-audit
+@end example
+
+@code{cargo-audit} used here must be consistent with the identifier used for
+@code{cargo-inputs}.
+
+At this stage, package @code{cargo-audit} is buildable.
+
+@item
+Finally we'll unbundle vendored sources.  The lockfile importer inserts
+@code{TODO:} comments to dependencies with high probability of bundled sources.
+@code{cargo-build-system} also performs additional check in its
+@code{check-for-pregenerated-files} phase:
+
+@example
+$ ./pre-inst-env guix build cargo-audit
+@dots{}
+starting phase `check-for-pregenerated-files'
+Searching for binary files...
+./guix-vendor/rust-addr2line-0.21.0.tar.gz/rustfmt.toml
+./guix-vendor/rust-arc-swap-1.7.1.tar.gz/rustfmt.toml
+./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/dictionary-rust
+./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/dictionary-rust-other
+./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/lib.rs.zst
+./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/long-window-size-lib.rs.zst
+@dots{}
+@end example
+
+Although dependencies in @code{(gnu packages rust-crates)} are not exported, we
+can still select them via the Guix command-line interface through expression:
+
+@example
+$ guix build --expression='(@@@@ (gnu packages rust-crates) rust-ring-0.17.14)'
+@end example
+
+For most dependencies, a snippet is sufficient:
+
+@lisp
+(define rust-bzip2-sys-0.1.13+1.0.8
+  (crate-source "bzip2-sys" "0.1.13+1.0.8"
+                "056c39pgjh4272bdslv445f5ry64xvb0f7nph3z7860ln8rzynr2"
+                #:snippet
+                '(begin
+                   (delete-file-recursively "bzip2-1.0.8")
+                   (delete-file "build.rs")
+                   ;; Inspired by Debian's patch.
+                   (with-output-to-file "build.rs"
+                     (lambda _
+                       (format #t "fn main() @{~@@
+                        println!(\"cargo:rustc-link-lib=bz2\");~@@
+                        @}~%"))))))
+@end lisp
+
+In a more complex case, where unbundling one dependency requires other packages,
+we should package the dependency in @code{(gnu packages rust-sources)} first and
+reference it by a symbol in the imported definition.
+
+For example we have defined a @code{rust-ring-0.17} in @code{(gnu packages
+rust-sources)}, then the imported definition in @code{(gnu packages
+rust-crates)} should be modified to a matching symbol.
+
+@lisp
+(define rust-ring-0.17.14 'rust-ring-0.17)
+@end lisp
+
+When one dependency can be safely removed, modify it to @code{#f}.
+
+@lisp
+(define rust-openssl-src-300.4.2+3.4.1 #f)
+@end lisp
+@end enumerate
+
+@node Development Snapshots and Cargo Workspaces
+@subsubsection Development Snapshots and Cargo Workspaces
+
+In this example, we'll package @code{niri}, which depends on development
+snapshots (also Cargo workspaces here).
+
+As we can't ensure compatibility of a development snapshot, before executing
+@command{cargo generate-lockfile}, we should modify @file{Cargo.toml} to pin it
+to a known working revision.
+
+To use our packaged development snapshots, it's also necessary to modify
+@file{Cargo.toml} in a build phase, with a package-specific substitution
+pattern.
+
+@lisp
+(define-public niri
+  (package
+   (name "niri")
+   (version "25.02")
+   (source (origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/YaLTeR/niri")
+                   (commit (string-append "v" version))))
+             (file-name (git-file-name name version))
+             (sha256
+              (base32
+               "0vzskaalcz6pcml687n54adjddzgf5r07gggc4fhfsa08h1wfd4r"))))
+   (build-system cargo-build-system)
+   (arguments
+    (list #:install-source? #f
+          #:phases
+          #~(modify-phases %standard-phases
+              (add-after 'unpack 'use-guix-vendored-dependencies
+                (lambda _
+                  (substitute* "Cargo.toml"
+                    (("# version =.*")
+                     "version = \"*\"")
+                    (("git.*optional")
+                     "version = \"*\", optional")
+                    (("^git = .*")
+                     "")))))))
+   (native-inputs
+    (list pkg-config))
+   (inputs
+    (cons* clang
+           libdisplay-info
+           libinput-minimal
+           libseat
+           libxkbcommon
+           mesa
+           pango
+           pipewire
+           wayland
+           (cargo-inputs 'niri)))
+   (home-page "https://github.com/YaLTeR/niri")
+   (synopsis "Scrollable-tiling Wayland compositor")
+   (description
+    "Niri is a scrollable-tiling Wayland compositor which arranges windows in a
+scrollable format.  It is considered stable for daily use and performs most
+functions expected of a Wayland compositor.")
+   (license license:gpl3+)))
+@end lisp
+
+@code{niri} has Cargo workspace dependencies.  When packaging a Cargo workspace,
+argument @code{#:cargo-package-crates} is required.
+
+@lisp
+(define-public rust-pipewire-for-niri
+  (let ((commit "fd3d8f7861a29c2eeaa4c393402e013578bb36d9")
+        (revision "0"))
+    (package
+      (name "rust-pipewire")
+      (version (git-version "0.8.0" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://gitlab.freedesktop.org/pipewire/pipewire-rs.git")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32 "1hzyhz7xg0mz8a5y9j6yil513p1m610q3j9pzf6q55vdh5mcn79v"))))
+      (build-system cargo-build-system)
+      (arguments
+       (list #:skip-build? #t
+             #:cargo-package-crates
+             ''("libspa-sys" "libspa" "pipewire-sys" "pipewire")))
+      (inputs (cargo-inputs 'rust-pipewire-for-niri))
+      (home-page "https://pipewire.org/")
+      (synopsis "Rust bindings for PipeWire")
+      (description "This package provides Rust bindings for PipeWire.")
+      (license license:expat))))
+@end lisp
+
+Don't forget to modify all workspace members in @code{(gnu packages
+rust-crates)}:
+
+@lisp
+(define rust-pipewire-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
+(define rust-pipewire-sys-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
+@dots{}
+(define rust-libspa-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
+(define rust-libspa-sys-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
+@end lisp
+
+@node Rust Programs With Mixed Build Systems
+@subsubsection Rust Programs With Mixed Build Systems
+
+In this example, we'll package @code{fish}, which combines two build systems.
+
+When building Rust packages in other build systems, we need to add @code{rust}
+and @code{rust:cargo} to @code{native-inputs}, import and use modules from both
+build systems, and apply necessary build phases from @code{cargo-build-system}.
+
+@lisp
+(define-public fish
+  (package
+    (name "fish")
+    (version "4.0.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://github.com/fish-shell/fish-shell/"
+                           "releases/download/" version "/"
+                           "fish-" version ".tar.xz"))
+       (sha256
+        (base32 "1wv9kjwg6ax8m2f85i58l9f9cndshn1f15n8skc68w1mf3cmpnig"))))
+    (build-system cmake-build-system)
+    (inputs
+     (cons* fish-foreign-env ncurses pcre2
+            python                    ;for fish_config and manpage completions
+            (cargo-inputs 'fish)))
+    (native-inputs
+     (list doxygen groff                ;for 'fish --help'
+           pkg-config
+           procps                       ;for the test suite
+           rust
+           `(,rust "cargo")))
+    (arguments
+     (list #:imported-modules
+           (append %cargo-build-system-modules
+                   %cmake-build-system-modules)
+           #:modules
+           (((guix build cargo-build-system) #:prefix cargo:)
+            (guix build cmake-build-system)
+            (guix build utils))
+           #:phases
+           #~(modify-phases %standard-phases
+               (add-after 'unpack 'use-guix-vendored-dependencies
+                 (lambda _
+                   (substitute* "Cargo.toml"
+                     (("git.*tag.*,")
+                      "version = \"*\","))))
+               (add-after 'unpack 'prepare-cargo-build-system
+                 (lambda args
+                   (for-each
+                    (lambda (phase)
+                      (format #t "Running cargo phase: ~a~%" phase)
+                      (apply (assoc-ref cargo:%standard-phases phase)
+                             args))
+                    '(unpack-rust-crates
+                      configure
+                      check-for-pregenerated-files
+                      patch-cargo-checksums)))))))
+    (synopsis "The friendly interactive shell")
+    (description
+     "Fish (friendly interactive shell) is a shell focused on interactive use,
+discoverability, and friendliness.  Fish has very user-friendly and powerful
+tab-completion, including descriptions of every completion, completion of
+strings with wildcards, and many completions for specific commands.  It also
+has extensive and discoverable help.  A special @@command@{help@} command gives
+access to all the fish documentation in your web browser.  Other features
+include smart terminal handling based on terminfo, an easy to search history,
+and syntax highlighting.")
+    (home-page "https://fishshell.com/")
+    (license license:gpl2)))
+@end lisp
+
+
 @c *********************************************************************
 @node System Configuration
 @chapter System Configuration
diff --git a/etc/teams.scm b/etc/teams.scm
index 6bddbd91fa..c4bee8d3d9 100755
--- a/etc/teams.scm
+++ b/etc/teams.scm
@@ -389,6 +389,7 @@ (define-team rust
                       "guix/build/cargo-utils.scm"
                       "guix/build-system/cargo.scm"
                       "guix/import/crate.scm"
+                      "guix/import/crate/cargo-lock.scm"
                       "guix/scripts/import/crate.scm"
                       "tests/crate.scm")))

diff --git a/etc/teams/rust/audit-rust-crates b/etc/teams/rust/audit-rust-crates
new file mode 100755
index 0000000000..d5546fd1e1
--- /dev/null
+++ b/etc/teams/rust/audit-rust-crates
@@ -0,0 +1,70 @@
+#!/usr/bin/env -S gawk -f
+# GNU Guix --- Functional package management for GNU
+# Copyright © 2025 Efraim Flashner <efraim@HIDDEN>
+#
+# This file is part of GNU Guix.
+#
+# GNU Guix is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or (at
+# your option) any later version.
+#
+# GNU Guix is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+# To run:
+# ./etc/teams/rust/audit-rust-crates ./path/to/file.scm
+# Prints the output of cargo-audit to the shell.
+
+# Make sure we have cargo-audit in our PATH
+BEGIN {
+    if (system("which cargo-audit 1> /dev/null"))
+        exit 1;
+    # Parse a record at a time.
+    RS = "\n\n"
+    cargoAudit = "cargo-audit audit --file -"
+}
+
+# Check the crate-source origin-only inputs
+/crate-source/ {
+    for(i=3; i <= NF-2; i++) {
+        if($i == "(crate-source") {
+            cargoLock = cargoLock "[[package]]\nname = " $(i+1) "\nversion = " $(i+2) "\n"
+            next
+        }
+    }
+}
+
+# Check the crates packaged from crates.io tarballs
+/crate-uri/ {
+    for(i=3; i <= NF; i++) {
+        if($i == "(version")
+           crateVersion = $(i+1)
+        if($i == "(crate-uri")
+           crateName = $(i+1)
+    }
+    gsub(/)/, "", crateVersion)
+    cargoLock = cargoLock "[[package]]\nname = " crateName "\nversion = " crateVersion "\n"
+}
+
+# The xxxx-cargo-input variables have a set style
+# TODO: Replace the last dash between the name and the version with a space!
+# This doesn't take into account swapping between "-" and "_" so we skip it.
+#( $2 ~ /-cargo-inputs/ ) {
+#    sub(/-cargo-inputs/, "", $2)
+#    gsub(/)/, "", $0)
+#    gsub(/rust-/, "", $0)
+#    #gensub(/([[:alpha:]])-([[:digit:]]+)/, "\\1 \\2", "g", $i)
+#    print "[[package]]\nname = \"" $2 "\"\nversion = \"1.0.0\"\ndependencies = ["
+#    for (i = 4; i <= NF; i++) {
+#        print "\"" $i "\","
+#    }
+#    print "]"
+#}
+
+END { print cargoLock | cargoAudit }
diff --git a/etc/teams/rust/cleanup-crates.sh b/etc/teams/rust/cleanup-crates.sh
index cd4c2462b9..eca37ca00c 100755
--- a/etc/teams/rust/cleanup-crates.sh
+++ b/etc/teams/rust/cleanup-crates.sh
@@ -1,5 +1,4 @@
 #!/bin/sh
-
 # GNU Guix --- Functional package management for GNU
 # Copyright © 2025 Hilton Chain <hako@HIDDEN>
 #
@@ -28,7 +27,7 @@ do
 (begin
   (use-modules (guix utils))
   (let ((source-properties
-         (find-definition-location \"$FILE\" '$crate #:definer 'define)))
+         (find-definition-location \"$FILE\" '$crate #:define-prefix 'define)))
     (and=> source-properties delete-expression)))" |
             guix repl -t machine
     fi
diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
index 47d4f10969..bbfa2f933b 100644
--- a/guix/build-system/cargo.scm
+++ b/guix/build-system/cargo.scm
@@ -78,9 +78,11 @@ (define* (crate-source name version hash #:key (patches '()) (snippet #f))

 (define* (cargo-inputs name #:key (crates-module '(gnu packages rust-crates))
                        (sources-module '(gnu packages rust-sources)))
-  "Given NAME, resolve input list 'NAME-cargo-inputs' in CRATES-MODULE, return
-its copy with #f removed and symbols resolved to variables defined in
-SOURCES-MODULE, if the list exists, otherwise return an empty list."
+
+  "Given symbol NAME, resolve variable 'NAME-cargo-inputs', an input list, in
+CRATES-MODULE, return its copy with #f removed and symbols resolved to
+variables defined in SOURCES-MODULE if the input list exists, otherwise return
+an empty list."
   (let loop ((inputs
               (catch #t
                 (lambda ()
@@ -101,7 +103,7 @@ (define* (cargo-inputs name #:key (crates-module '(gnu packages rust-crates))
                   ((symbol? input)
                    (cons (module-ref (resolve-interface sources-module) input)
                          result))
-                  ;; Else: no change.
+                  ;; Else: keep it.
                   (else
                    (cons input result)))))))))

diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index 41adc03752..1012d7f401 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -350,17 +350,16 @@ (define* (package #:key

         (if (null? cargo-package-crates)
             (apply invoke `("cargo" "package" "--offline" ,@cargo-package-flags))
-            (begin
-              (for-each
-               (lambda (pkg)
-                 (apply invoke "cargo" "package" "--offline" "--package" pkg
-                        cargo-package-flags)
-                 (for-each
-                  (lambda (crate)
-                    (invoke "tar" "xzf" crate "-C" vendor-dir))
-                  (find-files "target/package" "\\.crate$"))
-                 (patch-cargo-checksums #:vendor-dir vendor-dir))
-               cargo-package-crates)))
+            (for-each
+             (lambda (pkg)
+               (apply invoke "cargo" "package" "--offline" "--package" pkg
+                      cargo-package-flags)
+               (for-each
+                (lambda (crate)
+                  (invoke "tar" "xzf" crate "-C" vendor-dir))
+                (find-files "target/package" "\\.crate$"))
+               (patch-cargo-checksums #:vendor-dir vendor-dir))
+             cargo-package-crates))

         ;; Then unpack the crate, reset the timestamp of all contained files, and
         ;; repack them.  This is necessary to ensure that they are reproducible.
diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index f6e2985ed9..1bddac15c6 100644
--- a/guix/scripts/import.scm
+++ b/guix/scripts/import.scm
@@ -126,21 +126,22 @@ (define-command (guix-import . args)
      (show-version-and-exit "guix import"))
     ((or ("-i" file importer args ...)
          ("--insert" file importer args ...))
-     (let* ((importer-definers
+     (let* ((define-prefixes
              `(,@(if (member importer '("crate"))
                      '(define)
                      '())
                define-public))
-            (definer? (cut member <> importer-definers))
+            (define-prefix? (cut member <> define-prefixes))
             (find-and-insert
              (lambda (expr)
                (match expr
-                 (((? definer? definer) term _ ...)
+                 (((? define-prefix? define-prefix) term _ ...)
                   ;; Skip existing definition.
-                  (unless (find-definition-location file term #:definer definer)
+                  (unless (find-definition-location
+                           file term #:define-prefix define-prefix)
                     (let ((source-properties
                            (find-definition-insertion-location
-                            file term #:definer definer)))
+                            file term #:define-prefix define-prefix)))
                       (if source-properties
                           (insert-expression source-properties expr)
                           (let ((port (open-file file "a")))
diff --git a/guix/utils.scm b/guix/utils.scm
index 77ec6d992a..3f85320845 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -522,19 +522,19 @@ (define (insert-expression source-properties expr)
     (edit-expression source-properties insert)))

 (define* (find-definition-location file term
-                                   #:key (definer 'define-public)
+                                   #:key (define-prefix 'define-public)
                                    (pred string=))
-  "Search in FILE for a top-level definition defined by DEFINER with defined
-term comparing to TERM through PRED.  Return the location if PRED returns #t,
-or #f otherwise."
+  "Search in FILE for a top-level definition defined by DEFINE-PREFIX with
+defined term comparing to TERM through PRED.  Return the location if PRED
+returns #t, or #f otherwise."
   (let ((search-term (symbol->string term))
-        (definer? (cut eq? definer <>)))
+        (define-prefix? (cut eq? define-prefix <>)))
     (call-with-input-file file
       (lambda (port)
         (do ((syntax (read-syntax port)
                      (read-syntax port)))
           ((match (syntax->datum syntax)
-             (((? definer?) current-term _ ...)
+             (((? define-prefix?) current-term _ ...)
               (pred (symbol->string current-term)
                     search-term))
              ((? eof-object?) #t)
@@ -543,11 +543,13 @@ (define* (find-definition-location file term
                 (syntax-source syntax))))))))

 (define* (find-definition-insertion-location file term
-                                             #:key (definer 'define-public))
-  "Search in FILE for a top-level definition defined by DEFINER with defined
-term alphabetically succeeds TERM. Return the location if found, or #f
+                                             #:key
+                                             (define-prefix 'define-public))
+  "Search in FILE for a top-level definition defined by DEFINE-PREFIX with
+defined term alphabetically succeeds TERM. Return the location if found, or #f
 otherwise."
-  (find-definition-location file term #:definer definer #:pred string>))
+  (find-definition-location
+   file term #:define-prefix define-prefix #:pred string>))

 
 ;;;




Information forwarded to ludo@HIDDEN, maxim.cournoyer@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:29:22 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 23 03:29:22 2025
Received: from localhost ([127.0.0.1]:47311 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twFlo-000499-CA
	for submit <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:29:21 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:41794)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1twFlm-00048n-Qb
 for 77093 <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:29:19 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742714957;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=rOqXENQGtdo4LW3H43hqvXpLA4xlwXAqGFQMFIXQIr8=;
 b=PeG9N9BxuzPdJ+xPi3j7N+huf7PTsDOaipyXMjYji6jcZzAn9hOW4ByNJj3t3bFcNlYzCe
 4GSRmMl4w+lu7h3xunf0qtUYsdy8qebTR8CMt7MXp3Azg6Rqkork3GEUv5Yuunv/N4XHmp
 Nxa1uvD0gLR1g54MwkveorFj1yEhE0iZLxp3P15jE7OSYypgTx2o8rSMpEfIGDQcSau6d4
 71+Oevspu1G+AEWtHN/E5xXk7r8bL/BJwPWhsBSjN7BKUWLGuFzczqCA9qH69QUOrOxLCx
 S6uIIQDZv5DULPpzmCEuOSSaA+7wbZPUuDkUffyUljkcaE8n5uTxuLwGSnQvLg==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v3 01/17] =?UTF-8?q?build/cargo:=20Pass=20?=
 =?UTF-8?q?=E2=80=98--offline=E2=80=99=20to=20cargo.?=
Date: Sun, 23 Mar 2025 15:28:23 +0800
Message-ID: <dda6d7f214b14dff1dd3e3760444b4ba917520eb.1742713356.git.hako@HIDDEN>
In-Reply-To: <cover.1742713356.git.hako@HIDDEN>
References: <cover.1742713356.git.hako@HIDDEN>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
X-Debbugs-Cc: Divya Ranjan Pattanaik <divya@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>, Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

This will make error messages more helpful.

* guix/build/cargo-build-system.scm (build,check,package,install): Pass
‘--offline’ to cargo.

Change-Id: Ic95f603b793319f99c9c1fbce43f773bfc8126c0
---
 guix/build/cargo-build-system.scm | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index 5ef6b23abd..41f54f42b7 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -246,7 +246,7 @@ (define* (build #:key
   "Build a given Cargo package."
   (or skip-build?
       (apply invoke
-             `("cargo" "build"
+             `("cargo" "build" "--offline"
                ,@(if parallel-build?
                      (list "-j" (number->string (parallel-job-count)))
                      (list "-j" "1"))
@@ -264,7 +264,7 @@ (define* (check #:key
   "Run tests for a given Cargo package."
   (when tests?
     (apply invoke
-           `("cargo" "test"
+           `("cargo" "test" "--offline"
              ,@(if parallel-build?
                    (list "-j" (number->string (parallel-job-count)))
                    (list "-j" "1"))
@@ -303,7 +303,7 @@ (define* (package #:key
         ;;error: invalid inclusion of reserved file name Cargo.toml.orig in package source
         (when (file-exists? "Cargo.toml.orig")
           (delete-file "Cargo.toml.orig"))
-        (apply invoke `("cargo" "package" ,@cargo-package-flags))
+        (apply invoke `("cargo" "package" "--offline" ,@cargo-package-flags))
 
         ;; Then unpack the crate, reset the timestamp of all contained files, and
         ;; repack them.  This is necessary to ensure that they are reproducible.
@@ -356,7 +356,8 @@ (define* (install #:key
     ;; otherwise cargo will raise an error.
     (or skip-build?
         (not (has-executable-target?))
-        (invoke "cargo" "install" "--no-track" "--path" "." "--root" out
+        (invoke "cargo" "install" "--offline" "--no-track"
+                "--path" "." "--root" out
                 "--features" (string-join features)))
 
     (when install-source?
-- 
2.49.0





Information forwarded to divya@HIDDEN, efraim@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:25:35 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 23 03:25:34 2025
Received: from localhost ([127.0.0.1]:47269 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twFi9-0003ZV-TR
	for submit <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:25:34 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:48142)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1twFhv-0003XK-5C
 for 77093 <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:25:20 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742714718;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=23lhd6o6dULzhofljL9UaScmfBPSTipNmygrpe7uEkk=;
 b=Bh5axcsuvPPBy6yGuBZly/qOTqxcL6lWMdcwhEAUD1ZHyWxpKKX5zc1yk42d4TiTMMQfZt
 Few+0Zl/0qYq6C/xtBjdZ22Yhgf/5rcqtMCmulH0TrNrV3TQ92G9lti2AVK+Ggy5O5U53F
 TwemPSZFp8vHMZuVoNPQV9DpBqwUM7KC0hyOoGntM1ibG68wy1zPvZwqPjr6B1y37vgcc2
 dSY7riBHB7Vzekw/rGYKWMpKyS0zIjZ6pSD5s9p/j6OFOS9KswkK6m32smMH3j9bFNYrlP
 TQ4IPT5WlRdv7zAymA937JSqCqFG1DvIynRUEmJRQX00Fx/Y2SbV78Nbe9lzCw==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v3 04/17] build-system: cargo: Support installing
 Cargo workspace.
Date: Sun, 23 Mar 2025 15:23:08 +0800
Message-ID: <d361c46719773763ac0938fc61f2f6c25af134f3.1742713356.git.hako@HIDDEN>
In-Reply-To: <cover.1742713356.git.hako@HIDDEN>
References: <cover.1742713356.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Hilton Chain <hako@HIDDEN>, Efraim Flashner <efraim@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>, Divya Ranjan Pattanaik <divya@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

*guix/build-system/cargo.scm (cargo-build,cargo-cross-build)
[#:cargo-install-paths]: New argument.
* guix/build/cargo-build-system.scm (install): Use it.
* doc/guix.texi (Build Systems)[cargo-build-system]: Document it.

Change-Id: I74ed1972a5716da05afeac8edb2b0e4b6834bf40
---
 doc/guix.texi                     |  5 ++++-
 guix/build-system/cargo.scm       |  4 ++++
 guix/build/cargo-build-system.scm | 17 +++++++++++++----
 3 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 0089f9e60f..7fa986b4b9 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -9369,7 +9369,10 @@ Build Systems
 library crates to package in the @code{package} phase.  Specified crates are
 packaged from left to right, in case there's dependency among them.  For
 example, specifying @code{''("pcre2-sys" "pcre2")} will package
-@code{"pcre2-sys"} first and then @code{"pcre2"}.
+@code{"pcre2-sys"} first and then @code{"pcre2"}.  Parameter
+@code{#:cargo-install-paths} (default: @code{''()}) allows specifying paths of
+binary crates to install in the @code{install} phase, @code{''("crates/atuin")},
+for example.
 @end defvar
 
 @defvar chicken-build-system
diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
index 4f6d46e70c..4486c706a1 100644
--- a/guix/build-system/cargo.scm
+++ b/guix/build-system/cargo.scm
@@ -96,6 +96,7 @@ (define* (cargo-build name inputs
                       (cargo-test-flags ''())
                       (cargo-package-crates ''())
                       (cargo-package-flags ''("--no-metadata" "--no-verify"))
+                      (cargo-install-paths ''())
                       (features ''())
                       (skip-build? #f)
                       (parallel-build? #t)
@@ -125,6 +126,7 @@ (define* (cargo-build name inputs
                        #:cargo-test-flags #$(sexp->gexp cargo-test-flags)
                        #:cargo-package-crates #$(sexp->gexp cargo-package-crates)
                        #:cargo-package-flags #$(sexp->gexp cargo-package-flags)
+                       #:cargo-install-paths #$(sexp->gexp cargo-install-paths)
                        #:cargo-target #$(cargo-triplet system)
                        #:features #$(sexp->gexp features)
                        #:skip-build? #$skip-build?
@@ -158,6 +160,7 @@ (define* (cargo-cross-build name
                             (cargo-test-flags ''())
                             (cargo-package-crates ''())
                             (cargo-package-flags ''("--no-metadata" "--no-verify"))
+                            (cargo-install-paths ''())
                             (cargo-target (cargo-triplet (or target system)))
                             (features ''())
                             (skip-build? #f)
@@ -190,6 +193,7 @@ (define* (cargo-cross-build name
                        #:cargo-test-flags #$(sexp->gexp cargo-test-flags)
                        #:cargo-package-crates #$(sexp->gexp cargo-package-crates)
                        #:cargo-package-flags #$(sexp->gexp cargo-package-flags)
+                       #:cargo-install-paths #$(sexp->gexp cargo-install-paths)
                        #:cargo-target #$(cargo-triplet (or target system))
                        #:features #$(sexp->gexp features)
                        #:skip-build? #$skip-build?
diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index 51a45b4eab..67311fc850 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -377,6 +377,7 @@ (define* (install #:key
                   skip-build?
                   install-source?
                   features
+                  (cargo-install-paths '())
                   #:allow-other-keys)
   "Install a given Cargo package."
   (let* ((out      (assoc-ref outputs "out"))
@@ -391,10 +392,18 @@ (define* (install #:key
     ;; Only install crates which include binary targets,
     ;; otherwise cargo will raise an error.
     (or skip-build?
-        (not (has-executable-target?))
-        (invoke "cargo" "install" "--offline" "--no-track"
-                "--path" "." "--root" out
-                "--features" (string-join features)))
+        ;; NOTE: Cargo workspace installation support:
+        ;; #:skip-build? #f + #:cargo-install-paths.
+        (and (null? cargo-install-paths)
+             (not (has-executable-target?)))
+        (for-each
+         (lambda (path)
+           (invoke "cargo" "install" "--offline" "--no-track"
+                   "--path" path "--root" out
+                   "--features" (string-join features)))
+         (if (null? cargo-install-paths)
+             '(".")
+             cargo-install-paths)))
 
     (when install-source?
       ;; Install crate tarballs and unpacked sources for later use.
-- 
2.49.0





Information forwarded to hako@HIDDEN, efraim@HIDDEN, maxim.cournoyer@HIDDEN, divya@HIDDEN, ludo@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:25:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 23 03:25:33 2025
Received: from localhost ([127.0.0.1]:47267 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twFi9-0003ZL-4I
	for submit <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:25:33 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:49662)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1twFhr-0003W7-Pl
 for 77093 <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:25:16 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742714714;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=TsqMeoEPxrWTz5BuoP/adKMehqeUtbJe5HaI+Gmux8I=;
 b=aeDw6nyUPrFrZPrpctZb53pMuth9AITIhrBcF0naovBEX0r4lkrqptEUAx/FEhnhRgZHJp
 IQb8s8poY/PghGFCftVoxLftaJu16dJmc+elkCd4UsK1jA0pUKz0tzsXRKDhtqEHGGpwZR
 PbKSEsSc07Btmsy2Zc2CX/fqfgJy6U9+hW+pujGvrLTihIaSaUgEawXdTis0q6HUk/oDdh
 ISdTolO6+KCRFGRxXFykHu9BuAi1BrgduklLAzBvExWo5DfB13PQreywYy0ygxSnIczVtl
 bWzfQtZ67yOT/iWJj/tomq4AdXXceHxLMMdg13+o92HUeECvDNpUk4a9mhW5Jg==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v3 03/17] build-system: cargo: Support packaging
 Cargo workspace.
Date: Sun, 23 Mar 2025 15:23:07 +0800
Message-ID: <9118bb6e582587547a1d0530d9b4db917cadca6a.1742713356.git.hako@HIDDEN>
In-Reply-To: <cover.1742713356.git.hako@HIDDEN>
References: <cover.1742713356.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Hilton Chain <hako@HIDDEN>, Efraim Flashner <efraim@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>, Divya Ranjan Pattanaik <divya@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/build-system/cargo.scm (cargo-build,cargo-cross-build)
[#:cargo-package-crates]: New argument.
* guix/build/cargo-build-system.scm (package): Use it.
* doc/guix.texi (Build Systems)[cargo-build-system]: Document it.

Change-Id: I45ccd95e90827d47127015cb0bda2d41f792335b
---
 doc/guix.texi                     |  7 +++++++
 guix/build-system/cargo.scm       |  4 ++++
 guix/build/cargo-build-system.scm | 21 +++++++++++++++++++--
 3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 0ca109a214..0089f9e60f 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -9363,6 +9363,13 @@ Build Systems
 the binaries defined by the crate.  Unless @code{install-source? #f} is
 defined it will also install a source crate repository of itself and unpacked
 sources, to ease in future hacking on rust packages.
+
+This build system supports cargo workspaces.  Parameter
+@code{#:cargo-package-crates} (default: @code{''()}) allows specifying names of
+library crates to package in the @code{package} phase.  Specified crates are
+packaged from left to right, in case there's dependency among them.  For
+example, specifying @code{''("pcre2-sys" "pcre2")} will package
+@code{"pcre2-sys"} first and then @code{"pcre2"}.
 @end defvar
 
 @defvar chicken-build-system
diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
index 452f7f78d0..4f6d46e70c 100644
--- a/guix/build-system/cargo.scm
+++ b/guix/build-system/cargo.scm
@@ -94,6 +94,7 @@ (define* (cargo-build name inputs
                       (vendor-dir "guix-vendor")
                       (cargo-build-flags ''("--release"))
                       (cargo-test-flags ''())
+                      (cargo-package-crates ''())
                       (cargo-package-flags ''("--no-metadata" "--no-verify"))
                       (features ''())
                       (skip-build? #f)
@@ -122,6 +123,7 @@ (define* (cargo-build name inputs
                        #:vendor-dir #$vendor-dir
                        #:cargo-build-flags #$(sexp->gexp cargo-build-flags)
                        #:cargo-test-flags #$(sexp->gexp cargo-test-flags)
+                       #:cargo-package-crates #$(sexp->gexp cargo-package-crates)
                        #:cargo-package-flags #$(sexp->gexp cargo-package-flags)
                        #:cargo-target #$(cargo-triplet system)
                        #:features #$(sexp->gexp features)
@@ -154,6 +156,7 @@ (define* (cargo-cross-build name
                             (vendor-dir "guix-vendor")
                             (cargo-build-flags ''("--release"))
                             (cargo-test-flags ''())
+                            (cargo-package-crates ''())
                             (cargo-package-flags ''("--no-metadata" "--no-verify"))
                             (cargo-target (cargo-triplet (or target system)))
                             (features ''())
@@ -185,6 +188,7 @@ (define* (cargo-cross-build name
                        #:vendor-dir #$vendor-dir
                        #:cargo-build-flags #$(sexp->gexp cargo-build-flags)
                        #:cargo-test-flags #$(sexp->gexp cargo-test-flags)
+                       #:cargo-package-crates #$(sexp->gexp cargo-package-crates)
                        #:cargo-package-flags #$(sexp->gexp cargo-package-flags)
                        #:cargo-target #$(cargo-triplet (or target system))
                        #:features #$(sexp->gexp features)
diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index 58238992b8..51a45b4eab 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -300,11 +300,16 @@ (define* (package #:key
                   source
                   skip-build?
                   install-source?
+                  (cargo-package-crates '())
                   (cargo-package-flags '("--no-metadata" "--no-verify"))
+                  (vendor-dir "guix-vendor")
                   #:allow-other-keys)
   "Run 'cargo-package' for a given Cargo package."
   (if install-source?
-    (if skip-build?
+    ;; NOTE: Cargo workspace packaging support:
+    ;; #:install-source? #t + #:cargo-package-crates.
+    (if (and (null? cargo-package-crates)
+             skip-build?)
       (begin
         (install-file source "target/package")
         (with-directory-excursion "target/package"
@@ -322,7 +327,19 @@ (define* (package #:key
         ;;error: invalid inclusion of reserved file name Cargo.toml.orig in package source
         (when (file-exists? "Cargo.toml.orig")
           (delete-file "Cargo.toml.orig"))
-        (apply invoke `("cargo" "package" "--offline" ,@cargo-package-flags))
+
+        (if (null? cargo-package-crates)
+            (apply invoke `("cargo" "package" "--offline" ,@cargo-package-flags))
+            (for-each
+             (lambda (pkg)
+               (apply invoke "cargo" "package" "--offline" "--package" pkg
+                      cargo-package-flags)
+               (for-each
+                (lambda (crate)
+                  (invoke "tar" "xzf" crate "-C" vendor-dir))
+                (find-files "target/package" "\\.crate$"))
+               (patch-cargo-checksums #:vendor-dir vendor-dir))
+             cargo-package-crates))
 
         ;; Then unpack the crate, reset the timestamp of all contained files, and
         ;; repack them.  This is necessary to ensure that they are reproducible.
-- 
2.49.0





Information forwarded to hako@HIDDEN, efraim@HIDDEN, maxim.cournoyer@HIDDEN, divya@HIDDEN, ludo@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:25:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 23 03:25:33 2025
Received: from localhost ([127.0.0.1]:47265 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twFi0-0003Ys-6E
	for submit <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:25:32 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:39424)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1twFhg-0003QF-On
 for 77093 <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:25:14 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742714702;
 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:
 content-transfer-encoding:content-transfer-encoding;
 bh=uykQ3f9snLl0Jk8YahIOIV0raQ2+niRJWypqAqTgSSI=;
 b=d9cB/Nd8tRtZD/H/Wj+3e/vPoIpD5rtQqgRijSzUfjAf3hKZl+YNvSzfxxc2wklS9XNTuA
 lS4aFHSULImSpkvqlQC/6as10sESUIACYUhvX8LfyDXtbpSoGJ5Ng/iMdJIP71AFrlvMu2
 GDq4ZEtSopGDoQqZ0i0NCotpTTghqkbkoCnz7O6bJphJveTyVW1uK353VF2+DpY0mXpH7N
 cdEBZkU57zXPxjxzVtds4U4PC3n87fWyQXjNeJjrsdrfCZ6f8xCRsVCYyZ8RynWHqmYfHx
 89+D4j3zlfqYVxB2SmBnL3IB6EHEUxl2yYjqmWHW2Ygn/ASIhMXDn19QbUZ4sw==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v3 00/17] New Rust packaging workflow based on
 lockfile importer.
Date: Sun, 23 Mar 2025 15:23:04 +0800
Message-ID: <cover.1742713356.git.hako@HIDDEN>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
X-Debbugs-Cc: Divya Ranjan Pattanaik <divya@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>, Steve George <steve@HIDDEN>
X-Debbugs-Cc: Hilton Chain <hako@HIDDEN>, Efraim Flashner <efraim@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.7 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

V2 -> V3:
* Add Efraim's etc/teams/rust/audit-rust-crates script.
* Add (guix import crate cargo-lock) to Rust team's scope.
* ‘definer’ -> ‘define-prefix’
* Adjust documentation and move examples to Guix Cookbook.
* Document ‘cargo-inputs’ and remove mentioning of files under etc/teams/rust.

Diff inserted at end.

Efraim Flashner (1):
  build/cargo: Don't try to unpack sanity-check.py.

Hilton Chain (16):
  build/cargo: Pass ‘--offline’ to cargo.
  build/cargo: Print out all non-empty binary files.
  build-system: cargo: Support packaging Cargo workspace.
  build-system: cargo: Support installing Cargo workspace.
  build/cargo: Set default value of arguments for build phases.
  build/cargo: Support non-workspace directory source inputs.
  scripts: import: Document argument for ‘--insert’ option in help
    message.
  scripts: import: Add two newlines for ‘--insert’ option.
  scripts: import: Support expressions defined by 'define.
  scripts: import: Pass "--insert" to importers.
  scripts: import: Skip existing definition for ‘--insert’ option.
  import: crate: crate-name->package-name: Move to (guix build-system
    cargo).
  build-system: cargo: Add ‘cargo-inputs’.
  import: crate: Add Cargo.lock parser.
  import: crate: Add ‘--lockfile’ option.
  doc: Document lockfile importer based Rust packaging workflow.

 Makefile.am                       |   1 +
 doc/contributing.texi             |  91 +++++---
 doc/guix-cookbook.texi            | 352 ++++++++++++++++++++++++++++++
 doc/guix.texi                     |  24 ++
 etc/teams.scm                     |   1 +
 etc/teams/rust/audit-rust-crates  |  70 ++++++
 etc/teams/rust/cleanup-crates.sh  |  37 ++++
 etc/teams/rust/rust-crates.tmpl   |  42 ++++
 gnu/local.mk                      |   2 +
 gnu/packages/rust-crates.scm      |  42 ++++
 gnu/packages/rust-sources.scm     |  29 +++
 guix/build-system/cargo.scm       |  59 ++++-
 guix/build/cargo-build-system.scm | 150 +++++++++----
 guix/import/crate.scm             |  81 ++++++-
 guix/import/crate/cargo-lock.scm  | 105 +++++++++
 guix/scripts/import.scm           |  54 +++--
 guix/scripts/import/crate.scm     |  58 ++++-
 guix/utils.scm                    |  29 ++-
 tests/crate.scm                   |  88 ++++++++
 19 files changed, 1209 insertions(+), 106 deletions(-)
 create mode 100755 etc/teams/rust/audit-rust-crates
 create mode 100755 etc/teams/rust/cleanup-crates.sh
 create mode 100644 etc/teams/rust/rust-crates.tmpl
 create mode 100644 gnu/packages/rust-crates.scm
 create mode 100644 gnu/packages/rust-sources.scm
 create mode 100644 guix/import/crate/cargo-lock.scm


base-commit: 127e1e89a83785f4ad8362bdc76b0d850279cf2f
--
2.49.0

diff --git a/doc/contributing.texi b/doc/contributing.texi
index 837074dead..17f22390d5 100644
--- a/doc/contributing.texi
+++ b/doc/contributing.texi
@@ -1600,12 +1600,6 @@ Rust Crates
 @subsection Rust Crates

 @cindex rust
-As currently there's no achievable way to reuse Rust packages as pre-compiled
-inputs for other packages at a distribution scale, and our previous approach on
-making all Rust dependencies as full packages doesn't cope well with Rust
-ecosystem thus causing issues on both contribution and maintenance sides, we
-have switched to a different packaging model.
-
 Rust programs (binary crates) and dependencies (library crates) are treated
 separately.  We put our main efforts into programs and only package Rust
 dependencies as sources, utilizing automation with a manual focus on unbundling
@@ -1625,19 +1619,11 @@ Rust Crates
 @item
 @code{(gnu packages rust-crates)}, storing source definitions imported from Rust
 programs' @file{Cargo.lock} via the lockfile importer (@pxref{Invoking guix
-import, crate, @code{--lockfile=@var{file}}}).
+import, @code{crate}, @code{--lockfile=@var{file}}}).

 Imported definitions must be checked and have vendored sources unbundled before
-contributing to Guix.  Naturally, this module serves as a store for both sources
-and unbundling strategies.
-
-This module is managed by the Rust team (@pxref{Teams}) to ensure there's always
-one version containing all changes from other branches, so that the maintained
-version can be used directly in case of merge conflicts, thus coordination is
-required for other committers to modify it.
-
-Guix source ships template @file{etc/teams/rust/rust-crates.tmpl} and cleanup
-script @file{etc/teams/rust/cleanup-crates.sh} for this module.
+being contributed to Guix.  This module is managed by the Rust team
+(@pxref{Teams}).

 @item
 @code{(gnu packages rust-sources)}, storing more complex definitions that need
@@ -1661,338 +1647,28 @@ Rust Crates

 In practice we are usually packaging development snapshots of Rust dependencies
 specifically for some Rust programs, and can't simply identity them by version.
-In this case we can use a @code{for-@var{program}} suffix.  Examples@:
-@code{rust-pipewire-for-niri}, @code{rust-pubgrub-for-uv}.
-@end enumerate
-
-Let's demonstrate the packaging workflow by examples, note that package-specific
-issues are not involved here.
-
-In preparation, we'll add the following packages to our environment:
-
-@example
-guix shell rust rust:cargo cargo-audit cargo-license
-@end example
-
-Example 1: @code{cargo-audit}, which is published on the crates.io Rust package
-repository @uref{https://crates.io, crates.io}.
-
-@enumerate
-@item
-We can generate a draft definition via the crates.io importer (@pxref{Invoking
-guix import, crate}).  In the end we'll have the following definiton:
-
-@lisp
-(define-public cargo-audit
-  (package
-    (name "cargo-audit")
-    (version "0.21.2")
-    (source
-     (origin
-       (method url-fetch)
-       (uri (crate-uri "cargo-audit" version))
-       (file-name (string-append name "-" version ".tar.gz"))
-       (sha256
-        (base32 "1a00yqpckkw86zh2hg7ra82c5fx0ird5766dyynimbvqiwg2ps0n"))))
-    (build-system cargo-build-system)
-    (arguments (list #:install-source? #f))
-    (inputs (cargo-inputs 'cargo-audit))
-    (home-page "https://rustsec.org/")
-    (synopsis "Audit Cargo.lock for crates with security vulnerabilities")
-    (description
-     "This package provides a Cargo subcommand, @@command@{cargo audit@}, to
-audit @@file@{Cargo.lock@} for crates with security vulnerabilities.")
-    (license (list license:asl2.0 license:expat))))
-@end lisp
-
-@code{cargo-inputs} is a procedure defined in @code{guix build-system cargo},
-facilitating dependency modification.  @code{'cargo-audit} used here must be a
-unique identifier, usually same to the program's variable name.
-
-@item
-Unpack package source and navigate to the unpacked directory, then execute the
-following commands:
-
-@example
-cargo generate-lockfile
-cargo audit
-cargo license
-@end example
-
-@command{cargo generate-lockfile} updates dependencies to compatible versions,
-@command{cargo audit} checks known vulnerabilities and @command{cargo license}
-checks licenses of all dependencies.
-
-We must have an acceptable output of @command{cargo audit} and ensure all
-dependencies are licensed with our supported licenses (@pxref{Defining Packages,
-@code{license}}).
-
-@item
-Import dependencies from previously generated lockfile:
-
-@example
-guix import --insert=gnu/packages/rust-crates.scm \
-    crate --lockfile=/path/to/Cargo.lock cargo-audit
-@end example
-
-@code{cargo-audit} used here must be consistent with the identifier used for
-@code{cargo-inputs}.
-
-At this stage, @code{cargo-audit} is buildable.
-
-@item
-Finally we'll unbundle vendored sources.  The lockfile importer inserts
-@code{TODO:} comments to dependencies with high probability of bundled sources.
-@code{cargo-build-system} also performs additional check in its
-@code{check-for-pregenerated-files} phase:
-
-@example
-$ ./pre-inst-env guix build cargo-audit
-@dots{}
-starting phase `check-for-pregenerated-files'
-Searching for binary files...
-./guix-vendor/rust-addr2line-0.21.0.tar.gz/rustfmt.toml
-./guix-vendor/rust-arc-swap-1.7.1.tar.gz/rustfmt.toml
-./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/dictionary-rust
-./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/dictionary-rust-other
-./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/lib.rs.zst
-./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/long-window-size-lib.rs.zst
-@dots{}
-@end example
-
-Although dependencies in @code{(gnu packages rust-crates)} are not exported, we
-can still select them in Guix command-line interface through expression:
-
-@example
-guix build --expression='(@@@@ (gnu packages rust-crates) rust-ring-0.17.14)'
-@end example
-
-For most dependencies, a snippet is sufficient:
-
-@lisp
-(define rust-bzip2-sys-0.1.13+1.0.8
-  (crate-source "bzip2-sys" "0.1.13+1.0.8"
-                "056c39pgjh4272bdslv445f5ry64xvb0f7nph3z7860ln8rzynr2"
-                #:snippet
-                '(begin
-                   (delete-file-recursively "bzip2-1.0.8")
-                   (delete-file "build.rs")
-                   ;; Inspired by Debian's patch.
-                   (with-output-to-file "build.rs"
-                     (lambda _
-                       (format #t "fn main() @{~@@
-                        println!(\"cargo:rustc-link-lib=bz2\");~@@
-                        @}~%"))))))
-@end lisp
-
-In a more complex case, where unbundling one dependency requires other packages,
-we should package the dependency in @code{(gnu packages rust-sources)} first and
-point the imported definition to a symbol with the same name.
-
-For example we have defined a @code{rust-ring-0.17} in @code{(gnu packages
-rust-sources)}, then the imported definition in @code{(gnu packages
-rust-crates)} should be modified to point to it:
-
-@lisp
-(define rust-ring-0.17.14 'rust-ring-0.17)
-@end lisp
-
-When one dependency can be safely removed, modify it to @code{#f}.
-
-@lisp
-(define rust-openssl-src-300.4.2+3.4.1 #f)
-@end lisp
-
-Such modifications are processed by @code{cargo-inputs} procedure.
-
-@code{cargo-inputs} can also be configured by keywoard arguments
-@code{#:crates-module} (default: @code{(gnu packages rust-crates)}, module to
-resolve imported definitions) and @code{#:sources-module} (default: @code{(gnu
-packages rust-sources)}, module to resolve modified symbols), which are useful
-to maintain an independent channel.
+In this case we can use a @code{for-@var{program}} suffix, for example,
+@code{rust-pipewire-for-niri} and @code{rust-pubgrub-for-uv}.
 @end enumerate

-Example 2: @code{niri}, which is not available on crates.io and depends on
-development snapshots (also Cargo workspaces in this example).
+Rust dependencies are not referenced directly.  @code{(guix build-sytem cargo)}
+provides a @code{cargo-inputs} procedure to create an input list, in combination
+with the lockfile importer.

-@enumerate
-@item
-As we can't ensure compatibility of a development snapshot, before executing
-@command{cargo generate-lockfile}, we should modify @file{Cargo.toml} to pin it
-in a known working revision.
+@cindex cargo-inputs
+@deffn {Procedure} cargo-inputs @var{name} @
+       [#:crates-module '(gnu packages rust-crates)] @
+       [#:sources-module '(gnu packages rust-sources)]
+Given symbol @code{'@var{name}}, resolve variable
+@code{@var{name}-cargo-inputs}, an input list, in @var{crates-module}, return
+its copy with @code{#f} removed and symbols resolved to variables defined in
+@var{sources-module} if the input list exists, otherwise return an empty list.

-To use our packaged development snapshots, it's also necessary to modify
-@file{Cargo.toml} in build environment, the substitution pattern is
-package-specific.
-
-@code{cargo-inputs} returns a list, all list operations apply to it too.
-
-@lisp
-(define-public niri
-  (package
-   (name "niri")
-   (version "25.02")
-   (source (origin
-             (method git-fetch)
-             (uri (git-reference
-                   (url "https://github.com/YaLTeR/niri")
-                   (commit (string-append "v" version))))
-             (file-name (git-file-name name version))
-             (sha256
-              (base32
-               "0vzskaalcz6pcml687n54adjddzgf5r07gggc4fhfsa08h1wfd4r"))))
-   (build-system cargo-build-system)
-   (arguments
-    (list #:install-source? #f
-          #:phases
-          #~(modify-phases %standard-phases
-              (add-after 'unpack 'use-guix-vendored-dependencies
-                (lambda _
-                  (substitute* "Cargo.toml"
-                    (("# version =.*")
-                     "version = \"*\"")
-                    (("git.*optional")
-                     "version = \"*\", optional")
-                    (("^git = .*")
-                     "")))))))
-   (native-inputs
-    (list pkg-config))
-   (inputs
-    (cons* clang
-           libdisplay-info
-           libinput-minimal
-           libseat
-           libxkbcommon
-           mesa
-           pango
-           pipewire
-           wayland
-           (cargo-inputs 'niri)))
-   (home-page "https://github.com/YaLTeR/niri")
-   (synopsis "Scrollable-tiling Wayland compositor")
-   (description
-    "Niri is a scrollable-tiling Wayland compositor which arranges windows in a
-scrollable format.  It is considered stable for daily use and performs most
-functions expected of a Wayland compositor.")
-   (license license:gpl3)))
-@end lisp
-
-@item
-@code{niri} also has Cargo workspace dependencies.  When packaging a Cargo
-workspace, build argument @code{#:cargo-package-crates} is required.
-
-@lisp
-(define-public rust-pipewire-for-niri
-  (let ((commit "fd3d8f7861a29c2eeaa4c393402e013578bb36d9")
-        (revision "0"))
-    (package
-      (name "rust-pipewire")
-      (version (git-version "0.8.0" revision commit))
-      (source
-       (origin
-         (method git-fetch)
-         (uri (git-reference
-               (url "https://gitlab.freedesktop.org/pipewire/pipewire-rs.git")
-               (commit commit)))
-         (file-name (git-file-name name version))
-         (sha256
-          (base32 "1hzyhz7xg0mz8a5y9j6yil513p1m610q3j9pzf6q55vdh5mcn79v"))))
-      (build-system cargo-build-system)
-      (arguments
-       (list #:skip-build? #t
-             #:cargo-package-crates
-             ''("libspa-sys" "libspa" "pipewire-sys" "pipewire")))
-      (inputs (cargo-inputs 'rust-pipewire-for-niri))
-      (home-page "https://pipewire.org/")
-      (synopsis "Rust bindings for PipeWire")
-      (description "This package provides Rust bindings for PipeWire.")
-      (license license:expat))))
-@end lisp
-
-Don't forget to modify all workspace members in @code{(gnu packages
-rust-crates)}:
-
-@lisp
-(define rust-pipewire-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
-(define rust-pipewire-sys-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
-@dots{}
-(define rust-libspa-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
-(define rust-libspa-sys-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
-@end lisp
-@end enumerate
-
-Example 3: @code{fish}, which combines two build systems.
-
-@enumerate
-@item
-When building Rust packages in other build systems, we need to add @code{rust}
-and @code{rust:cargo} to @code{native-inputs}, import and use modules from both
-build systems, and apply necessary build phases from @code{cargo-build-system}.
+@var{name} must be consistent with the one used in lockfile importer invocation.
+@end deffn

-@lisp
-(define-public fish
-  (package
-    (name "fish")
-    (version "4.0.0")
-    (source
-     (origin
-       (method url-fetch)
-       (uri (string-append "https://github.com/fish-shell/fish-shell/"
-                           "releases/download/" version "/"
-                           "fish-" version ".tar.xz"))
-       (sha256
-        (base32 "1wv9kjwg6ax8m2f85i58l9f9cndshn1f15n8skc68w1mf3cmpnig"))))
-    (build-system cmake-build-system)
-    (inputs
-     (cons* fish-foreign-env ncurses pcre2
-            python                    ;for fish_config and manpage completions
-            (cargo-inputs 'fish)))
-    (native-inputs
-     (list doxygen groff                ;for 'fish --help'
-           pkg-config
-           procps                       ;for the test suite
-           rust
-           `(,rust "cargo")))
-    (arguments
-     (list #:imported-modules
-           (append %cargo-build-system-modules
-                   %cmake-build-system-modules)
-           #:modules
-           (((guix build cargo-build-system) #:prefix cargo:)
-            (guix build cmake-build-system)
-            (guix build utils))
-           #:phases
-           #~(modify-phases %standard-phases
-               (add-after 'unpack 'use-guix-vendored-dependencies
-                 (lambda _
-                   (substitute* "Cargo.toml"
-                     (("git.*tag.*,")
-                      "version = \"*\","))))
-               (add-after 'unpack 'prepare-cargo-build-system
-                 (lambda args
-                   (for-each
-                    (lambda (phase)
-                      (format #t "Running cargo phase: ~a~%" phase)
-                      (apply (assoc-ref cargo:%standard-phases phase)
-                             args))
-                    '(unpack-rust-crates
-                      configure
-                      check-for-pregenerated-files
-                      patch-cargo-checksums)))))))
-    (synopsis "The friendly interactive shell")
-    (description
-     "Fish (friendly interactive shell) is a shell focused on interactive use,
-discoverability, and friendliness.  Fish has very user-friendly and powerful
-tab-completion, including descriptions of every completion, completion of
-strings with wildcards, and many completions for specific commands.  It also
-has extensive and discoverable help.  A special @@command@{help@} command gives
-access to all the fish documentation in your web browser.  Other features
-include smart terminal handling based on terminfo, an easy to search history,
-and syntax highlighting.")
-    (home-page "https://fishshell.com/")
-    (license license:gpl2)))
-@end lisp
-@end enumerate
+For a more detailed packaging workflow, @pxref{Packaging Rust Crates,,,
+guix-cookbook, GNU Guix Cookbook}.


 @node Elm Packages
diff --git a/doc/guix-cookbook.texi b/doc/guix-cookbook.texi
index d9b98a2ab3..1f0e5eee54 100644
--- a/doc/guix-cookbook.texi
+++ b/doc/guix-cookbook.texi
@@ -103,6 +103,7 @@ Top
 Packaging

 * Packaging Tutorial::          A tutorial on how to add packages to Guix.
+* Packaging Workflows::         Real life examples on working with specific build systems.

 Packaging Tutorial

@@ -127,6 +128,16 @@ Top
 * Automatic update::
 * Inheritance::

+Packaging Workflows
+
+* Packaging Rust Crates::
+
+Packaging Rust Crates
+
+* Common Workflow for Packaging Rust Crates::
+* Development Snapshots and Cargo Workspaces::
+* Rust Programs With Mixed Build Systems::
+
 System Configuration

 * Auto-Login to a Specific TTY::  Automatically Login a User to a Specific TTY
@@ -514,6 +525,7 @@ Packaging

 @menu
 * Packaging Tutorial::          A tutorial on how to add packages to Guix.
+* Packaging Workflows::         Real life examples on working with specific build systems.
 @end menu

 @node Packaging Tutorial
@@ -1593,6 +1605,346 @@ References
 @uref{https://www.gnu.org/software/guix/guix-ghm-andreas-20130823.pdf, ``GNU Guix: Package without a scheme!''}, by Andreas Enge
 @end itemize

+@node Packaging Workflows
+@section Packaging Workflows
+
+The following sections are real life examples on working with specific build
+systems, serving as extensions to the concise packaging guidelines
+(@pxref{Packaging Guidelines,,, guix, GNU Guix Reference Manual}).
+
+@menu
+* Packaging Rust Crates::
+@end menu
+
+@node Packaging Rust Crates
+@subsection Packaging Rust Crates
+
+In preparation, add the following packages to our environment:
+
+@example
+$ guix shell rust rust:cargo cargo-audit cargo-license
+@end example
+
+@menu
+* Common Workflow for Packaging Rust Crates::
+* Development Snapshots and Cargo Workspaces::
+* Rust Programs With Mixed Build Systems::
+@end menu
+
+@node Common Workflow for Packaging Rust Crates
+@subsubsection Common Workflow for Packaging Rust Crates
+
+In this example, we'll package @code{cargo-audit}, which is published on the
+@uref{https://crates.io, crates.io} Rust package repository.  All its
+dependencies are on crates.io as well.
+
+@enumerate
+@item
+Since @code{cargo-audit} is available on crates.io, We can generate a draft
+definition via the crates.io importer (@pxref{Invoking guix import,,, guix, GNU
+Guix Reference Manual}).  In the end we'll have the following definiton:
+
+@lisp
+(define-public cargo-audit
+  (package
+    (name "cargo-audit")
+    (version "0.21.2")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (crate-uri "cargo-audit" version))
+       (file-name (string-append name "-" version ".tar.gz"))
+       (sha256
+        (base32 "1a00yqpckkw86zh2hg7ra82c5fx0ird5766dyynimbvqiwg2ps0n"))))
+    (build-system cargo-build-system)
+    (arguments (list #:install-source? #f))
+    (inputs (cargo-inputs 'cargo-audit))
+    (home-page "https://rustsec.org/")
+    (synopsis "Audit Cargo.lock for crates with security vulnerabilities")
+    (description
+     "This package provides a Cargo subcommand, @@command@{cargo audit@}, to
+audit @@file@{Cargo.lock@} for crates with security vulnerabilities.")
+    (license (list license:asl2.0 license:expat))))
+@end lisp
+
+The symbol used in @code{cargo-inputs}, @code{'cargo-audit} here, must be a
+unique identifier, usually matching the variable name of the package.
+
+@item
+Unpack package source and navigate to the unpacked directory, then execute the
+following commands:
+
+@example
+$ cargo generate-lockfile
+$ cargo audit
+$ cargo license
+@end example
+
+@command{cargo generate-lockfile} updates dependencies to compatible versions,
+@command{cargo audit} checks known vulnerabilities and @command{cargo license}
+checks licenses of all dependencies.
+
+We must have an acceptable output of @command{cargo audit} and ensure all
+dependencies are licensed with our supported licenses (@pxref{Defining
+Packages,,, guix, GNU Guix Reference Manual}).
+
+@item
+Import dependencies from previously generated lockfile:
+
+@example
+$ guix import --insert=gnu/packages/rust-crates.scm \
+      crate --lockfile=/path/to/Cargo.lock cargo-audit
+@end example
+
+@code{cargo-audit} used here must be consistent with the identifier used for
+@code{cargo-inputs}.
+
+At this stage, package @code{cargo-audit} is buildable.
+
+@item
+Finally we'll unbundle vendored sources.  The lockfile importer inserts
+@code{TODO:} comments to dependencies with high probability of bundled sources.
+@code{cargo-build-system} also performs additional check in its
+@code{check-for-pregenerated-files} phase:
+
+@example
+$ ./pre-inst-env guix build cargo-audit
+@dots{}
+starting phase `check-for-pregenerated-files'
+Searching for binary files...
+./guix-vendor/rust-addr2line-0.21.0.tar.gz/rustfmt.toml
+./guix-vendor/rust-arc-swap-1.7.1.tar.gz/rustfmt.toml
+./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/dictionary-rust
+./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/dictionary-rust-other
+./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/lib.rs.zst
+./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/long-window-size-lib.rs.zst
+@dots{}
+@end example
+
+Although dependencies in @code{(gnu packages rust-crates)} are not exported, we
+can still select them via the Guix command-line interface through expression:
+
+@example
+$ guix build --expression='(@@@@ (gnu packages rust-crates) rust-ring-0.17.14)'
+@end example
+
+For most dependencies, a snippet is sufficient:
+
+@lisp
+(define rust-bzip2-sys-0.1.13+1.0.8
+  (crate-source "bzip2-sys" "0.1.13+1.0.8"
+                "056c39pgjh4272bdslv445f5ry64xvb0f7nph3z7860ln8rzynr2"
+                #:snippet
+                '(begin
+                   (delete-file-recursively "bzip2-1.0.8")
+                   (delete-file "build.rs")
+                   ;; Inspired by Debian's patch.
+                   (with-output-to-file "build.rs"
+                     (lambda _
+                       (format #t "fn main() @{~@@
+                        println!(\"cargo:rustc-link-lib=bz2\");~@@
+                        @}~%"))))))
+@end lisp
+
+In a more complex case, where unbundling one dependency requires other packages,
+we should package the dependency in @code{(gnu packages rust-sources)} first and
+reference it by a symbol in the imported definition.
+
+For example we have defined a @code{rust-ring-0.17} in @code{(gnu packages
+rust-sources)}, then the imported definition in @code{(gnu packages
+rust-crates)} should be modified to a matching symbol.
+
+@lisp
+(define rust-ring-0.17.14 'rust-ring-0.17)
+@end lisp
+
+When one dependency can be safely removed, modify it to @code{#f}.
+
+@lisp
+(define rust-openssl-src-300.4.2+3.4.1 #f)
+@end lisp
+@end enumerate
+
+@node Development Snapshots and Cargo Workspaces
+@subsubsection Development Snapshots and Cargo Workspaces
+
+In this example, we'll package @code{niri}, which depends on development
+snapshots (also Cargo workspaces here).
+
+As we can't ensure compatibility of a development snapshot, before executing
+@command{cargo generate-lockfile}, we should modify @file{Cargo.toml} to pin it
+to a known working revision.
+
+To use our packaged development snapshots, it's also necessary to modify
+@file{Cargo.toml} in a build phase, with a package-specific substitution
+pattern.
+
+@lisp
+(define-public niri
+  (package
+   (name "niri")
+   (version "25.02")
+   (source (origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/YaLTeR/niri")
+                   (commit (string-append "v" version))))
+             (file-name (git-file-name name version))
+             (sha256
+              (base32
+               "0vzskaalcz6pcml687n54adjddzgf5r07gggc4fhfsa08h1wfd4r"))))
+   (build-system cargo-build-system)
+   (arguments
+    (list #:install-source? #f
+          #:phases
+          #~(modify-phases %standard-phases
+              (add-after 'unpack 'use-guix-vendored-dependencies
+                (lambda _
+                  (substitute* "Cargo.toml"
+                    (("# version =.*")
+                     "version = \"*\"")
+                    (("git.*optional")
+                     "version = \"*\", optional")
+                    (("^git = .*")
+                     "")))))))
+   (native-inputs
+    (list pkg-config))
+   (inputs
+    (cons* clang
+           libdisplay-info
+           libinput-minimal
+           libseat
+           libxkbcommon
+           mesa
+           pango
+           pipewire
+           wayland
+           (cargo-inputs 'niri)))
+   (home-page "https://github.com/YaLTeR/niri")
+   (synopsis "Scrollable-tiling Wayland compositor")
+   (description
+    "Niri is a scrollable-tiling Wayland compositor which arranges windows in a
+scrollable format.  It is considered stable for daily use and performs most
+functions expected of a Wayland compositor.")
+   (license license:gpl3+)))
+@end lisp
+
+@code{niri} has Cargo workspace dependencies.  When packaging a Cargo workspace,
+argument @code{#:cargo-package-crates} is required.
+
+@lisp
+(define-public rust-pipewire-for-niri
+  (let ((commit "fd3d8f7861a29c2eeaa4c393402e013578bb36d9")
+        (revision "0"))
+    (package
+      (name "rust-pipewire")
+      (version (git-version "0.8.0" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://gitlab.freedesktop.org/pipewire/pipewire-rs.git")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32 "1hzyhz7xg0mz8a5y9j6yil513p1m610q3j9pzf6q55vdh5mcn79v"))))
+      (build-system cargo-build-system)
+      (arguments
+       (list #:skip-build? #t
+             #:cargo-package-crates
+             ''("libspa-sys" "libspa" "pipewire-sys" "pipewire")))
+      (inputs (cargo-inputs 'rust-pipewire-for-niri))
+      (home-page "https://pipewire.org/")
+      (synopsis "Rust bindings for PipeWire")
+      (description "This package provides Rust bindings for PipeWire.")
+      (license license:expat))))
+@end lisp
+
+Don't forget to modify all workspace members in @code{(gnu packages
+rust-crates)}:
+
+@lisp
+(define rust-pipewire-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
+(define rust-pipewire-sys-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
+@dots{}
+(define rust-libspa-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
+(define rust-libspa-sys-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
+@end lisp
+
+@node Rust Programs With Mixed Build Systems
+@subsubsection Rust Programs With Mixed Build Systems
+
+In this example, we'll package @code{fish}, which combines two build systems.
+
+When building Rust packages in other build systems, we need to add @code{rust}
+and @code{rust:cargo} to @code{native-inputs}, import and use modules from both
+build systems, and apply necessary build phases from @code{cargo-build-system}.
+
+@lisp
+(define-public fish
+  (package
+    (name "fish")
+    (version "4.0.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://github.com/fish-shell/fish-shell/"
+                           "releases/download/" version "/"
+                           "fish-" version ".tar.xz"))
+       (sha256
+        (base32 "1wv9kjwg6ax8m2f85i58l9f9cndshn1f15n8skc68w1mf3cmpnig"))))
+    (build-system cmake-build-system)
+    (inputs
+     (cons* fish-foreign-env ncurses pcre2
+            python                    ;for fish_config and manpage completions
+            (cargo-inputs 'fish)))
+    (native-inputs
+     (list doxygen groff                ;for 'fish --help'
+           pkg-config
+           procps                       ;for the test suite
+           rust
+           `(,rust "cargo")))
+    (arguments
+     (list #:imported-modules
+           (append %cargo-build-system-modules
+                   %cmake-build-system-modules)
+           #:modules
+           (((guix build cargo-build-system) #:prefix cargo:)
+            (guix build cmake-build-system)
+            (guix build utils))
+           #:phases
+           #~(modify-phases %standard-phases
+               (add-after 'unpack 'use-guix-vendored-dependencies
+                 (lambda _
+                   (substitute* "Cargo.toml"
+                     (("git.*tag.*,")
+                      "version = \"*\","))))
+               (add-after 'unpack 'prepare-cargo-build-system
+                 (lambda args
+                   (for-each
+                    (lambda (phase)
+                      (format #t "Running cargo phase: ~a~%" phase)
+                      (apply (assoc-ref cargo:%standard-phases phase)
+                             args))
+                    '(unpack-rust-crates
+                      configure
+                      check-for-pregenerated-files
+                      patch-cargo-checksums)))))))
+    (synopsis "The friendly interactive shell")
+    (description
+     "Fish (friendly interactive shell) is a shell focused on interactive use,
+discoverability, and friendliness.  Fish has very user-friendly and powerful
+tab-completion, including descriptions of every completion, completion of
+strings with wildcards, and many completions for specific commands.  It also
+has extensive and discoverable help.  A special @@command@{help@} command gives
+access to all the fish documentation in your web browser.  Other features
+include smart terminal handling based on terminfo, an easy to search history,
+and syntax highlighting.")
+    (home-page "https://fishshell.com/")
+    (license license:gpl2)))
+@end lisp
+
+
 @c *********************************************************************
 @node System Configuration
 @chapter System Configuration
diff --git a/etc/teams.scm b/etc/teams.scm
index 6bddbd91fa..c4bee8d3d9 100755
--- a/etc/teams.scm
+++ b/etc/teams.scm
@@ -389,6 +389,7 @@ (define-team rust
                       "guix/build/cargo-utils.scm"
                       "guix/build-system/cargo.scm"
                       "guix/import/crate.scm"
+                      "guix/import/crate/cargo-lock.scm"
                       "guix/scripts/import/crate.scm"
                       "tests/crate.scm")))

diff --git a/etc/teams/rust/audit-rust-crates b/etc/teams/rust/audit-rust-crates
new file mode 100755
index 0000000000..d5546fd1e1
--- /dev/null
+++ b/etc/teams/rust/audit-rust-crates
@@ -0,0 +1,70 @@
+#!/usr/bin/env -S gawk -f
+# GNU Guix --- Functional package management for GNU
+# Copyright © 2025 Efraim Flashner <efraim@HIDDEN>
+#
+# This file is part of GNU Guix.
+#
+# GNU Guix is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or (at
+# your option) any later version.
+#
+# GNU Guix is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+# To run:
+# ./etc/teams/rust/audit-rust-crates ./path/to/file.scm
+# Prints the output of cargo-audit to the shell.
+
+# Make sure we have cargo-audit in our PATH
+BEGIN {
+    if (system("which cargo-audit 1> /dev/null"))
+        exit 1;
+    # Parse a record at a time.
+    RS = "\n\n"
+    cargoAudit = "cargo-audit audit --file -"
+}
+
+# Check the crate-source origin-only inputs
+/crate-source/ {
+    for(i=3; i <= NF-2; i++) {
+        if($i == "(crate-source") {
+            cargoLock = cargoLock "[[package]]\nname = " $(i+1) "\nversion = " $(i+2) "\n"
+            next
+        }
+    }
+}
+
+# Check the crates packaged from crates.io tarballs
+/crate-uri/ {
+    for(i=3; i <= NF; i++) {
+        if($i == "(version")
+           crateVersion = $(i+1)
+        if($i == "(crate-uri")
+           crateName = $(i+1)
+    }
+    gsub(/)/, "", crateVersion)
+    cargoLock = cargoLock "[[package]]\nname = " crateName "\nversion = " crateVersion "\n"
+}
+
+# The xxxx-cargo-input variables have a set style
+# TODO: Replace the last dash between the name and the version with a space!
+# This doesn't take into account swapping between "-" and "_" so we skip it.
+#( $2 ~ /-cargo-inputs/ ) {
+#    sub(/-cargo-inputs/, "", $2)
+#    gsub(/)/, "", $0)
+#    gsub(/rust-/, "", $0)
+#    #gensub(/([[:alpha:]])-([[:digit:]]+)/, "\\1 \\2", "g", $i)
+#    print "[[package]]\nname = \"" $2 "\"\nversion = \"1.0.0\"\ndependencies = ["
+#    for (i = 4; i <= NF; i++) {
+#        print "\"" $i "\","
+#    }
+#    print "]"
+#}
+
+END { print cargoLock | cargoAudit }
diff --git a/etc/teams/rust/cleanup-crates.sh b/etc/teams/rust/cleanup-crates.sh
index cd4c2462b9..eca37ca00c 100755
--- a/etc/teams/rust/cleanup-crates.sh
+++ b/etc/teams/rust/cleanup-crates.sh
@@ -1,5 +1,4 @@
 #!/bin/sh
-
 # GNU Guix --- Functional package management for GNU
 # Copyright © 2025 Hilton Chain <hako@HIDDEN>
 #
@@ -28,7 +27,7 @@ do
 (begin
   (use-modules (guix utils))
   (let ((source-properties
-         (find-definition-location \"$FILE\" '$crate #:definer 'define)))
+         (find-definition-location \"$FILE\" '$crate #:define-prefix 'define)))
     (and=> source-properties delete-expression)))" |
             guix repl -t machine
     fi
diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
index 47d4f10969..bbfa2f933b 100644
--- a/guix/build-system/cargo.scm
+++ b/guix/build-system/cargo.scm
@@ -78,9 +78,11 @@ (define* (crate-source name version hash #:key (patches '()) (snippet #f))

 (define* (cargo-inputs name #:key (crates-module '(gnu packages rust-crates))
                        (sources-module '(gnu packages rust-sources)))
-  "Given NAME, resolve input list 'NAME-cargo-inputs' in CRATES-MODULE, return
-its copy with #f removed and symbols resolved to variables defined in
-SOURCES-MODULE, if the list exists, otherwise return an empty list."
+
+  "Given symbol NAME, resolve variable 'NAME-cargo-inputs', an input list, in
+CRATES-MODULE, return its copy with #f removed and symbols resolved to
+variables defined in SOURCES-MODULE if the input list exists, otherwise return
+an empty list."
   (let loop ((inputs
               (catch #t
                 (lambda ()
@@ -101,7 +103,7 @@ (define* (cargo-inputs name #:key (crates-module '(gnu packages rust-crates))
                   ((symbol? input)
                    (cons (module-ref (resolve-interface sources-module) input)
                          result))
-                  ;; Else: no change.
+                  ;; Else: keep it.
                   (else
                    (cons input result)))))))))

diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index 41adc03752..1012d7f401 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -350,17 +350,16 @@ (define* (package #:key

         (if (null? cargo-package-crates)
             (apply invoke `("cargo" "package" "--offline" ,@cargo-package-flags))
-            (begin
-              (for-each
-               (lambda (pkg)
-                 (apply invoke "cargo" "package" "--offline" "--package" pkg
-                        cargo-package-flags)
-                 (for-each
-                  (lambda (crate)
-                    (invoke "tar" "xzf" crate "-C" vendor-dir))
-                  (find-files "target/package" "\\.crate$"))
-                 (patch-cargo-checksums #:vendor-dir vendor-dir))
-               cargo-package-crates)))
+            (for-each
+             (lambda (pkg)
+               (apply invoke "cargo" "package" "--offline" "--package" pkg
+                      cargo-package-flags)
+               (for-each
+                (lambda (crate)
+                  (invoke "tar" "xzf" crate "-C" vendor-dir))
+                (find-files "target/package" "\\.crate$"))
+               (patch-cargo-checksums #:vendor-dir vendor-dir))
+             cargo-package-crates))

         ;; Then unpack the crate, reset the timestamp of all contained files, and
         ;; repack them.  This is necessary to ensure that they are reproducible.
diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index f6e2985ed9..1bddac15c6 100644
--- a/guix/scripts/import.scm
+++ b/guix/scripts/import.scm
@@ -126,21 +126,22 @@ (define-command (guix-import . args)
      (show-version-and-exit "guix import"))
     ((or ("-i" file importer args ...)
          ("--insert" file importer args ...))
-     (let* ((importer-definers
+     (let* ((define-prefixes
              `(,@(if (member importer '("crate"))
                      '(define)
                      '())
                define-public))
-            (definer? (cut member <> importer-definers))
+            (define-prefix? (cut member <> define-prefixes))
             (find-and-insert
              (lambda (expr)
                (match expr
-                 (((? definer? definer) term _ ...)
+                 (((? define-prefix? define-prefix) term _ ...)
                   ;; Skip existing definition.
-                  (unless (find-definition-location file term #:definer definer)
+                  (unless (find-definition-location
+                           file term #:define-prefix define-prefix)
                     (let ((source-properties
                            (find-definition-insertion-location
-                            file term #:definer definer)))
+                            file term #:define-prefix define-prefix)))
                       (if source-properties
                           (insert-expression source-properties expr)
                           (let ((port (open-file file "a")))
diff --git a/guix/utils.scm b/guix/utils.scm
index 77ec6d992a..3f85320845 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -522,19 +522,19 @@ (define (insert-expression source-properties expr)
     (edit-expression source-properties insert)))

 (define* (find-definition-location file term
-                                   #:key (definer 'define-public)
+                                   #:key (define-prefix 'define-public)
                                    (pred string=))
-  "Search in FILE for a top-level definition defined by DEFINER with defined
-term comparing to TERM through PRED.  Return the location if PRED returns #t,
-or #f otherwise."
+  "Search in FILE for a top-level definition defined by DEFINE-PREFIX with
+defined term comparing to TERM through PRED.  Return the location if PRED
+returns #t, or #f otherwise."
   (let ((search-term (symbol->string term))
-        (definer? (cut eq? definer <>)))
+        (define-prefix? (cut eq? define-prefix <>)))
     (call-with-input-file file
       (lambda (port)
         (do ((syntax (read-syntax port)
                      (read-syntax port)))
           ((match (syntax->datum syntax)
-             (((? definer?) current-term _ ...)
+             (((? define-prefix?) current-term _ ...)
               (pred (symbol->string current-term)
                     search-term))
              ((? eof-object?) #t)
@@ -543,11 +543,13 @@ (define* (find-definition-location file term
                 (syntax-source syntax))))))))

 (define* (find-definition-insertion-location file term
-                                             #:key (definer 'define-public))
-  "Search in FILE for a top-level definition defined by DEFINER with defined
-term alphabetically succeeds TERM. Return the location if found, or #f
+                                             #:key
+                                             (define-prefix 'define-public))
+  "Search in FILE for a top-level definition defined by DEFINE-PREFIX with
+defined term alphabetically succeeds TERM. Return the location if found, or #f
 otherwise."
-  (find-definition-location file term #:definer definer #:pred string>))
+  (find-definition-location
+   file term #:define-prefix define-prefix #:pred string>))

 
 ;;;




Information forwarded to hako@HIDDEN, efraim@HIDDEN, maxim.cournoyer@HIDDEN, ludo@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:25:24 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 23 03:25:24 2025
Received: from localhost ([127.0.0.1]:47263 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twFhx-0003YQ-BY
	for submit <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:25:24 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:39440)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1twFho-0003TU-J3
 for 77093 <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:25:14 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742714711;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=4dyk8EhTBpU4zaPXLxseyoCZCVCVNbObU/8XSgx1X8g=;
 b=KsoGJCp/ovpUDNazgqtT7VNkuTjlFZQJEaqWW7o8F7ya2sFO+9f7XebQqbiF5gxauw2t0y
 rW25hdHAG71zIUR7AyEgGsmAI842bfDNnX8Dgs9E+znkr6m2Loi0lSN3UPjK7DghFKrA8r
 cd44cPrmSIyCFBPxLi6Mhz2nv/nFWGDaSG4+pTL9k46VWAr4d15bAxalCJbJDX+s9K0sx7
 CuibCXyNeX/4rzWTSiizgLzJ4foa2PzjVVQDDQmvv33BGpDsFX/EXDee8731fMRPpxhzkF
 WlT9Ew6VphQiUysSSH3428KUPnMoQ4igSoh0U+DAuGRpHS3Y14BFqrwSga1e8A==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v3 02/17] build/cargo: Print out all non-empty
 binary files.
Date: Sun, 23 Mar 2025 15:23:06 +0800
Message-ID: <eae23e0485704990b9a27df8b02bfaaf4190eff1.1742713356.git.hako@HIDDEN>
In-Reply-To: <cover.1742713356.git.hako@HIDDEN>
References: <cover.1742713356.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Hilton Chain <hako@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>,
 Maxim Cournoyer <maxim.cournoyer@HIDDEN>,
 Divya Ranjan Pattanaik <divya@HIDDEN>,
 Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/build/cargo-build-system.scm (%standard-phases): Move
'unpack-rust-crates after 'unpack.
Move 'check-for-pregenerated-files after 'configure.
(check-for-pregenerated-files): Only check non-empty files.
Print out binary files.
Run in parallel.
Don't fail to keep compatibility for phase order change.

Change-Id: I0a332fe843e97687324bd908fa111422a63e475d
---
 guix/build/cargo-build-system.scm | 31 +++++++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index 41f54f42b7..58238992b8 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -29,9 +29,11 @@ (define-module (guix build cargo-build-system)
   #:use-module ((guix build utils) #:hide (delete))
   #:use-module (ice-9 popen)
   #:use-module (ice-9 rdelim)
+  #:use-module (ice-9 regex)
   #:use-module (ice-9 ftw)
   #:use-module (ice-9 format)
   #:use-module (ice-9 match)
+  #:use-module (ice-9 threads)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
   #:export (%standard-phases
@@ -111,12 +113,29 @@ (define* (unpack-rust-crates #:key inputs vendor-dir #:allow-other-keys)
 (define (rust-package? name)
   (string-prefix? "rust-" name))
 
-(define* (check-for-pregenerated-files #:rest _)
+(define* (check-for-pregenerated-files #:key parallel-build? #:allow-other-keys)
   "Check the source code for files which are known to generally be bundled
 libraries or executables."
-  (let ((pregenerated-files (find-files "." "\\.(a|dll|dylib|exe|lib)$")))
-    (when (not (null-list? pregenerated-files))
-      (error "Possible pre-generated files found:" pregenerated-files))))
+  (format #t "Searching for binary files...~%")
+  (let ((known-pattern (make-regexp "\\.(a|dll|dylib|exe|lib)$"))
+        (empty-file?
+         (lambda (filename)
+           (call-with-ascii-input-file filename
+             (lambda (p)
+               (eqv? #\0 (read-char p)))))))
+    (n-par-for-each
+     (if parallel-build?
+         (parallel-job-count)
+         1)
+     (lambda (file)
+       (unless (empty-file? file)
+         ;; Print out binary files.
+         (false-if-exception (invoke "grep" "-IL" "." file))
+         ;; Warn about known pre-generated files.
+         ;; Not failing here for compatibility with existing packages.
+         (when (regexp-exec known-pattern file)
+           (format #t "error: Possible pre-generated file found: ~a~%" file))))
+     (find-files "."))))
 
 (define* (configure #:key inputs
                     target system
@@ -380,8 +399,8 @@ (define %standard-phases
     (replace 'check check)
     (replace 'install install)
     (add-after 'build 'package package)
-    (add-after 'unpack 'check-for-pregenerated-files check-for-pregenerated-files)
-    (add-after 'check-for-pregenerated-files 'unpack-rust-crates unpack-rust-crates)
+    (add-after 'unpack 'unpack-rust-crates unpack-rust-crates)
+    (add-after 'configure 'check-for-pregenerated-files check-for-pregenerated-files)
     (add-after 'patch-generated-file-shebangs 'patch-cargo-checksums patch-cargo-checksums)))
 
 (define* (cargo-build #:key inputs (phases %standard-phases)
-- 
2.49.0





Information forwarded to hako@HIDDEN, efraim@HIDDEN, maxim.cournoyer@HIDDEN, divya@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:25:13 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 23 03:25:13 2025
Received: from localhost ([127.0.0.1]:47255 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twFho-0003Tr-Lx
	for submit <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:25:13 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:36306)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1twFhk-0003RU-GJ
 for 77093 <at> debbugs.gnu.org; Sun, 23 Mar 2025 03:25:10 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742714706;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=rOqXENQGtdo4LW3H43hqvXpLA4xlwXAqGFQMFIXQIr8=;
 b=BJDq0GyayHXvKid3un79D2brusr79NzcSD+ltIxZ65xCNlt47U/9ZT09k5xlv8JVyC9qzO
 8UxFQz5SZ/hxB4vGMQWeqpO5U1r91BcR66zK3bztnKXdy5peOuTnDZx7IYWlGgOcnZOQ51
 5dWE0GKxZB5l4yIn65BoFUgynkUi6I0fj2fOUTCxbA0tRn8CqI65CwNq653D66tyImKHTo
 zhkPajNNdtUzN8ecvCAs+QciIMSLFa94htcUP17RZqId0o1FuYlrCciSvdUCGhAwEiwQPs
 DxL1aEO5HtCInIbtT6ONv6sRQ1UUeFYH09FAZh2wcMJuzscpbJeq03xe9zOU0g==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v3 01/17] =?UTF-8?q?build/cargo:=20Pass=20?=
 =?UTF-8?q?=E2=80=98--offline=E2=80=99=20to=20cargo.?=
Date: Sun, 23 Mar 2025 15:23:05 +0800
Message-ID: <dda6d7f214b14dff1dd3e3760444b4ba917520eb.1742713356.git.hako@HIDDEN>
In-Reply-To: <cover.1742713356.git.hako@HIDDEN>
References: <cover.1742713356.git.hako@HIDDEN>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
X-Debbugs-Cc: Hilton Chain <hako@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>,
 Maxim Cournoyer <maxim.cournoyer@HIDDEN>,
 Divya Ranjan Pattanaik <divya@HIDDEN>,
 Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

This will make error messages more helpful.

* guix/build/cargo-build-system.scm (build,check,package,install): Pass
‘--offline’ to cargo.

Change-Id: Ic95f603b793319f99c9c1fbce43f773bfc8126c0
---
 guix/build/cargo-build-system.scm | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index 5ef6b23abd..41f54f42b7 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -246,7 +246,7 @@ (define* (build #:key
   "Build a given Cargo package."
   (or skip-build?
       (apply invoke
-             `("cargo" "build"
+             `("cargo" "build" "--offline"
                ,@(if parallel-build?
                      (list "-j" (number->string (parallel-job-count)))
                      (list "-j" "1"))
@@ -264,7 +264,7 @@ (define* (check #:key
   "Run tests for a given Cargo package."
   (when tests?
     (apply invoke
-           `("cargo" "test"
+           `("cargo" "test" "--offline"
              ,@(if parallel-build?
                    (list "-j" (number->string (parallel-job-count)))
                    (list "-j" "1"))
@@ -303,7 +303,7 @@ (define* (package #:key
         ;;error: invalid inclusion of reserved file name Cargo.toml.orig in package source
         (when (file-exists? "Cargo.toml.orig")
           (delete-file "Cargo.toml.orig"))
-        (apply invoke `("cargo" "package" ,@cargo-package-flags))
+        (apply invoke `("cargo" "package" "--offline" ,@cargo-package-flags))
 
         ;; Then unpack the crate, reset the timestamp of all contained files, and
         ;; repack them.  This is necessary to ensure that they are reproducible.
@@ -356,7 +356,8 @@ (define* (install #:key
     ;; otherwise cargo will raise an error.
     (or skip-build?
         (not (has-executable-target?))
-        (invoke "cargo" "install" "--no-track" "--path" "." "--root" out
+        (invoke "cargo" "install" "--offline" "--no-track"
+                "--path" "." "--root" out
                 "--features" (string-join features)))
 
     (when install-source?
-- 
2.49.0





Information forwarded to hako@HIDDEN, efraim@HIDDEN, maxim.cournoyer@HIDDEN, divya@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 20 Mar 2025 12:03:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 20 08:03:03 2025
Received: from localhost ([127.0.0.1]:55945 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tvEc1-0002HQ-VK
	for submit <at> debbugs.gnu.org; Thu, 20 Mar 2025 08:03:02 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:48770)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tvEbx-0002H5-AD
 for 77093 <at> debbugs.gnu.org; Thu, 20 Mar 2025 08:02:59 -0400
Date: Thu, 20 Mar 2025 20:02:37 +0800
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742472175;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=nGoi5dnwkdiBTHur6pJa1q58ioEDmT/uictLd76Z9Q4=;
 b=A5I7ETKl9E/318JYGDzA8s7HOFj5YS+bYZ4UKueY7i7dxuUFLuY6vkC4OgzqcpY2bRihgL
 8YLXHu7sD0BuKe6HX/kOJ0GwjEGcyJ8U4ea30r4a1EntGxzt9+rTGZIDiyMwhHv0f3EqTV
 aeBPkZm/jCxoDw2TwhZXjW2j7PWmsCwqQ0gXe/pLD40114pdyhIB3FLE6uRbXXMltp+cbX
 HcKNTZclI8tkuH0pnyaN2vyCmq6l9/n8gstyBJ/k3UNsWOPF7M0jYYLpSU31R6iSNiNuh1
 URG6FOi0FY3WMCsf9xlbAWXLifyf81lGw/zyMCwh3Wte3b5Bq0JrkDd6lijVEA==
Message-ID: <87tt7nyko2.wl-hako@HIDDEN>
From: Hilton Chain <hako@HIDDEN>
To: Maxim Cournoyer <maxim.cournoyer@HIDDEN>
Subject: Re: [bug#77093] [PATCH rust-team v2 17/17] doc: Document lockfile
 importer based Rust packaging workflow.
In-Reply-To: <87frj9rvcc.fsf@HIDDEN>
References: <cover.1742306960.git.hako@HIDDEN>
 <613319a41cd8d7823cb1d0aa6cc710cf24239a6b.1742306960.git.hako@HIDDEN>
 <87frj9rvcc.fsf@HIDDEN>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=ISO-8859-7
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Ludovic =?ISO-8859-1?Q?Court=E8s?= <ludo@HIDDEN>, 77093 <at> debbugs.gnu.org,
 Efraim Flashner <efraim@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Wed, 19 Mar 2025 21:41:39 +0800,
Maxim Cournoyer wrote:
>
> [...]
> > +@end lisp
> > +
> > +@item
> > +@code{niri} also has Cargo workspace dependencies.  When packaging a C=
argo
> > +workspace, build argument @code{#:cargo-package-crates} is required.
>
> Hm.  Does that mean we're still in a situation where some inputs are not
> true Guix inputs, and some Rust-packaging oddity that our tooling
> doesn't handle (e.g. 'guix graph' ?).

This argument is meant to specify a order, workspace members may depend on =
each
other, so the dependencies should be packaged and put into "guix-vendor" fi=
rst.

The naming might be confusing but I can't come up with a better one :(

cargo- : cargo-build-system specific
package- : package phase
crates : list of crate names

Rust <package>s will have all their Rust dependencies in inputs field but m=
ost
of them are origins, so there won't be much difference in terms of =A1guix =
graph=A2.

--8<---------------cut here---------------start------------->8---
$ guix graph niri | grep '"rust-.*'
  "140032307245408" [label =3D "rust-bindgen-cli@HIDDEN", shape =3D box, fo=
ntname =3D sans];
  "140032307245936" [label =3D "rust-cbindgen@HIDDEN", shape =3D box, fontn=
ame =3D sans];
  "140032240396352" [label =3D "rust-ring@HIDDEN", shape =3D box, fontname =
=3D sans];
  "140032307276192" [label =3D "rust-cargo-c@HIDDEN+cargo-0.85.0", shape =
=3D box, fontname =3D sans];
  "140032240396176" [label =3D "rust-smithay@HIDDEN", shape =3D bo=
x, fontname =3D sans];
  "140032240396880" [label =3D "rust-pipewire@HIDDEN", shape =3D b=
ox, fontname =3D sans];
$ guix graph niri --type=3Dbag-with-origins | grep '"rust-.*'
  "/gnu/store/kzl3bv8yfczwg18kcx649p7nmf8n2m55-rust-bindgen-cli-0.71.1.drv"=
 [label =3D "rust-bindgen-cli@HIDDEN", shape =3D box, fontname =3D sans];
  "/gnu/store/d28511hifkbpzr8hrnngb5hlsy7js2na-rust-windows-x86-64-msvc-0.5=
2.6.tar.zst.drv" [label =3D "rust-windows-x86-64-msvc-0.52.6.tar.gz", shape=
 =3D box, fontname =3D sans];
  "/gnu/store/7kh3innc661lf8fcya6nziglv93hy2yl-rust-windows-x86-64-gnullvm-=
0.52.6.tar.zst.drv" [label =3D "rust-windows-x86-64-gnullvm-0.52.6.tar.gz",=
 shape =3D box, fontname =3D sans];
  "/gnu/store/fc73asklfa1q29g46bc8gpkggqwpc83w-rust-windows-x86-64-gnu-0.52=
.6.tar.zst.drv" [label =3D "rust-windows-x86-64-gnu-0.52.6.tar.gz", shape =
=3D box, fontname =3D sans];
  "/gnu/store/ca8laa955hw96r49dg5pzsl5pjxqs37j-rust-windows-i686-msvc-0.52.=
6.tar.zst.drv" [label =3D "rust-windows-i686-msvc-0.52.6.tar.gz", shape =3D=
 box, fontname =3D sans];
  "/gnu/store/9czqdmfglvmag8xi69a4jyabblhff72j-rust-windows-i686-gnullvm-0.=
52.6.tar.zst.drv" [label =3D "rust-windows-i686-gnullvm-0.52.6.tar.gz", sha=
pe =3D box, fontname =3D sans];
  "/gnu/store/wjmvcdbqjm1zxqaih1c5f52d7990h40p-rust-windows-i686-gnu-0.52.6=
.tar.zst.drv" [label =3D "rust-windows-i686-gnu-0.52.6.tar.gz", shape =3D b=
ox, fontname =3D sans];
  "/gnu/store/w16561c65nzsqmif3ww634mijfk835gl-rust-windows-aarch64-msvc-0.=
52.6.tar.zst.drv" [label =3D "rust-windows-aarch64-msvc-0.52.6.tar.gz", sha=
pe =3D box, fontname =3D sans];
  "/gnu/store/aaw14iijajsxv5s3p6g58py1ippbr3ql-rust-windows-aarch64-gnullvm=
-0.52.6.tar.zst.drv" [label =3D "rust-windows-aarch64-gnullvm-0.52.6.tar.gz=
", shape =3D box, fontname =3D sans];
  "/gnu/store/xp4i48sdij8qmq2xwpq8dq5h4ax0mzgs-rust-windows-targets-0.52.6.=
tar.gz.drv" [label =3D "rust-windows-targets-0.52.6.tar.gz", shape =3D box,=
 fontname =3D sans];
  "/gnu/store/wlfg3iy55ph6ffwp96sqyzg22isx8573-rust-windows-sys-0.59.0.tar.=
gz.drv" [label =3D "rust-windows-sys-0.59.0.tar.gz", shape =3D box, fontnam=
e =3D sans];
  "/gnu/store/q8x8721s5r6rb8nrb19jkwbszrqih26f-rust-winapi-util-0.1.9.tar.g=
z.drv" [label =3D "rust-winapi-util-0.1.9.tar.gz", shape =3D box, fontname =
=3D sans];
  "/gnu/store/qynjbqr3md18m6q4ynrpvglfa8xjys0d-rust-utf8parse-0.2.2.tar.gz.=
drv" [label =3D "rust-utf8parse-0.2.2.tar.gz", shape =3D box, fontname =3D =
sans];
[...]
--8<---------------cut here---------------end--------------->8---

Thanks for the review!  I'll prepare v3 soon :)




Information forwarded to guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 19 Mar 2025 13:42:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 19 09:42:09 2025
Received: from localhost ([127.0.0.1]:49590 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tutgM-0000AP-1m
	for submit <at> debbugs.gnu.org; Wed, 19 Mar 2025 09:42:09 -0400
Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]:50563)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <maxim.cournoyer@HIDDEN>)
 id 1tutgG-00008p-Dv
 for 77093 <at> debbugs.gnu.org; Wed, 19 Mar 2025 09:42:04 -0400
Received: by mail-pl1-x632.google.com with SMTP id
 d9443c01a7336-225a28a511eso118185395ad.1
 for <77093 <at> debbugs.gnu.org>; Wed, 19 Mar 2025 06:42:00 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1742391714; x=1742996514; darn=debbugs.gnu.org;
 h=mime-version:user-agent:message-id:date:references:in-reply-to
 :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to;
 bh=jbyv1lrOmX0aQJQ+NKiFcXzJfi5hMBzhqzJV0sFax2E=;
 b=cqq/uZqWeQseMbZ28yrHGqjqSJ8779tTx5bUG5JfX7y880Ab3bxr214IXqXhyiL8xj
 C7iOWwDinKqPkTZhPkWeqaM08f3d0epkwYp82uZZlf80kqWl/t6er478c8SPWWLtcoh9
 aQNq7E3uJPVtBAAiB/OvMEhedcip1QYT2Ab42G2/4fV0sDoksXcOMAMHDNVMXl4qqd/9
 g4wGnp4PfsnQYFjWxhgQfojwCvOxi6PXvaI59B9O1p0O6vKTsrv9dzA7OzM7PcLv9mxY
 xB1Uk6/Rbq/eIuoo4d1ri++OYhdE+RDkl7YGHVnIajzndYQMCmYHm6qfsYRz4YBX7GkT
 l2Mw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1742391714; x=1742996514;
 h=mime-version:user-agent:message-id:date:references:in-reply-to
 :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date
 :message-id:reply-to;
 bh=jbyv1lrOmX0aQJQ+NKiFcXzJfi5hMBzhqzJV0sFax2E=;
 b=gWjiE3NAXCkPMHP1XtVk8ZoN2ONTUcrCvTFMVlZl1SWLeJ0r5Z4FYccm5gxOAadINV
 edHuaUKBArF69VIandV8D2pLewyQGREDclnJcXeKyKMYoUjtcfJaNdbd8QOMEwtRD1N5
 Azo+YG4iY7C2eZ311Zqc25vIO4iBbPuuftSuz5wAuTpGLQagItzCaupCOpLmnpy50MMy
 MLPMRharYbCabuiIsyff3zwuuxjHEe0PQ/OXK5d/96e6dcSASHio9JoyqP7uXZkV6+ff
 8iyJeXgTEUhsvQXVmFijQgjhSG54k3ojaNQ+DeZQ7Bfc04/LoPt5CaShSq2wDEH6N1MR
 hV3g==
X-Gm-Message-State: AOJu0Yx74YIOQzoT0JPmAzt4zkbMrn/a8qkk3CCoAI6R3AcDwKFDzDmq
 WuA2L/1y7b0drZMSzdbXWEsb4HontaUlja6w+3Zxhn1j7oLK9Y7H
X-Gm-Gg: ASbGncvktaE7nhZkjDpyqF3py87lRwhuB0o5pZuszNiY5oaEd6N0sQhJq2C0jCCsK7d
 3nuGwOo5L9w9oydqkaeJS/n3c4ArthB9zZlyGAVwZNae9E3sp64aDu8wsPoO0mnW/gFCtvInFOn
 /U7TKWdmhLrWyP0bmdHqQpRK4y6w5LdtKHOCA09EfEXbOdmFg171Prw9jzM/1uGAvBhhwd+OSva
 5HZB/jh83CClMCtTW9kG4wyERbBmP0oNt6wnIJuDTk/RR24/9Q7d1aTQZEXL4UIAw/Y9ylMQqz7
 MPcItTL2Fu9hi94Z0GfTesWBS0e6pfr1bGzbbiI5Czw=
X-Google-Smtp-Source: AGHT+IGDz6ijW/zAhQltKTmUv2aqxnqSvFkW47v59leMcFONfDe879bbovMJW0+/Rscvq0PQkYVsqA==
X-Received: by 2002:a05:6a21:3986:b0:1f5:9301:1c02 with SMTP id
 adf61e73a8af0-1fbebc870camr4992737637.25.1742391713817; 
 Wed, 19 Mar 2025 06:41:53 -0700 (PDT)
Received: from terra ([2405:6586:be0:0:83c8:d31d:2cec:f542])
 by smtp.gmail.com with ESMTPSA id
 41be03b00d2f7-af56ea98dcbsm9147506a12.75.2025.03.19.06.41.51
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 19 Mar 2025 06:41:53 -0700 (PDT)
From: Maxim Cournoyer <maxim.cournoyer@HIDDEN>
To: Hilton Chain <hako@HIDDEN>
Subject: Re: [bug#77093] [PATCH rust-team v2 17/17] doc: Document lockfile
 importer based Rust packaging workflow.
In-Reply-To: <613319a41cd8d7823cb1d0aa6cc710cf24239a6b.1742306960.git.hako@HIDDEN>
 (Hilton Chain's message of "Tue, 18 Mar 2025 22:27:00 +0800")
References: <cover.1742306960.git.hako@HIDDEN>
 <613319a41cd8d7823cb1d0aa6cc710cf24239a6b.1742306960.git.hako@HIDDEN>
Date: Wed, 19 Mar 2025 22:41:39 +0900
Message-ID: <87frj9rvcc.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.7 (/)
X-Debbugs-Envelope-To: 77093
Cc: Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, 77093 <at> debbugs.gnu.org,
 Efraim Flashner <efraim@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.3 (/)

Hi,

Hilton Chain <hako@HIDDEN> writes:

> * doc/contributing.texi (Packaging Guidelines)[Rust Crates]: Update
> documentation.
>
> Change-Id: Ic0c6378cf5f5df97d6f8bdd040b486be62c7bddc
> ---
>  doc/contributing.texi | 415 +++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 390 insertions(+), 25 deletions(-)
>
> diff --git a/doc/contributing.texi b/doc/contributing.texi
> index ab4f30d54b..837074dead 100644
> --- a/doc/contributing.texi
> +++ b/doc/contributing.texi
> @@ -1600,34 +1600,399 @@ Rust Crates
>  @subsection Rust Crates
>  
>  @cindex rust
> -Rust programs standing for themselves are named as any other package, using the
> -lowercase upstream name.
> +As currently there's no achievable way to reuse Rust packages as pre-compiled
> +inputs for other packages at a distribution scale, and our previous approach on
> +making all Rust dependencies as full packages doesn't cope well with Rust
> +ecosystem thus causing issues on both contribution and maintenance sides, we
> +have switched to a different packaging model.

I'd drop the above paragraph; it won't age well.

> +Rust programs (binary crates) and dependencies (library crates) are treated
> +separately.  We put our main efforts into programs and only package Rust
> +dependencies as sources, utilizing automation with a manual focus on unbundling
> +vendored dependencies.  The following paragraphs will explain them and give
> +several examples.
> +
> +Rust programs are treated like any other package and named using the lowercase
> +upstream name.  When using the Cargo build system (@pxref{Build Systems,
> +@code{cargo-build-system}}), Rust programs should have @code{#:install-source?}
> +argument set to @code{#f}, as this argument only makes sense for dependencies.
> +When the package source is a Cargo workspace, @code{#:cargo-install-paths} must
> +be set to enable relevant support.
> +
> +Rust dependencies are managed in two modules:
>  
> -To prevent namespace collisions we prefix all other Rust packages with the
> -@code{rust-} prefix.  The name should be changed to lowercase as appropriate and
> -dashes should remain in place.
> +@enumerate
> +@item
> +@code{(gnu packages rust-crates)}, storing source definitions imported from Rust
> +programs' @file{Cargo.lock} via the lockfile importer (@pxref{Invoking guix
> +import, crate, @code{--lockfile=@var{file}}}).
> +
> +Imported definitions must be checked and have vendored sources unbundled before
> +contributing to Guix.  Naturally, this module serves as a store for both sources

s/contributing/being contributed/.  The next sentence (Naturally, ...)
seems superfluous to me.

> +This module is managed by the Rust team (@pxref{Teams}) to ensure there's always
> +one version containing all changes from other branches, so that the maintained
> +version can be used directly in case of merge conflicts, thus coordination is
> +required for other committers to modify it.

I think the above could be simplified like: This module is managed by
the Rust team, via the @file{etc/teams/rust/rust-crates.tmpl} template
file and @file{etc/teams/rust/rust-crates.tmpl} cleanup script.

[...]

> +@item
> +@code{(gnu packages rust-sources)}, storing more complex definitions that need
> +to be full packages.  This includes Rust dependencies requiring external inputs
> +to unbundle and Cargo workspaces.
> +
> +These dependencies should have the @code{#:skip-build?} argument set to
> +@code{#t}.  For Cargo workspaces, @code{#:cargo-package-crates} must be set.
> +
> +Since they are added manually, the following naming convention applies:
> +
> +To prevent namespace collisions they are named with @code{rust-} prefix.  The
> +name should be changed to lowercase as appropriate and dashes should remain in
> +place.
>  
>  In the rust ecosystem it is common for multiple incompatible versions of a
> -package to be used at any given time, so all package definitions should have a
> -versioned suffix.  The versioned suffix is the left-most non-zero digit (and
> -any leading zeros, of course).  This follows the ``caret'' version scheme
> -intended by Cargo.  Examples@: @code{rust-clap-2}, @code{rust-rand-0.6}.
> -
> -Because of the difficulty in reusing rust packages as pre-compiled inputs for
> -other packages the Cargo build system (@pxref{Build Systems,
> -@code{cargo-build-system}}) presents the @code{#:cargo-inputs} and
> -@code{cargo-development-inputs} keywords as build system arguments.  It would be
> -helpful to think of these as similar to @code{propagated-inputs} and
> -@code{native-inputs}.  Rust @code{dependencies} and @code{build-dependencies}
> -should go in @code{#:cargo-inputs}, and @code{dev-dependencies} should go in
> -@code{#:cargo-development-inputs}.  If a Rust package links to other libraries
> -then the standard placement in @code{inputs} and the like should be used.
> -
> -Care should be taken to ensure the correct version of dependencies are used; to
> -this end we try to refrain from skipping the tests or using @code{#:skip-build?}
> -when possible.  Of course this is not always possible, as the package may be
> -developed for a different Operating System, depend on features from the Nightly
> -Rust compiler, or the test suite may have atrophied since it was released.
> +package to be used at any given time, so all dependencies should have a
> +versioned suffix.  The versioned suffix is the left-most non-zero digit (and any
> +leading zeros, of course).  This follows the ``caret'' version scheme intended
> +by Cargo.  Examples@: @code{rust-clap-2}, @code{rust-rand-0.6}.

@: is not needed before a colon.  Refer to (info "(texinfo) Not Ending a Sentence").

> +In practice we are usually packaging development snapshots of Rust dependencies
> +specifically for some Rust programs, and can't simply identity them by version.
> +In this case we can use a @code{for-@var{program}} suffix.  Examples@:

I'd join the last sentence with the previous one, e.g. [...] suffix, for
example: [...]

> +@code{rust-pipewire-for-niri}, @code{rust-pubgrub-for-uv}.
> +@end enumerate
> +
> +Let's demonstrate the packaging workflow by examples, note that package-specific
> +issues are not involved here.

I'd drop the part after examples.  

> +In preparation, we'll add the following packages to our environment:
> +
> +@example
> +guix shell rust rust:cargo cargo-audit cargo-license
> +@end example
> +
> +Example 1: @code{cargo-audit}, which is published on the crates.io Rust package
> +repository @uref{https://crates.io, crates.io}.

I'd replace the textual crates.io with the later @uref, end place the
period after 'repository'.

This verbose how-to Rust packaging, while useful, would better belong in
the cookbook, in my opinion.  The GNU Guix Cookbook document section can
then be referenced from here, for example:

@ref{Rust Packaging Examples,,,guix-cookbook,GNU Guix Cookbook} for real
life examples of packaging Rust applications.

> +@enumerate
> +@item
> +We can generate a draft definition via the crates.io importer (@pxref{Invoking
> +guix import, crate}).  In the end we'll have the following definiton:
> +
> +@lisp
> +(define-public cargo-audit
> +  (package
> +    (name "cargo-audit")
> +    (version "0.21.2")
> +    (source
> +     (origin
> +       (method url-fetch)
> +       (uri (crate-uri "cargo-audit" version))
> +       (file-name (string-append name "-" version ".tar.gz"))
> +       (sha256
> +        (base32 "1a00yqpckkw86zh2hg7ra82c5fx0ird5766dyynimbvqiwg2ps0n"))))
> +    (build-system cargo-build-system)
> +    (arguments (list #:install-source? #f))
> +    (inputs (cargo-inputs 'cargo-audit))
> +    (home-page "https://rustsec.org/")
> +    (synopsis "Audit Cargo.lock for crates with security vulnerabilities")
> +    (description
> +     "This package provides a Cargo subcommand, @@command@{cargo audit@}, to
> +audit @@file@{Cargo.lock@} for crates with security vulnerabilities.")
> +    (license (list license:asl2.0 license:expat))))
> +@end lisp
> +
> +@code{cargo-inputs} is a procedure defined in @code{guix build-system cargo},
> +facilitating dependency modification.  @code{'cargo-audit} used here must be a
> +unique identifier, usually same to the program's variable name.

I'd reword to: [...], usually matching the variable name of the package.

> +
> +@item
> +Unpack package source and navigate to the unpacked directory, then execute the
> +following commands:
> +
> +@example
> +cargo generate-lockfile
> +cargo audit
> +cargo license
> +@end example
> +
> +@command{cargo generate-lockfile} updates dependencies to compatible versions,
> +@command{cargo audit} checks known vulnerabilities and @command{cargo license}
> +checks licenses of all dependencies.
> +
> +We must have an acceptable output of @command{cargo audit} and ensure all
> +dependencies are licensed with our supported licenses (@pxref{Defining Packages,
> +@code{license}}).
> +
> +@item
> +Import dependencies from previously generated lockfile:
> +
> +@example
> +guix import --insert=gnu/packages/rust-crates.scm \
> +    crate --lockfile=/path/to/Cargo.lock cargo-audit
> +@end example
> +
> +@code{cargo-audit} used here must be consistent with the identifier used for
> +@code{cargo-inputs}.
> +
> +At this stage, @code{cargo-audit} is buildable.
> +
> +@item
> +Finally we'll unbundle vendored sources.  The lockfile importer inserts
> +@code{TODO:} comments to dependencies with high probability of bundled sources.
> +@code{cargo-build-system} also performs additional check in its
> +@code{check-for-pregenerated-files} phase:
> +
> +@example
> +$ ./pre-inst-env guix build cargo-audit
> +@dots{}
> +starting phase `check-for-pregenerated-files'
> +Searching for binary files...
> +./guix-vendor/rust-addr2line-0.21.0.tar.gz/rustfmt.toml
> +./guix-vendor/rust-arc-swap-1.7.1.tar.gz/rustfmt.toml
> +./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/dictionary-rust
> +./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/dictionary-rust-other
> +./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/lib.rs.zst
> +./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/long-window-size-lib.rs.zst
> +@dots{}
> +@end example
> +
> +Although dependencies in @code{(gnu packages rust-crates)} are not exported, we
> +can still select them in Guix command-line interface through expression:

select them *via* the Guix command-line interface [...]

> +
> +@example
> +guix build --expression='(@@@@ (gnu packages rust-crates) rust-ring-0.17.14)'
> +@end example
> +
> +For most dependencies, a snippet is sufficient:
> +
> +@lisp
> +(define rust-bzip2-sys-0.1.13+1.0.8
> +  (crate-source "bzip2-sys" "0.1.13+1.0.8"
> +                "056c39pgjh4272bdslv445f5ry64xvb0f7nph3z7860ln8rzynr2"
> +                #:snippet
> +                '(begin
> +                   (delete-file-recursively "bzip2-1.0.8")
> +                   (delete-file "build.rs")
> +                   ;; Inspired by Debian's patch.
> +                   (with-output-to-file "build.rs"
> +                     (lambda _
> +                       (format #t "fn main() @{~@@
> +                        println!(\"cargo:rustc-link-lib=bz2\");~@@
> +                        @}~%"))))))
> +@end lisp
> +
> +In a more complex case, where unbundling one dependency requires other packages,
> +we should package the dependency in @code{(gnu packages rust-sources)} first and
> +point the imported definition to a symbol with the same name.
> +
> +For example we have defined a @code{rust-ring-0.17} in @code{(gnu packages
> +rust-sources)}, then the imported definition in @code{(gnu packages
> +rust-crates)} should be modified to point to it:
> +
> +@lisp
> +(define rust-ring-0.17.14 'rust-ring-0.17)
> +@end lisp
> +
> +When one dependency can be safely removed, modify it to @code{#f}.
> +
> +@lisp
> +(define rust-openssl-src-300.4.2+3.4.1 #f)
> +@end lisp
> +
> +Such modifications are processed by @code{cargo-inputs} procedure.
> +
> +@code{cargo-inputs} can also be configured by keywoard arguments
> +@code{#:crates-module} (default: @code{(gnu packages rust-crates)}, module to
> +resolve imported definitions) and @code{#:sources-module} (default: @code{(gnu
> +packages rust-sources)}, module to resolve modified symbols), which are useful
> +to maintain an independent channel.
> +@end enumerate
> +
> +Example 2: @code{niri}, which is not available on crates.io and depends on

It seems to me these examples should have their own structure node
(subsection or subsubsection, as appropriate).

> +development snapshots (also Cargo workspaces in this example).
> +
> +@enumerate
> +@item
> +As we can't ensure compatibility of a development snapshot, before executing
> +@command{cargo generate-lockfile}, we should modify @file{Cargo.toml} to pin it
> +in a known working revision.
> +
> +To use our packaged development snapshots, it's also necessary to modify
> +@file{Cargo.toml} in build environment, the substitution pattern is
> +package-specific.

The above sentence appears incomplete or disconnected.  Perhaps, 

  To use our packaged development snapshots, it's also necessary to modify
  @file{Cargo.toml} in a phase, with a package-specific substitution
  pattern.

> +@code{cargo-inputs} returns a list, all list operations apply to it too.

This appears to be out of context?

> +
> +@lisp
> +(define-public niri
> +  (package
> +   (name "niri")
> +   (version "25.02")
> +   (source (origin
> +             (method git-fetch)
> +             (uri (git-reference
> +                   (url "https://github.com/YaLTeR/niri")
> +                   (commit (string-append "v" version))))
> +             (file-name (git-file-name name version))
> +             (sha256
> +              (base32
> +               "0vzskaalcz6pcml687n54adjddzgf5r07gggc4fhfsa08h1wfd4r"))))
> +   (build-system cargo-build-system)
> +   (arguments
> +    (list #:install-source? #f
> +          #:phases
> +          #~(modify-phases %standard-phases
> +              (add-after 'unpack 'use-guix-vendored-dependencies
> +                (lambda _
> +                  (substitute* "Cargo.toml"
> +                    (("# version =.*")
> +                     "version = \"*\"")
> +                    (("git.*optional")
> +                     "version = \"*\", optional")
> +                    (("^git = .*")
> +                     "")))))))
> +   (native-inputs
> +    (list pkg-config))
> +   (inputs
> +    (cons* clang
> +           libdisplay-info
> +           libinput-minimal
> +           libseat
> +           libxkbcommon
> +           mesa
> +           pango
> +           pipewire
> +           wayland
> +           (cargo-inputs 'niri)))
> +   (home-page "https://github.com/YaLTeR/niri")
> +   (synopsis "Scrollable-tiling Wayland compositor")
> +   (description
> +    "Niri is a scrollable-tiling Wayland compositor which arranges windows in a
> +scrollable format.  It is considered stable for daily use and performs most
> +functions expected of a Wayland compositor.")
> +   (license license:gpl3)))

I think this should be gpl3+, as the license file carries the original
'or any later version' and apparently no further directions to limit
gpl3 only.

> +@end lisp
> +
> +@item
> +@code{niri} also has Cargo workspace dependencies.  When packaging a Cargo
> +workspace, build argument @code{#:cargo-package-crates} is required.

Hm.  Does that mean we're still in a situation where some inputs are not
true Guix inputs, and some Rust-packaging oddity that our tooling
doesn't handle (e.g. 'guix graph' ?).

> +@lisp
> +(define-public rust-pipewire-for-niri
> +  (let ((commit "fd3d8f7861a29c2eeaa4c393402e013578bb36d9")
> +        (revision "0"))
> +    (package
> +      (name "rust-pipewire")
> +      (version (git-version "0.8.0" revision commit))
> +      (source
> +       (origin
> +         (method git-fetch)
> +         (uri (git-reference
> +               (url "https://gitlab.freedesktop.org/pipewire/pipewire-rs.git")
> +               (commit commit)))
> +         (file-name (git-file-name name version))
> +         (sha256
> +          (base32 "1hzyhz7xg0mz8a5y9j6yil513p1m610q3j9pzf6q55vdh5mcn79v"))))
> +      (build-system cargo-build-system)
> +      (arguments
> +       (list #:skip-build? #t
> +             #:cargo-package-crates
> +             ''("libspa-sys" "libspa" "pipewire-sys" "pipewire")))
> +      (inputs (cargo-inputs 'rust-pipewire-for-niri))
> +      (home-page "https://pipewire.org/")
> +      (synopsis "Rust bindings for PipeWire")
> +      (description "This package provides Rust bindings for PipeWire.")
> +      (license license:expat))))
> +@end lisp
> +
> +Don't forget to modify all workspace members in @code{(gnu packages
> +rust-crates)}:
> +
> +@lisp
> +(define rust-pipewire-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
> +(define rust-pipewire-sys-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
> +@dots{}
> +(define rust-libspa-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
> +(define rust-libspa-sys-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
> +@end lisp
> +@end enumerate
> +
> +Example 3: @code{fish}, which combines two build systems.
> +
> +@enumerate
> +@item
> +When building Rust packages in other build systems, we need to add @code{rust}
> +and @code{rust:cargo} to @code{native-inputs}, import and use modules from both
> +build systems, and apply necessary build phases from @code{cargo-build-system}.
> +
> +@lisp
> +(define-public fish
> +  (package
> +    (name "fish")
> +    (version "4.0.0")
> +    (source
> +     (origin
> +       (method url-fetch)
> +       (uri (string-append "https://github.com/fish-shell/fish-shell/"
> +                           "releases/download/" version "/"
> +                           "fish-" version ".tar.xz"))
> +       (sha256
> +        (base32 "1wv9kjwg6ax8m2f85i58l9f9cndshn1f15n8skc68w1mf3cmpnig"))))
> +    (build-system cmake-build-system)
> +    (inputs
> +     (cons* fish-foreign-env ncurses pcre2
> +            python                    ;for fish_config and manpage completions
> +            (cargo-inputs 'fish)))
> +    (native-inputs
> +     (list doxygen groff                ;for 'fish --help'
> +           pkg-config
> +           procps                       ;for the test suite
> +           rust
> +           `(,rust "cargo")))
> +    (arguments
> +     (list #:imported-modules
> +           (append %cargo-build-system-modules
> +                   %cmake-build-system-modules)
> +           #:modules
> +           (((guix build cargo-build-system) #:prefix cargo:)
> +            (guix build cmake-build-system)
> +            (guix build utils))
> +           #:phases
> +           #~(modify-phases %standard-phases
> +               (add-after 'unpack 'use-guix-vendored-dependencies
> +                 (lambda _
> +                   (substitute* "Cargo.toml"
> +                     (("git.*tag.*,")
> +                      "version = \"*\","))))
> +               (add-after 'unpack 'prepare-cargo-build-system
> +                 (lambda args
> +                   (for-each
> +                    (lambda (phase)
> +                      (format #t "Running cargo phase: ~a~%" phase)
> +                      (apply (assoc-ref cargo:%standard-phases phase)
> +                             args))
> +                    '(unpack-rust-crates
> +                      configure
> +                      check-for-pregenerated-files
> +                      patch-cargo-checksums)))))))
> +    (synopsis "The friendly interactive shell")
> +    (description
> +     "Fish (friendly interactive shell) is a shell focused on interactive use,
> +discoverability, and friendliness.  Fish has very user-friendly and powerful
> +tab-completion, including descriptions of every completion, completion of
> +strings with wildcards, and many completions for specific commands.  It also
> +has extensive and discoverable help.  A special @@command@{help@} command gives
> +access to all the fish documentation in your web browser.  Other features
> +include smart terminal handling based on terminfo, an easy to search history,
> +and syntax highlighting.")
> +    (home-page "https://fishshell.com/")
> +    (license license:gpl2)))
> +@end lisp
> +@end enumerate

Thanks for taking the time to author all of this!

-- 
Maxim




Information forwarded to guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 19 Mar 2025 12:44:01 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 19 08:44:01 2025
Received: from localhost ([127.0.0.1]:49337 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tusm8-0003Aw-N3
	for submit <at> debbugs.gnu.org; Wed, 19 Mar 2025 08:44:01 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:32980)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tusm6-0003Am-9d
 for 77093 <at> debbugs.gnu.org; Wed, 19 Mar 2025 08:43:59 -0400
Date: Wed, 19 Mar 2025 19:34:46 +0800
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742388235;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=v8WId0Az7VmqlCxFqx7CM8T0TUDCCujoEDnkAonPhqk=;
 b=fpVERCI7LcLJa8ZtLdHtLeIVMqCcVKnABPpCVWMbj2a0EVdvWGKIrHkEBMqUMrvUnVGRGW
 keKkU22mOqt07qk7mFwY6q7T6tJI1RQNBp1OfihEvKVWWqNSndoeyN3ahlzxOsZBTMp66J
 Ll7Y3Ix13g2tdIikYJy2oRT52ahF9d9XFOi5Qtd+jqGa98SX3fr6FQUOO68RiP1nxvHXr+
 MXsnRSqV1vlT0Mqz4RwwT/yEtJZY8Yoa2yyAQtRG95muAiZfDZrN2PVzxYpwu48J1B9fw1
 Qj91iulXVmQPI3LmHODpLBtT4WPj46z0POVGM+MT3elyF3YvMqWWOc9ZAePl5A==
Message-ID: <87v7s5xnhl.wl-hako@HIDDEN>
From: Hilton Chain <hako@HIDDEN>
To: Efraim Flashner <efraim@HIDDEN>
Subject: Re: [PATCH rust-team v2 17/17] doc: Document lockfile importer based
 Rust packaging workflow.
In-Reply-To: <Z9ppsJjBWh8hcIPH@3900XT>
References: <cover.1742306960.git.hako@HIDDEN>
 <613319a41cd8d7823cb1d0aa6cc710cf24239a6b.1742306960.git.hako@HIDDEN>
 <Z9ppsJjBWh8hcIPH@3900XT>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=ISO-8859-7
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: 77093 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Wed, 19 Mar 2025 14:52:32 +0800,
Efraim Flashner wrote:
>
> > +Let's demonstrate the packaging workflow by examples, note that packag=
e-specific
> > +issues are not involved here.
> > +
> > +In preparation, we'll add the following packages to our environment:
> > +
> > +@example
> > +guix shell rust rust:cargo cargo-audit cargo-license
> > +@end example
>
> I was able to run cargo-audit as 'cargo-audit audit ...' but I wouldn't
> actually recommend that to anyone.  I'm not sure we actually need rust
> in the shell but I don't have a strong preference.  More thinking aloud,

=A1cargo generate-lockfile=A2 sometimes requires rust.

> perhaps we should adjust rust:cargo to automatically pull in rust:out?

Sounds reasonable.

> I also find it amusing to suggest using cargo-audit when it's not (yet)
> in guix and we immediately follow up with importing it.

XD yes, it's funny to use cargo-audit audit cargo-audit, and cargo-license =
to
check license of cargo-license.

> I could see an argument for putting this part in the cookbook instead of
> here but I feel strongly that it should be here.
> > [...]
> > +@item
> > +@code{niri} also has Cargo workspace dependencies.  When packaging a C=
argo
> > +workspace, build argument @code{#:cargo-package-crates} is required.
> > +
> > +@lisp
> > +(define-public rust-pipewire-for-niri
> > +  (let ((commit "fd3d8f7861a29c2eeaa4c393402e013578bb36d9")
> > +        (revision "0"))
> > +    (package
> > +      (name "rust-pipewire")
> > +      (version (git-version "0.8.0" revision commit))
> > +      (source
> > +       (origin
> > +         (method git-fetch)
> > +         (uri (git-reference
> > +               (url "https://gitlab.freedesktop.org/pipewire/pipewire-=
rs.git")
> > +               (commit commit)))
> > +         (file-name (git-file-name name version))
> > +         (sha256
> > +          (base32 "1hzyhz7xg0mz8a5y9j6yil513p1m610q3j9pzf6q55vdh5mcn79=
v"))))
> > +      (build-system cargo-build-system)
> > +      (arguments
> > +       (list #:skip-build? #t
> > +             #:cargo-package-crates
> > +             ''("libspa-sys" "libspa" "pipewire-sys" "pipewire")))
> > +      (inputs (cargo-inputs 'rust-pipewire-for-niri))
>
> should these be inputs or propagated-inputs? in rust-ring-0.17 in
> rust-sources they are propagated. I would think inputs would be enough
> since the Cargo.lock file will let us know which other crates are
> necessary for actually building it as a dependency of that package.

For rust-ring-0.17 the propagation is necessary, I think this is because our
packaged version is a bit older than the one used in generated lockfile.




Information forwarded to guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 19 Mar 2025 06:53:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 19 02:53:18 2025
Received: from localhost ([127.0.0.1]:47007 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tunIi-0006hG-8y
	for submit <at> debbugs.gnu.org; Wed, 19 Mar 2025 02:53:18 -0400
Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]:53429)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <efraim.flashner@HIDDEN>)
 id 1tunIH-0006e4-HU
 for 77093 <at> debbugs.gnu.org; Wed, 19 Mar 2025 02:52:58 -0400
Received: by mail-ej1-x62a.google.com with SMTP id
 a640c23a62f3a-ac2963dc379so1101118266b.2
 for <77093 <at> debbugs.gnu.org>; Tue, 18 Mar 2025 23:52:49 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1742367163; x=1742971963; darn=debbugs.gnu.org;
 h=in-reply-to:content-disposition:mime-version:references
 :mail-followup-to:message-id:subject:cc:to:from:date:sender:from:to
 :cc:subject:date:message-id:reply-to;
 bh=OCkAKhEaetr4IrYUXWdx7vCeybKaf5A+C1DrXTpnZQk=;
 b=DhH1z8IOPK0TL9CPBlXmXrBI1pO4HPj2jXpsAvGCiFbsU5+Qzgofhc9h0qocvm6tDK
 p44JO/1XDZDHpCRoIUO+hhNWyhBY7dFsHCTs99NpM+ZunYm9Uz/PBHF1uh0T7QOQq9Gy
 DALuodGPrNLAU7UPVKY1hLxXvQyhYQBMi5P6D4JKfAxm30iK8+WgbmMbmFIXBIfRiLtb
 nUgXw6RYy01exUQ2NPSZbqK3I3RxWGPFFp6QZ0A/H7J1Oku0WIAa1d6EJvAIsftTBTZX
 P/9+rikAcHataKyB1CgIZctXznz2qdt54C4W/4X6iUraBOcnzFF6fSpMlZkVWZ5drcCA
 GfRQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1742367163; x=1742971963;
 h=in-reply-to:content-disposition:mime-version:references
 :mail-followup-to:message-id:subject:cc:to:from:date:sender
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=OCkAKhEaetr4IrYUXWdx7vCeybKaf5A+C1DrXTpnZQk=;
 b=MlOUzIqmwRWNVustNEzuqbvYO98pfoGCNQGjHa96p5ambdNCSEdmm6ikvWpWVqqide
 /A1I8hgMOrwPLUX7O/f0Tc8XZbcDqtS0kai5LQ1LeIJyhUSt1m3X7++XGYyOFqSSGMSv
 qm3eFnXVpn3MtkTaqIIkv0psCeXQFWeyqI/4suJLGOEr3o+pqARMGOEMxBXvKS5PRSeM
 jJf+tkSquArjTI9y1QP4nqabXd0tsosdvBZEckiA+7498LCup+gMPjX1tQEGAhm6dW/x
 KTtNyy2DRRnL9QBmupOPphIAQGWkfutMI6G1E4tq8TOfRb9RDHqmk7J08rBFE07iOrQF
 94YA==
X-Gm-Message-State: AOJu0YyJjfviVW/ov/psfkXo864Kwi5Y3zwJy6NMByZnrsAis3YYsyad
 rX+flTZgtAKqZrASUdF+S/73j1K3kDYuPhOMB4Wvo+lm7D+kq7EN
X-Gm-Gg: ASbGncvbVK57VKoSg3dFXMUNWxqZ9i5Z7sBEEgCZ90Tmgav/X9aPw3tBBB2AkY0Yowb
 J6SBUfWiouMdwYxqOIo5cuDJ3Bb1kWO8/+2SSOBvsTGoFc59nDZA1ZziPxB9r+IVvwJh+snX+AM
 J4okjluD7v+Fn3fSUAnQQ7J7nzmLcwsQip3eeQS6pgeNVUVyLfOp37pKuAChP6eNTswYfpWKIAr
 YYfjmr/40Zc5JY9az8Mkv0Cn2nLF+kno1hrQtEZugYpBy2y7ppnWNbP1akQjnPbbUqMZ6JdLEYK
 y/qqsekaB5ZuA71MCZyVGMQCY/bNr59J3sZe1rwD7z8cxJZGakFKRw==
X-Google-Smtp-Source: AGHT+IEkNZ4Fz4gZDNNfrDaIJgJtj/J2AvBN6smh+OMMfi31ZUtPpalI4C+R3Ms7aKRY2uQuJ6i9Cg==
X-Received: by 2002:a17:907:2ce2:b0:ac1:791c:1532 with SMTP id
 a640c23a62f3a-ac3b7f79733mr133176366b.51.1742367162788; 
 Tue, 18 Mar 2025 23:52:42 -0700 (PDT)
Received: from localhost ([31.210.181.32]) by smtp.gmail.com with ESMTPSA id
 a640c23a62f3a-ac38f091c7bsm277053366b.38.2025.03.18.23.52.41
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 18 Mar 2025 23:52:42 -0700 (PDT)
Date: Wed, 19 Mar 2025 08:52:40 +0200
From: Efraim Flashner <efraim@HIDDEN>
To: Hilton Chain <hako@HIDDEN>
Subject: Re: [PATCH rust-team v2 10/17] scripts: import: Support expressions
 defined by 'define.
Message-ID: <Z9ppuDXVXYsrgaAj@3900XT>
Mail-Followup-To: Efraim Flashner <efraim@HIDDEN>,
 Hilton Chain <hako@HIDDEN>, 77093 <at> debbugs.gnu.org
References: <cover.1742306960.git.hako@HIDDEN>
 <592685c77f24f1052112c00965c9fa1deeedaf33.1742306960.git.hako@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature"; boundary="oQ3LDUlmYSILA+It"
Content-Disposition: inline
In-Reply-To: <592685c77f24f1052112c00965c9fa1deeedaf33.1742306960.git.hako@HIDDEN>
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-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: 77093 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


--oQ3LDUlmYSILA+It
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

How about 'define-prefix' instead of 'definer'? It seems more
descriptive.

On Tue, Mar 18, 2025 at 10:26:53PM +0800, Hilton Chain wrote:
> * guix/utils.scm (find-definition-location): New procedure.
> (find-definition-insertion-location): Define with it.
> * guix/scripts/import.scm (import-as-definitions, guix-import): Support
> expressions defined by 'define.
>=20
> Change-Id: I03118e1a3372028b4f0530964aba871b4a1a4d25
> ---
>  guix/scripts/import.scm | 19 ++++++++++++++-----
>  guix/utils.scm          | 27 +++++++++++++++++++--------
>  2 files changed, 33 insertions(+), 13 deletions(-)
>=20
> diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
> index 58a84d0db7..e53028e747 100644
> --- a/guix/scripts/import.scm
> +++ b/guix/scripts/import.scm
> @@ -30,6 +30,7 @@ (define-module (guix scripts import)
>    #:use-module (guix read-print)
>    #:use-module (guix utils)
>    #:use-module (srfi srfi-1)
> +  #:use-module (srfi srfi-26)
>    #:use-module (ice-9 format)
>    #:use-module (ice-9 match)
>    #:export (%standard-import-options
> @@ -83,7 +84,8 @@ (define (import-as-definitions importer args proc)
>          ((and expr (or ('package _ ...)
>                         ('let _ ...)))
>           (proc (package->definition expr)))
> -        ((and expr ('define-public _ ...))
> +        ((and expr (or ('define-public _ ...)
> +                       ('define _ ...)))
>           (proc expr))
>          ((expressions ...)
>           (for-each (lambda (expr)
> @@ -91,7 +93,8 @@ (define (import-as-definitions importer args proc)
>                         ((and expr (or ('package _ ...)
>                                        ('let _ ...)))
>                          (proc (package->definition expr)))
> -                       ((and expr ('define-public _ ...))
> +                       ((and expr (or ('define-public _ ...)
> +                                      ('define _ ...)))
>                          (proc expr))))
>                     expressions))
>          (x
> @@ -117,13 +120,19 @@ (define-command (guix-import . args)
>       (show-version-and-exit "guix import"))
>      ((or ("-i" file importer args ...)
>           ("--insert" file importer args ...))
> -     (let ((find-and-insert
> +     (let* ((importer-definers
> +             `(,@(if (member importer '("crate"))
> +                     '(define)
> +                     '())
> +               define-public))
> +            (definer? (cut member <> importer-definers))
> +            (find-and-insert
>               (lambda (expr)
>                 (match expr
> -                 (('define-public term _ ...)
> +                 (((? definer? definer) term _ ...)
>                    (let ((source-properties
>                            (find-definition-insertion-location
> -                            file term)))
> +                            file term #:definer definer)))
>                      (if source-properties
>                        (insert-expression source-properties expr)
>                        (let ((port (open-file file "a")))
> diff --git a/guix/utils.scm b/guix/utils.scm
> index c7c23d9d5b..77ec6d992a 100644
> --- a/guix/utils.scm
> +++ b/guix/utils.scm
> @@ -154,6 +154,7 @@ (define-module (guix utils)
>              edit-expression
>              delete-expression
>              insert-expression
> +            find-definition-location
>              find-definition-insertion-location
> =20
>              filtered-port
> @@ -520,24 +521,34 @@ (define (insert-expression source-properties expr)
>                     (string-append expr "\n\n" str))))
>      (edit-expression source-properties insert)))
> =20
> -(define (find-definition-insertion-location file term)
> -  "Search in FILE for a top-level public definition whose defined term
> -alphabetically succeeds TERM. Return the location if found, or #f
> -otherwise."
> -  (let ((search-term (symbol->string term)))
> +(define* (find-definition-location file term
> +                                   #:key (definer 'define-public)
> +                                   (pred string=3D))
> +  "Search in FILE for a top-level definition defined by DEFINER with def=
ined
> +term comparing to TERM through PRED.  Return the location if PRED return=
s #t,
> +or #f otherwise."
> +  (let ((search-term (symbol->string term))
> +        (definer? (cut eq? definer <>)))
>      (call-with-input-file file
>        (lambda (port)
>          (do ((syntax (read-syntax port)
>                       (read-syntax port)))
>            ((match (syntax->datum syntax)
> -             (('define-public current-term _ ...)
> -              (string> (symbol->string current-term)
> -                       search-term))
> +             (((? definer?) current-term _ ...)
> +              (pred (symbol->string current-term)
> +                    search-term))
>               ((? eof-object?) #t)
>               (_ #f))
>             (and (not (eof-object? syntax))
>                  (syntax-source syntax))))))))
> =20
> +(define* (find-definition-insertion-location file term
> +                                             #:key (definer 'define-publ=
ic))
> +  "Search in FILE for a top-level definition defined by DEFINER with def=
ined
> +term alphabetically succeeds TERM. Return the location if found, or #f
> +otherwise."
> +  (find-definition-location file term #:definer definer #:pred string>))
> +
>  =0C
>  ;;;
>  ;;; Keyword arguments.
> --=20
> 2.48.1
>=20

--=20
Efraim Flashner   <efraim@HIDDEN>   =D7=90=D7=A4=D7=A8=D7=99=D7=9D =
=D7=A4=D7=9C=D7=A9=D7=A0=D7=A8
GPG key =3D A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted

--oQ3LDUlmYSILA+It
Content-Type: application/pgp-signature; name=signature.asc

-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAmfaabgACgkQQarn3Mo9
g1HGIxAAs3WA7vFsiwApZ0Uf2GtnhuDFi3GzCweahT3cn+xsN4ZpW0e5UGWRYfpx
Lhr83HL+DwZZuGeEpcVjlzHF2GHaipfH2kbUR5HCdmEDEV011fQKBKq8uZiuQ9X8
mZngOdPhbtstJvFqVgapgcJkR6/wo8VNaNyY5hj2WMUgqKnEjdcl7WZNQU2RUOaC
TRjjQHa72QIrHxvkJ66pfLsWwz53gI2J3NmOeCEuMf8MbQDb957MKx5jUwXW82KW
ZSt1Kecha7mENMPw76tfwqTYbxEhCK1OPMqz8hHwSeT9HRrE5Jepfv98Alm0NVZc
GTUtpMV8b9/6E7IFPhkCYgu3fbsXuemQWFRa/vvV2wFSPEHiWGzktbuJOnRj1JjQ
4iZPAxzSNnypj1v72AT1au5+ZksP7lsUwygT5zxwAmt4FCMAv/+pRgtxnGyNEeel
lrSPI7bavxak/dkR4AWkftsEgPb1g7Kdpy1AIZsI5VGDq6BF6FWc0rjllQI6Ox6H
uuXAfTY71ZYYYd5EaAM9YtN1MohRczjN0tEIw7TIVHm9XBq4aHh/aNwfhWcFq61O
dq7kQDCE882zuUrafL/OzIU/kFysfsdFVsKZvzIcse15/q3pl6QOGLhze0s/8OX7
M4kzO/1aFlBPpZsnbGwtG1GuK2uwio0BGbKhI0t5QWZHuD0iP48=
=QhXd
-----END PGP SIGNATURE-----

--oQ3LDUlmYSILA+It--




Information forwarded to guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 19 Mar 2025 06:53:16 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 19 02:53:16 2025
Received: from localhost ([127.0.0.1]:47005 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tunIc-0006gp-03
	for submit <at> debbugs.gnu.org; Wed, 19 Mar 2025 02:53:16 -0400
Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]:58714)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <efraim.flashner@HIDDEN>)
 id 1tunI9-0006cy-Oh
 for 77093 <at> debbugs.gnu.org; Wed, 19 Mar 2025 02:52:56 -0400
Received: by mail-ed1-x52f.google.com with SMTP id
 4fb4d7f45d1cf-5e8be1c6ff8so2500768a12.1
 for <77093 <at> debbugs.gnu.org>; Tue, 18 Mar 2025 23:52:41 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1742367155; x=1742971955; darn=debbugs.gnu.org;
 h=in-reply-to:content-disposition:mime-version:references
 :mail-followup-to:message-id:subject:cc:to:from:date:sender:from:to
 :cc:subject:date:message-id:reply-to;
 bh=7CBqGRWW+HWdOTpYMzX4Hy5/k4rrZVsKQxtgZfvJEYI=;
 b=dn0z1iLormVMiL5lIXpfdI+QtxSwezR/G7WhH2uiMejCMMluHOxOfcZRab8zs/fOYM
 iXfHXBR880KgoqL+YxTqwAB+0bJJjdvbsUgct+DrKnVNtdR4dwxCMhilVicEm1JeT+9R
 a96OZ9o582u52eXH877U7M+x4pnr+rJXLp0I9cxsJTCw3Yb2dzWypqfg1sBNyPGeXCoN
 kQ8h14E1ws1DA4qXOBU0fgJHUN1ksdGjHREopy4WahxY031Qj8dro+/oU6uMri80bavy
 g7E2vCE637LfWUeXJ/X6nCu0B4MJQ1ak/E/o7Dhqbe7S1cad/c78DpoMzwF/VD+cLhq9
 jq3Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1742367155; x=1742971955;
 h=in-reply-to:content-disposition:mime-version:references
 :mail-followup-to:message-id:subject:cc:to:from:date:sender
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=7CBqGRWW+HWdOTpYMzX4Hy5/k4rrZVsKQxtgZfvJEYI=;
 b=p54V2zPtCyWy6KgWwa+LnOy+Ne6D6OwuneAqN8dje1mTJ7+uVgT77zSfCRiqnsOuCP
 D9Rx89LdcjYdTnJmxBINM1Gav8jZLi9T2wm4D+kNe4hRtgHuPXqDAXRRbZimM7qgCWHW
 LQsOvYi10AnrAruPT7PNmxAXTi6fThqtEAvErJbEI5Ak5MhVV9LwKxRHB4WJ7axYMmwT
 etmJJ/ZMdx2jCc4TwAwIJADYvbRRkvWVb+E9SjFAodwXdcthZGSH2r6M/lzSQwU53EJ8
 vkVXtzcYGEPKoQTpkNFz6yAokpkb933921D3jh7K9NjX/2tyWvTeGIYvf62dyf18rlTn
 SFfg==
X-Gm-Message-State: AOJu0Yw/fVgwypr1Ple6zm9wlcKRX2NZtuh5TD/yYv1AWbU9ozYVj3j1
 p3fdaqmptYYYTIlk5ZaOXdFTFqtoC/gZfPreQEYxx1jap1O9nguC
X-Gm-Gg: ASbGncvHsy37UjxVGYtBHD7f77ovnAVtOLjCY0fC4HYDEfy/0/LSovGoZl6H27vLUAt
 zcEcBXKzbPzOeA1ntsIfHYxgW3cjSOC07kuLY3oSabV0KK2JmxOkfbBbxKZ2AzX3AiK94wYnCaK
 EtanFg/vduscMhlBprqAb7P4i7Jxz/suqneHcTSfBkhS4RQb3Afh3vZp+iLU1vWfMjF5oKGT9Dj
 MHuCULwXtlOAMQ07m8FNMyo3JnZ/mSqSYuHVBt+ygEtqoFEeFuiMPiWfYSI4os76p4RfHD81QFe
 gOv6c7lxUWmWhye3ct9h2tDx0XpxVHLZ+5bDclCRU5E=
X-Google-Smtp-Source: AGHT+IG+o1AEpXmjei0W5DzsxqLD5WuAeNPO2FKMPaRaf2mks9s3WIl+T4bKvxxkAsJKC10zRj5HDA==
X-Received: by 2002:a05:6402:3481:b0:5e7:c42e:3cc0 with SMTP id
 4fb4d7f45d1cf-5eb80d407e2mr1598201a12.9.1742367154897; 
 Tue, 18 Mar 2025 23:52:34 -0700 (PDT)
Received: from localhost ([31.210.181.32]) by smtp.gmail.com with ESMTPSA id
 4fb4d7f45d1cf-5e816afc851sm8637586a12.66.2025.03.18.23.52.33
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 18 Mar 2025 23:52:34 -0700 (PDT)
Date: Wed, 19 Mar 2025 08:52:32 +0200
From: Efraim Flashner <efraim@HIDDEN>
To: Hilton Chain <hako@HIDDEN>
Subject: Re: [PATCH rust-team v2 17/17] doc: Document lockfile importer based
 Rust packaging workflow.
Message-ID: <Z9ppsJjBWh8hcIPH@3900XT>
Mail-Followup-To: Efraim Flashner <efraim@HIDDEN>,
 Hilton Chain <hako@HIDDEN>, 77093 <at> debbugs.gnu.org
References: <cover.1742306960.git.hako@HIDDEN>
 <613319a41cd8d7823cb1d0aa6cc710cf24239a6b.1742306960.git.hako@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature"; boundary="PgpE1194i8qUUqjo"
Content-Disposition: inline
In-Reply-To: <613319a41cd8d7823cb1d0aa6cc710cf24239a6b.1742306960.git.hako@HIDDEN>
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-Spam-Score: 0.7 (/)
X-Debbugs-Envelope-To: 77093
Cc: 77093 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.3 (/)


--PgpE1194i8qUUqjo
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, Mar 18, 2025 at 10:27:00PM +0800, Hilton Chain wrote:
> * doc/contributing.texi (Packaging Guidelines)[Rust Crates]: Update
> documentation.
>=20
> Change-Id: Ic0c6378cf5f5df97d6f8bdd040b486be62c7bddc
> ---
>  doc/contributing.texi | 415 +++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 390 insertions(+), 25 deletions(-)
>=20
> diff --git a/doc/contributing.texi b/doc/contributing.texi
> index ab4f30d54b..837074dead 100644
> --- a/doc/contributing.texi
> +++ b/doc/contributing.texi
> @@ -1600,34 +1600,399 @@ Rust Crates
>  @subsection Rust Crates
> =20
>  @cindex rust
> -Rust programs standing for themselves are named as any other package, us=
ing the
> -lowercase upstream name.
> +As currently there's no achievable way to reuse Rust packages as pre-com=
piled
> +inputs for other packages at a distribution scale, and our previous appr=
oach on
> +making all Rust dependencies as full packages doesn't cope well with Rust
> +ecosystem thus causing issues on both contribution and maintenance sides=
, we
> +have switched to a different packaging model.
> +
> +Rust programs (binary crates) and dependencies (library crates) are trea=
ted
> +separately.  We put our main efforts into programs and only package Rust
> +dependencies as sources, utilizing automation with a manual focus on unb=
undling
> +vendored dependencies.  The following paragraphs will explain them and g=
ive
> +several examples.
> +
> +Rust programs are treated like any other package and named using the low=
ercase
> +upstream name.  When using the Cargo build system (@pxref{Build Systems,
> +@code{cargo-build-system}}), Rust programs should have @code{#:install-s=
ource?}
> +argument set to @code{#f}, as this argument only makes sense for depende=
ncies.
> +When the package source is a Cargo workspace, @code{#:cargo-install-path=
s} must
> +be set to enable relevant support.
> +
> +Rust dependencies are managed in two modules:
> =20
> -To prevent namespace collisions we prefix all other Rust packages with t=
he
> -@code{rust-} prefix.  The name should be changed to lowercase as appropr=
iate and
> -dashes should remain in place.
> +@enumerate
> +@item
> +@code{(gnu packages rust-crates)}, storing source definitions imported f=
rom Rust
> +programs' @file{Cargo.lock} via the lockfile importer (@pxref{Invoking g=
uix
> +import, crate, @code{--lockfile=3D@var{file}}}).
> +
> +Imported definitions must be checked and have vendored sources unbundled=
 before
> +contributing to Guix.  Naturally, this module serves as a store for both=
 sources
> +and unbundling strategies.
> +
> +This module is managed by the Rust team (@pxref{Teams}) to ensure there'=
s always
> +one version containing all changes from other branches, so that the main=
tained
> +version can be used directly in case of merge conflicts, thus coordinati=
on is
> +required for other committers to modify it.
> +
> +Guix source ships template @file{etc/teams/rust/rust-crates.tmpl} and cl=
eanup
> +script @file{etc/teams/rust/cleanup-crates.sh} for this module.
> +
> +@item
> +@code{(gnu packages rust-sources)}, storing more complex definitions tha=
t need
> +to be full packages.  This includes Rust dependencies requiring external=
 inputs
> +to unbundle and Cargo workspaces.
> +
> +These dependencies should have the @code{#:skip-build?} argument set to
> +@code{#t}.  For Cargo workspaces, @code{#:cargo-package-crates} must be =
set.
> +
> +Since they are added manually, the following naming convention applies:
> +
> +To prevent namespace collisions they are named with @code{rust-} prefix.=
  The
> +name should be changed to lowercase as appropriate and dashes should rem=
ain in
> +place.
> =20
>  In the rust ecosystem it is common for multiple incompatible versions of=
 a
> -package to be used at any given time, so all package definitions should =
have a
> -versioned suffix.  The versioned suffix is the left-most non-zero digit =
(and
> -any leading zeros, of course).  This follows the ``caret'' version scheme
> -intended by Cargo.  Examples@: @code{rust-clap-2}, @code{rust-rand-0.6}.
> -
> -Because of the difficulty in reusing rust packages as pre-compiled input=
s for
> -other packages the Cargo build system (@pxref{Build Systems,
> -@code{cargo-build-system}}) presents the @code{#:cargo-inputs} and
> -@code{cargo-development-inputs} keywords as build system arguments.  It =
would be
> -helpful to think of these as similar to @code{propagated-inputs} and
> -@code{native-inputs}.  Rust @code{dependencies} and @code{build-dependen=
cies}
> -should go in @code{#:cargo-inputs}, and @code{dev-dependencies} should g=
o in
> -@code{#:cargo-development-inputs}.  If a Rust package links to other lib=
raries
> -then the standard placement in @code{inputs} and the like should be used.
> -
> -Care should be taken to ensure the correct version of dependencies are u=
sed; to
> -this end we try to refrain from skipping the tests or using @code{#:skip=
-build?}
> -when possible.  Of course this is not always possible, as the package ma=
y be
> -developed for a different Operating System, depend on features from the =
Nightly
> -Rust compiler, or the test suite may have atrophied since it was release=
d.
> +package to be used at any given time, so all dependencies should have a
> +versioned suffix.  The versioned suffix is the left-most non-zero digit =
(and any
> +leading zeros, of course).  This follows the ``caret'' version scheme in=
tended
> +by Cargo.  Examples@: @code{rust-clap-2}, @code{rust-rand-0.6}.
> +
> +In practice we are usually packaging development snapshots of Rust depen=
dencies
> +specifically for some Rust programs, and can't simply identity them by v=
ersion.
> +In this case we can use a @code{for-@var{program}} suffix.  Examples@:
> +@code{rust-pipewire-for-niri}, @code{rust-pubgrub-for-uv}.
> +@end enumerate
> +
> +Let's demonstrate the packaging workflow by examples, note that package-=
specific
> +issues are not involved here.
> +
> +In preparation, we'll add the following packages to our environment:
> +
> +@example
> +guix shell rust rust:cargo cargo-audit cargo-license
> +@end example

I was able to run cargo-audit as 'cargo-audit audit ...' but I wouldn't
actually recommend that to anyone.  I'm not sure we actually need rust
in the shell but I don't have a strong preference.  More thinking aloud,
perhaps we should adjust rust:cargo to automatically pull in rust:out?

I also find it amusing to suggest using cargo-audit when it's not (yet)
in guix and we immediately follow up with importing it.

I could see an argument for putting this part in the cookbook instead of
here but I feel strongly that it should be here.

> +
> +Example 1: @code{cargo-audit}, which is published on the crates.io Rust =
package
> +repository @uref{https://crates.io, crates.io}.
> +
> +@enumerate
> +@item
> +We can generate a draft definition via the crates.io importer (@pxref{In=
voking
> +guix import, crate}).  In the end we'll have the following definiton:
> +
> +@lisp
> +(define-public cargo-audit
> +  (package
> +    (name "cargo-audit")
> +    (version "0.21.2")
> +    (source
> +     (origin
> +       (method url-fetch)
> +       (uri (crate-uri "cargo-audit" version))
> +       (file-name (string-append name "-" version ".tar.gz"))
> +       (sha256
> +        (base32 "1a00yqpckkw86zh2hg7ra82c5fx0ird5766dyynimbvqiwg2ps0n"))=
))
> +    (build-system cargo-build-system)
> +    (arguments (list #:install-source? #f))
> +    (inputs (cargo-inputs 'cargo-audit))
> +    (home-page "https://rustsec.org/")
> +    (synopsis "Audit Cargo.lock for crates with security vulnerabilities=
")
> +    (description
> +     "This package provides a Cargo subcommand, @@command@{cargo audit@}=
, to
> +audit @@file@{Cargo.lock@} for crates with security vulnerabilities.")
> +    (license (list license:asl2.0 license:expat))))
> +@end lisp
> +
> +@code{cargo-inputs} is a procedure defined in @code{guix build-system ca=
rgo},
> +facilitating dependency modification.  @code{'cargo-audit} used here mus=
t be a
> +unique identifier, usually same to the program's variable name.
> +
> +@item
> +Unpack package source and navigate to the unpacked directory, then execu=
te the
> +following commands:
> +
> +@example
> +cargo generate-lockfile
> +cargo audit
> +cargo license
> +@end example
> +
> +@command{cargo generate-lockfile} updates dependencies to compatible ver=
sions,
> +@command{cargo audit} checks known vulnerabilities and @command{cargo li=
cense}
> +checks licenses of all dependencies.
> +
> +We must have an acceptable output of @command{cargo audit} and ensure all
> +dependencies are licensed with our supported licenses (@pxref{Defining P=
ackages,
> +@code{license}}).
> +
> +@item
> +Import dependencies from previously generated lockfile:
> +
> +@example
> +guix import --insert=3Dgnu/packages/rust-crates.scm \
> +    crate --lockfile=3D/path/to/Cargo.lock cargo-audit
> +@end example
> +
> +@code{cargo-audit} used here must be consistent with the identifier used=
 for
> +@code{cargo-inputs}.
> +
> +At this stage, @code{cargo-audit} is buildable.
> +
> +@item
> +Finally we'll unbundle vendored sources.  The lockfile importer inserts
> +@code{TODO:} comments to dependencies with high probability of bundled s=
ources.
> +@code{cargo-build-system} also performs additional check in its
> +@code{check-for-pregenerated-files} phase:
> +
> +@example
> +$ ./pre-inst-env guix build cargo-audit
> +@dots{}
> +starting phase `check-for-pregenerated-files'
> +Searching for binary files...
> +./guix-vendor/rust-addr2line-0.21.0.tar.gz/rustfmt.toml
> +./guix-vendor/rust-arc-swap-1.7.1.tar.gz/rustfmt.toml
> +./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/dicti=
onary-rust
> +./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/dicti=
onary-rust-other
> +./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/lib.r=
s.zst
> +./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/long-=
window-size-lib.rs.zst
> +@dots{}
> +@end example
> +
> +Although dependencies in @code{(gnu packages rust-crates)} are not expor=
ted, we
> +can still select them in Guix command-line interface through expression:
> +
> +@example
> +guix build --expression=3D'(@@@@ (gnu packages rust-crates) rust-ring-0.=
17.14)'
> +@end example
> +
> +For most dependencies, a snippet is sufficient:
> +
> +@lisp
> +(define rust-bzip2-sys-0.1.13+1.0.8
> +  (crate-source "bzip2-sys" "0.1.13+1.0.8"
> +                "056c39pgjh4272bdslv445f5ry64xvb0f7nph3z7860ln8rzynr2"
> +                #:snippet
> +                '(begin
> +                   (delete-file-recursively "bzip2-1.0.8")
> +                   (delete-file "build.rs")
> +                   ;; Inspired by Debian's patch.
> +                   (with-output-to-file "build.rs"
> +                     (lambda _
> +                       (format #t "fn main() @{~@@
> +                        println!(\"cargo:rustc-link-lib=3Dbz2\");~@@
> +                        @}~%"))))))
> +@end lisp
> +
> +In a more complex case, where unbundling one dependency requires other p=
ackages,
> +we should package the dependency in @code{(gnu packages rust-sources)} f=
irst and
> +point the imported definition to a symbol with the same name.
> +
> +For example we have defined a @code{rust-ring-0.17} in @code{(gnu packag=
es
> +rust-sources)}, then the imported definition in @code{(gnu packages
> +rust-crates)} should be modified to point to it:
> +
> +@lisp
> +(define rust-ring-0.17.14 'rust-ring-0.17)
> +@end lisp
> +
> +When one dependency can be safely removed, modify it to @code{#f}.
> +
> +@lisp
> +(define rust-openssl-src-300.4.2+3.4.1 #f)
> +@end lisp
> +
> +Such modifications are processed by @code{cargo-inputs} procedure.
> +
> +@code{cargo-inputs} can also be configured by keywoard arguments
> +@code{#:crates-module} (default: @code{(gnu packages rust-crates)}, modu=
le to
> +resolve imported definitions) and @code{#:sources-module} (default: @cod=
e{(gnu
> +packages rust-sources)}, module to resolve modified symbols), which are =
useful
> +to maintain an independent channel.
> +@end enumerate
> +
> +Example 2: @code{niri}, which is not available on crates.io and depends =
on
> +development snapshots (also Cargo workspaces in this example).
> +
> +@enumerate
> +@item
> +As we can't ensure compatibility of a development snapshot, before execu=
ting
> +@command{cargo generate-lockfile}, we should modify @file{Cargo.toml} to=
 pin it
> +in a known working revision.
> +
> +To use our packaged development snapshots, it's also necessary to modify
> +@file{Cargo.toml} in build environment, the substitution pattern is
> +package-specific.
> +
> +@code{cargo-inputs} returns a list, all list operations apply to it too.
> +
> +@lisp
> +(define-public niri
> +  (package
> +   (name "niri")
> +   (version "25.02")
> +   (source (origin
> +             (method git-fetch)
> +             (uri (git-reference
> +                   (url "https://github.com/YaLTeR/niri")
> +                   (commit (string-append "v" version))))
> +             (file-name (git-file-name name version))
> +             (sha256
> +              (base32
> +               "0vzskaalcz6pcml687n54adjddzgf5r07gggc4fhfsa08h1wfd4r"))))
> +   (build-system cargo-build-system)
> +   (arguments
> +    (list #:install-source? #f
> +          #:phases
> +          #~(modify-phases %standard-phases
> +              (add-after 'unpack 'use-guix-vendored-dependencies
> +                (lambda _
> +                  (substitute* "Cargo.toml"
> +                    (("# version =3D.*")
> +                     "version =3D \"*\"")
> +                    (("git.*optional")
> +                     "version =3D \"*\", optional")
> +                    (("^git =3D .*")
> +                     "")))))))
> +   (native-inputs
> +    (list pkg-config))
> +   (inputs
> +    (cons* clang
> +           libdisplay-info
> +           libinput-minimal
> +           libseat
> +           libxkbcommon
> +           mesa
> +           pango
> +           pipewire
> +           wayland
> +           (cargo-inputs 'niri)))
> +   (home-page "https://github.com/YaLTeR/niri")
> +   (synopsis "Scrollable-tiling Wayland compositor")
> +   (description
> +    "Niri is a scrollable-tiling Wayland compositor which arranges windo=
ws in a
> +scrollable format.  It is considered stable for daily use and performs m=
ost
> +functions expected of a Wayland compositor.")
> +   (license license:gpl3)))
> +@end lisp
> +
> +@item
> +@code{niri} also has Cargo workspace dependencies.  When packaging a Car=
go
> +workspace, build argument @code{#:cargo-package-crates} is required.
> +
> +@lisp
> +(define-public rust-pipewire-for-niri
> +  (let ((commit "fd3d8f7861a29c2eeaa4c393402e013578bb36d9")
> +        (revision "0"))
> +    (package
> +      (name "rust-pipewire")
> +      (version (git-version "0.8.0" revision commit))
> +      (source
> +       (origin
> +         (method git-fetch)
> +         (uri (git-reference
> +               (url "https://gitlab.freedesktop.org/pipewire/pipewire-rs=
=2Egit")
> +               (commit commit)))
> +         (file-name (git-file-name name version))
> +         (sha256
> +          (base32 "1hzyhz7xg0mz8a5y9j6yil513p1m610q3j9pzf6q55vdh5mcn79v"=
))))
> +      (build-system cargo-build-system)
> +      (arguments
> +       (list #:skip-build? #t
> +             #:cargo-package-crates
> +             ''("libspa-sys" "libspa" "pipewire-sys" "pipewire")))
> +      (inputs (cargo-inputs 'rust-pipewire-for-niri))

should these be inputs or propagated-inputs? in rust-ring-0.17 in
rust-sources they are propagated. I would think inputs would be enough
since the Cargo.lock file will let us know which other crates are
necessary for actually building it as a dependency of that package.

> +      (home-page "https://pipewire.org/")
> +      (synopsis "Rust bindings for PipeWire")
> +      (description "This package provides Rust bindings for PipeWire.")
> +      (license license:expat))))
> +@end lisp
> +
> +Don't forget to modify all workspace members in @code{(gnu packages
> +rust-crates)}:
> +
> +@lisp
> +(define rust-pipewire-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
> +(define rust-pipewire-sys-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
> +@dots{}
> +(define rust-libspa-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
> +(define rust-libspa-sys-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
> +@end lisp
> +@end enumerate
> +
> +Example 3: @code{fish}, which combines two build systems.
> +
> +@enumerate
> +@item
> +When building Rust packages in other build systems, we need to add @code=
{rust}
> +and @code{rust:cargo} to @code{native-inputs}, import and use modules fr=
om both
> +build systems, and apply necessary build phases from @code{cargo-build-s=
ystem}.
> +
> +@lisp
> +(define-public fish
> +  (package
> +    (name "fish")
> +    (version "4.0.0")
> +    (source
> +     (origin
> +       (method url-fetch)
> +       (uri (string-append "https://github.com/fish-shell/fish-shell/"
> +                           "releases/download/" version "/"
> +                           "fish-" version ".tar.xz"))
> +       (sha256
> +        (base32 "1wv9kjwg6ax8m2f85i58l9f9cndshn1f15n8skc68w1mf3cmpnig"))=
))
> +    (build-system cmake-build-system)
> +    (inputs
> +     (cons* fish-foreign-env ncurses pcre2
> +            python                    ;for fish_config and manpage compl=
etions
> +            (cargo-inputs 'fish)))
> +    (native-inputs
> +     (list doxygen groff                ;for 'fish --help'
> +           pkg-config
> +           procps                       ;for the test suite
> +           rust
> +           `(,rust "cargo")))
> +    (arguments
> +     (list #:imported-modules
> +           (append %cargo-build-system-modules
> +                   %cmake-build-system-modules)
> +           #:modules
> +           (((guix build cargo-build-system) #:prefix cargo:)
> +            (guix build cmake-build-system)
> +            (guix build utils))
> +           #:phases
> +           #~(modify-phases %standard-phases
> +               (add-after 'unpack 'use-guix-vendored-dependencies
> +                 (lambda _
> +                   (substitute* "Cargo.toml"
> +                     (("git.*tag.*,")
> +                      "version =3D \"*\","))))
> +               (add-after 'unpack 'prepare-cargo-build-system
> +                 (lambda args
> +                   (for-each
> +                    (lambda (phase)
> +                      (format #t "Running cargo phase: ~a~%" phase)
> +                      (apply (assoc-ref cargo:%standard-phases phase)
> +                             args))
> +                    '(unpack-rust-crates
> +                      configure
> +                      check-for-pregenerated-files
> +                      patch-cargo-checksums)))))))
> +    (synopsis "The friendly interactive shell")
> +    (description
> +     "Fish (friendly interactive shell) is a shell focused on interactiv=
e use,
> +discoverability, and friendliness.  Fish has very user-friendly and powe=
rful
> +tab-completion, including descriptions of every completion, completion of
> +strings with wildcards, and many completions for specific commands.  It =
also
> +has extensive and discoverable help.  A special @@command@{help@} comman=
d gives
> +access to all the fish documentation in your web browser.  Other features
> +include smart terminal handling based on terminfo, an easy to search his=
tory,
> +and syntax highlighting.")
> +    (home-page "https://fishshell.com/")
> +    (license license:gpl2)))
> +@end lisp
> +@end enumerate
> =20
> =20
>  @node Elm Packages
> --=20
> 2.48.1
>=20

--=20
Efraim Flashner   <efraim@HIDDEN>   =D7=90=D7=A4=D7=A8=D7=99=D7=9D =
=D7=A4=D7=9C=D7=A9=D7=A0=D7=A8
GPG key =3D A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted

--PgpE1194i8qUUqjo
Content-Type: application/pgp-signature; name=signature.asc

-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAmfaabAACgkQQarn3Mo9
g1HVkA//QYeNozP3xpaD8E4iAt0nO1PSinMMbCx8FLKH7YzhM25hZbGlkawZzFlx
GHfwiRr/8xqSTL2yOVgMEc0sLCxxMwyf1WyNtfo9WKh9ngOqAceuktyVHmd/JrZF
HP4pHrYZyjn9F1wJ6k1X3lBexs3KPzUJzfXzCOtVXZLaibsoj+fyJwscLam6B7D9
zQhPBgEpVvpNGTEbFDadeI9Iz/CWFHNHiR6Ygpwa4APMV5EPfkg8J+P7GpK2Lc17
+5F1S9hpeDQQDTKS/zYdjyaktzDMt4180sSvxQ1X0h8FK8JSGzIywsT5p8m9mFbP
h80VIXhcEKCIbgdTqPKq2jRo4srwuOdmva8w/sW61loSFksPtEl0fAEjUPvXDtxQ
M2Ln0I8AHLO6118qfP/3Vce0wI3oHjv8DEOSbuxfBcgyuLi/8rHaMCNk3UgzxfPm
BewWYQcZoufpOxlV2vzvJ3PZZ80zY5hnXsT0KdvCLRMIg3N/tzjLh8/pCwbZIsOP
ZZlCxptuYSp06fx9qdltmf6HTcFlbT+4sZZ3eyCqISylbdIIG3EYtWIlxG63LmwV
KnU1GtAqgcQog24SpJx/FP0oev+szeh7T4Bv90R/wrreBtO9mlmCQgQF6yIhAFGB
IGvM5D0VDUU9Jm90/XX6Eb4ixj0lFkh45+R2HcAtOI1nrSE1yM4=
=pEFm
-----END PGP SIGNATURE-----

--PgpE1194i8qUUqjo--




Information forwarded to guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 19 Mar 2025 06:52:36 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 19 02:52:36 2025
Received: from localhost ([127.0.0.1]:46991 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tunI0-0006ci-OA
	for submit <at> debbugs.gnu.org; Wed, 19 Mar 2025 02:52:36 -0400
Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]:59835)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <efraim.flashner@HIDDEN>)
 id 1tunHw-0006c8-MN
 for 77093 <at> debbugs.gnu.org; Wed, 19 Mar 2025 02:52:30 -0400
Received: by mail-ed1-x52e.google.com with SMTP id
 4fb4d7f45d1cf-5e5c7d6b96fso2585257a12.3
 for <77093 <at> debbugs.gnu.org>; Tue, 18 Mar 2025 23:52:28 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1742367142; x=1742971942; darn=debbugs.gnu.org;
 h=in-reply-to:content-disposition:mime-version:references
 :mail-followup-to:message-id:subject:cc:to:from:date:sender:from:to
 :cc:subject:date:message-id:reply-to;
 bh=QprRndshgChdzpKu08/65nz5WAoCOL1TNgIFe62ZQQg=;
 b=cTr6nOWZAg6XpKWeNlKHKCjAxsarZUAmdi3XW6G4tryguYM2oSLFH9b0josKFhe20c
 eSVKA2UVyanMvKJtG9TbbDew3o/x22TCfwDI5lR6uIw8guoqgPm/UWSlszwJ13y1p5aq
 mkgXktu3SlJrKOSaAHPe6NdkVnCpyaWkJyVOErosOOTB3PALf3tykfSLmtXUtwa77IRL
 yFUaWJpNOT6c9loiRYNi+srYU4yRa/mE4sMxPQ0jOz9QtHqLlEf0seb2dyi2EhKY79/U
 O+WDWsuBHhb/vNJAEVCUBebHucoofAfTRTYFk4ycXsllPJo6Kr92m5XeajLxfoB/Pgic
 jglQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1742367142; x=1742971942;
 h=in-reply-to:content-disposition:mime-version:references
 :mail-followup-to:message-id:subject:cc:to:from:date:sender
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=QprRndshgChdzpKu08/65nz5WAoCOL1TNgIFe62ZQQg=;
 b=EM+tlVix985Vusv6FYR9lbTQUVnD55EsTQVdXDKVA1IY6zqP1tkIzresoiNjZiwbo4
 KF1x7p0rkpxYHosa12/b8DVzk4JUVs+P2CVlhN0T5VbBe19rROHHdhYfnNJ9ckyngXaE
 S4tjZPGQCaFURFGGFXMCrJqDF1XX5nxCKHCuOo2hK7Qh5MSDGS0Uo+dt2IB0L+dMkoQ4
 J+zcTHFxwEdBKUpqorA1wjPWlF3C1+8is5i7tKJr3F2xnWjVj6ZpF8GPnp9qEGvjv1c2
 O6FAT9wuyVqbJLfnbtSsGQk1yPZqq17zecatXU8XOAs0/s41PEH8twfjiqgN4/Mbsi0s
 9GxA==
X-Gm-Message-State: AOJu0YzfLtBuTwMs1O0yyfwNEazVuT/y8dnnyMsHN/y/lGtzSmMGPfOM
 hlQIv9/FQJ0lfOmYnN+s4vGibJN85Tr2gkX9uHyBpApCHMSKhq+yyaQ9geOK
X-Gm-Gg: ASbGnctD+Yk41IARXX/fw0b3p/ZLGfmSy6xDaeN/NDaUHPS0IBhz/YjDULBDqLPuQsR
 jUtKN5uE0qdR0whK1OcexKhOdWRhCUHl8QxrsBTKHyYdzdzhXgNsxHTV1XA4aIkmXTQ3uBYQi7z
 f6EDkGR8m6yHkjDSSkDBNWb/6+MzGUWTDT1m/4/4V4DWzObta7eib5CMtG/dMMk0WoPQAWfD98Q
 dwXbuah7EX7ZtMvZUtwMXZPeDwywceDpdQVfLo1zfVukZArmfadREAg/JJuhHTa5DH6ocKfFwme
 GY11re19wbByAfXwID1MqcQym4Fk8k2LnS2kIUI76Qg=
X-Google-Smtp-Source: AGHT+IFbxMIQoErAhTxggCo/lJqyJoIGm9/gjQmHo0G59CMJ6RHCcEF6ZuQQo8Ewh6xrg/3yMuGOxQ==
X-Received: by 2002:a05:6402:2350:b0:5e7:b081:d6e0 with SMTP id
 4fb4d7f45d1cf-5eb80d6231amr1590666a12.19.1742367141737; 
 Tue, 18 Mar 2025 23:52:21 -0700 (PDT)
Received: from localhost ([31.210.181.32]) by smtp.gmail.com with ESMTPSA id
 4fb4d7f45d1cf-5e81692e6d4sm8589167a12.9.2025.03.18.23.52.20
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 18 Mar 2025 23:52:20 -0700 (PDT)
Date: Wed, 19 Mar 2025 08:52:19 +0200
From: Efraim Flashner <efraim@HIDDEN>
To: Hilton Chain <hako@HIDDEN>
Subject: Re: [PATCH rust-team v2 00/17] New Rust packaging workflow based on
 lockfile importer.
Message-ID: <Z9ppo2Md7omVh00Y@3900XT>
Mail-Followup-To: Efraim Flashner <efraim@HIDDEN>,
 Hilton Chain <hako@HIDDEN>, 77093 <at> debbugs.gnu.org,
 divya@HIDDEN, steve@HIDDEN
References: <cover.1742306960.git.hako@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature"; boundary="95v81pkqxLBZrl3H"
Content-Disposition: inline
In-Reply-To: <cover.1742306960.git.hako@HIDDEN>
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-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: steve@HIDDEN, 77093 <at> debbugs.gnu.org, divya@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


--95v81pkqxLBZrl3H
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

+CC the other rust-team members, not sure how they got left out.

guix/import/crate/cargo-lock.scm should be added to etc/teams.scm.

I was thinking some more about the rust-crates.tmpl file and I think it
makes sense to keep it since it'll likely be useful for people who want
rust packages in their own channel or for working into a guix.scm file.

Some of the patches, specifically some of the importer ones, seem like
they could go straight to master.

On Tue, Mar 18, 2025 at 10:26:43PM +0800, Hilton Chain wrote:
> V1 -> V2:
>   * Drop jemalloc environment variable patch.
>   * Remove use of RUSTC_BOOTSTRAP.
>   * Adjust documentation.
>   Diff inserted at end.
>=20
> Efraim Flashner (1):
>   build/cargo: Don't try to unpack sanity-check.py.
>=20
> Hilton Chain (16):
>   build/cargo: Pass =E2=80=98--offline=E2=80=99 to cargo.
>   build/cargo: Print out all non-empty binary files.
>   build-system: cargo: Support packaging Cargo workspace.
>   build-system: cargo: Support installing Cargo workspace.
>   build/cargo: Set default value of arguments for build phases.
>   build/cargo: Support non-workspace directory source inputs.
>   scripts: import: Document argument for =E2=80=98--insert=E2=80=99 optio=
n in help
>     message.
>   scripts: import: Add two newlines for =E2=80=98--insert=E2=80=99 option.
>   scripts: import: Support expressions defined by 'define.
>   scripts: import: Pass "--insert" to importers.
>   scripts: import: Skip existing definition for =E2=80=98--insert=E2=80=
=99 option.
>   import: crate: crate-name->package-name: Move to (guix build-system
>     cargo).
>   build-system: cargo: Add =E2=80=98cargo-inputs=E2=80=99.
>   import: crate: Add Cargo.lock parser.
>   import: crate: Add =E2=80=98--lockfile=E2=80=99 option.
>   doc: Document lockfile importer based Rust packaging workflow.
>=20
>  Makefile.am                       |   1 +
>  doc/contributing.texi             | 415 ++++++++++++++++++++++++++++--
>  doc/guix.texi                     |  24 ++
>  etc/teams/rust/cleanup-crates.sh  |  38 +++
>  etc/teams/rust/rust-crates.tmpl   |  42 +++
>  gnu/local.mk                      |   2 +
>  gnu/packages/rust-crates.scm      |  42 +++
>  gnu/packages/rust-sources.scm     |  29 +++
>  guix/build-system/cargo.scm       |  57 +++-
>  guix/build/cargo-build-system.scm | 151 ++++++++---
>  guix/import/crate.scm             |  81 +++++-
>  guix/import/crate/cargo-lock.scm  | 105 ++++++++
>  guix/scripts/import.scm           |  53 ++--
>  guix/scripts/import/crate.scm     |  58 ++++-
>  guix/utils.scm                    |  27 +-
>  tests/crate.scm                   |  88 +++++++
>  16 files changed, 1107 insertions(+), 106 deletions(-)
>  create mode 100755 etc/teams/rust/cleanup-crates.sh
>  create mode 100644 etc/teams/rust/rust-crates.tmpl
>  create mode 100644 gnu/packages/rust-crates.scm
>  create mode 100644 gnu/packages/rust-sources.scm
>  create mode 100644 guix/import/crate/cargo-lock.scm
>=20
>=20
> base-commit: b54a9ca849f013300c633fb79d80bc754f6b28a2
> --
> 2.48.1
>=20
> --8<---------------cut here---------------start------------->8---
> diff --git a/doc/contributing.texi b/doc/contributing.texi
> index e7c5116a3d..837074dead 100644
> --- a/doc/contributing.texi
> +++ b/doc/contributing.texi
> @@ -1607,15 +1607,15 @@ Rust Crates
>  have switched to a different packaging model.
>=20
>  Rust programs (binary crates) and dependencies (library crates) are trea=
ted
> -separately.  We put main efforts into programs and only package Rust
> -dependencies as sources, utilizing automation with manual focus on unbun=
dling
> +separately.  We put our main efforts into programs and only package Rust
> +dependencies as sources, utilizing automation with a manual focus on unb=
undling
>  vendored dependencies.  The following paragraphs will explain them and g=
ive
>  several examples.
>=20
>  Rust programs are treated like any other package and named using the low=
ercase
>  upstream name.  When using the Cargo build system (@pxref{Build Systems,
>  @code{cargo-build-system}}), Rust programs should have @code{#:install-s=
ource?}
> -argument set to @code{#f}, as this argument only makes sense to dependen=
cies.
> +argument set to @code{#f}, as this argument only makes sense for depende=
ncies.
>  When the package source is a Cargo workspace, @code{#:cargo-install-path=
s} must
>  be set to enable relevant support.
>=20
> @@ -1631,21 +1631,21 @@ Rust Crates
>  contributing to Guix.  Naturally, this module serves as a store for both=
 sources
>  and unbundling strategies.
>=20
> -This module is managed by Rust team (@pxref{Teams}) to ensure there's al=
ways one
> -version containing all changes from other branches, so that the maintain=
ed
> +This module is managed by the Rust team (@pxref{Teams}) to ensure there'=
s always
> +one version containing all changes from other branches, so that the main=
tained
>  version can be used directly in case of merge conflicts, thus coordinati=
on is
>  required for other committers to modify it.
>=20
>  Guix source ships template @file{etc/teams/rust/rust-crates.tmpl} and cl=
eanup
> -script @file{etc/teams/rust/cleanup-crates.sh} for this moudle.
> +script @file{etc/teams/rust/cleanup-crates.sh} for this module.
>=20
>  @item
>  @code{(gnu packages rust-sources)}, storing more complex definitions tha=
t need
>  to be full packages.  This includes Rust dependencies requiring external=
 inputs
>  to unbundle and Cargo workspaces.
>=20
> -These dependencies should have @code{#:skip-build?} argument set to @cod=
e{#t}.
> -For Cargo workspaces, @code{#:cargo-package-crates} must be set.
> +These dependencies should have the @code{#:skip-build?} argument set to
> +@code{#t}.  For Cargo workspaces, @code{#:cargo-package-crates} must be =
set.
>=20
>  Since they are added manually, the following naming convention applies:
>=20
> @@ -1668,7 +1668,7 @@ Rust Crates
>  Let's demonstrate the packaging workflow by examples, note that package-=
specific
>  issues are not involved here.
>=20
> -In preparation, we'll adding the following packages to our environment:
> +In preparation, we'll add the following packages to our environment:
>=20
>  @example
>  guix shell rust rust:cargo cargo-audit cargo-license
> @@ -1747,7 +1747,7 @@ Rust Crates
>  @code{check-for-pregenerated-files} phase:
>=20
>  @example
> -$ guix build cargo-audit
> +$ ./pre-inst-env guix build cargo-audit
>  @dots{}
>  starting phase `check-for-pregenerated-files'
>  Searching for binary files...
> diff --git a/doc/guix.texi b/doc/guix.texi
> index 029c8cf59c..218c2ba630 100644
> --- a/doc/guix.texi
> +++ b/doc/guix.texi
> @@ -9365,14 +9365,14 @@ Build Systems
>  sources, to ease in future hacking on rust packages.
>=20
>  This build system supports cargo workspaces.  Parameter
> -@code{#:cargo-package-crates} (default: @code{''()}) allows specifying
> -names of library crates to package in @code{package} phase.  Specified
> -crates are packaged from left to right, in case there's dependency among
> -them.  For example, specifying @code{''("pcre2-sys" "pcre2")} will
> -package @code{"pcre2-sys"} first and then @code{"pcre2"}.  Parameter
> -@code{#:cargo-install-paths} (default: @code{''()}) allows specifying
> -paths of binary crates to install in @code{install} phase,
> -@code{''("crates/atuin")}, for example.
> +@code{#:cargo-package-crates} (default: @code{''()}) allows specifying n=
ames of
> +library crates to package in the @code{package} phase.  Specified crates=
 are
> +packaged from left to right, in case there's dependency among them.  For
> +example, specifying @code{''("pcre2-sys" "pcre2")} will package
> +@code{"pcre2-sys"} first and then @code{"pcre2"}.  Parameter
> +@code{#:cargo-install-paths} (default: @code{''()}) allows specifying pa=
ths of
> +binary crates to install in the @code{install} phase, @code{''("crates/a=
tuin")},
> +for example.
>  @end defvar
>=20
>  @defvar chicken-build-system
> @@ -14705,19 +14705,18 @@ Invoking guix import
>  a comment.
>  @item --lockfile=3D@var{file}
>  @itemx -f @var{file}
> -When @option{--lockfile} is specified, importer will ignore other
> -options and won't output package definitions, instead generating source
> -definition for all dependencies in @var{file}, a @file{Cargo.lock} file.
> -For example:
> +When @option{--lockfile} is specified, the importer will ignore other op=
tions
> +and won't output package definitions, instead generating source definiti=
ons for
> +all dependencies in @var{file}, a @file{Cargo.lock} file.  For example:
>=20
>  @example
>  guix import crate --lockfile=3D/path/to/Cargo.lock my-package
>  @end example
>=20
> -generates sources from @file{/path/to/Cargo.lock}, and a list
> -@code{my-package-cargo-inputs} referencing these sources.  The generated
> -list is intended for package's base @code{inputs}, replacing
> -@code{#:cargo-inputs} and @code{#:cargo-development-inputs}.
> +generates sources from @file{/path/to/Cargo.lock} and a list
> +@code{my-package-cargo-inputs} referencing these sources.  The generated=
 list is
> +intended for the package's @code{inputs}, replacing @code{#:cargo-inputs=
} and
> +@code{#:cargo-development-inputs}.
>  @end table
>=20
>  @item elm
> diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-s=
ystem.scm
> index b547421b88..41adc03752 100644
> --- a/guix/build/cargo-build-system.scm
> +++ b/guix/build/cargo-build-system.scm
> @@ -248,12 +248,6 @@ (define* (configure #:key inputs
>    (setenv "LIBSSH2_SYS_USE_PKG_CONFIG" "1")
>    (setenv "SODIUM_USE_PKG_CONFIG" "1")
>    (setenv "ZSTD_SYS_USE_PKG_CONFIG" "1")
> -  ;; This flag is needed when not using the bundled jemalloc.
> -  ;; https://github.com/tikv/jemallocator/issues/19
> -  (setenv "CARGO_FEATURE_UNPREFIXED_MALLOC_ON_SUPPORTED_PLATFORMS" "1")
> -  (when (assoc-ref inputs "jemalloc")
> -    (setenv "JEMALLOC_OVERRIDE"
> -            (string-append (assoc-ref inputs "jemalloc") "/lib/libjemall=
oc.so")))
>    (when (assoc-ref inputs "openssl")
>      (setenv "OPENSSL_DIR" (assoc-ref inputs "openssl")))
>    (when (assoc-ref inputs "gettext")
> @@ -356,23 +350,17 @@ (define* (package #:key
>=20
>          (if (null? cargo-package-crates)
>              (apply invoke `("cargo" "package" "--offline" ,@cargo-packag=
e-flags))
> -            ;; Use unstable feature =E2=80=98--registry=E2=80=99.
>              (begin
> -              (setenv "RUSTC_BOOTSTRAP" "1")
>                (for-each
>                 (lambda (pkg)
>                   (apply invoke "cargo" "package" "--offline" "--package"=
 pkg
> -                        "--registry" "crates-io" "-Z" "package-workspace"
>                          cargo-package-flags)
>                   (for-each
>                    (lambda (crate)
>                      (invoke "tar" "xzf" crate "-C" vendor-dir))
> -                  (begin
> -                    (delete-file-recursively "target/package/tmp-registr=
y")
> -                    (find-files "target/package" "\\.crate$")))
> +                  (find-files "target/package" "\\.crate$"))
>                   (patch-cargo-checksums #:vendor-dir vendor-dir))
> -               cargo-package-crates)
> -              (unsetenv "RUSTC_BOOTSTRAP")))
> +               cargo-package-crates)))
>=20
>          ;; Then unpack the crate, reset the timestamp of all contained f=
iles, and
>          ;; repack them.  This is necessary to ensure that they are repro=
ducible.
> diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
> index d8e1ed3e6f..f6e2985ed9 100644
> --- a/guix/scripts/import.scm
> +++ b/guix/scripts/import.scm
> @@ -126,13 +126,12 @@ (define-command (guix-import . args)
>       (show-version-and-exit "guix import"))
>      ((or ("-i" file importer args ...)
>           ("--insert" file importer args ...))
> -     (let* ((definer?
> -              (cut member
> -                   <>
> -                   `(,@(if (member importer '("crate"))
> -                           '(define)
> -                           '())
> -                     define-public)))
> +     (let* ((importer-definers
> +             `(,@(if (member importer '("crate"))
> +                     '(define)
> +                     '())
> +               define-public))
> +            (definer? (cut member <> importer-definers))
>              (find-and-insert
>               (lambda (expr)
>                 (match expr
> diff --git a/tests/crate.scm b/tests/crate.scm
> index d46f753f9c..9b7066c3b1 100644
> --- a/tests/crate.scm
> +++ b/tests/crate.scm
> @@ -478,7 +478,7 @@ (define rust-leaf-bob-3.0.2-yanked
>      (license #f)))
>=20
>  (define temp-file
> -  (string-append "t-utils-" (number->string (getpid))))
> +  (string-append "t-crate-" (number->string (getpid))))
>=20
>  =0C
>  (test-begin "crate")
> --8<---------------cut here---------------end--------------->8---

--=20
Efraim Flashner   <efraim@HIDDEN>   =D7=90=D7=A4=D7=A8=D7=99=D7=9D =
=D7=A4=D7=9C=D7=A9=D7=A0=D7=A8
GPG key =3D A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted

--95v81pkqxLBZrl3H
Content-Type: application/pgp-signature; name=signature.asc

-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAmfaaZ8ACgkQQarn3Mo9
g1GHzxAAiTp4X4BH/4Ul44GJI+8J4/6WLxnQhlZvhkqMaQCmklhoUoOhijAiX//V
zI6XgMc8LQ158FUtS4DZTbg8xN72IAWaXCGEYHMKEAjjc8/e9ppUjE2PkvDyPEd+
AQR/K/UlIKTKhQq3QsfFA3q6USUbL3D2grKJeMYT+IfI7KqSNiYDRg1NMP3/Qs/L
J2o5xMbQQKIc6I78Vy3av4341+SH5qr+1v59atC8tKKxWvZEJgMPIzhMoi5oJW+B
FD55vVITkgcFJ6oXORdoohKNPNVZz6kBSFd1Qfih4nx8CuX/fqDVRBswrZE9ghlU
npqEWRnQiCol87MtWHcIvugtARhhej4nDlxFl6FOMnJV6q1hAQ1vfV3H0vZ+dpQ4
Wg8ING2uhBe2xb4dvgLfN77fnN+RGb4ggZoM5u7wEQKWwpmzXJDldFMrSvMiTCNl
vlEmt3zdX9nxAmFyirCq+2HSR2+DwIlCAa8rqHT6dxH9EL9BSizMtCw6dHq1/rR3
vi9uL0niTn7Gs8+XM51toP4Uqo1tH7IOijDXBj7tZoMVz3LemrWj+/Mv591GYHms
lagTUy4ZugOAVIRs5kUSovDmJCeiSluts5IV2WEHqa0SF7JK5nj/S69uxbS5bOnp
rDijiYkMbMjERgYLBJC3sx8YA+qumY/juv+qD1R0U/AYUAZWxpo=
=WPM3
-----END PGP SIGNATURE-----

--95v81pkqxLBZrl3H--




Information forwarded to guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:29:45 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 10:29:45 2025
Received: from localhost ([127.0.0.1]:41750 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuXws-0004nh-7W
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:29:45 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:48336)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuXvO-0004Yb-8M
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:28:17 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742308089;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=fYh+Bj/HtW5J1+1CPK1CvQMLgPhMjNp3CvRauv6IPNA=;
 b=NI4Ms1eYTbjlSB5yOYWzh9VxwxTW/+s12q7SiFJ1+JOuZDx5QaXoliXQtb9TuABv7PJXIi
 B8sNdq1hCptdmARUPl/VppuEoz8cs1L9c0gKpTBh4nkYuFBDwO+ACtFkcS7FCi/AAlUxnX
 6+E0UZGOthHkwrGXhxyZpm0nfCoRL8qgbFc6p8Rskp+TCnMqoLwGBPS9J2VtdVgTjX5xjR
 /h9wGVK73iut+1Ydoz6hyuI6y4rYkj7KrSWGiyPPkJq/e5yf1tZWDMy15ShDDIz8YSTbcr
 Eyr6gaa6NmaDF84mBK4PbKxYUa7u2v5yJi+nej5NSLqYRZ9Pc4nKOHlzd+BE9w==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v2 17/17] doc: Document lockfile importer based Rust
 packaging workflow.
Date: Tue, 18 Mar 2025 22:27:00 +0800
Message-ID: <613319a41cd8d7823cb1d0aa6cc710cf24239a6b.1742306960.git.hako@HIDDEN>
In-Reply-To: <cover.1742306960.git.hako@HIDDEN>
References: <cover.1742306960.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Ludovic Courtès <ludo@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.7 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.3 (/)

* doc/contributing.texi (Packaging Guidelines)[Rust Crates]: Update
documentation.

Change-Id: Ic0c6378cf5f5df97d6f8bdd040b486be62c7bddc
---
 doc/contributing.texi | 415 +++++++++++++++++++++++++++++++++++++++---
 1 file changed, 390 insertions(+), 25 deletions(-)

diff --git a/doc/contributing.texi b/doc/contributing.texi
index ab4f30d54b..837074dead 100644
--- a/doc/contributing.texi
+++ b/doc/contributing.texi
@@ -1600,34 +1600,399 @@ Rust Crates
 @subsection Rust Crates
 
 @cindex rust
-Rust programs standing for themselves are named as any other package, using the
-lowercase upstream name.
+As currently there's no achievable way to reuse Rust packages as pre-compiled
+inputs for other packages at a distribution scale, and our previous approach on
+making all Rust dependencies as full packages doesn't cope well with Rust
+ecosystem thus causing issues on both contribution and maintenance sides, we
+have switched to a different packaging model.
+
+Rust programs (binary crates) and dependencies (library crates) are treated
+separately.  We put our main efforts into programs and only package Rust
+dependencies as sources, utilizing automation with a manual focus on unbundling
+vendored dependencies.  The following paragraphs will explain them and give
+several examples.
+
+Rust programs are treated like any other package and named using the lowercase
+upstream name.  When using the Cargo build system (@pxref{Build Systems,
+@code{cargo-build-system}}), Rust programs should have @code{#:install-source?}
+argument set to @code{#f}, as this argument only makes sense for dependencies.
+When the package source is a Cargo workspace, @code{#:cargo-install-paths} must
+be set to enable relevant support.
+
+Rust dependencies are managed in two modules:
 
-To prevent namespace collisions we prefix all other Rust packages with the
-@code{rust-} prefix.  The name should be changed to lowercase as appropriate and
-dashes should remain in place.
+@enumerate
+@item
+@code{(gnu packages rust-crates)}, storing source definitions imported from Rust
+programs' @file{Cargo.lock} via the lockfile importer (@pxref{Invoking guix
+import, crate, @code{--lockfile=@var{file}}}).
+
+Imported definitions must be checked and have vendored sources unbundled before
+contributing to Guix.  Naturally, this module serves as a store for both sources
+and unbundling strategies.
+
+This module is managed by the Rust team (@pxref{Teams}) to ensure there's always
+one version containing all changes from other branches, so that the maintained
+version can be used directly in case of merge conflicts, thus coordination is
+required for other committers to modify it.
+
+Guix source ships template @file{etc/teams/rust/rust-crates.tmpl} and cleanup
+script @file{etc/teams/rust/cleanup-crates.sh} for this module.
+
+@item
+@code{(gnu packages rust-sources)}, storing more complex definitions that need
+to be full packages.  This includes Rust dependencies requiring external inputs
+to unbundle and Cargo workspaces.
+
+These dependencies should have the @code{#:skip-build?} argument set to
+@code{#t}.  For Cargo workspaces, @code{#:cargo-package-crates} must be set.
+
+Since they are added manually, the following naming convention applies:
+
+To prevent namespace collisions they are named with @code{rust-} prefix.  The
+name should be changed to lowercase as appropriate and dashes should remain in
+place.
 
 In the rust ecosystem it is common for multiple incompatible versions of a
-package to be used at any given time, so all package definitions should have a
-versioned suffix.  The versioned suffix is the left-most non-zero digit (and
-any leading zeros, of course).  This follows the ``caret'' version scheme
-intended by Cargo.  Examples@: @code{rust-clap-2}, @code{rust-rand-0.6}.
-
-Because of the difficulty in reusing rust packages as pre-compiled inputs for
-other packages the Cargo build system (@pxref{Build Systems,
-@code{cargo-build-system}}) presents the @code{#:cargo-inputs} and
-@code{cargo-development-inputs} keywords as build system arguments.  It would be
-helpful to think of these as similar to @code{propagated-inputs} and
-@code{native-inputs}.  Rust @code{dependencies} and @code{build-dependencies}
-should go in @code{#:cargo-inputs}, and @code{dev-dependencies} should go in
-@code{#:cargo-development-inputs}.  If a Rust package links to other libraries
-then the standard placement in @code{inputs} and the like should be used.
-
-Care should be taken to ensure the correct version of dependencies are used; to
-this end we try to refrain from skipping the tests or using @code{#:skip-build?}
-when possible.  Of course this is not always possible, as the package may be
-developed for a different Operating System, depend on features from the Nightly
-Rust compiler, or the test suite may have atrophied since it was released.
+package to be used at any given time, so all dependencies should have a
+versioned suffix.  The versioned suffix is the left-most non-zero digit (and any
+leading zeros, of course).  This follows the ``caret'' version scheme intended
+by Cargo.  Examples@: @code{rust-clap-2}, @code{rust-rand-0.6}.
+
+In practice we are usually packaging development snapshots of Rust dependencies
+specifically for some Rust programs, and can't simply identity them by version.
+In this case we can use a @code{for-@var{program}} suffix.  Examples@:
+@code{rust-pipewire-for-niri}, @code{rust-pubgrub-for-uv}.
+@end enumerate
+
+Let's demonstrate the packaging workflow by examples, note that package-specific
+issues are not involved here.
+
+In preparation, we'll add the following packages to our environment:
+
+@example
+guix shell rust rust:cargo cargo-audit cargo-license
+@end example
+
+Example 1: @code{cargo-audit}, which is published on the crates.io Rust package
+repository @uref{https://crates.io, crates.io}.
+
+@enumerate
+@item
+We can generate a draft definition via the crates.io importer (@pxref{Invoking
+guix import, crate}).  In the end we'll have the following definiton:
+
+@lisp
+(define-public cargo-audit
+  (package
+    (name "cargo-audit")
+    (version "0.21.2")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (crate-uri "cargo-audit" version))
+       (file-name (string-append name "-" version ".tar.gz"))
+       (sha256
+        (base32 "1a00yqpckkw86zh2hg7ra82c5fx0ird5766dyynimbvqiwg2ps0n"))))
+    (build-system cargo-build-system)
+    (arguments (list #:install-source? #f))
+    (inputs (cargo-inputs 'cargo-audit))
+    (home-page "https://rustsec.org/")
+    (synopsis "Audit Cargo.lock for crates with security vulnerabilities")
+    (description
+     "This package provides a Cargo subcommand, @@command@{cargo audit@}, to
+audit @@file@{Cargo.lock@} for crates with security vulnerabilities.")
+    (license (list license:asl2.0 license:expat))))
+@end lisp
+
+@code{cargo-inputs} is a procedure defined in @code{guix build-system cargo},
+facilitating dependency modification.  @code{'cargo-audit} used here must be a
+unique identifier, usually same to the program's variable name.
+
+@item
+Unpack package source and navigate to the unpacked directory, then execute the
+following commands:
+
+@example
+cargo generate-lockfile
+cargo audit
+cargo license
+@end example
+
+@command{cargo generate-lockfile} updates dependencies to compatible versions,
+@command{cargo audit} checks known vulnerabilities and @command{cargo license}
+checks licenses of all dependencies.
+
+We must have an acceptable output of @command{cargo audit} and ensure all
+dependencies are licensed with our supported licenses (@pxref{Defining Packages,
+@code{license}}).
+
+@item
+Import dependencies from previously generated lockfile:
+
+@example
+guix import --insert=gnu/packages/rust-crates.scm \
+    crate --lockfile=/path/to/Cargo.lock cargo-audit
+@end example
+
+@code{cargo-audit} used here must be consistent with the identifier used for
+@code{cargo-inputs}.
+
+At this stage, @code{cargo-audit} is buildable.
+
+@item
+Finally we'll unbundle vendored sources.  The lockfile importer inserts
+@code{TODO:} comments to dependencies with high probability of bundled sources.
+@code{cargo-build-system} also performs additional check in its
+@code{check-for-pregenerated-files} phase:
+
+@example
+$ ./pre-inst-env guix build cargo-audit
+@dots{}
+starting phase `check-for-pregenerated-files'
+Searching for binary files...
+./guix-vendor/rust-addr2line-0.21.0.tar.gz/rustfmt.toml
+./guix-vendor/rust-arc-swap-1.7.1.tar.gz/rustfmt.toml
+./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/dictionary-rust
+./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/dictionary-rust-other
+./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/lib.rs.zst
+./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/long-window-size-lib.rs.zst
+@dots{}
+@end example
+
+Although dependencies in @code{(gnu packages rust-crates)} are not exported, we
+can still select them in Guix command-line interface through expression:
+
+@example
+guix build --expression='(@@@@ (gnu packages rust-crates) rust-ring-0.17.14)'
+@end example
+
+For most dependencies, a snippet is sufficient:
+
+@lisp
+(define rust-bzip2-sys-0.1.13+1.0.8
+  (crate-source "bzip2-sys" "0.1.13+1.0.8"
+                "056c39pgjh4272bdslv445f5ry64xvb0f7nph3z7860ln8rzynr2"
+                #:snippet
+                '(begin
+                   (delete-file-recursively "bzip2-1.0.8")
+                   (delete-file "build.rs")
+                   ;; Inspired by Debian's patch.
+                   (with-output-to-file "build.rs"
+                     (lambda _
+                       (format #t "fn main() @{~@@
+                        println!(\"cargo:rustc-link-lib=bz2\");~@@
+                        @}~%"))))))
+@end lisp
+
+In a more complex case, where unbundling one dependency requires other packages,
+we should package the dependency in @code{(gnu packages rust-sources)} first and
+point the imported definition to a symbol with the same name.
+
+For example we have defined a @code{rust-ring-0.17} in @code{(gnu packages
+rust-sources)}, then the imported definition in @code{(gnu packages
+rust-crates)} should be modified to point to it:
+
+@lisp
+(define rust-ring-0.17.14 'rust-ring-0.17)
+@end lisp
+
+When one dependency can be safely removed, modify it to @code{#f}.
+
+@lisp
+(define rust-openssl-src-300.4.2+3.4.1 #f)
+@end lisp
+
+Such modifications are processed by @code{cargo-inputs} procedure.
+
+@code{cargo-inputs} can also be configured by keywoard arguments
+@code{#:crates-module} (default: @code{(gnu packages rust-crates)}, module to
+resolve imported definitions) and @code{#:sources-module} (default: @code{(gnu
+packages rust-sources)}, module to resolve modified symbols), which are useful
+to maintain an independent channel.
+@end enumerate
+
+Example 2: @code{niri}, which is not available on crates.io and depends on
+development snapshots (also Cargo workspaces in this example).
+
+@enumerate
+@item
+As we can't ensure compatibility of a development snapshot, before executing
+@command{cargo generate-lockfile}, we should modify @file{Cargo.toml} to pin it
+in a known working revision.
+
+To use our packaged development snapshots, it's also necessary to modify
+@file{Cargo.toml} in build environment, the substitution pattern is
+package-specific.
+
+@code{cargo-inputs} returns a list, all list operations apply to it too.
+
+@lisp
+(define-public niri
+  (package
+   (name "niri")
+   (version "25.02")
+   (source (origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/YaLTeR/niri")
+                   (commit (string-append "v" version))))
+             (file-name (git-file-name name version))
+             (sha256
+              (base32
+               "0vzskaalcz6pcml687n54adjddzgf5r07gggc4fhfsa08h1wfd4r"))))
+   (build-system cargo-build-system)
+   (arguments
+    (list #:install-source? #f
+          #:phases
+          #~(modify-phases %standard-phases
+              (add-after 'unpack 'use-guix-vendored-dependencies
+                (lambda _
+                  (substitute* "Cargo.toml"
+                    (("# version =.*")
+                     "version = \"*\"")
+                    (("git.*optional")
+                     "version = \"*\", optional")
+                    (("^git = .*")
+                     "")))))))
+   (native-inputs
+    (list pkg-config))
+   (inputs
+    (cons* clang
+           libdisplay-info
+           libinput-minimal
+           libseat
+           libxkbcommon
+           mesa
+           pango
+           pipewire
+           wayland
+           (cargo-inputs 'niri)))
+   (home-page "https://github.com/YaLTeR/niri")
+   (synopsis "Scrollable-tiling Wayland compositor")
+   (description
+    "Niri is a scrollable-tiling Wayland compositor which arranges windows in a
+scrollable format.  It is considered stable for daily use and performs most
+functions expected of a Wayland compositor.")
+   (license license:gpl3)))
+@end lisp
+
+@item
+@code{niri} also has Cargo workspace dependencies.  When packaging a Cargo
+workspace, build argument @code{#:cargo-package-crates} is required.
+
+@lisp
+(define-public rust-pipewire-for-niri
+  (let ((commit "fd3d8f7861a29c2eeaa4c393402e013578bb36d9")
+        (revision "0"))
+    (package
+      (name "rust-pipewire")
+      (version (git-version "0.8.0" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://gitlab.freedesktop.org/pipewire/pipewire-rs.git")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32 "1hzyhz7xg0mz8a5y9j6yil513p1m610q3j9pzf6q55vdh5mcn79v"))))
+      (build-system cargo-build-system)
+      (arguments
+       (list #:skip-build? #t
+             #:cargo-package-crates
+             ''("libspa-sys" "libspa" "pipewire-sys" "pipewire")))
+      (inputs (cargo-inputs 'rust-pipewire-for-niri))
+      (home-page "https://pipewire.org/")
+      (synopsis "Rust bindings for PipeWire")
+      (description "This package provides Rust bindings for PipeWire.")
+      (license license:expat))))
+@end lisp
+
+Don't forget to modify all workspace members in @code{(gnu packages
+rust-crates)}:
+
+@lisp
+(define rust-pipewire-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
+(define rust-pipewire-sys-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
+@dots{}
+(define rust-libspa-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
+(define rust-libspa-sys-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
+@end lisp
+@end enumerate
+
+Example 3: @code{fish}, which combines two build systems.
+
+@enumerate
+@item
+When building Rust packages in other build systems, we need to add @code{rust}
+and @code{rust:cargo} to @code{native-inputs}, import and use modules from both
+build systems, and apply necessary build phases from @code{cargo-build-system}.
+
+@lisp
+(define-public fish
+  (package
+    (name "fish")
+    (version "4.0.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://github.com/fish-shell/fish-shell/"
+                           "releases/download/" version "/"
+                           "fish-" version ".tar.xz"))
+       (sha256
+        (base32 "1wv9kjwg6ax8m2f85i58l9f9cndshn1f15n8skc68w1mf3cmpnig"))))
+    (build-system cmake-build-system)
+    (inputs
+     (cons* fish-foreign-env ncurses pcre2
+            python                    ;for fish_config and manpage completions
+            (cargo-inputs 'fish)))
+    (native-inputs
+     (list doxygen groff                ;for 'fish --help'
+           pkg-config
+           procps                       ;for the test suite
+           rust
+           `(,rust "cargo")))
+    (arguments
+     (list #:imported-modules
+           (append %cargo-build-system-modules
+                   %cmake-build-system-modules)
+           #:modules
+           (((guix build cargo-build-system) #:prefix cargo:)
+            (guix build cmake-build-system)
+            (guix build utils))
+           #:phases
+           #~(modify-phases %standard-phases
+               (add-after 'unpack 'use-guix-vendored-dependencies
+                 (lambda _
+                   (substitute* "Cargo.toml"
+                     (("git.*tag.*,")
+                      "version = \"*\","))))
+               (add-after 'unpack 'prepare-cargo-build-system
+                 (lambda args
+                   (for-each
+                    (lambda (phase)
+                      (format #t "Running cargo phase: ~a~%" phase)
+                      (apply (assoc-ref cargo:%standard-phases phase)
+                             args))
+                    '(unpack-rust-crates
+                      configure
+                      check-for-pregenerated-files
+                      patch-cargo-checksums)))))))
+    (synopsis "The friendly interactive shell")
+    (description
+     "Fish (friendly interactive shell) is a shell focused on interactive use,
+discoverability, and friendliness.  Fish has very user-friendly and powerful
+tab-completion, including descriptions of every completion, completion of
+strings with wildcards, and many completions for specific commands.  It also
+has extensive and discoverable help.  A special @@command@{help@} command gives
+access to all the fish documentation in your web browser.  Other features
+include smart terminal handling based on terminfo, an easy to search history,
+and syntax highlighting.")
+    (home-page "https://fishshell.com/")
+    (license license:gpl2)))
+@end lisp
+@end enumerate
 
 
 @node Elm Packages
-- 
2.48.1





Information forwarded to ludo@HIDDEN, maxim.cournoyer@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:29:42 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 10:29:42 2025
Received: from localhost ([127.0.0.1]:41748 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuXwr-0004na-LK
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:29:42 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:47174)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuXvD-0004WO-71
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:28:00 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742308078;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=geOOtBEsBNx2ONmmiPLL/kMPcijDpsDJ3ulRZK3Fa/w=;
 b=EuETuZnwfYW37KeMPeFIi+aiciz3xzhePgYXIHSLCbF5OxeyJESkPTG8h1JnM1Qzgpfn6P
 Mv3LlPmNhsIbTfvnbirQJnVy/izl1cK7wwQpmZ9FgS1DP23v0a/dHk5a8OqFYrYScStMk6
 9TmdpADlDw6ijMMYYh3WebxGTBnYEZSHQc+ickk7aCyS4N8Y3MhCfhzdpNpuOqS0j5Au5f
 6X/HZhjT9MvX2ba7UoWHJ3D0IbEnPV/5JNDuONO5dzRLf0HOMl3VprRuiW0VS2F8EJYPPR
 CzWXXFtl+fUhG40a9l56cUiC0qbLdNjef+e3MgelJgSpp/QpSymy4TyAsHprqA==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v2 13/17] import: crate: crate-name->package-name:
 Move to (guix build-system cargo).
Date: Tue, 18 Mar 2025 22:26:56 +0800
Message-ID: <68e9dbe1fba53dc68b274d78b7ee084db36c0f77.1742306960.git.hako@HIDDEN>
In-Reply-To: <cover.1742306960.git.hako@HIDDEN>
References: <cover.1742306960.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Divya Ranjan Pattanaik <divya@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>, Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/import/crate.scm (crate-name->package-name): Move to...
* guix/build-system/cargo.scm (crate-name->package-name): ...here and export.

Change-Id: Ie9813179d6c40d159956cc1e2ae59a74dea0a42d
---
 guix/build-system/cargo.scm | 6 +++++-
 guix/import/crate.scm       | 5 -----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
index 4486c706a1..7a07003262 100644
--- a/guix/build-system/cargo.scm
+++ b/guix/build-system/cargo.scm
@@ -44,7 +44,8 @@ (define-module (guix build-system cargo)
             %crate-base-url
             crate-url
             crate-url?
-            crate-uri))
+            crate-uri
+            crate-name->package-name))
 
 (define %crate-base-url
   (make-parameter "https://crates.io"))
@@ -58,6 +59,9 @@ (define (crate-uri name version)
 to NAME and VERSION."
   (string-append crate-url name "/" version "/download"))
 
+(define (crate-name->package-name name)
+  (downstream-package-name "rust-" name))
+
 (define (default-rust target)
   "Return the default Rust package."
   ;; Lazily resolve the binding to avoid a circular dependency.
diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index 5a8caeb3e1..14e6e28c5b 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -481,10 +481,6 @@ (define (guix-package->crate-name package)
     (match parts
       ((name _ ...) name))))
 
-(define (crate-name->package-name name)
-  (downstream-package-name "rust-" name))
-
-
 
 ;;;
 ;;; Updater
@@ -528,4 +524,3 @@ (define %crate-updater
    (description "Updater for crates.io packages")
    (pred crate-package?)
    (import import-release)))
-
-- 
2.48.1





Information forwarded to divya@HIDDEN, efraim@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:29:42 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 10:29:41 2025
Received: from localhost ([127.0.0.1]:41746 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuXwq-0004nP-CO
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:29:41 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:34732)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuXvA-0004W2-Sk
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:27:57 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742308075;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=WGvHTrbjVrTWfbllNr3p4AZWghFWH2g/oDoIhRm6W2s=;
 b=G2aGzYzWbSodqrD4micPgmM8oGw3wVpdLr9dCA7LdTR+wHrENKn+2+qD4TtAxVAFu+Wxan
 ctyWGgCg3R1CvJikUPhiGX6A125zdvWIguafVzsyzKeb9IoMcEAFV7vbi5vvhfUhtfHg3t
 ThMXoOIHxooGVPOWsKCVDjQH4CaxzLct/AhauNya4FwE0x1lscuj8mu1BSaIadDOsgfYyB
 ETtPSwYAjCtnTyROaHVRtH4UlYemMAgmHItIAskRg+gz4+FFUg3U0qRvqaX6gZKy+mywvM
 Lx8jVatsEdM2FIFmy/MUNock98wyQAkwf8PTA2uadiZbWJmB3IndhkEN4wSHyA==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v2 12/17] =?UTF-8?q?scripts:=20import:=20Skip=20?=
 =?UTF-8?q?existing=20definition=20for=20=E2=80=98--insert=E2=80=99=20opti?=
 =?UTF-8?q?on.?=
Date: Tue, 18 Mar 2025 22:26:55 +0800
Message-ID: <bd80b3049f066679194380a52f91feb574b2b46e.1742306960.git.hako@HIDDEN>
In-Reply-To: <cover.1742306960.git.hako@HIDDEN>
References: <cover.1742306960.git.hako@HIDDEN>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
X-Debbugs-Cc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/scripts/import.scm (guix-import): Skip existing definition for
‘--insert’ option.

Change-Id: I2c4242669f974b263a018ab0cf56538bd7c81d06
---
 guix/scripts/import.scm | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index e99796a430..f6e2985ed9 100644
--- a/guix/scripts/import.scm
+++ b/guix/scripts/import.scm
@@ -136,16 +136,18 @@ (define-command (guix-import . args)
              (lambda (expr)
                (match expr
                  (((? definer? definer) term _ ...)
-                  (let ((source-properties
-                          (find-definition-insertion-location
+                  ;; Skip existing definition.
+                  (unless (find-definition-location file term #:definer definer)
+                    (let ((source-properties
+                           (find-definition-insertion-location
                             file term #:definer definer)))
-                    (if source-properties
-                      (insert-expression source-properties expr)
-                      (let ((port (open-file file "a")))
-                        (pretty-print-with-comments port expr)
-                        (newline port)
-                        (newline port)
-                        (close-port port)))))))))
+                      (if source-properties
+                          (insert-expression source-properties expr)
+                          (let ((port (open-file file "a")))
+                            (pretty-print-with-comments port expr)
+                            (newline port)
+                            (newline port)
+                            (close-port port))))))))))
        (import-as-definitions importer
                               (cons (string-append "--file-to-insert=" file)
                                     args)
-- 
2.48.1





Information forwarded to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:29:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 10:29:32 2025
Received: from localhost ([127.0.0.1]:41744 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuXwh-0004m6-4F
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:29:32 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:34724)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuXv8-0004VT-Di
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:27:55 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742308073;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=DLq4SKTvIUKhNdT4MG9AOvdpprzJe1kspIQL8Xf/xDg=;
 b=LDxR8ddkRPLaRVag6kUc9H8D40RWpjLjmiH1lZp+jWM2kn3Ja7UaIDqavoXYKpKPawoRGL
 ESb9yt+c1JuST6rSA11Y10mD/IsfnxAKCUIjuDrZyRkB/THhEC9/faHzU1dbMJUUKL+V9h
 YEez3qwMR1UaAp6AIarB28Vk3oo84MwuQK2tsC2E6eGfe8xdRk70ZyNfLeGY/IqfXnfrZN
 /wIaecex1DUtQp7xJhPQjr9DnzRWPbnpP/b46JEWqJiDfCqtV6Lq9EHNfOfigo5C0wH/z7
 tXUHuIIS1YeaTb3At8U51yBVlJF4OLtaLAMCU/m8wX2zmwERTuBZVwLuyfZq4A==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v2 11/17] scripts: import: Pass "--insert" to
 importers.
Date: Tue, 18 Mar 2025 22:26:54 +0800
Message-ID: <c38a653b19af464a3dd45a203031e5fbb9e15704.1742306960.git.hako@HIDDEN>
In-Reply-To: <cover.1742306960.git.hako@HIDDEN>
References: <cover.1742306960.git.hako@HIDDEN>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
X-Debbugs-Cc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

So that importers can adjust the file before inserting.

* guix/scripts/import.scm (%standard-import-options): Add ‘--file-to-insert’.
(guix-import): Pass it to importers when ‘--insert’ is set.

Change-Id: I8e7a18ee8e0f96d7fc5688a207a7a5390ad2fa30
---
 guix/scripts/import.scm | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index e53028e747..e99796a430 100644
--- a/guix/scripts/import.scm
+++ b/guix/scripts/import.scm
@@ -31,6 +31,7 @@ (define-module (guix scripts import)
   #:use-module (guix utils)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
+  #:use-module (srfi srfi-37)
   #:use-module (ice-9 format)
   #:use-module (ice-9 match)
   #:export (%standard-import-options
@@ -41,7 +42,12 @@ (define-module (guix scripts import)
 ;;; Command line options.
 ;;;
 
-(define %standard-import-options '())
+(define %standard-import-options
+  (list
+   ;; Hidden option for importer-specific file preprocessing.
+   (option '("file-to-insert") #f #t
+           (lambda (opt name arg result)
+             (alist-cons 'file-to-insert arg result)))))
 
 
 ;;;
@@ -140,7 +146,10 @@ (define-command (guix-import . args)
                         (newline port)
                         (newline port)
                         (close-port port)))))))))
-       (import-as-definitions importer args find-and-insert)))
+       (import-as-definitions importer
+                              (cons (string-append "--file-to-insert=" file)
+                                    args)
+                              find-and-insert)))
     ((importer args ...)
      (let ((print (lambda (expr)
                     (leave-on-EPIPE
-- 
2.48.1





Information forwarded to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:29:31 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 10:29:31 2025
Received: from localhost ([127.0.0.1]:41742 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuXwf-0004lj-Gg
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:29:30 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:38154)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuXv5-0004Uv-Su
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:27:54 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742308070;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=q2tsWLuz/lnLteMu2aRrCXUHhNIAVmLTRUC1j3a1vQk=;
 b=W64XFJwpCs840RtbiO0R18/NZ3Oi3b92HwmCqWWnvh5z+YoNa5CqSzNNDgY6thTpumjSbm
 E+BCTIxTa0yHLdXEpPSlj5ed//ArpCLbPX6ZhdY1RPWvMbV3Y78yMyirN3+R44/7tjbIV8
 kd/PMGh4ZMuauNv2JOchwZQVj+/9gY5FI/Wd5CIQAIBwkVoe/ldccXmzMsqZhF7LInsI4T
 pwbB/2fluQA5AmsjK3wBRlfIa0z5kUTttFMDICuuXDOdFI8XEl04rjS9thtlGJ0DOg/s68
 kcZhuifcywfrDBMHRJZz5UPNljXfJNsZuJqmxYhwZYsmqaOK0kG9vyZMqGBrng==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v2 10/17] scripts: import: Support expressions
 defined by 'define.
Date: Tue, 18 Mar 2025 22:26:53 +0800
Message-ID: <592685c77f24f1052112c00965c9fa1deeedaf33.1742306960.git.hako@HIDDEN>
In-Reply-To: <cover.1742306960.git.hako@HIDDEN>
References: <cover.1742306960.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/utils.scm (find-definition-location): New procedure.
(find-definition-insertion-location): Define with it.
* guix/scripts/import.scm (import-as-definitions, guix-import): Support
expressions defined by 'define.

Change-Id: I03118e1a3372028b4f0530964aba871b4a1a4d25
---
 guix/scripts/import.scm | 19 ++++++++++++++-----
 guix/utils.scm          | 27 +++++++++++++++++++--------
 2 files changed, 33 insertions(+), 13 deletions(-)

diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index 58a84d0db7..e53028e747 100644
--- a/guix/scripts/import.scm
+++ b/guix/scripts/import.scm
@@ -30,6 +30,7 @@ (define-module (guix scripts import)
   #:use-module (guix read-print)
   #:use-module (guix utils)
   #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-26)
   #:use-module (ice-9 format)
   #:use-module (ice-9 match)
   #:export (%standard-import-options
@@ -83,7 +84,8 @@ (define (import-as-definitions importer args proc)
         ((and expr (or ('package _ ...)
                        ('let _ ...)))
          (proc (package->definition expr)))
-        ((and expr ('define-public _ ...))
+        ((and expr (or ('define-public _ ...)
+                       ('define _ ...)))
          (proc expr))
         ((expressions ...)
          (for-each (lambda (expr)
@@ -91,7 +93,8 @@ (define (import-as-definitions importer args proc)
                        ((and expr (or ('package _ ...)
                                       ('let _ ...)))
                         (proc (package->definition expr)))
-                       ((and expr ('define-public _ ...))
+                       ((and expr (or ('define-public _ ...)
+                                      ('define _ ...)))
                         (proc expr))))
                    expressions))
         (x
@@ -117,13 +120,19 @@ (define-command (guix-import . args)
      (show-version-and-exit "guix import"))
     ((or ("-i" file importer args ...)
          ("--insert" file importer args ...))
-     (let ((find-and-insert
+     (let* ((importer-definers
+             `(,@(if (member importer '("crate"))
+                     '(define)
+                     '())
+               define-public))
+            (definer? (cut member <> importer-definers))
+            (find-and-insert
              (lambda (expr)
                (match expr
-                 (('define-public term _ ...)
+                 (((? definer? definer) term _ ...)
                   (let ((source-properties
                           (find-definition-insertion-location
-                            file term)))
+                            file term #:definer definer)))
                     (if source-properties
                       (insert-expression source-properties expr)
                       (let ((port (open-file file "a")))
diff --git a/guix/utils.scm b/guix/utils.scm
index c7c23d9d5b..77ec6d992a 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -154,6 +154,7 @@ (define-module (guix utils)
             edit-expression
             delete-expression
             insert-expression
+            find-definition-location
             find-definition-insertion-location
 
             filtered-port
@@ -520,24 +521,34 @@ (define (insert-expression source-properties expr)
                    (string-append expr "\n\n" str))))
     (edit-expression source-properties insert)))
 
-(define (find-definition-insertion-location file term)
-  "Search in FILE for a top-level public definition whose defined term
-alphabetically succeeds TERM. Return the location if found, or #f
-otherwise."
-  (let ((search-term (symbol->string term)))
+(define* (find-definition-location file term
+                                   #:key (definer 'define-public)
+                                   (pred string=))
+  "Search in FILE for a top-level definition defined by DEFINER with defined
+term comparing to TERM through PRED.  Return the location if PRED returns #t,
+or #f otherwise."
+  (let ((search-term (symbol->string term))
+        (definer? (cut eq? definer <>)))
     (call-with-input-file file
       (lambda (port)
         (do ((syntax (read-syntax port)
                      (read-syntax port)))
           ((match (syntax->datum syntax)
-             (('define-public current-term _ ...)
-              (string> (symbol->string current-term)
-                       search-term))
+             (((? definer?) current-term _ ...)
+              (pred (symbol->string current-term)
+                    search-term))
              ((? eof-object?) #t)
              (_ #f))
            (and (not (eof-object? syntax))
                 (syntax-source syntax))))))))
 
+(define* (find-definition-insertion-location file term
+                                             #:key (definer 'define-public))
+  "Search in FILE for a top-level definition defined by DEFINER with defined
+term alphabetically succeeds TERM. Return the location if found, or #f
+otherwise."
+  (find-definition-location file term #:definer definer #:pred string>))
+
 
 ;;;
 ;;; Keyword arguments.
-- 
2.48.1





Information forwarded to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:29:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 10:29:29 2025
Received: from localhost ([127.0.0.1]:41740 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuXwa-0004kq-1J
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:29:29 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:58320)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuXvL-0004Y3-OA
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:28:11 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742308086;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=tLsvHH8VgEZ9trUTlGPnGfx4OlFJVsZlzG2s3udRpug=;
 b=S7EPp0En2htH14PODV0zkTTVrbP8jeAZxviPL8WyrXGew/Ol1wpvgAO06I2sXkmODyGshs
 ojuVKPJPslqKL/tA2ZmijeboTKvwXBICSgrMnCQWplQOXSG6VTuTgZlnWk7SOQaFkJ5oj4
 FmPB0/IQnn8ns9WsBeSEYwNrNWkSofGX/rU7Yt03q2ycr6wcCCn+UjY+09z9aymqpwtDWT
 gHAcQ/vSFt1M2T1vVMSu1eDCzR+00+ka4rKmhrzasDD1zarkZy++XzBK6lyOuPhAp68NJt
 PA32O4aJWlxx3gjkQPsvjSGYrwuvMgkj0pL5j4g0Z+mC2PlmtCnPfbOq+HtW5Q==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v2 16/17] =?UTF-8?q?import:=20crate:=20Add=20?=
 =?UTF-8?q?=E2=80=98--lockfile=E2=80=99=20option.?=
Date: Tue, 18 Mar 2025 22:26:59 +0800
Message-ID: <2cdc1f3f422de5c16aa0b653d4a740867a4e2cee.1742306960.git.hako@HIDDEN>
In-Reply-To: <cover.1742306960.git.hako@HIDDEN>
References: <cover.1742306960.git.hako@HIDDEN>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
X-Debbugs-Cc: Christopher Baines <guix@HIDDEN>, Divya Ranjan Pattanaik <divya@HIDDEN>, Efraim Flashner <efraim@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Steve George <steve@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/scripts/import/crate.scm (%options): Add ‘--lockfile’ option.
* guix/scripts/import/crate.scm (show-help): Add it.
(guix-import-crate): Use it.
* doc/guix.texi (Invoking guix import): Document it.
* tests/crate.scm (temp-file): New variable.
("crate-lockfile-import"): New test.

Change-Id: I291478e04adf9f2df0bf216425a5e8aeba0bedd9
---
 doc/guix.texi                 | 14 ++++++
 guix/scripts/import/crate.scm | 58 +++++++++++++++++++----
 tests/crate.scm               | 88 +++++++++++++++++++++++++++++++++++
 3 files changed, 150 insertions(+), 10 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 7fa986b4b9..218c2ba630 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -14703,6 +14703,20 @@ Invoking guix import
 If a crate dependency is not (yet) packaged, make the corresponding
 input in @code{#:cargo-inputs} or @code{#:cargo-development-inputs} into
 a comment.
+@item --lockfile=@var{file}
+@itemx -f @var{file}
+When @option{--lockfile} is specified, the importer will ignore other options
+and won't output package definitions, instead generating source definitions for
+all dependencies in @var{file}, a @file{Cargo.lock} file.  For example:
+
+@example
+guix import crate --lockfile=/path/to/Cargo.lock my-package
+@end example
+
+generates sources from @file{/path/to/Cargo.lock} and a list
+@code{my-package-cargo-inputs} referencing these sources.  The generated list is
+intended for the package's @code{inputs}, replacing @code{#:cargo-inputs} and
+@code{#:cargo-development-inputs}.
 @end table
 
 @item elm
diff --git a/guix/scripts/import/crate.scm b/guix/scripts/import/crate.scm
index 723cbb3665..3b536e135a 100644
--- a/guix/scripts/import/crate.scm
+++ b/guix/scripts/import/crate.scm
@@ -25,11 +25,13 @@
 (define-module (guix scripts import crate)
   #:use-module (guix ui)
   #:use-module (guix utils)
+  #:use-module (guix read-print)
   #:use-module (guix scripts)
   #:use-module (guix import crate)
   #:use-module (guix scripts import)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-11)
+  #:use-module (srfi srfi-26)
   #:use-module (srfi srfi-37)
   #:use-module (ice-9 match)
   #:use-module (ice-9 format)
@@ -60,6 +62,9 @@ (define (show-help)
                          sufficient package exists for it"))
   (newline)
   (display (G_ "
+  -f, --lockfile=FILE    import dependencies from FILE, a 'Cargo.lock' file"))
+  (newline)
+  (display (G_ "
   -h, --help             display this help and exit"))
   (display (G_ "
   -V, --version          display version information and exit"))
@@ -87,6 +92,9 @@ (define %options
          (option '("mark-missing") #f #f
                  (lambda (opt name arg result)
                    (alist-cons 'mark-missing #t result)))
+         (option '(#\f "lockfile") #f #t
+                 (lambda (opt name arg result)
+                   (alist-cons 'lockfile arg result)))
          %standard-import-options))
 
 
@@ -101,6 +109,8 @@ (define (guix-import-crate . args)
                         #:build-options? #f))
 
   (let* ((opts (parse-options))
+         (lockfile (assoc-ref opts 'lockfile))
+         (file-to-insert (assoc-ref opts 'file-to-insert))
          (args (filter-map (match-lambda
                              (('argument . value)
                               value)
@@ -111,16 +121,44 @@ (define (guix-import-crate . args)
        (define-values (name version)
          (package-name->name+version spec))
 
-       (match (if (assoc-ref opts 'recursive)
-                  (crate-recursive-import
-                   name #:version version
-                   #:recursive-dev-dependencies?
-                   (assoc-ref opts 'recursive-dev-dependencies)
-                   #:allow-yanked? (assoc-ref opts 'allow-yanked))
-                  (crate->guix-package
-                   name #:version version #:include-dev-deps? #t
-                   #:allow-yanked? (assoc-ref opts 'allow-yanked)
-                   #:mark-missing? (assoc-ref opts 'mark-missing)))
+       (match (cond
+               ((and=> lockfile
+                       (lambda (file)
+                         (or (file-exists? file)
+                             (leave (G_ "file '~a' does not exist~%") file))))
+                (let-values (((crate-definitions input-list)
+                              (cargo-lock->definitions lockfile name)))
+                  (if file-to-insert
+                      ;; Adjusted from ‘--insert’ option of guix-import.
+                      (let ((term (second input-list)))
+                        (begin
+                          ;; Remove existing input list definition.
+                          (and=> (find-definition-location file-to-insert term)
+                                 delete-expression)
+                          ;; Insert input list alphabetically.
+                          (or (and=> (find-definition-insertion-location
+                                      file-to-insert term)
+                                     (cut insert-expression <> input-list))
+                              (let ((port (open-file file-to-insert "a")))
+                                (newline port)
+                                (pretty-print-with-comments port input-list)
+                                (newline port)
+                                (newline port)
+                                (close-port port))))
+                        crate-definitions)
+                      `(,@crate-definitions
+                        ,input-list))))
+               ((assoc-ref opts 'recursive)
+                (crate-recursive-import
+                 name #:version version
+                 #:recursive-dev-dependencies?
+                 (assoc-ref opts 'recursive-dev-dependencies)
+                 #:allow-yanked? (assoc-ref opts 'allow-yanked)))
+               (else
+                (crate->guix-package
+                 name #:version version #:include-dev-deps? #t
+                 #:allow-yanked? (assoc-ref opts 'allow-yanked)
+                 #:mark-missing? (assoc-ref opts 'mark-missing))))
          ((or #f '())
           (leave (G_ "failed to download meta-data for package '~a'~%")
                  (if version
diff --git a/tests/crate.scm b/tests/crate.scm
index d0dc779cd2..9b7066c3b1 100644
--- a/tests/crate.scm
+++ b/tests/crate.scm
@@ -34,6 +34,7 @@ (define-module (test-crate)
   #:use-module (gnu packages)
   #:use-module (ice-9 iconv)
   #:use-module (ice-9 match)
+  #:use-module (srfi srfi-11)
   #:use-module (srfi srfi-64))
 
 
@@ -476,6 +477,9 @@ (define rust-leaf-bob-3.0.2-yanked
     (description #f)
     (license #f)))
 
+(define temp-file
+  (string-append "t-crate-" (number->string (getpid))))
+
 
 (test-begin "crate")
 
@@ -1178,4 +1182,88 @@ (define rust-leaf-bob-3.0.2-yanked
           (x
            (pk 'fail (pretty-print-with-comments (current-output-port) x) #f)))))
 
+
+(test-assert "crate-lockfile-import"
+  (begin
+    (call-with-output-file temp-file
+      (lambda (port)
+        (display "\
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = \"adler2\"
+version = \"2.0.0\"
+source = \"registry+https://github.com/rust-lang/crates.io-index\"
+checksum = \"512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627\"
+
+[[package]]
+name = \"aho-corasick\"
+version = \"1.1.3\"
+source = \"registry+https://github.com/rust-lang/crates.io-index\"
+checksum = \"8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916\"
+dependencies = [
+ \"memchr\",
+]
+
+[[package]]
+name = \"smithay\"
+version = \"0.4.0\"
+source = \"git+https://github.com/Smithay/smithay.git?rev=\
+0cd3345c59f7cb139521f267956a1a4e33248393#\
+0cd3345c59f7cb139521f267956a1a4e33248393\"
+dependencies = [
+ \"appendlist\",
+]
+
+[[package]]
+name = \"test\"
+version = \"25.2.0\"\n" port)))
+    (mock
+     ((guix scripts download) guix-download
+      (lambda _
+        (format #t "~a~%~a~%"
+                "/gnu/store/in056fyrz6nvy3jpxrxglgj30g0lwniv-smithay-0cd3345"
+                "191h87bpzg0l1ihfb4hmx00b86pfb5mwwc6s8i49al0vigc14l37")))
+     (let-values
+         (((crates-definitions input-list)
+           (cargo-lock->definitions temp-file "test")))
+       (and
+        (match crates-definitions
+          (((define 'rust-adler2-2.0.0
+              (crate-source
+               "adler2" "2.0.0"
+               "09r6drylvgy8vv8k20lnbvwq8gp09h7smfn6h1rxsy15pgh629si"))
+            (define 'rust-aho-corasick-1.1.3
+              (crate-source
+               "aho-corasick" "1.1.3"
+               "05mrpkvdgp5d20y2p989f187ry9diliijgwrs254fs9s1m1x6q4f"))
+            (define 'rust-smithay-0.4.0.0cd3345
+              ($ <comment>
+                 ";; TODO: Define standalone package if this is a workspace.\n"
+                 #f)
+              (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/Smithay/smithay.git")
+                      (commit "0cd3345c59f7cb139521f267956a1a4e33248393")))
+                (file-name (git-file-name "rust-smithay" "0.4.0.0cd3345"))
+                (sha256
+                 (base32
+                  "191h87bpzg0l1ihfb4hmx00b86pfb5mwwc6s8i49al0vigc14l37")))))
+           #t)
+          (x
+           (pk 'fail (pretty-print-with-comments (current-output-port) x) #f)))
+        (match input-list
+          ((define-public 'test-cargo-inputs
+             (list rust-adler2-2.0.0
+                   rust-aho-corasick-1.1.3
+                   rust-smithay-0.4.0.0cd3345))
+           #t)
+          (x
+           (pk 'fail x #f))))))))
+
 (test-end "crate")
+
+(false-if-exception (delete-file temp-file))
-- 
2.48.1





Information forwarded to guix@HIDDEN, divya@HIDDEN, efraim@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, maxim.cournoyer@HIDDEN, zimon.toutoune@HIDDEN, steve@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:29:24 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 10:29:24 2025
Received: from localhost ([127.0.0.1]:41738 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuXwX-0004kA-Ii
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:29:23 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:48328)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuXvJ-0004XX-8H
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:28:09 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742308084;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=cf59W6KffTl6mWAaIPklzAyqdmp+Dj1qOd4/4qF6zPY=;
 b=iDkLvWQkDZ3crXEznk+pCjdeT0MRLwCzgungzMXwmMUPsJDQcn5uUE2oyAwz6Z84ow4RgT
 4T86RoCVxCW5lvZ29QypAIbBMyNOVrw0jHegDAfSEQzkcj6TZ6xw4qRPrfVXuwTaS3llTN
 gRNsgnL1s1eq63bOCUS6jcmex/c3YZt3t0dGv96iMseXxYJO/sITkfgNFNqG8Ny1jFrAjQ
 R9KrrXO/EAKcAjfBFKSVUBtkIiE9XWFCxksd/QqJuPCI7uZU9IIGqZgC2omq7z/XGusNiz
 fYl8aBtM6zkzTuAZ0eKafcpbFf70qch2SwmXutW3lKn7OuGqcxNBWE5qJWkG5A==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v2 15/17] import: crate: Add Cargo.lock parser.
Date: Tue, 18 Mar 2025 22:26:58 +0800
Message-ID: <ef8f9b48e340a82177e0a5fefe72b4ff09d3e193.1742306960.git.hako@HIDDEN>
In-Reply-To: <cover.1742306960.git.hako@HIDDEN>
References: <cover.1742306960.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Divya Ranjan Pattanaik <divya@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>, Steve George <steve@HIDDEN>
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Murilo <murilo@HIDDEN>, Hilton Chain <hako@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>,
 Luis Guilherme Coelho <lgcoelho@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/import/crate/cargo-lock.scm: New file.
* Makefile.am (MODULES): Regisiter it.
* guix/import/crate.scm (cargo-lock->definitions): New procedure.

Co-authored-by: Murilo <murilo@HIDDEN>
Co-authored-by: Luis Guilherme Coelho <lgcoelho@HIDDEN>
Change-Id: I95421e9e2ba11a671b4bc4e1323c6d31a1b012c5
---
 Makefile.am                      |   1 +
 guix/import/crate.scm            |  78 +++++++++++++++++++++++
 guix/import/crate/cargo-lock.scm | 105 +++++++++++++++++++++++++++++++
 3 files changed, 184 insertions(+)
 create mode 100644 guix/import/crate/cargo-lock.scm

diff --git a/Makefile.am b/Makefile.am
index 4091a52387..a04e461ea8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -295,6 +295,7 @@ MODULES =					\
   guix/import/cpan.scm				\
   guix/import/cran.scm				\
   guix/import/crate.scm				\
+  guix/import/crate/cargo-lock.scm		\
   guix/import/egg.scm   			\
   guix/import/elm.scm				\
   guix/import/elpa.scm   			\
diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index a6f247bbae..ef3a6d0b4b 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -9,6 +9,9 @@
 ;;; Copyright © 2023, 2024 David Elsing <david.elsing@HIDDEN>
 ;;; Copyright © 2024 Maxim Cournoyer <maxim.cournoyer@HIDDEN>
 ;;; Copyright © 2025 Herman Rimm <herman@HIDDEN>
+;;; Copyright © 2024 Murilo <murilo@HIDDEN>
+;;; Copyright © 2024-2025 Luis Guilherme Coelho <lgcoelho@HIDDEN>
+;;; Copyright © 2025 Hilton Chain <hako@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -26,12 +29,14 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (guix import crate)
+  #:use-module (guix base16)
   #:use-module (guix base32)
   #:use-module ((guix build-system cargo) #:hide (crate-source))
   #:use-module (guix diagnostics)
   #:use-module (gcrypt hash)
   #:use-module (guix http-client)
   #:use-module (guix i18n)
+  #:use-module (guix import crate cargo-lock)
   #:use-module (guix import json)
   #:use-module (guix import utils)
   #:use-module (guix memoization)
@@ -39,9 +44,11 @@ (define-module (guix import crate)
   #:use-module (guix read-print)
   #:use-module (guix upstream)
   #:use-module (guix utils)
+  #:use-module (guix scripts download)
   #:use-module (gnu packages)
   #:use-module (ice-9 match)
   #:use-module (ice-9 regex)
+  #:use-module (ice-9 textual-ports)
   #:use-module (json)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-2)
@@ -52,6 +59,7 @@ (define-module (guix import crate)
             guix-package->crate-name
             string->license
             crate-recursive-import
+            cargo-lock->definitions
             %crate-updater))
 
 
@@ -481,6 +489,76 @@ (define (guix-package->crate-name package)
     (match parts
       ((name _ ...) name))))
 
+
+;;;
+;;; Convert ‘Cargo.lock’ to Guix sources.
+;;;
+
+(define (cargo-lock->definitions lockfile package-name)
+  "Given LOCKFILE, a 'Cargo.lock' file, convert its content into source
+definitions.  Return a list of sources and 'PACKAGE-NAME-cargo-inputs', an input
+list referencing all imported sources."
+  (define (crate->definition crate)
+    (match crate
+      (('crate
+        ('crate-name name)
+        ('crate-version version)
+        ('crate-source _)
+        ('crate-checksum checksum))
+       `(define
+          ,(string->symbol
+            (string-append (crate-name->package-name name) "-" version))
+          ,@(if (or (string-suffix? "src" name)
+                    (string-suffix? "sys" name))
+                (list (comment ";; TODO: Check bundled sources.\n" #f))
+                '())
+          (crate-source ,name ,version
+                        ,(bytevector->nix-base32-string
+                          (base16-string->bytevector checksum)))))
+      ;; Git snapshot.
+      (('crate
+        ('crate-name name)
+        ('crate-version version)
+        ('crate-source source))
+       (begin
+         (let* ((src (string-split source (char-set #\+ #\? #\#)))
+                (url (second src))
+                (commit (last src))
+                (version (string-append version "." (string-take commit 7)))
+                (checksum
+                 (second
+                  (string-split
+                   (with-output-to-string
+                     (lambda _
+                       (guix-download "-g" url
+                                      (string-append "--commit=" commit))))
+                   #\newline))))
+           `(define
+              ,(string->symbol
+                (string-append (crate-name->package-name name) "-" version))
+              ,(comment
+                ";; TODO: Define standalone package if this is a workspace.\n"
+                #f)
+              (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url ,url)
+                      (commit ,commit)))
+                (file-name
+                 (git-file-name ,(crate-name->package-name name) ,version))
+                (sha256 (base32 ,checksum)))))))
+      ;; Workspace member.
+      (else #f)))
+
+  (let ((definitions
+          (filter-map crate->definition
+                      (cargo-lock-string->scm
+                       (call-with-input-file lockfile get-string-all)))))
+    (values definitions
+            `(define-public
+               ,(string->symbol (string-append package-name "-cargo-inputs"))
+               (list ,@(map second definitions))))))
+
 
 ;;;
 ;;; Updater
diff --git a/guix/import/crate/cargo-lock.scm b/guix/import/crate/cargo-lock.scm
new file mode 100644
index 0000000000..b8a6ab20c0
--- /dev/null
+++ b/guix/import/crate/cargo-lock.scm
@@ -0,0 +1,105 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2024 Murilo <murilo@HIDDEN>
+;;; Copyright © 2024 Luis Guilherme Coelho <lgcoelho@HIDDEN>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix import crate cargo-lock)
+  #:use-module (ice-9 peg)
+  #:export (cargo-lock-string->scm
+
+            crate-name
+            crate-version
+            crate-source
+            crate-checksum
+            crate-dependencies
+            cargo-lock))
+
+;;;
+;;; PEG parser for ‘Cargo.lock’.
+;;;
+
+(define (cargo-lock-string->scm str)
+  (peg:tree (search-for-pattern cargo-lock str)))
+
+;; Auxiliar peg patterns
+(define-peg-pattern numeric-char body
+  (range #\0 #\9))
+
+(define-peg-pattern lowercase-char body
+  (range #\a #\z))
+
+(define-peg-pattern uppercase-char body
+  (range #\A #\Z))
+
+(define-peg-pattern alphabetic-char body
+  (or lowercase-char uppercase-char))
+
+(define-peg-pattern alphanumeric-char body
+  (or alphabetic-char numeric-char))
+
+;; name
+(define-peg-pattern crate-name all
+  (+ (or "-" alphabetic-char
+         "_" numeric-char)))
+
+;; version
+(define-peg-pattern non-negative-integer body
+  (+ numeric-char))
+
+(define-peg-pattern crate-version all
+  (and non-negative-integer "."
+       non-negative-integer "."
+       non-negative-integer
+       (? (+ (or "-" lowercase-char
+                 "." uppercase-char
+                 "+" numeric-char "_")))))
+
+;; source
+(define-peg-pattern crate-source all
+  (and (or "registry" "git")
+       "+https://"
+       (+ (or "/" "." "?" "=" "-" "#" "_"
+              alphanumeric-char))))
+
+;; checksum
+(define-peg-pattern crate-checksum all
+  (+ (or lowercase-char numeric-char)))
+
+;; dependency specification
+(define-peg-pattern dependency-specification all
+  (and crate-name (? (and (ignore " ") crate-version))))
+
+;; dependencies
+(define-peg-pattern crate-dependencies all
+  (and (ignore "[\n")
+       (+ (and (ignore " \"")
+               (capture dependency-specification)
+               (ignore "\",\n")))
+       (ignore "]")))
+
+;; crates
+(define-peg-pattern crate all
+  (and (ignore "[[package]]\n")
+       (ignore "name = \"") (capture crate-name) (ignore "\"\n")
+       (ignore "version = \"") (capture crate-version) (ignore "\"\n")
+       (? (and (ignore "source = \"") (capture crate-source) (ignore "\"\n")))
+       (? (and (ignore "checksum = \"") (capture crate-checksum) (ignore "\"\n")))
+       (? (ignore (and "dependencies = " crate-dependencies "\n")))))
+
+;; Cargo.lock
+(define-peg-pattern cargo-lock all
+  (+ (and (ignore "\n") crate)))
-- 
2.48.1





Information forwarded to divya@HIDDEN, efraim@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:29:21 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 10:29:21 2025
Received: from localhost ([127.0.0.1]:41735 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuXwU-0004jj-EA
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:29:21 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:47182)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuXvF-0004Wt-S0
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:28:06 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742308080;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=cM5fQi5K4lwBJ78ozo82ZN0cgMrgMJeJ69wt4C0ZkjI=;
 b=IOee4n9ixTvHYF5Ou9B7arrpPnnFU6cwR8fQDbqX/imr/MiN1XM4wVUChKNM0nDKUNl2i3
 RYbcIDt72gwYwFDdAgaUo/i5ROPJgYJwXDdAFgsa+oek4NRLG600b37ECZvDReSrTc+rwI
 d4ZufVLS9BuucHBqxwftW+iZh40k38Q4fbzQ8pg6SA8h+pYs5/RKrFUn8/716KYK8h1TFY
 Sz9MoW/uwGN7ddqV2iQJIqFgHj9HqB9B9iW3L9W4LngQFYVl2bC9Na0URUfg+9dKU+WZw4
 Jpnr5ugkLD2DDEQ6xPRJmkyV3tpDNad5VcqzZgT79UpeNgiW/cJq1YbDroTZAg==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v2 14/17] =?UTF-8?q?build-system:=20cargo:=20Add?=
 =?UTF-8?q?=20=E2=80=98cargo-inputs=E2=80=99.?=
Date: Tue, 18 Mar 2025 22:26:57 +0800
Message-ID: <647adc3bc797d6c8d86b9d35ff2eb1f03a1db32d.1742306960.git.hako@HIDDEN>
In-Reply-To: <cover.1742306960.git.hako@HIDDEN>
References: <cover.1742306960.git.hako@HIDDEN>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
X-Debbugs-Cc: Divya Ranjan Pattanaik <divya@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>, Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* gnu/packages/rust-crates.scm: New file.
* gnu/packages/rust-sources.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Regisiter them.
* guix/build-system/cargo.scm (crate-source,cargo-inputs): New procedures.
* guix/import/crate.scm: Hide ‘crate-source’ from (guix build-system cargo).
* etc/teams/rust/cleanup-crates.sh: New file.
* etc/teams/rust/rust-crates.tmpl: New file.

Change-Id: I2f2d705a3e376ed3c646f31b824052a2278d4fb3
---
 etc/teams/rust/cleanup-crates.sh | 38 +++++++++++++++++++++++++++
 etc/teams/rust/rust-crates.tmpl  | 42 +++++++++++++++++++++++++++++
 gnu/local.mk                     |  2 ++
 gnu/packages/rust-crates.scm     | 42 +++++++++++++++++++++++++++++
 gnu/packages/rust-sources.scm    | 29 ++++++++++++++++++++
 guix/build-system/cargo.scm      | 45 +++++++++++++++++++++++++++++++-
 guix/import/crate.scm            |  2 +-
 7 files changed, 198 insertions(+), 2 deletions(-)
 create mode 100755 etc/teams/rust/cleanup-crates.sh
 create mode 100644 etc/teams/rust/rust-crates.tmpl
 create mode 100644 gnu/packages/rust-crates.scm
 create mode 100644 gnu/packages/rust-sources.scm

diff --git a/etc/teams/rust/cleanup-crates.sh b/etc/teams/rust/cleanup-crates.sh
new file mode 100755
index 0000000000..cd4c2462b9
--- /dev/null
+++ b/etc/teams/rust/cleanup-crates.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+# GNU Guix --- Functional package management for GNU
+# Copyright © 2025 Hilton Chain <hako@HIDDEN>
+#
+# This file is part of GNU Guix.
+#
+# GNU Guix is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or (at
+# your option) any later version.
+#
+# GNU Guix is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+FILE=gnu/packages/rust-crates.scm
+PATTERN='^(define rust-'
+
+grep "$PATTERN" $FILE | cut -d' ' -f2 | while IFS= read -r crate
+do
+    if [ "$(grep -wc "$crate" $FILE)" -eq 1 ]; then
+        echo "\
+(begin
+  (use-modules (guix utils))
+  (let ((source-properties
+         (find-definition-location \"$FILE\" '$crate #:definer 'define)))
+    (and=> source-properties delete-expression)))" |
+            guix repl -t machine
+    fi
+done
+
+# Delete extra newlines.
+sed --in-place ':a;N;$!ba;s/\n\n\+/\n\n/g' $FILE
diff --git a/etc/teams/rust/rust-crates.tmpl b/etc/teams/rust/rust-crates.tmpl
new file mode 100644
index 0000000000..98053b7151
--- /dev/null
+++ b/etc/teams/rust/rust-crates.tmpl
@@ -0,0 +1,42 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2025 Hilton Chain <hako@HIDDEN>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages rust-crates)
+  #:use-module (guix gexp)
+  #:use-module (guix packages)
+  #:use-module (guix download)
+  #:use-module (guix git-download)
+  #:use-module (guix build-system cargo))
+
+;;;
+;;; This file is managed by ‘guix import’.  DO NOT add definitions manually.
+;;;
+
+;;;
+;;; Rust dependencies fetched from crates.io and non-workspace development
+;;; snapshots.
+;;;
+
+(define qqqq-separator 'begin-of-crates)
+
+(define ssss-separator 'end-of-crates)
+
+
+;;;
+;;; Cargo inputs.
+;;;
diff --git a/gnu/local.mk b/gnu/local.mk
index 02de02e65f..8d8bd6ebbe 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -616,6 +616,8 @@ GNU_SYSTEM_MODULES =				\
   %D%/packages/rush.scm				\
   %D%/packages/rust.scm				\
   %D%/packages/rust-apps.scm			\
+  %D%/packages/rust-crates.scm			\
+  %D%/packages/rust-sources.scm			\
   %D%/packages/samba.scm			\
   %D%/packages/sagemath.scm			\
   %D%/packages/sawfish.scm			\
diff --git a/gnu/packages/rust-crates.scm b/gnu/packages/rust-crates.scm
new file mode 100644
index 0000000000..98053b7151
--- /dev/null
+++ b/gnu/packages/rust-crates.scm
@@ -0,0 +1,42 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2025 Hilton Chain <hako@HIDDEN>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages rust-crates)
+  #:use-module (guix gexp)
+  #:use-module (guix packages)
+  #:use-module (guix download)
+  #:use-module (guix git-download)
+  #:use-module (guix build-system cargo))
+
+;;;
+;;; This file is managed by ‘guix import’.  DO NOT add definitions manually.
+;;;
+
+;;;
+;;; Rust dependencies fetched from crates.io and non-workspace development
+;;; snapshots.
+;;;
+
+(define qqqq-separator 'begin-of-crates)
+
+(define ssss-separator 'end-of-crates)
+
+
+;;;
+;;; Cargo inputs.
+;;;
diff --git a/gnu/packages/rust-sources.scm b/gnu/packages/rust-sources.scm
new file mode 100644
index 0000000000..bf9b91a671
--- /dev/null
+++ b/gnu/packages/rust-sources.scm
@@ -0,0 +1,29 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2025 Hilton Chain <hako@HIDDEN>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages rust-sources)
+  #:use-module (guix gexp)
+  #:use-module (guix packages)
+  #:use-module (guix download)
+  #:use-module (guix git-download)
+  #:use-module (guix build-system cargo))
+
+;;;
+;;; Cargo workspaces and Rust dependencies requiring external inputs to
+;;; unbundle.
+;;;
diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
index 7a07003262..47d4f10969 100644
--- a/guix/build-system/cargo.scm
+++ b/guix/build-system/cargo.scm
@@ -31,6 +31,7 @@ (define-module (guix build-system cargo)
   #:use-module (guix gexp)
   #:use-module (guix monads)
   #:use-module (guix packages)
+  #:use-module (guix download)
   #:use-module (guix platform)
   #:use-module (guix build-system)
   #:use-module (guix build-system gnu)
@@ -45,7 +46,9 @@ (define-module (guix build-system cargo)
             crate-url
             crate-url?
             crate-uri
-            crate-name->package-name))
+            crate-name->package-name
+            crate-source
+            cargo-inputs))
 
 (define %crate-base-url
   (make-parameter "https://crates.io"))
@@ -62,6 +65,46 @@ (define (crate-uri name version)
 (define (crate-name->package-name name)
   (downstream-package-name "rust-" name))
 
+(define* (crate-source name version hash #:key (patches '()) (snippet #f))
+  (origin
+    (method url-fetch)
+    (uri (crate-uri name version))
+    (file-name
+     (string-append (crate-name->package-name name) "-" version ".tar.gz"))
+    (sha256 (base32 hash))
+    (modules '((guix build utils)))
+    (patches patches)
+    (snippet snippet)))
+
+(define* (cargo-inputs name #:key (crates-module '(gnu packages rust-crates))
+                       (sources-module '(gnu packages rust-sources)))
+  "Given NAME, resolve input list 'NAME-cargo-inputs' in CRATES-MODULE, return
+its copy with #f removed and symbols resolved to variables defined in
+SOURCES-MODULE, if the list exists, otherwise return an empty list."
+  (let loop ((inputs
+              (catch #t
+                (lambda ()
+                  (module-ref (resolve-interface crates-module)
+                              (symbol-append name '-cargo-inputs)))
+                (const '())))
+             (result '()))
+    (if (null? inputs)
+        result
+        (match inputs
+          ((input . rest)
+           (loop rest
+                 (cond
+                  ;; #f, remove it.
+                  ((not input)
+                   result)
+                  ;; Symbol, resolve it in SOURCES-MODULE.
+                  ((symbol? input)
+                   (cons (module-ref (resolve-interface sources-module) input)
+                         result))
+                  ;; Else: no change.
+                  (else
+                   (cons input result)))))))))
+
 (define (default-rust target)
   "Return the default Rust package."
   ;; Lazily resolve the binding to avoid a circular dependency.
diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index 14e6e28c5b..a6f247bbae 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -27,7 +27,7 @@
 
 (define-module (guix import crate)
   #:use-module (guix base32)
-  #:use-module (guix build-system cargo)
+  #:use-module ((guix build-system cargo) #:hide (crate-source))
   #:use-module (guix diagnostics)
   #:use-module (gcrypt hash)
   #:use-module (guix http-client)
-- 
2.48.1





Information forwarded to divya@HIDDEN, efraim@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:29:18 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 10:29:18 2025
Received: from localhost ([127.0.0.1]:41733 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuXwT-0004jO-2S
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:29:18 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:38140)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuXv3-0004UY-AT
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:27:51 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742308067;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=q8EtGgJNAcVCCAJm1iKNtDwPxS31GnBy41AJ8jW1jdQ=;
 b=DWE9XCjmRlLX7HFhHZXUlpfb/OhnZd9ckEofxUVLsJCMuS7C6bXvxt+LfrqkJusD11Mxds
 6iDni4s8DRSe6tseb/2IGTMtG4g4zmXOhfekssmxt87ziHPLf46gUnytOF0p3G826Bzhrd
 cIVHC0vMJU1kEDEvis0ZTzHu8Z1T90c9WGsPMylnDGCJT1nb0oLGMHJJP/ZK+E7NtcLB4R
 n08FxaMAjKh3R8u25xs2cRkdqCVZ4yjRhvD8rJL2O2J2a+9ZXYWhNhHDHAbuQftTNHNR7X
 79CLv3tN7jeYGBe/71vY2x4ekba1oN+bm7I3s9Wuht8Hz2d5tFCZM3RBKV49Gg==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v2 09/17] =?UTF-8?q?scripts:=20import:=20Add=20t?=
 =?UTF-8?q?wo=20newlines=20for=20=E2=80=98--insert=E2=80=99=20option.?=
Date: Tue, 18 Mar 2025 22:26:52 +0800
Message-ID: <11fef5174ac01e0da00318799b2cf10826d09d3c.1742306960.git.hako@HIDDEN>
In-Reply-To: <cover.1742306960.git.hako@HIDDEN>
References: <cover.1742306960.git.hako@HIDDEN>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
X-Debbugs-Cc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

For consistency with ‘insert-expression’.

* guix/scripts/import.scm (guix-import): Add two newlines when inserting.

Change-Id: I55b45ca137d175fdf6ee5c0bb2b6b1ca8385750d
---
 guix/scripts/import.scm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index 4fad329cd3..58a84d0db7 100644
--- a/guix/scripts/import.scm
+++ b/guix/scripts/import.scm
@@ -129,6 +129,7 @@ (define-command (guix-import . args)
                       (let ((port (open-file file "a")))
                         (pretty-print-with-comments port expr)
                         (newline port)
+                        (newline port)
                         (close-port port)))))))))
        (import-as-definitions importer args find-and-insert)))
     ((importer args ...)
-- 
2.48.1





Information forwarded to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:28:31 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 10:28:30 2025
Received: from localhost ([127.0.0.1]:41696 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuXvh-0004cL-1S
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:28:30 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:39486)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuXv0-0004Ty-TF
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:27:47 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742308065;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=0gATDkYY9+HlIpSIiMsJydmF48/8/FeFvqFI8MW5iOs=;
 b=bKCp1oTeDsOC3bbgW5b+Ihxi1pdpT5TN9fEhtDts0Ra3OUYjm6UdUS63H3FSuCQoS7p0Wu
 xZ7ss5Jtr+5HMoNCgak+P4uuTktR7FnsKOb3HtOlth4AlMtxtYE+TejdYR9/HG88BIFWdH
 lFmuckOjIW1uAeRBhSXkqoVvBwoOc5P7l20aJYb37LQWST2ws3LlkEZWk1wMTt9LjFktcY
 rrcVT+HtjoewFfUHX+Qp7CMIV6APjOtXr1Y/azlttn4UKYQ/b3Y5lkX863DyCR11/M7YM/
 CeSdjNV/M61GopSGX90GbHxRen/vfRqVaXrqonTODuIc4aO1m+pesQ56jNAqyQ==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v2 08/17] =?UTF-8?q?scripts:=20import:=20Documen?=
 =?UTF-8?q?t=20argument=20for=20=E2=80=98--insert=E2=80=99=20option=20in?=
 =?UTF-8?q?=20help=20message.?=
Date: Tue, 18 Mar 2025 22:26:51 +0800
Message-ID: <dc76e32f899a1fd41610a31423de5539801c954c.1742306960.git.hako@HIDDEN>
In-Reply-To: <cover.1742306960.git.hako@HIDDEN>
References: <cover.1742306960.git.hako@HIDDEN>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
X-Debbugs-Cc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/scripts/import.scm (show-help): Add missing ‘FILE’.

Change-Id: I540d5feae3fe49c00e9bd6f7a8649ffe0d6e006d
---
 guix/scripts/import.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index bbf31baa15..4fad329cd3 100644
--- a/guix/scripts/import.scm
+++ b/guix/scripts/import.scm
@@ -69,7 +69,7 @@ (define (show-help)
   (display (G_ "
   -h, --help             display this help and exit"))
   (display (G_ "
-  -i, --insert           insert packages into file alphabetically"))
+  -i, --insert=FILE      insert packages into FILE alphabetically"))
   (display (G_ "
   -V, --version          display version information and exit"))
   (newline)
-- 
2.48.1





Information forwarded to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:28:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 10:28:29 2025
Received: from localhost ([127.0.0.1]:41694 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuXvd-0004bm-UE
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:28:28 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:38134)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuXuy-0004Th-4q
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:27:44 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742308063;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=tbbBEmq0fTJiCFdj43NMRydjWkPfzpnZqNYgFZF3pNU=;
 b=LFgfcxT7MjNSXr5KYNd/HoVXERwJS3UwwoskEXk3t8s2Sox5gKkkCSjFDxY5XjW03pBT0j
 48Ai0yTsTTih8+UQB6rNSGb+E0jHxO60gzhpecJxKbI5cz+27OR0wdOIxlkVXbFhPOYP1J
 WeQTruLRJrIUl4NgGVUEueTRs96/72S8k2yXDn4v/fWx9h4+uQGZ7q2CVUmdcZ3/kHPRTB
 36G67L6YYkjrM+fwkXppj5B7KkI5bpjWKon8RD1gOIX2uAxljo54ordTcoCAuJBlvE9UIL
 F72mH8wsEd7XxB0y0tED/8azxIyaorKXkYGdasWKl500KAB5Nnn/Z1x9JO7mtQ==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v2 07/17] build/cargo: Support non-workspace
 directory source inputs.
Date: Tue, 18 Mar 2025 22:26:50 +0800
Message-ID: <61e545567eda8714f688c1f0655d72a2efbe2245.1742306960.git.hako@HIDDEN>
In-Reply-To: <cover.1742306960.git.hako@HIDDEN>
References: <cover.1742306960.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Divya Ranjan Pattanaik <divya@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>, Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/build/cargo-build-system.scm (single-crate?): New procedure.
(crate-src?): Support non-workspace directory source inputs.
(configure): Likewise.

Change-Id: If2bd318b44ed765baec69309f25d320edceee116
---
 guix/build/cargo-build-system.scm | 60 ++++++++++++++++++++-----------
 1 file changed, 39 insertions(+), 21 deletions(-)

diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index 32a756ad99..41adc03752 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -33,6 +33,7 @@ (define-module (guix build cargo-build-system)
   #:use-module (ice-9 ftw)
   #:use-module (ice-9 format)
   #:use-module (ice-9 match)
+  #:use-module (ice-9 textual-ports)
   #:use-module (ice-9 threads)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
@@ -60,22 +61,35 @@ (define (has-executable-target?)
          (bin-dep? (lambda (dep) (find bin? (get-kinds dep)))))
     (find bin-dep? (manifest-targets))))
 
+(define (single-crate? dir)
+  "Check if directory DIR contains 'Cargo.toml' and is not a workspace."
+  (let ((manifest-file (in-vicinity dir "Cargo.toml")))
+    (and (file-exists? manifest-file)
+         (not (string-contains
+               (call-with-input-file manifest-file get-string-all)
+               "[workspace]")))))
+
 (define (crate-src? path)
   "Check if PATH refers to a crate source, namely a gzipped tarball with a
 Cargo.toml file present at its root."
-    (and (not (directory-exists? path)) ; not a tarball
-         (not (string-suffix? "py" path))   ; sanity-check.py
-         ;; First we print out all file names within the tarball to see if it
-         ;; looks like the source of a crate. However, the tarball will include
-         ;; an extra path component which we would like to ignore (since we're
-         ;; interested in checking if a Cargo.toml exists at the root of the
-         ;; archive, but not nested anywhere else). We do this by cutting up
-         ;; each output line and only looking at the second component. We then
-         ;; check if it matches Cargo.toml exactly and short circuit if it does.
-         (apply invoke (list "sh" "-c"
-                             (string-append "tar -tf " path
-                                            " | cut -d/ -f2"
-                                            " | grep -q '^Cargo.toml$'")))))
+  (if (directory-exists? path)
+      ;; The build system only handles sources containing single crate.
+      ;; Workspaces should be packaged into crates (via 'package phase)
+      ;; and used in inputs.
+      (single-crate? path)
+      (and (not (string-suffix? "py" path)) ;sanity-check.py
+           ;; First we print out all file names within the tarball to see
+           ;; if it looks like the source of a crate. However, the tarball
+           ;; will include an extra path component which we would like to
+           ;; ignore (since we're interested in checking if a Cargo.toml
+           ;; exists at the root of the archive, but not nested anywhere
+           ;; else). We do this by cutting up each output line and only
+           ;; looking at the second component. We then check if it matches
+           ;; Cargo.toml exactly and short circuit if it does.
+           (invoke "sh" "-c"
+                   (string-append "tar -tf " path
+                                  " | cut -d/ -f2"
+                                  " | grep -q '^Cargo.toml$'")))))
 
 (define* (unpack-rust-crates #:key inputs (vendor-dir "guix-vendor")
                              #:allow-other-keys)
@@ -159,14 +173,18 @@ (define* (configure #:key inputs
          (and (crate-src? path)
               ;; Gracefully handle duplicate inputs
               (not (file-exists? crate-dir))
-              (mkdir-p crate-dir)
-              ;; Cargo crates are simply gzipped tarballs but with a .crate
-              ;; extension. We expand the source to a directory name we control
-              ;; so that we can generate any cargo checksums.
-              ;; The --strip-components argument is needed to prevent creating
-              ;; an extra directory within `crate-dir`.
-              (format #t "Unpacking ~a~%" name)
-              (invoke "tar" "xf" path "-C" crate-dir "--strip-components" "1")))))
+              (if (directory-exists? path)
+                  (copy-recursively path crate-dir)
+                  (begin
+                    (mkdir-p crate-dir)
+                    ;; Cargo crates are simply gzipped tarballs but with a
+                    ;; .crate extension. We expand the source to a directory
+                    ;; name we control so that we can generate any cargo
+                    ;; checksums.  The --strip-components argument is needed to
+                    ;; prevent creating an extra directory within `crate-dir`.
+                    (format #t "Unpacking ~a~%" name)
+                    (invoke "tar" "xf" path "-C" crate-dir
+                            "--strip-components" "1")))))))
     inputs)
 
   ;; For cross-building
-- 
2.48.1





Information forwarded to divya@HIDDEN, efraim@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:28:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 10:28:26 2025
Received: from localhost ([127.0.0.1]:41692 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuXvc-0004bO-5C
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:28:25 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:50906)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuXuu-0004TE-GQ
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:27:41 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742308059;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=/rzdlzWItiPgm9mMM9D4fKw9AdkNnt3Yvo2naRK6/Yg=;
 b=Qzyq0uWL7RXZO8jEBhfhYwUmTk1H5uZjyK+6DvE9UuUG3oYKbz9GpP5+sgRcIo6jcgxf42
 lEP+Au0t+f4ugXYxIMD4Cdi6g6/gQ2KyL+lMICIpnk5tGEzZk1Qa++jX3vj4JCpva6B+qv
 Z0tFI0jZoi9i/9VMZoUOYau882Mpw0PWkQO47zsdQX7SIYTjutY8cdEwcwz0pNDp4nKVmn
 5nH06ogWUA2bz8mZE7tRsHjulwbH5Np1+ZTc5OoRtrdK/4Dc+yckiHriro9icYRrRXkKM4
 Rv5TI05lTL5LNfXsl5DAzVnnL9vi0jNABZObmlU7LmatAj5unyt85s3yz+XVFw==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v2 06/17] build/cargo: Don't try to unpack
 sanity-check.py.
Date: Tue, 18 Mar 2025 22:26:49 +0800
Message-ID: <61a9a8ca7dce12d0a05dc060ea891c5443648bcc.1742306960.git.hako@HIDDEN>
In-Reply-To: <cover.1742306960.git.hako@HIDDEN>
References: <cover.1742306960.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Divya Ranjan Pattanaik <divya@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>, Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Efraim Flashner <efraim@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

From: Efraim Flashner <efraim@HIDDEN>

* guix/build/cargo-build-system.scm (crate-src?): Also don't try to
check python scripts for Cargo.toml.

Change-Id: I001a89b83d2e472706b1263007be45d1153c140f
---
 guix/build/cargo-build-system.scm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index 85a9698680..32a756ad99 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -64,6 +64,7 @@ (define (crate-src? path)
   "Check if PATH refers to a crate source, namely a gzipped tarball with a
 Cargo.toml file present at its root."
     (and (not (directory-exists? path)) ; not a tarball
+         (not (string-suffix? "py" path))   ; sanity-check.py
          ;; First we print out all file names within the tarball to see if it
          ;; looks like the source of a crate. However, the tarball will include
          ;; an extra path component which we would like to ignore (since we're
-- 
2.48.1





Information forwarded to divya@HIDDEN, efraim@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:28:24 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 10:28:24 2025
Received: from localhost ([127.0.0.1]:41690 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuXva-0004ay-83
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:28:24 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:50904)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuXup-0004SK-Dg
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:27:37 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742308054;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=FWpLZ+ufoQV1Ds7z8c897yBpgjk/6z32S6Qk4j1sjwo=;
 b=O9k3cljz5hK42oZonMmCCOarwI+540RHkQNjxEboUE3z0Epnl36dwxCpUTGtVt3PsXdDdH
 sMU27t00Ztc/WFz7GlZlJdE+Qh7+Xv+NCXgfmN2W+fAwhYsXqtl/pP4zjve2xMUchanTMF
 Kzq9hPjb/2smr+kBkdHsbA0Ws7jANxJxAqCwYH0Y+zx+MxnJK2X4kuUdqJZcqyKOX7DSJ/
 oM8XfkRgDJA0TCiNxytpcZVNPfbodTjW2UR3GIcYeiK1YKRNiiueBnqRxKAeZIuo1/d0eZ
 AeLdHXOEOimbAhkyjJG1v2RBzrNz9/Pja2mZtJN9lCjLVKMt8LJeT6RwvoHq4Q==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v2 04/17] build-system: cargo: Support installing
 Cargo workspace.
Date: Tue, 18 Mar 2025 22:26:47 +0800
Message-ID: <131e76c748cd19bbda57ad11a4b83884b7eebf0e.1742306960.git.hako@HIDDEN>
In-Reply-To: <cover.1742306960.git.hako@HIDDEN>
References: <cover.1742306960.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Divya Ranjan Pattanaik <divya@HIDDEN>, Efraim Flashner <efraim@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>, Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

*guix/build-system/cargo.scm (cargo-build,cargo-cross-build)
[#:cargo-install-paths]: New argument.
* guix/build/cargo-build-system.scm (install): Use it.
* doc/guix.texi (Build Systems)[cargo-build-system]: Document it.

Change-Id: I74ed1972a5716da05afeac8edb2b0e4b6834bf40
---
 doc/guix.texi                     |  5 ++++-
 guix/build-system/cargo.scm       |  4 ++++
 guix/build/cargo-build-system.scm | 17 +++++++++++++----
 3 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 0089f9e60f..7fa986b4b9 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -9369,7 +9369,10 @@ Build Systems
 library crates to package in the @code{package} phase.  Specified crates are
 packaged from left to right, in case there's dependency among them.  For
 example, specifying @code{''("pcre2-sys" "pcre2")} will package
-@code{"pcre2-sys"} first and then @code{"pcre2"}.
+@code{"pcre2-sys"} first and then @code{"pcre2"}.  Parameter
+@code{#:cargo-install-paths} (default: @code{''()}) allows specifying paths of
+binary crates to install in the @code{install} phase, @code{''("crates/atuin")},
+for example.
 @end defvar
 
 @defvar chicken-build-system
diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
index 4f6d46e70c..4486c706a1 100644
--- a/guix/build-system/cargo.scm
+++ b/guix/build-system/cargo.scm
@@ -96,6 +96,7 @@ (define* (cargo-build name inputs
                       (cargo-test-flags ''())
                       (cargo-package-crates ''())
                       (cargo-package-flags ''("--no-metadata" "--no-verify"))
+                      (cargo-install-paths ''())
                       (features ''())
                       (skip-build? #f)
                       (parallel-build? #t)
@@ -125,6 +126,7 @@ (define* (cargo-build name inputs
                        #:cargo-test-flags #$(sexp->gexp cargo-test-flags)
                        #:cargo-package-crates #$(sexp->gexp cargo-package-crates)
                        #:cargo-package-flags #$(sexp->gexp cargo-package-flags)
+                       #:cargo-install-paths #$(sexp->gexp cargo-install-paths)
                        #:cargo-target #$(cargo-triplet system)
                        #:features #$(sexp->gexp features)
                        #:skip-build? #$skip-build?
@@ -158,6 +160,7 @@ (define* (cargo-cross-build name
                             (cargo-test-flags ''())
                             (cargo-package-crates ''())
                             (cargo-package-flags ''("--no-metadata" "--no-verify"))
+                            (cargo-install-paths ''())
                             (cargo-target (cargo-triplet (or target system)))
                             (features ''())
                             (skip-build? #f)
@@ -190,6 +193,7 @@ (define* (cargo-cross-build name
                        #:cargo-test-flags #$(sexp->gexp cargo-test-flags)
                        #:cargo-package-crates #$(sexp->gexp cargo-package-crates)
                        #:cargo-package-flags #$(sexp->gexp cargo-package-flags)
+                       #:cargo-install-paths #$(sexp->gexp cargo-install-paths)
                        #:cargo-target #$(cargo-triplet (or target system))
                        #:features #$(sexp->gexp features)
                        #:skip-build? #$skip-build?
diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index 979f93aef4..85f10a7ac4 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -378,6 +378,7 @@ (define* (install #:key
                   skip-build?
                   install-source?
                   features
+                  (cargo-install-paths '())
                   #:allow-other-keys)
   "Install a given Cargo package."
   (let* ((out      (assoc-ref outputs "out"))
@@ -392,10 +393,18 @@ (define* (install #:key
     ;; Only install crates which include binary targets,
     ;; otherwise cargo will raise an error.
     (or skip-build?
-        (not (has-executable-target?))
-        (invoke "cargo" "install" "--offline" "--no-track"
-                "--path" "." "--root" out
-                "--features" (string-join features)))
+        ;; NOTE: Cargo workspace installation support:
+        ;; #:skip-build? #f + #:cargo-install-paths.
+        (and (null? cargo-install-paths)
+             (not (has-executable-target?)))
+        (for-each
+         (lambda (path)
+           (invoke "cargo" "install" "--offline" "--no-track"
+                   "--path" path "--root" out
+                   "--features" (string-join features)))
+         (if (null? cargo-install-paths)
+             '(".")
+             cargo-install-paths)))
 
     (when install-source?
       ;; Install crate tarballs and unpacked sources for later use.
-- 
2.48.1





Information forwarded to divya@HIDDEN, efraim@HIDDEN, ludo@HIDDEN, maxim.cournoyer@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:28:22 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 10:28:22 2025
Received: from localhost ([127.0.0.1]:41688 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuXvY-0004ak-BU
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:28:22 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:41352)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuXum-0004Rg-OD
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:27:37 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742308051;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=MBzb7Ibac3SmOWIkI8ON7GjHlsaB/193XKHyjTRQoqk=;
 b=CAO3v5ls3poQIH4dEqgJb7w/xXCmbp02frI+NEooFoPefbxbQxiC7E1dEiTimkERBqP0hC
 NM5faMK0/9DZ+O9YAIsf85r/91MoMKxvKcZTlm/G3a7balkcL1kO5jQXYvWuzToTO41GBM
 hGOnLE87MiwaaRKP1Uo9hVRhoDN7reZ8NcTfeEjJ7YcVINH3VNlC5gRCXKJlnVQLNQqyCE
 AusZcUoaawHQ8BXL3+osscYigeSvDVKL5eRhQ3o2vZV9INCZooRXhsM91omvw/oVvwzboo
 /gSk/fDsPIBJDOPXg1Qo4fNstkNMcsnAtwEbw26+QCoSFcoEYQSqWCC/n8HbZA==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v2 03/17] build-system: cargo: Support packaging
 Cargo workspace.
Date: Tue, 18 Mar 2025 22:26:46 +0800
Message-ID: <e3ab9a2aa850aecf17f73d21ce77528bcbaf0298.1742306960.git.hako@HIDDEN>
In-Reply-To: <cover.1742306960.git.hako@HIDDEN>
References: <cover.1742306960.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Divya Ranjan Pattanaik <divya@HIDDEN>, Efraim Flashner <efraim@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>, Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/build-system/cargo.scm (cargo-build,cargo-cross-build)
[#:cargo-package-crates]: New argument.
* guix/build/cargo-build-system.scm (package): Use it.
* doc/guix.texi (Build Systems)[cargo-build-system]: Document it.

Change-Id: I45ccd95e90827d47127015cb0bda2d41f792335b
---
 doc/guix.texi                     |  7 +++++++
 guix/build-system/cargo.scm       |  4 ++++
 guix/build/cargo-build-system.scm | 22 ++++++++++++++++++++--
 3 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 0ca109a214..0089f9e60f 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -9363,6 +9363,13 @@ Build Systems
 the binaries defined by the crate.  Unless @code{install-source? #f} is
 defined it will also install a source crate repository of itself and unpacked
 sources, to ease in future hacking on rust packages.
+
+This build system supports cargo workspaces.  Parameter
+@code{#:cargo-package-crates} (default: @code{''()}) allows specifying names of
+library crates to package in the @code{package} phase.  Specified crates are
+packaged from left to right, in case there's dependency among them.  For
+example, specifying @code{''("pcre2-sys" "pcre2")} will package
+@code{"pcre2-sys"} first and then @code{"pcre2"}.
 @end defvar
 
 @defvar chicken-build-system
diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
index 452f7f78d0..4f6d46e70c 100644
--- a/guix/build-system/cargo.scm
+++ b/guix/build-system/cargo.scm
@@ -94,6 +94,7 @@ (define* (cargo-build name inputs
                       (vendor-dir "guix-vendor")
                       (cargo-build-flags ''("--release"))
                       (cargo-test-flags ''())
+                      (cargo-package-crates ''())
                       (cargo-package-flags ''("--no-metadata" "--no-verify"))
                       (features ''())
                       (skip-build? #f)
@@ -122,6 +123,7 @@ (define* (cargo-build name inputs
                        #:vendor-dir #$vendor-dir
                        #:cargo-build-flags #$(sexp->gexp cargo-build-flags)
                        #:cargo-test-flags #$(sexp->gexp cargo-test-flags)
+                       #:cargo-package-crates #$(sexp->gexp cargo-package-crates)
                        #:cargo-package-flags #$(sexp->gexp cargo-package-flags)
                        #:cargo-target #$(cargo-triplet system)
                        #:features #$(sexp->gexp features)
@@ -154,6 +156,7 @@ (define* (cargo-cross-build name
                             (vendor-dir "guix-vendor")
                             (cargo-build-flags ''("--release"))
                             (cargo-test-flags ''())
+                            (cargo-package-crates ''())
                             (cargo-package-flags ''("--no-metadata" "--no-verify"))
                             (cargo-target (cargo-triplet (or target system)))
                             (features ''())
@@ -185,6 +188,7 @@ (define* (cargo-cross-build name
                        #:vendor-dir #$vendor-dir
                        #:cargo-build-flags #$(sexp->gexp cargo-build-flags)
                        #:cargo-test-flags #$(sexp->gexp cargo-test-flags)
+                       #:cargo-package-crates #$(sexp->gexp cargo-package-crates)
                        #:cargo-package-flags #$(sexp->gexp cargo-package-flags)
                        #:cargo-target #$(cargo-triplet (or target system))
                        #:features #$(sexp->gexp features)
diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index 58238992b8..979f93aef4 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -300,11 +300,16 @@ (define* (package #:key
                   source
                   skip-build?
                   install-source?
+                  (cargo-package-crates '())
                   (cargo-package-flags '("--no-metadata" "--no-verify"))
+                  (vendor-dir "guix-vendor")
                   #:allow-other-keys)
   "Run 'cargo-package' for a given Cargo package."
   (if install-source?
-    (if skip-build?
+    ;; NOTE: Cargo workspace packaging support:
+    ;; #:install-source? #t + #:cargo-package-crates.
+    (if (and (null? cargo-package-crates)
+             skip-build?)
       (begin
         (install-file source "target/package")
         (with-directory-excursion "target/package"
@@ -322,7 +327,20 @@ (define* (package #:key
         ;;error: invalid inclusion of reserved file name Cargo.toml.orig in package source
         (when (file-exists? "Cargo.toml.orig")
           (delete-file "Cargo.toml.orig"))
-        (apply invoke `("cargo" "package" "--offline" ,@cargo-package-flags))
+
+        (if (null? cargo-package-crates)
+            (apply invoke `("cargo" "package" "--offline" ,@cargo-package-flags))
+            (begin
+              (for-each
+               (lambda (pkg)
+                 (apply invoke "cargo" "package" "--offline" "--package" pkg
+                        cargo-package-flags)
+                 (for-each
+                  (lambda (crate)
+                    (invoke "tar" "xzf" crate "-C" vendor-dir))
+                  (find-files "target/package" "\\.crate$"))
+                 (patch-cargo-checksums #:vendor-dir vendor-dir))
+               cargo-package-crates)))
 
         ;; Then unpack the crate, reset the timestamp of all contained files, and
         ;; repack them.  This is necessary to ensure that they are reproducible.
-- 
2.48.1





Information forwarded to divya@HIDDEN, efraim@HIDDEN, ludo@HIDDEN, maxim.cournoyer@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:28:20 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 10:28:20 2025
Received: from localhost ([127.0.0.1]:41686 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuXvW-0004aM-1l
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:28:20 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:57856)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuXus-0004Sf-4F
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:27:39 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742308056;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=lnQ3fNha3tTpiuYZ0UQT7xqK8VBIVtWVUs+XKQhkaWc=;
 b=KdEZAyyY7obD8DuLcmGAHnlUsXMEP4ty/m8aTfpMbBgrFHoiLs6P4wwePRLodql3z7Oh2x
 rHNWzXd2G/arkzanDgzEKRNhPIzqUCYgsa1lwxglr2MUHMPH+y690L5OqMXWFRlXmZifVX
 iZdvaGy0QGoD/UmbOipNbamUIXLPrECVfl8ZXjWQzlEpFj1dUSA5mgvnYxb4OX6dQxSiqy
 d7uT/uqGmKLJGpzh9LSTI35eM86eokfRULFAZJ6FJrUpnv8q0i422XjEsb0iO9e69cOqwG
 0W7JUL6RoHQXyl7SKzq6ErulwPnkbhaGPan4++Jlsv4mi8TnWB4eWPdfctMgAA==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v2 05/17] build/cargo: Set default value of
 arguments for build phases.
Date: Tue, 18 Mar 2025 22:26:48 +0800
Message-ID: <7a65eca436b0880f9cd829d3f3703696a08386df.1742306960.git.hako@HIDDEN>
In-Reply-To: <cover.1742306960.git.hako@HIDDEN>
References: <cover.1742306960.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Divya Ranjan Pattanaik <divya@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>, Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

This makes it easier to use these phases in other bulid systems.

* guix/build/cargo-build-system.scm (unpack-rust-crates,configure,build,package)
(install): Set default value of arguments.

Change-Id: I1dde1b063d8eee57967903abd2fce94574211a0a
---
 guix/build/cargo-build-system.scm | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index 85f10a7ac4..85a9698680 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -76,7 +76,8 @@ (define (crate-src? path)
                                             " | cut -d/ -f2"
                                             " | grep -q '^Cargo.toml$'")))))
 
-(define* (unpack-rust-crates #:key inputs vendor-dir #:allow-other-keys)
+(define* (unpack-rust-crates #:key inputs (vendor-dir "guix-vendor")
+                             #:allow-other-keys)
   (define (inputs->rust-inputs inputs)
     "Filter using the label part from INPUTS."
     (filter (lambda (input)
@@ -139,7 +140,7 @@ (define* (check-for-pregenerated-files #:key parallel-build? #:allow-other-keys)
 
 (define* (configure #:key inputs
                     target system
-                    cargo-target
+                    (cargo-target #f)
                     (vendor-dir "guix-vendor")
                     #:allow-other-keys)
   "Vendor Cargo.toml dependencies as guix inputs."
@@ -258,7 +259,7 @@ (define* (patch-cargo-checksums #:key
 
 (define* (build #:key
                 parallel-build?
-                skip-build?
+                (skip-build? #f)
                 (features '())
                 (cargo-build-flags '("--release"))
                 #:allow-other-keys)
@@ -298,8 +299,8 @@ (define* (check #:key
 
 (define* (package #:key
                   source
-                  skip-build?
-                  install-source?
+                  (skip-build? #f)
+                  (install-source? #t)
                   (cargo-package-crates '())
                   (cargo-package-flags '("--no-metadata" "--no-verify"))
                   (vendor-dir "guix-vendor")
@@ -375,9 +376,9 @@ (define* (package #:key
 (define* (install #:key
                   inputs
                   outputs
-                  skip-build?
-                  install-source?
-                  features
+                  (skip-build? #f)
+                  (install-source? #t)
+                  (features '())
                   (cargo-install-paths '())
                   #:allow-other-keys)
   "Install a given Cargo package."
-- 
2.48.1





Information forwarded to divya@HIDDEN, efraim@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:27:52 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 10:27:51 2025
Received: from localhost ([127.0.0.1]:41664 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuXv2-0004UN-7O
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:27:51 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:41348)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuXul-0004RA-AC
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:27:34 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742308048;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=tWCnhX4OoBIrcF5cBlDIauVuJiVPteEuBGDYdX+/oyI=;
 b=Q+FGJ79dZ/Bb/v3BD1Ny//thnaO/ficuGIf6+L4/pbz3tgLWhUb/8saZjwjGRiM4Og2qQP
 pR75+uVAtoUsId3aJHEKcZgFVH3VBQUp4eWx6ewgIIqPlXPwXtXhHsyQpsrk51xLB4o5iG
 EkzXUYlqE4L8cB+NxQLrEByUFhORQOAZKVSDA/wT1FBJGNbcnr1ENk2gf5XA6M9NaN72+C
 E2unnnAqLThQTbMfJt1uTsVtHbD4LtrUtYdBBk4ExBTBL2jSMAgRPeS7WXGt/i/99Yafv4
 x0vHEDgrGT/EUd8D+2fcAIWTn74Sc6KYJyzrbISCh76H9S8ltRNlTd/5KXFBpg==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v2 02/17] build/cargo: Print out all non-empty
 binary files.
Date: Tue, 18 Mar 2025 22:26:45 +0800
Message-ID: <ab84d8151185aac6692999d1971c4fb9ee2c8191.1742306960.git.hako@HIDDEN>
In-Reply-To: <cover.1742306960.git.hako@HIDDEN>
References: <cover.1742306960.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Divya Ranjan Pattanaik <divya@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>, Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/build/cargo-build-system.scm (%standard-phases): Move
'unpack-rust-crates after 'unpack.
Move 'check-for-pregenerated-files after 'configure.
(check-for-pregenerated-files): Only check non-empty files.
Print out binary files.
Run in parallel.
Don't fail to keep compatibility for phase order change.

Change-Id: I0a332fe843e97687324bd908fa111422a63e475d
---
 guix/build/cargo-build-system.scm | 31 +++++++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index 41f54f42b7..58238992b8 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -29,9 +29,11 @@ (define-module (guix build cargo-build-system)
   #:use-module ((guix build utils) #:hide (delete))
   #:use-module (ice-9 popen)
   #:use-module (ice-9 rdelim)
+  #:use-module (ice-9 regex)
   #:use-module (ice-9 ftw)
   #:use-module (ice-9 format)
   #:use-module (ice-9 match)
+  #:use-module (ice-9 threads)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
   #:export (%standard-phases
@@ -111,12 +113,29 @@ (define* (unpack-rust-crates #:key inputs vendor-dir #:allow-other-keys)
 (define (rust-package? name)
   (string-prefix? "rust-" name))
 
-(define* (check-for-pregenerated-files #:rest _)
+(define* (check-for-pregenerated-files #:key parallel-build? #:allow-other-keys)
   "Check the source code for files which are known to generally be bundled
 libraries or executables."
-  (let ((pregenerated-files (find-files "." "\\.(a|dll|dylib|exe|lib)$")))
-    (when (not (null-list? pregenerated-files))
-      (error "Possible pre-generated files found:" pregenerated-files))))
+  (format #t "Searching for binary files...~%")
+  (let ((known-pattern (make-regexp "\\.(a|dll|dylib|exe|lib)$"))
+        (empty-file?
+         (lambda (filename)
+           (call-with-ascii-input-file filename
+             (lambda (p)
+               (eqv? #\0 (read-char p)))))))
+    (n-par-for-each
+     (if parallel-build?
+         (parallel-job-count)
+         1)
+     (lambda (file)
+       (unless (empty-file? file)
+         ;; Print out binary files.
+         (false-if-exception (invoke "grep" "-IL" "." file))
+         ;; Warn about known pre-generated files.
+         ;; Not failing here for compatibility with existing packages.
+         (when (regexp-exec known-pattern file)
+           (format #t "error: Possible pre-generated file found: ~a~%" file))))
+     (find-files "."))))
 
 (define* (configure #:key inputs
                     target system
@@ -380,8 +399,8 @@ (define %standard-phases
     (replace 'check check)
     (replace 'install install)
     (add-after 'build 'package package)
-    (add-after 'unpack 'check-for-pregenerated-files check-for-pregenerated-files)
-    (add-after 'check-for-pregenerated-files 'unpack-rust-crates unpack-rust-crates)
+    (add-after 'unpack 'unpack-rust-crates unpack-rust-crates)
+    (add-after 'configure 'check-for-pregenerated-files check-for-pregenerated-files)
     (add-after 'patch-generated-file-shebangs 'patch-cargo-checksums patch-cargo-checksums)))
 
 (define* (cargo-build #:key inputs (phases %standard-phases)
-- 
2.48.1





Information forwarded to divya@HIDDEN, efraim@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:27:49 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 10:27:48 2025
Received: from localhost ([127.0.0.1]:41661 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuXuy-0004Tj-HB
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:27:48 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:48544)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuXuf-0004Qa-Vx
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:27:30 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742308044;
 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:
 content-transfer-encoding:content-transfer-encoding;
 bh=8YJ9OAP6sPQNiunvQM9CKMsUixIPuKAOpTsO0vPegxY=;
 b=QiscMu+EY817owp62ew8rFOupzqV/jFxxcg7L7ZSlV2QpJA1gTRd2SN7KTW+gisR5V+04k
 Qa3ZZaDBeVd5lFTVjBKa30yuX4wY6DH2wkue4e5isUvzDKB0g+zhKcoZcBlnjuXokwxAcy
 nktfh3lNT0VXVoguGNB77lB0c3bU2RJ17dvLpoV5U3T0OBx5hghx6pHOgdyYso2QRqWMJo
 AZlRqVWnhcLJZLMWfME2IZqjchetVJCxo2WL7mGqtMHAzr2x9uhdqDPBp0nyIXJG8EbN4c
 KD6kwMrGqrHXH6WDoA7PLG0DLaWUbZ7fAzhN4SMa+v8XnyddUKDAGWrSHxKVFA==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v2 00/17] New Rust packaging workflow based on
 lockfile importer.
Date: Tue, 18 Mar 2025 22:26:43 +0800
Message-ID: <cover.1742306960.git.hako@HIDDEN>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
X-Debbugs-Cc: Ludovic Courtès <ludo@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

V1 -> V2:
  * Drop jemalloc environment variable patch.
  * Remove use of RUSTC_BOOTSTRAP.
  * Adjust documentation.
  Diff inserted at end.

Efraim Flashner (1):
  build/cargo: Don't try to unpack sanity-check.py.

Hilton Chain (16):
  build/cargo: Pass ‘--offline’ to cargo.
  build/cargo: Print out all non-empty binary files.
  build-system: cargo: Support packaging Cargo workspace.
  build-system: cargo: Support installing Cargo workspace.
  build/cargo: Set default value of arguments for build phases.
  build/cargo: Support non-workspace directory source inputs.
  scripts: import: Document argument for ‘--insert’ option in help
    message.
  scripts: import: Add two newlines for ‘--insert’ option.
  scripts: import: Support expressions defined by 'define.
  scripts: import: Pass "--insert" to importers.
  scripts: import: Skip existing definition for ‘--insert’ option.
  import: crate: crate-name->package-name: Move to (guix build-system
    cargo).
  build-system: cargo: Add ‘cargo-inputs’.
  import: crate: Add Cargo.lock parser.
  import: crate: Add ‘--lockfile’ option.
  doc: Document lockfile importer based Rust packaging workflow.

 Makefile.am                       |   1 +
 doc/contributing.texi             | 415 ++++++++++++++++++++++++++++--
 doc/guix.texi                     |  24 ++
 etc/teams/rust/cleanup-crates.sh  |  38 +++
 etc/teams/rust/rust-crates.tmpl   |  42 +++
 gnu/local.mk                      |   2 +
 gnu/packages/rust-crates.scm      |  42 +++
 gnu/packages/rust-sources.scm     |  29 +++
 guix/build-system/cargo.scm       |  57 +++-
 guix/build/cargo-build-system.scm | 151 ++++++++---
 guix/import/crate.scm             |  81 +++++-
 guix/import/crate/cargo-lock.scm  | 105 ++++++++
 guix/scripts/import.scm           |  53 ++--
 guix/scripts/import/crate.scm     |  58 ++++-
 guix/utils.scm                    |  27 +-
 tests/crate.scm                   |  88 +++++++
 16 files changed, 1107 insertions(+), 106 deletions(-)
 create mode 100755 etc/teams/rust/cleanup-crates.sh
 create mode 100644 etc/teams/rust/rust-crates.tmpl
 create mode 100644 gnu/packages/rust-crates.scm
 create mode 100644 gnu/packages/rust-sources.scm
 create mode 100644 guix/import/crate/cargo-lock.scm


base-commit: b54a9ca849f013300c633fb79d80bc754f6b28a2
--
2.48.1

--8<---------------cut here---------------start------------->8---
diff --git a/doc/contributing.texi b/doc/contributing.texi
index e7c5116a3d..837074dead 100644
--- a/doc/contributing.texi
+++ b/doc/contributing.texi
@@ -1607,15 +1607,15 @@ Rust Crates
 have switched to a different packaging model.

 Rust programs (binary crates) and dependencies (library crates) are treated
-separately.  We put main efforts into programs and only package Rust
-dependencies as sources, utilizing automation with manual focus on unbundling
+separately.  We put our main efforts into programs and only package Rust
+dependencies as sources, utilizing automation with a manual focus on unbundling
 vendored dependencies.  The following paragraphs will explain them and give
 several examples.

 Rust programs are treated like any other package and named using the lowercase
 upstream name.  When using the Cargo build system (@pxref{Build Systems,
 @code{cargo-build-system}}), Rust programs should have @code{#:install-source?}
-argument set to @code{#f}, as this argument only makes sense to dependencies.
+argument set to @code{#f}, as this argument only makes sense for dependencies.
 When the package source is a Cargo workspace, @code{#:cargo-install-paths} must
 be set to enable relevant support.

@@ -1631,21 +1631,21 @@ Rust Crates
 contributing to Guix.  Naturally, this module serves as a store for both sources
 and unbundling strategies.

-This module is managed by Rust team (@pxref{Teams}) to ensure there's always one
-version containing all changes from other branches, so that the maintained
+This module is managed by the Rust team (@pxref{Teams}) to ensure there's always
+one version containing all changes from other branches, so that the maintained
 version can be used directly in case of merge conflicts, thus coordination is
 required for other committers to modify it.

 Guix source ships template @file{etc/teams/rust/rust-crates.tmpl} and cleanup
-script @file{etc/teams/rust/cleanup-crates.sh} for this moudle.
+script @file{etc/teams/rust/cleanup-crates.sh} for this module.

 @item
 @code{(gnu packages rust-sources)}, storing more complex definitions that need
 to be full packages.  This includes Rust dependencies requiring external inputs
 to unbundle and Cargo workspaces.

-These dependencies should have @code{#:skip-build?} argument set to @code{#t}.
-For Cargo workspaces, @code{#:cargo-package-crates} must be set.
+These dependencies should have the @code{#:skip-build?} argument set to
+@code{#t}.  For Cargo workspaces, @code{#:cargo-package-crates} must be set.

 Since they are added manually, the following naming convention applies:

@@ -1668,7 +1668,7 @@ Rust Crates
 Let's demonstrate the packaging workflow by examples, note that package-specific
 issues are not involved here.

-In preparation, we'll adding the following packages to our environment:
+In preparation, we'll add the following packages to our environment:

 @example
 guix shell rust rust:cargo cargo-audit cargo-license
@@ -1747,7 +1747,7 @@ Rust Crates
 @code{check-for-pregenerated-files} phase:

 @example
-$ guix build cargo-audit
+$ ./pre-inst-env guix build cargo-audit
 @dots{}
 starting phase `check-for-pregenerated-files'
 Searching for binary files...
diff --git a/doc/guix.texi b/doc/guix.texi
index 029c8cf59c..218c2ba630 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -9365,14 +9365,14 @@ Build Systems
 sources, to ease in future hacking on rust packages.

 This build system supports cargo workspaces.  Parameter
-@code{#:cargo-package-crates} (default: @code{''()}) allows specifying
-names of library crates to package in @code{package} phase.  Specified
-crates are packaged from left to right, in case there's dependency among
-them.  For example, specifying @code{''("pcre2-sys" "pcre2")} will
-package @code{"pcre2-sys"} first and then @code{"pcre2"}.  Parameter
-@code{#:cargo-install-paths} (default: @code{''()}) allows specifying
-paths of binary crates to install in @code{install} phase,
-@code{''("crates/atuin")}, for example.
+@code{#:cargo-package-crates} (default: @code{''()}) allows specifying names of
+library crates to package in the @code{package} phase.  Specified crates are
+packaged from left to right, in case there's dependency among them.  For
+example, specifying @code{''("pcre2-sys" "pcre2")} will package
+@code{"pcre2-sys"} first and then @code{"pcre2"}.  Parameter
+@code{#:cargo-install-paths} (default: @code{''()}) allows specifying paths of
+binary crates to install in the @code{install} phase, @code{''("crates/atuin")},
+for example.
 @end defvar

 @defvar chicken-build-system
@@ -14705,19 +14705,18 @@ Invoking guix import
 a comment.
 @item --lockfile=@var{file}
 @itemx -f @var{file}
-When @option{--lockfile} is specified, importer will ignore other
-options and won't output package definitions, instead generating source
-definition for all dependencies in @var{file}, a @file{Cargo.lock} file.
-For example:
+When @option{--lockfile} is specified, the importer will ignore other options
+and won't output package definitions, instead generating source definitions for
+all dependencies in @var{file}, a @file{Cargo.lock} file.  For example:

 @example
 guix import crate --lockfile=/path/to/Cargo.lock my-package
 @end example

-generates sources from @file{/path/to/Cargo.lock}, and a list
-@code{my-package-cargo-inputs} referencing these sources.  The generated
-list is intended for package's base @code{inputs}, replacing
-@code{#:cargo-inputs} and @code{#:cargo-development-inputs}.
+generates sources from @file{/path/to/Cargo.lock} and a list
+@code{my-package-cargo-inputs} referencing these sources.  The generated list is
+intended for the package's @code{inputs}, replacing @code{#:cargo-inputs} and
+@code{#:cargo-development-inputs}.
 @end table

 @item elm
diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index b547421b88..41adc03752 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -248,12 +248,6 @@ (define* (configure #:key inputs
   (setenv "LIBSSH2_SYS_USE_PKG_CONFIG" "1")
   (setenv "SODIUM_USE_PKG_CONFIG" "1")
   (setenv "ZSTD_SYS_USE_PKG_CONFIG" "1")
-  ;; This flag is needed when not using the bundled jemalloc.
-  ;; https://github.com/tikv/jemallocator/issues/19
-  (setenv "CARGO_FEATURE_UNPREFIXED_MALLOC_ON_SUPPORTED_PLATFORMS" "1")
-  (when (assoc-ref inputs "jemalloc")
-    (setenv "JEMALLOC_OVERRIDE"
-            (string-append (assoc-ref inputs "jemalloc") "/lib/libjemalloc.so")))
   (when (assoc-ref inputs "openssl")
     (setenv "OPENSSL_DIR" (assoc-ref inputs "openssl")))
   (when (assoc-ref inputs "gettext")
@@ -356,23 +350,17 @@ (define* (package #:key

         (if (null? cargo-package-crates)
             (apply invoke `("cargo" "package" "--offline" ,@cargo-package-flags))
-            ;; Use unstable feature ‘--registry’.
             (begin
-              (setenv "RUSTC_BOOTSTRAP" "1")
               (for-each
                (lambda (pkg)
                  (apply invoke "cargo" "package" "--offline" "--package" pkg
-                        "--registry" "crates-io" "-Z" "package-workspace"
                         cargo-package-flags)
                  (for-each
                   (lambda (crate)
                     (invoke "tar" "xzf" crate "-C" vendor-dir))
-                  (begin
-                    (delete-file-recursively "target/package/tmp-registry")
-                    (find-files "target/package" "\\.crate$")))
+                  (find-files "target/package" "\\.crate$"))
                  (patch-cargo-checksums #:vendor-dir vendor-dir))
-               cargo-package-crates)
-              (unsetenv "RUSTC_BOOTSTRAP")))
+               cargo-package-crates)))

         ;; Then unpack the crate, reset the timestamp of all contained files, and
         ;; repack them.  This is necessary to ensure that they are reproducible.
diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index d8e1ed3e6f..f6e2985ed9 100644
--- a/guix/scripts/import.scm
+++ b/guix/scripts/import.scm
@@ -126,13 +126,12 @@ (define-command (guix-import . args)
      (show-version-and-exit "guix import"))
     ((or ("-i" file importer args ...)
          ("--insert" file importer args ...))
-     (let* ((definer?
-              (cut member
-                   <>
-                   `(,@(if (member importer '("crate"))
-                           '(define)
-                           '())
-                     define-public)))
+     (let* ((importer-definers
+             `(,@(if (member importer '("crate"))
+                     '(define)
+                     '())
+               define-public))
+            (definer? (cut member <> importer-definers))
             (find-and-insert
              (lambda (expr)
                (match expr
diff --git a/tests/crate.scm b/tests/crate.scm
index d46f753f9c..9b7066c3b1 100644
--- a/tests/crate.scm
+++ b/tests/crate.scm
@@ -478,7 +478,7 @@ (define rust-leaf-bob-3.0.2-yanked
     (license #f)))

 (define temp-file
-  (string-append "t-utils-" (number->string (getpid))))
+  (string-append "t-crate-" (number->string (getpid))))

 
 (test-begin "crate")
--8<---------------cut here---------------end--------------->8---




Information forwarded to ludo@HIDDEN, maxim.cournoyer@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:27:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 10:27:30 2025
Received: from localhost ([127.0.0.1]:41653 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuXuj-0004RC-VA
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:27:30 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:48548)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuXuh-0004R1-TI
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 10:27:28 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742308046;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=fTJrKeLT9GSPYJTsuUaujgtn6qA4bB0llojftLqgAJM=;
 b=JutdcqmR1uzloFVvY2bsPE0/zLRhuLXZbLI3I19KvlkMYZn4zU3FG+KXc/OhZ0rc8Tcaba
 tfFsR1XytixURscQKLDoBVm9ATCF4XWRG3Eg2Tlu3bUlh4No7eoqURDN1nnLuV0DPLCLUO
 Cw6q3r3FnHAa6ZYlMjnLvzpm+JT5CYrTfB8YtYQXzuiEy+b1L/yU+DlJJTh8TdcNJ2ObPj
 9X5xEN/u9Kzk3JyIh+2XFg9iDhpjqDFCBxiCrv/mh76nVHtRhp6On76pa4gHLX6Wctm/Pp
 NHN9z5xce6RncKFSsieebRF88FM+uj1z97tjh698tFLjP5AKtLr8ZeCx9hufhg==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team v2 01/17] =?UTF-8?q?build/cargo:=20Pass=20?=
 =?UTF-8?q?=E2=80=98--offline=E2=80=99=20to=20cargo.?=
Date: Tue, 18 Mar 2025 22:26:44 +0800
Message-ID: <73db5916ba93efd5f30d9e45945a0ccff88c330f.1742306960.git.hako@HIDDEN>
In-Reply-To: <cover.1742306960.git.hako@HIDDEN>
References: <cover.1742306960.git.hako@HIDDEN>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
X-Debbugs-Cc: Divya Ranjan Pattanaik <divya@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>, Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

This will make error messages more helpful.

* guix/build/cargo-build-system.scm (build,check,package,install): Pass
‘--offline’ to cargo.

Change-Id: Ic95f603b793319f99c9c1fbce43f773bfc8126c0
---
 guix/build/cargo-build-system.scm | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index 5ef6b23abd..41f54f42b7 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -246,7 +246,7 @@ (define* (build #:key
   "Build a given Cargo package."
   (or skip-build?
       (apply invoke
-             `("cargo" "build"
+             `("cargo" "build" "--offline"
                ,@(if parallel-build?
                      (list "-j" (number->string (parallel-job-count)))
                      (list "-j" "1"))
@@ -264,7 +264,7 @@ (define* (check #:key
   "Run tests for a given Cargo package."
   (when tests?
     (apply invoke
-           `("cargo" "test"
+           `("cargo" "test" "--offline"
              ,@(if parallel-build?
                    (list "-j" (number->string (parallel-job-count)))
                    (list "-j" "1"))
@@ -303,7 +303,7 @@ (define* (package #:key
         ;;error: invalid inclusion of reserved file name Cargo.toml.orig in package source
         (when (file-exists? "Cargo.toml.orig")
           (delete-file "Cargo.toml.orig"))
-        (apply invoke `("cargo" "package" ,@cargo-package-flags))
+        (apply invoke `("cargo" "package" "--offline" ,@cargo-package-flags))
 
         ;; Then unpack the crate, reset the timestamp of all contained files, and
         ;; repack them.  This is necessary to ensure that they are reproducible.
@@ -356,7 +356,8 @@ (define* (install #:key
     ;; otherwise cargo will raise an error.
     (or skip-build?
         (not (has-executable-target?))
-        (invoke "cargo" "install" "--no-track" "--path" "." "--root" out
+        (invoke "cargo" "install" "--offline" "--no-track"
+                "--path" "." "--root" out
                 "--features" (string-join features)))
 
     (when install-source?
-- 
2.48.1





Information forwarded to divya@HIDDEN, efraim@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 13:16:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 09:16:32 2025
Received: from localhost ([127.0.0.1]:38677 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuWo3-00035Z-7J
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 09:16:32 -0400
Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:45396)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <efraim.flashner@HIDDEN>)
 id 1tuWnz-00034l-H0
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 09:16:28 -0400
Received: by mail-wm1-x329.google.com with SMTP id
 5b1f17b1804b1-4393dc02b78so21349845e9.3
 for <77093 <at> debbugs.gnu.org>; Tue, 18 Mar 2025 06:16:27 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1742303781; x=1742908581; darn=debbugs.gnu.org;
 h=in-reply-to:content-disposition:mime-version:references
 :mail-followup-to:message-id:subject:cc:to:from:date:sender:from:to
 :cc:subject:date:message-id:reply-to;
 bh=Q6U/Z0V+NkL7pA5daooX+Pm5uYKO6bxOTEHnLfPxNyE=;
 b=kjR+PrVzrbstNgRh9hCZTvuficA6YysElKmx10QSw2cHboZf9BS4IG6D8FyEqgolA2
 NZ4xxFNHKPH3Yo3pDwvc7z+tVOwKhsDpXPeexVgRu+xIz62WEQVKWCo5FG/I06Nn8MiK
 FuPoqsZJUOPsQFqxFKILVpjWjqzhVuGNH7T3Fe9xFDCocPjGWJtqFyzg7M/yuXnmMx+h
 E/hpxQLIBtNNsP0ZTfTvCSSv3pLh3YT6CmoNh/qjdgYhANRJTQVDBWBT64UTEYdPRbiE
 0h3LDJPDOBXQW4hgiGG2AC42LfUjxvK68x82h2NdL9FCJ9hwMZX+fYsClH2kCL7kVRhL
 zuow==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1742303781; x=1742908581;
 h=in-reply-to:content-disposition:mime-version:references
 :mail-followup-to:message-id:subject:cc:to:from:date:sender
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=Q6U/Z0V+NkL7pA5daooX+Pm5uYKO6bxOTEHnLfPxNyE=;
 b=DYFXSdF/H+3/+XsVfIFxxQMtw0avlGqI6vBwyaizH+rouA5eXX5AcltcFDgLAnkuOM
 j6Qkoh/O5j2pxfOnS88URCNpLLYpXtQKexKp1E7v9DQoa/96jHnB85okgAFLWEBQ4lXO
 EcmYlTbOApSdKF8b3d4BImRmp56X9N5va7b3seF9WwkNX0AF5/nofleQiiW9ZfpU+9K7
 9Zv9yjQZ9/o8cdx3Cg0IWXgfkCUorNwSqNOPb3nssByp848fR+Yisfv9TznhYjExNrdv
 NL4VqNxUdAb8P85CRai57zgRPkRrE/rqN8B3A9MUjIBHtEOPMGk+KRASGVAfOMuJfWWF
 CQkQ==
X-Gm-Message-State: AOJu0YwAAfjnhwy1vmNDUQBtfs3OHB9ie+cWSc6VhAuQg26abId8KtnR
 7023leQHluFoOszXYx+ywQm+2JSiLCv3z6H/O6QCdJaFm7LrE/gf
X-Gm-Gg: ASbGncvKiiScBZiRaR7DF82wJ48bzC+yNpDNbdcqM6s3l3XA1skPMV4XOeNAiSYqAkq
 SvprhgAOyabU4gqX2nfjgUSgafQFFZIQ1BAws5FF0upGH6Vic9uET2VZM+//XkuQ5sEybfPGekp
 wJW91OhnEfBsoomv7Il/xPzhDOtaQWOtQ+itD7brdMpKbu5xIjCtQ5FHB525avNtIDgtm4ZfgZd
 Lp8PNO7opNcr/qju7DHhek3gPaXafCWY09UwKjtsLZIGSb0ShzUbG+A5bZV8o4cSc/kerGk7CtQ
 +b7YYz7qZwzL/dllfjSWnRfiVNxTDwWKvDhvDoo6hYsDsA==
X-Google-Smtp-Source: AGHT+IFtph5Ib9rgyOHmJDus29RFn4Pn+2ZaQEJK+XqDFwPwXknpUoExiG7NXzZTG7nTXKJnK1logA==
X-Received: by 2002:a05:600c:5489:b0:43c:f4b3:b094 with SMTP id
 5b1f17b1804b1-43d3f20387amr9381645e9.6.1742303780737; 
 Tue, 18 Mar 2025 06:16:20 -0700 (PDT)
Received: from localhost ([188.120.128.147]) by smtp.gmail.com with ESMTPSA id
 5b1f17b1804b1-43d1ffbfa90sm133638875e9.16.2025.03.18.06.16.19
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 18 Mar 2025 06:16:19 -0700 (PDT)
Date: Tue, 18 Mar 2025 15:16:18 +0200
From: Efraim Flashner <efraim@HIDDEN>
To: Hilton Chain <hako@HIDDEN>
Subject: Re: [bug#77093] [PATCH rust-team 11/18] scripts: import: Support
 expressions defined by 'define.
Message-ID: <Z9lyIuJhHvbt_nEE@3900XT>
Mail-Followup-To: Efraim Flashner <efraim@HIDDEN>,
 Hilton Chain <hako@HIDDEN>, 77093 <at> debbugs.gnu.org,
 Christopher Baines <guix@HIDDEN>,
 Josselin Poiret <dev@HIDDEN>,
 Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>,
 Mathieu Othacehe <othacehe@HIDDEN>,
 Simon Tournier <zimon.toutoune@HIDDEN>,
 Tobias Geerinckx-Rice <me@HIDDEN>
References: <cover.1742281797.git.hako@HIDDEN>
 <c185c0310885a4fcce6df3bcf52bb2cd00abd79f.1742281797.git.hako@HIDDEN>
 <Z9ld074gGnMQrl-o@3900XT> <87bjty5xoi.wl-hako@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature"; boundary="U+hccSaHGdAaUljj"
Content-Disposition: inline
In-Reply-To: <87bjty5xoi.wl-hako@HIDDEN>
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-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Josselin Poiret <dev@HIDDEN>, 77093 <at> debbugs.gnu.org,
 Simon Tournier <zimon.toutoune@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>,
 Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>,
 Tobias Geerinckx-Rice <me@HIDDEN>, Christopher Baines <guix@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


--U+hccSaHGdAaUljj
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, Mar 18, 2025 at 08:29:49PM +0800, Hilton Chain wrote:
> On Tue, 18 Mar 2025 19:49:39 +0800,
> Efraim Flashner wrote:
> >
> > [1  <text/plain; utf-8 (quoted-printable)>]
> > On Tue, Mar 18, 2025 at 03:24:24PM +0800, Hilton Chain wrote:
> > > * guix/utils.scm (find-definition-location): New procedure.
> > > (find-definition-insertion-location): Define with it.
> > > * guix/scripts/import.scm (import-as-definitions, guix-import): Suppo=
rt
> > > expressions defined by 'define.
> > >
> > > Change-Id: I03118e1a3372028b4f0530964aba871b4a1a4d25
> > > ---
> > >  guix/scripts/import.scm | 20 +++++++++++++++-----
> > >  guix/utils.scm          | 27 +++++++++++++++++++--------
> > >  2 files changed, 34 insertions(+), 13 deletions(-)
> > >
> > > diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
> > > index 58a84d0db7..aaa3d26673 100644
> > > --- a/guix/scripts/import.scm
> > > +++ b/guix/scripts/import.scm
> > > @@ -30,6 +30,7 @@ (define-module (guix scripts import)
> > >    #:use-module (guix read-print)
> > >    #:use-module (guix utils)
> > >    #:use-module (srfi srfi-1)
> > > +  #:use-module (srfi srfi-26)
> > >    #:use-module (ice-9 format)
> > >    #:use-module (ice-9 match)
> > >    #:export (%standard-import-options
> > > @@ -83,7 +84,8 @@ (define (import-as-definitions importer args proc)
> > >          ((and expr (or ('package _ ...)
> > >                         ('let _ ...)))
> > >           (proc (package->definition expr)))
> > > -        ((and expr ('define-public _ ...))
> > > +        ((and expr (or ('define-public _ ...)
> > > +                       ('define _ ...)))
> > >           (proc expr))
> > >          ((expressions ...)
> > >           (for-each (lambda (expr)
> > > @@ -91,7 +93,8 @@ (define (import-as-definitions importer args proc)
> > >                         ((and expr (or ('package _ ...)
> > >                                        ('let _ ...)))
> > >                          (proc (package->definition expr)))
> > > -                       ((and expr ('define-public _ ...))
> > > +                       ((and expr (or ('define-public _ ...)
> > > +                                      ('define _ ...)))
> > >                          (proc expr))))
> > >                     expressions))
> > >          (x
> > > @@ -117,13 +120,20 @@ (define-command (guix-import . args)
> > >       (show-version-and-exit "guix import"))
> > >      ((or ("-i" file importer args ...)
> > >           ("--insert" file importer args ...))
> > > -     (let ((find-and-insert
> > > +     (let* ((definer?
> > > +              (cut member
> > > +                   <>
> > > +                   `(,@(if (member importer '("crate"))
> > > +                           '(define)
> > > +                           '())
> > > +                     define-public)))
> >
> > This part above seems like it would break the option to use 'guix import
> > crate' with the --insert flag for "normal" packages.  I question how
> > useful it currently is in that scenario since we normally have to strip
> > the rust- prefix from those packages anyway.
>=20
> Hmmm, since the crate importer now checks both =E2=80=98define=E2=80=99 a=
nd =E2=80=98define-public=E2=80=99,
> there might be ordering issue when the module to insert uses =E2=80=98def=
ine=E2=80=99.  But it's
> still managable I think.

Reading it over again I think I was in need of more coffee. I thought
that the importer for cargo would only search for define, not for
define-public also.

As for needing to strip the rust- prefix, there's no change from our
current setup, so we can ignore that for now.

--=20
Efraim Flashner   <efraim@HIDDEN>   =D7=90=D7=A4=D7=A8=D7=99=D7=9D =
=D7=A4=D7=9C=D7=A9=D7=A0=D7=A8
GPG key =3D A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted

--U+hccSaHGdAaUljj
Content-Type: application/pgp-signature; name=signature.asc

-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAmfZch8ACgkQQarn3Mo9
g1EPUBAAib05rC26q7zbXfW2v351nUeCIrqUYUvB5jjl/H7Vegz4sj9P4grxQPKs
wHUbsjp4SA9xr/4Adqqml6iWjuWOI3SmSyvI5j1SA+a1bVlxghoiI4acGO1+8Z4a
AZgF2VDUOZje5+g7G7vPpHsAcaVWEA5lT8BRPjR1PZ7NPaDJrAEVkD4GVbMYPhOx
t67zshHwt6guXdcT8AR87nEaIrj0ZcNw29m8z+pIOJukQl04ZsJPqgqAQ7wfcSqC
pdA+mdzXat387r5n71TS+bBQX52rzpFYEP4fdxPsW/ZW6WyK8dQUOnzEa4lKcuNu
WrLl7v9oFZR8ZvlLldzA0jBYnqwLxQuJIuY2JlEZ0LJNiUxQvGrZySp+inQIvbl4
Gug1BBRcRiWHxfh80NgDVgrSOFdTj1nqzTRHuujcHf2HYkOlh7lPkH9vKF5oaEa9
mvnNiiTPKOF6kAe176AlM6GwTtJyNhzIOWKEtFvmdEXlvqQzmpw1WaoueRDIj9Nj
qVrOKUMI6wIpX+OkiVjp02SuXr52PPF7D+ZBhyBoYWO/qwKMfv3qJTKcr7ZjZzFd
TZ7pl+JSnqI8JeQxZECbSwabjfeh5aFWsbU0/mCf83y1IiPMCdPkmVwtooA8M22h
GHqHAqielqNi1ChNOjYZzw5fEQcBfOgknBo6edpnGIWMPTTnxIU=
=zPn4
-----END PGP SIGNATURE-----

--U+hccSaHGdAaUljj--




Information forwarded to guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 12:38:58 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 08:38:58 2025
Received: from localhost ([127.0.0.1]:38223 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuWDh-0006jk-On
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 08:38:58 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:40108)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuWDb-0006j5-VZ
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 08:38:52 -0400
Date: Tue, 18 Mar 2025 20:36:17 +0800
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742301530;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:mime-version:mime-version:content-type:content-type:
 in-reply-to:in-reply-to:references:references;
 bh=H4psvo0mt24l90Y6/wHHa7gikL9TTo0mZ2PR7iBBj4k=;
 b=RGCJMbO5/qFBrMuE14U2CIJ/kO23l3E8Cmul6gHPf88bP/b/n4Y34xepR+FpFQ+eytMGjC
 p/eR9frjpdTDE6+CRjkV9kjE/v7ymWRNUe1mUug0UvIigI2N9CiH5q4VRNXLv/Vekh42Qc
 Ie0KiYakNQbF5FVdOvi9T0CGA9Rl/Bkl1Nj20e9xttzQfwwyECFdEVH7jt9rFiwLElKQ0j
 wtwl5Zolcg4K/GaPvV/EqtugJl/14lP3cS7Zhd4ZrYk05iKQm1HW4k9+zOhnpHxSlxUfAq
 etAuOWFMNOh1thMbk74UZ9o9ExCHw0gknBxOBaSwVBXTfH6ypKFELEXc46aMRQ==
Message-ID: <87a59i5xdq.wl-hako@HIDDEN>
From: Hilton Chain <hako@HIDDEN>
To: Efraim Flashner <efraim@HIDDEN>,	Hilton Chain
 <hako@HIDDEN>,	77093 <at> debbugs.gnu.org,	Ludovic =?ISO-8859-1?Q?Cou?=
 =?ISO-8859-1?Q?rt=E8s?= <ludo@HIDDEN>,	Maxim Cournoyer
 <maxim.cournoyer@HIDDEN>
Subject: Re: [bug#77093] [PATCH rust-team 18/18] doc: Document lockfile
 importer based Rust packaging workflow.
In-Reply-To: <Z9ld4v5cAK2ocr-J@3900XT>
References: <cover.1742281797.git.hako@HIDDEN>
 <7ffcf6a3f50491ea953731444de449dfd7cb8d39.1742281797.git.hako@HIDDEN>
 <Z9ld4v5cAK2ocr-J@3900XT>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=US-ASCII
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Tue, 18 Mar 2025 19:49:54 +0800,
Efraim Flashner wrote:
>
> [1  <text/plain; utf-8 (quoted-printable)>]
> On Tue, Mar 18, 2025 at 03:24:31PM +0800, Hilton Chain wrote:
> > * doc/contributing.texi (Packaging Guidelines)[Rust Crates]: Update
> > documentation.
> >
> > Change-Id: Ic0c6378cf5f5df97d6f8bdd040b486be62c7bddc
> > ---
> >  doc/contributing.texi | 415 +++++++++++++++++++++++++++++++++++++++---
> >  1 file changed, 390 insertions(+), 25 deletions(-)
> >
> > diff --git a/doc/contributing.texi b/doc/contributing.texi
> > index ab4f30d54b..e7c5116a3d 100644
> > --- a/doc/contributing.texi
> > +++ b/doc/contributing.texi
> > @@ -1600,34 +1600,399 @@ Rust Crates
> >  @subsection Rust Crates
> >
> >  @cindex rust
> > -Rust programs standing for themselves are named as any other package, using the
> > -lowercase upstream name.
> > +As currently there's no achievable way to reuse Rust packages as pre-compiled
> > +inputs for other packages at a distribution scale, and our previous approach on
> > +making all Rust dependencies as full packages doesn't cope well with Rust
> > +ecosystem thus causing issues on both contribution and maintenance sides, we
> > +have switched to a different packaging model.
>
> I'm not sure the first paragraph is necessary.

I think we need to clarify why do we only do this for Rust, since similar
workflow can be applied to other ecosystems with a package manager as well.


Thanks for the review, I'll prepare V2 soon.




Information forwarded to guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 12:38:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 08:38:57 2025
Received: from localhost ([127.0.0.1]:38221 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuWDh-0006jh-6s
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 08:38:57 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:42470)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuWDU-0006hn-OH
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 08:38:47 -0400
Date: Tue, 18 Mar 2025 20:29:49 +0800
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742301523;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=Jb0Vu1RNBdPuX1nDtf5x8f09mnTiEIigglW7COeP7sE=;
 b=iTOGCIj4y4UZovG9gizFuA0g8eYss6y/XUC/dFt6PmHww/zKZ2Fsh0Fi+9lB/Mk6hIddSr
 6pYxeld9XtXxWd0PqBWBKFxtxgqKq4Y0UnHgDjn4JE5/QF/DiWVuquRDGcx897+2L1DwxU
 IIy9RGz4gAUhZ2AaOxkjydrEb/2+hmuKua6zscCcSIlKWF0emxABVlNkycFBVzilO2R4GL
 8uY+iLZI7fLe+GcfAH0ZnGS48bg0pSlquz9Ceg//jdEpj4Ho/AKXG9b7dGr5Ztlj+2KBLt
 iO0pxp8v+QAPOb6xWNbbvpO9YTBCpOkVOmTMI+LGHFirKRiY+OucrVYROP1odA==
Message-ID: <87bjty5xoi.wl-hako@HIDDEN>
From: Hilton Chain <hako@HIDDEN>
To: Efraim Flashner <efraim@HIDDEN>,	Hilton Chain
 <hako@HIDDEN>,	77093 <at> debbugs.gnu.org,	Christopher Baines
 <guix@HIDDEN>,	Josselin Poiret <dev@HIDDEN>,	Ludovic
 =?ISO-8859-1?Q?Court=E8s?= <ludo@HIDDEN>,	Mathieu Othacehe
 <othacehe@HIDDEN>,	Simon Tournier <zimon.toutoune@HIDDEN>,	Tobias
 Geerinckx-Rice <me@HIDDEN>
Subject: Re: [bug#77093] [PATCH rust-team 11/18] scripts: import: Support
 expressions defined by 'define.
In-Reply-To: <Z9ld074gGnMQrl-o@3900XT>
References: <cover.1742281797.git.hako@HIDDEN>
 <c185c0310885a4fcce6df3bcf52bb2cd00abd79f.1742281797.git.hako@HIDDEN>
 <Z9ld074gGnMQrl-o@3900XT>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=ISO-8859-7
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Tue, 18 Mar 2025 19:49:39 +0800,
Efraim Flashner wrote:
>
> [1  <text/plain; utf-8 (quoted-printable)>]
> On Tue, Mar 18, 2025 at 03:24:24PM +0800, Hilton Chain wrote:
> > * guix/utils.scm (find-definition-location): New procedure.
> > (find-definition-insertion-location): Define with it.
> > * guix/scripts/import.scm (import-as-definitions, guix-import): Support
> > expressions defined by 'define.
> >
> > Change-Id: I03118e1a3372028b4f0530964aba871b4a1a4d25
> > ---
> >  guix/scripts/import.scm | 20 +++++++++++++++-----
> >  guix/utils.scm          | 27 +++++++++++++++++++--------
> >  2 files changed, 34 insertions(+), 13 deletions(-)
> >
> > diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
> > index 58a84d0db7..aaa3d26673 100644
> > --- a/guix/scripts/import.scm
> > +++ b/guix/scripts/import.scm
> > @@ -30,6 +30,7 @@ (define-module (guix scripts import)
> >    #:use-module (guix read-print)
> >    #:use-module (guix utils)
> >    #:use-module (srfi srfi-1)
> > +  #:use-module (srfi srfi-26)
> >    #:use-module (ice-9 format)
> >    #:use-module (ice-9 match)
> >    #:export (%standard-import-options
> > @@ -83,7 +84,8 @@ (define (import-as-definitions importer args proc)
> >          ((and expr (or ('package _ ...)
> >                         ('let _ ...)))
> >           (proc (package->definition expr)))
> > -        ((and expr ('define-public _ ...))
> > +        ((and expr (or ('define-public _ ...)
> > +                       ('define _ ...)))
> >           (proc expr))
> >          ((expressions ...)
> >           (for-each (lambda (expr)
> > @@ -91,7 +93,8 @@ (define (import-as-definitions importer args proc)
> >                         ((and expr (or ('package _ ...)
> >                                        ('let _ ...)))
> >                          (proc (package->definition expr)))
> > -                       ((and expr ('define-public _ ...))
> > +                       ((and expr (or ('define-public _ ...)
> > +                                      ('define _ ...)))
> >                          (proc expr))))
> >                     expressions))
> >          (x
> > @@ -117,13 +120,20 @@ (define-command (guix-import . args)
> >       (show-version-and-exit "guix import"))
> >      ((or ("-i" file importer args ...)
> >           ("--insert" file importer args ...))
> > -     (let ((find-and-insert
> > +     (let* ((definer?
> > +              (cut member
> > +                   <>
> > +                   `(,@(if (member importer '("crate"))
> > +                           '(define)
> > +                           '())
> > +                     define-public)))
>
> This part above seems like it would break the option to use 'guix import
> crate' with the --insert flag for "normal" packages.  I question how
> useful it currently is in that scenario since we normally have to strip
> the rust- prefix from those packages anyway.

Hmmm, since the crate importer now checks both =A1define=A2 and =A1define-p=
ublic=A2,
there might be ordering issue when the module to insert uses =A1define=A2. =
 But it's
still managable I think.




Information forwarded to guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 12:38:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 08:38:45 2025
Received: from localhost ([127.0.0.1]:38217 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuWDT-0006he-6J
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 08:38:45 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:55236)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuWDL-0006gZ-R4
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 08:38:37 -0400
Date: Tue, 18 Mar 2025 20:18:43 +0800
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742301514;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=/0kqXWmfTkPhqTH9L7boPzKZiSvF455dOq5jwEsPuJc=;
 b=UGE430g49HbVxOgM318uXFZpwDY3J/OT/aCHULIQw5AtY+v6sP6X/M1D9Taizrd5dMdpeK
 KeHf6kXemPms2UznyrXjfzNqm0oMobRFhGW3dJN529FTdP1UWYhbLkrPN4JJKgvUCvnwSL
 8QPWK+Q8iHiPSr+hd+6tsuyQHV0rd4q5octZPQwi/I+OjGKv38Cn15KYZoqAEsKwcLJYXq
 UuvzpP+L89bi4AzdgB2P9EHmABVw9ej8Fq6BH2NqI671kXRJTifC1SibzdtXUn7XtVaI4Z
 fDRfgJJ3IR1r09ntxMLiiT3+mTlP4fY0oI5AUxbeQh3vNKgf7l8fCtZpIKpx1g==
Message-ID: <87cyee5y70.wl-hako@HIDDEN>
From: Hilton Chain <hako@HIDDEN>
To: Efraim Flashner <efraim@HIDDEN>,	Hilton Chain
 <hako@HIDDEN>,	77093 <at> debbugs.gnu.org,	Christopher Baines
 <guix@HIDDEN>,	Josselin Poiret <dev@HIDDEN>,	Ludovic
 =?ISO-8859-1?Q?Court=E8s?= <ludo@HIDDEN>,	Mathieu Othacehe
 <othacehe@HIDDEN>,	Simon Tournier <zimon.toutoune@HIDDEN>,	Tobias
 Geerinckx-Rice <me@HIDDEN>
Subject: Re: [bug#77093] [PATCH rust-team 10/18] scripts: import: Add two
 newlines for =?ISO-8859-7?Q?=A1--insert=A2?= option.
In-Reply-To: <Z9ldzbgZMKVoa1Ed@3900XT>
References: <cover.1742281797.git.hako@HIDDEN>
 <4e38cd180a457bcd8ca56b6a6ad58042cef81014.1742281797.git.hako@HIDDEN>
 <Z9ldzbgZMKVoa1Ed@3900XT>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=ISO-8859-7
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Tue, 18 Mar 2025 19:49:33 +0800,
Efraim Flashner wrote:
>
> [1  <text/plain; utf-8 (quoted-printable)>]
> Is this only relevant for packages crated with 'guix import cargo'? If
> so we should probably just change the importer to add a newline to the
> misbehaving importer.
>
> On Tue, Mar 18, 2025 at 03:24:23PM +0800, Hilton Chain wrote:
> > For consistency with =A1insert-expression=A2.
> >
> > * guix/scripts/import.scm (guix-import): Add two newlines when insertin=
g.
> >
> > Change-Id: I55b45ca137d175fdf6ee5c0bb2b6b1ca8385750d
> > ---
> >  guix/scripts/import.scm | 1 +
> >  1 file changed, 1 insertion(+)

This is a general issue, adding one newline doesn't work well with appending
multiple definitions.  For appending n definitions, (n - 1) lines need manu=
al
addition:
--8<---------------cut here---------------start------------->8---
a
b
c
--8<---------------cut here---------------end--------------->8---

By adding two newlines, only one line needs manual deletion:
--8<---------------cut here---------------start------------->8---
a

b

c

--8<---------------cut here---------------end--------------->8---




Information forwarded to guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 12:38:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 08:38:34 2025
Received: from localhost ([127.0.0.1]:38214 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuWDJ-0006gA-6X
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 08:38:34 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:42810)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuWDC-0006f1-KS
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 08:38:27 -0400
Date: Tue, 18 Mar 2025 20:09:07 +0800
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742301504;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:mime-version:mime-version:content-type:content-type:
 in-reply-to:in-reply-to:references:references;
 bh=NOIj+rwlprGf9OLOUHjHt+F65x8UFTTagFGUIKKP4BQ=;
 b=X+dpOH0FKwZHBWjeqBEFF6oZSV8akWDnfzh1z5pa1VqKlaegfHMfnCKpx19UNAaAfDt5Ds
 zUqI9o88MXQ8YfTpLU4pd95dgjMauP7v6EiBzVVQOLhMRdQh1MXn2yFnpVXWw4yH4YCYUf
 c592nQa/vzEIDEbwfb8g5yHQLV/AapC2wICmpEONXqFwIvSk3TqLZCKDysKQcLGvvJuTRo
 xmcDIOc19Sd5nUPDNTtEyXoe83wJSkFdldbi8NszhyrZf5ToMBudd10Za4jDUKUVpfn81W
 PBp0e+yfn1s4iuGiitJhXJJfR7E7zhig0BWFoeYTHjuA2me1PgmziyrNICBZxA==
Message-ID: <87ecyu5yn0.wl-hako@HIDDEN>
From: Hilton Chain <hako@HIDDEN>
To: Efraim Flashner <efraim@HIDDEN>,
 Hilton Chain <hako@HIDDEN>, 77093 <at> debbugs.gnu.org
Subject: Re: [PATCH rust-team 08/18] build/cargo: Use system jemalloc.
In-Reply-To: <Z9ldwa9OgoIb-A2R@3900XT>
References: <cover.1742281797.git.hako@HIDDEN>
 <02e5f7ff3d45b516a797c3e68c257748336dbae2.1742281797.git.hako@HIDDEN>
 <Z9ldwa9OgoIb-A2R@3900XT>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=US-ASCII
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Tue, 18 Mar 2025 19:49:21 +0800,
Efraim Flashner wrote:
>
> [1  <text/plain; utf-8 (quoted-printable)>]
> I'm not sure how I feel about this one.  On one hand the
> unprefixed_malloc flag is definitely necessary.  On the other hand
> sometimes we use libjemalloc.so and sometimes libjemalloc_pic.a, and I
> don't remember when/why we use one over the other, other than "it just
> works"
>
> On Tue, Mar 18, 2025 at 03:24:21PM +0800, Hilton Chain wrote:
> > From: Efraim Flashner <efraim@HIDDEN>
> >
> > * guix/build/cargo-build-system.scm (configure): Set environment variables to
> > use system jemalloc.
> >
> > Change-Id: Ibb1c025c7354ba2befd2770e3f1ccd785baa06c3
> > Modified-by: Hilton Chain <hako@HIDDEN>
> > ---
> >  guix/build/cargo-build-system.scm | 6 ++++++
> >  1 file changed, 6 insertions(+)

I'll drop this one for now then, I didn't search the source tree :P




Information forwarded to guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 12:38:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 08:38:25 2025
Received: from localhost ([127.0.0.1]:38210 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuWD9-0006ek-Gw
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 08:38:25 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:57926)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuWD5-0006dV-AI
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 08:38:21 -0400
Date: Tue, 18 Mar 2025 20:07:26 +0800
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742301497;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=qcKEkwEJkKM+WE3SUMRb15jGdJe1v/RRrIGEqMflceE=;
 b=MGOnPvfTs1cYqsYlGORhWLg2u1mrtkeE7hZKfSJxusAzIPbRW47d6mFwtKPon2yiTfRhN7
 C1W+agSAjlitKNciE9DYBJ+/JC1CYm814oCum0kwYQKH4sobhOEfRM129kg3xwKYVUMKqP
 cO5KVr3hOkArJFOZqirarb5hguq5zv9dlbTLzuPdPKsoCOFnH/jF/+eh6wgLYKKBbRvmP/
 gvhe3hAG9RyfTJbSA2BRj/iVRfN7p2LrPeLIdiQGe/osGO/NeP07+f7P6onlxL2HaZNqk2
 fJhP2N5JDB4ATnO18AuKRs+lPLOEf02dKSd0Hf8GqMkkdkF1MGw4CIqI8Es19Q==
Message-ID: <87frja5ypt.wl-hako@HIDDEN>
From: Hilton Chain <hako@HIDDEN>
To: Efraim Flashner <efraim@HIDDEN>,	Hilton Chain
 <hako@HIDDEN>,	77093 <at> debbugs.gnu.org,	Divya Ranjan Pattanaik
 <divya@HIDDEN>,	Ludovic =?ISO-8859-1?Q?Court=E8s?=
 <ludo@HIDDEN>,	Maxim Cournoyer <maxim.cournoyer@HIDDEN>,	Steve George
 <steve@HIDDEN>
Subject: Re: [bug#77093] [PATCH rust-team 03/18] build-system: cargo: Support
 packaging Cargo workspace.
In-Reply-To: <Z9ldu8IeBWVna2xO@3900XT>
References: <cover.1742281797.git.hako@HIDDEN>
 <0478229ef1b10a866b0c1cc9e33ec5bf27346d37.1742281797.git.hako@HIDDEN>
 <Z9ldu8IeBWVna2xO@3900XT>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Tue, 18 Mar 2025 19:49:15 +0800,
Efraim Flashner wrote:
>
> [1  <multipart/mixed (7bit)>]
> [1.1  <text/plain; utf-8 (quoted-printable)>]
> I've attached a diff that removes the need for RUSTC_BOOTSTRAP that
> seems to work when I rebuilt rust-pubgrub.
>
> Some links I followed:
> https://doc.rust-lang.org/cargo/commands/cargo-publish.html#package-selec=
tion
> https://github.com/rust-lang/cargo/issues/10948#issuecomment-1229236664
> "One background knowledge: cargo publish is roughly `cargo package` +
> call crates.io API."
>
> Before and after:
>
> (ins)efraim@3900XT ~/workspace/guix-rust-team$ tree /gnu/store/zk1n23l2wd=
ca8snz1wqllmjxv83hccl5-rust-pubgrub-0.3.0-0.b70cf70 | head
> /gnu/store/zk1n23l2wdca8snz1wqllmjxv83hccl5-rust-pubgrub-0.3.0-0.b70cf70
> =E2=94=94=E2=94=80=E2=94=80 share
>     =E2=94=9C=E2=94=80=E2=94=80 cargo
>     =E2=94=82=C2=A0=C2=A0 =E2=94=9C=E2=94=80=E2=94=80 registry
>     =E2=94=82=C2=A0=C2=A0 =E2=94=82=C2=A0=C2=A0 =E2=94=9C=E2=94=80=E2=94=
=80 pubgrub-0.3.0.crate
>     =E2=94=82=C2=A0=C2=A0 =E2=94=82=C2=A0=C2=A0 =E2=94=94=E2=94=80=E2=94=
=80 version-ranges-0.1.1.crate
>     =E2=94=82=C2=A0=C2=A0 =E2=94=94=E2=94=80=E2=94=80 src
>     =E2=94=82=C2=A0=C2=A0     =E2=94=9C=E2=94=80=E2=94=80 pubgrub-0.3.0
>     =E2=94=82=C2=A0=C2=A0     =E2=94=82=C2=A0=C2=A0 =E2=94=9C=E2=94=80=E2=
=94=80 benches
>     =E2=94=82=C2=A0=C2=A0     =E2=94=82=C2=A0=C2=A0 =E2=94=82=C2=A0=C2=A0=
 =E2=94=9C=E2=94=80=E2=94=80 backtracking.rs
> (ins)efraim@3900XT ~/workspace/guix-rust-team$ tree /gnu/store/9310sgn182=
cgqy4p1xkn2hi8x4wg0nn8-rust-pubgrub-0.3.0-0.b70cf70 | head
> /gnu/store/9310sgn182cgqy4p1xkn2hi8x4wg0nn8-rust-pubgrub-0.3.0-0.b70cf70
> =E2=94=94=E2=94=80=E2=94=80 share
>     =E2=94=9C=E2=94=80=E2=94=80 cargo
>     =E2=94=82=C2=A0=C2=A0 =E2=94=9C=E2=94=80=E2=94=80 registry
>     =E2=94=82=C2=A0=C2=A0 =E2=94=82=C2=A0=C2=A0 =E2=94=9C=E2=94=80=E2=94=
=80 pubgrub-0.3.0.crate
>     =E2=94=82=C2=A0=C2=A0 =E2=94=82=C2=A0=C2=A0 =E2=94=94=E2=94=80=E2=94=
=80 version-ranges-0.1.1.crate
>     =E2=94=82=C2=A0=C2=A0 =E2=94=94=E2=94=80=E2=94=80 src
>     =E2=94=82=C2=A0=C2=A0     =E2=94=9C=E2=94=80=E2=94=80 pubgrub-0.3.0
>     =E2=94=82=C2=A0=C2=A0     =E2=94=82=C2=A0=C2=A0 =E2=94=9C=E2=94=80=E2=
=94=80 benches
>     =E2=94=82=C2=A0=C2=A0     =E2=94=82=C2=A0=C2=A0 =E2=94=82=C2=A0=C2=A0=
 =E2=94=9C=E2=94=80=E2=94=80 backtracking.rs

Thanks!  It works for rust-pipewire too.




Information forwarded to guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 11:51:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 07:51:03 2025
Received: from localhost ([127.0.0.1]:37711 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuVTG-0000Ed-L2
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 07:51:02 -0400
Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:59579)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <efraim.flashner@HIDDEN>)
 id 1tuVSE-0008Q0-Ln
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 07:49:59 -0400
Received: by mail-wm1-x331.google.com with SMTP id
 5b1f17b1804b1-4394036c0efso21733405e9.2
 for <77093 <at> debbugs.gnu.org>; Tue, 18 Mar 2025 04:49:54 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1742298588; x=1742903388; darn=debbugs.gnu.org;
 h=in-reply-to:content-disposition:mime-version:references
 :mail-followup-to:message-id:subject:cc:to:from:date:sender:from:to
 :cc:subject:date:message-id:reply-to;
 bh=SOJ2ZL+oikK7iIUqOkr+il5stQLbVnIEm88mQ6nFsbY=;
 b=ClGEc8Jik3iP9UhSIq7J9P3pS6qoP4xvB9B1kMHYExCxzeswIMDth0MFReN5h/a3ne
 1E6IOOsBuO+SCm4C6vQouqNANjFZhbFO6wF8qmDCN5t2oC5lLbFPWaaLKgRr7aidvQQb
 upZ3c+IdnerFHnHqXzB5Np8T4udmeZZkdWL+fI9Nru0iUZ7OciIjkw/1WG26zYD890j+
 pDgPXvJhAe6koE1S2LZB3ubqsaRPbEaDc1y3ocgEBQ9A7fuNUqq1GiRZnYhidsZI/QBw
 nMgJqU3V/0H2TQMpGiGxl5l9wLxjHDEk5IpTEF++jzZGLcXK6ByInU836f9ipRBzTtcH
 5pKg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1742298588; x=1742903388;
 h=in-reply-to:content-disposition:mime-version:references
 :mail-followup-to:message-id:subject:cc:to:from:date:sender
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=SOJ2ZL+oikK7iIUqOkr+il5stQLbVnIEm88mQ6nFsbY=;
 b=OkpFV82uCE0rOhhIHBQw+t9T6xRgAHOUs57CGgSa+RiG577xJfuBiH0MUl12FJCEWY
 5Ff3Wf0tJt0AxTytIQWf0NgC22f7sSH+4TyKPOu0wgq3+B3k5G9bAFel7LlbeykTjtaQ
 SzXd3pXqAKFwkrcsHgrGcDvDSOczcRub35INBTVF0Mvwxkb1Xrels78Y+SSnq2RGdZto
 R5ILBqCtHBX9O1C/iXPzMcGcf82CErIXUN3XBsRO2nHNX8QGiKhGZo7X6xceNO1hLYks
 lJ6QoODzj2mE7mbI26QGVJMuqZ6axs/3T39T6KOzNBXB48G6AtYvDcPIcDQqnhKKXBXX
 lVcQ==
X-Gm-Message-State: AOJu0YzZtHONTvwO3+fhXy5L9/cUPZ55GTGtZCe/7DdlFuV6aLVyyDSC
 JCrN2uPftJEJaxvtaG8zdO+QMcTEiXRpt7ZDqMwD8pyJ7zDOKQcKBqjn8s6/
X-Gm-Gg: ASbGncv/SM1/93T70yCJYzp8ghpxeviTHA+1vGR10fwg72gaUwR8l+I9T16FXrOqslB
 AXSh/siKsyFpuKnbn8f8bmC6G0Qzjku6utKxy9g+5ogsg2XrsvJxV2wOSqQ8WzejXXLEMT41HXl
 6j/1Rc2D/P83ynzLqAX3NdeQTgsC6Q0iplHnFeCMO+eKjsBpLwdmRs3Sc0Lkpmee+q8WEHKw7gy
 De0HTWSP2+hMkege5+UqM0qaDL+qVpoxFk4vDxG2vk5c+yIRP2kXM2VYJB7TjNL3104cOhb0jnx
 Qe+hP5LGqljh3ZnOvnCKXLZZdJ1DY8NTOvKm2uOcqzHuyw==
X-Google-Smtp-Source: AGHT+IFIXcnGuKyu02zslPM/Hjc7EWLHC6IYzjato97JJRWoIhNlmH8h4/bU7L+bcMaZi3/5EwhXeg==
X-Received: by 2002:a5d:598b:0:b0:391:3b70:2dab with SMTP id
 ffacd0b85a97d-3971d51fce9mr12739045f8f.17.1742298588287; 
 Tue, 18 Mar 2025 04:49:48 -0700 (PDT)
Received: from localhost ([188.120.128.147]) by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-395cb40fa30sm18061871f8f.68.2025.03.18.04.49.47
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 18 Mar 2025 04:49:47 -0700 (PDT)
Date: Tue, 18 Mar 2025 13:49:46 +0200
From: Efraim Flashner <efraim@HIDDEN>
To: Hilton Chain <hako@HIDDEN>
Subject: Re: [bug#77093] [PATCH =?utf-8?Q?rust-team?=
 =?utf-8?Q?_17=2F18=5D_import=3A_crate=3A_Add_=E2=80=98--lockfile?=
 =?utf-8?B?4oCZ?= option.
Message-ID: <Z9ld2pDUynfDjTT5@3900XT>
Mail-Followup-To: Efraim Flashner <efraim@HIDDEN>,
 Hilton Chain <hako@HIDDEN>, 77093 <at> debbugs.gnu.org,
 Christopher Baines <guix@HIDDEN>,
 Divya Ranjan Pattanaik <divya@HIDDEN>,
 Josselin Poiret <dev@HIDDEN>,
 Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>,
 Mathieu Othacehe <othacehe@HIDDEN>,
 Maxim Cournoyer <maxim.cournoyer@HIDDEN>,
 Simon Tournier <zimon.toutoune@HIDDEN>,
 Steve George <steve@HIDDEN>,
 Tobias Geerinckx-Rice <me@HIDDEN>
References: <cover.1742281797.git.hako@HIDDEN>
 <9e07061c7a9a4dacaa437acca4d951047c599573.1742281797.git.hako@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature"; boundary="be6ZRfFMsnnRi1UO"
Content-Disposition: inline
In-Reply-To: <9e07061c7a9a4dacaa437acca4d951047c599573.1742281797.git.hako@HIDDEN>
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-Spam-Score: 3.0 (+++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 
 Content preview:  On Tue, Mar 18, 2025 at 03:24:30PM +0800, Hilton Chain wrote:
    > * guix/scripts/import/crate.scm (%options): Add ‘--lockfile’ option.
    > * guix/scripts/import/crate.scm (show-help): Add it. > (guix- [...] 
 
 Content analysis details:   (3.0 points, 10.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.0 RCVD_IN_DNSWL_NONE     RBL: Sender listed at https://www.dnswl.org/,
                              no trust
                             [2a00:1450:4864:20:0:0:0:331 listed in]
                             [list.dnswl.org]
  3.0 MANY_TO_CC             Sent to 10+ recipients
  0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
  0.0 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level
                             mail domains are different
 -0.0 SPF_PASS               SPF: sender matches SPF record
  0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
                             provider (efraim.flashner[at]gmail.com)
  0.0 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and
                             EnvelopeFrom freemail headers are
                             different
X-Debbugs-Envelope-To: 77093
Cc: Josselin Poiret <dev@HIDDEN>, 77093 <at> debbugs.gnu.org,
 Maxim Cournoyer <maxim.cournoyer@HIDDEN>,
 Simon Tournier <zimon.toutoune@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>,
 Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>,
 Tobias Geerinckx-Rice <me@HIDDEN>, Steve George <steve@HIDDEN>,
 Divya Ranjan Pattanaik <divya@HIDDEN>,
 Christopher Baines <guix@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 2.0 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 
 Content preview:  On Tue, Mar 18, 2025 at 03:24:30PM +0800, Hilton Chain wrote:
    > * guix/scripts/import/crate.scm (%options): Add ‘--lockfile’ option.
    > * guix/scripts/import/crate.scm (show-help): Add it. > (guix- [...] 
 
 Content analysis details:   (2.0 points, 10.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.0 RCVD_IN_DNSWL_NONE     RBL: Sender listed at https://www.dnswl.org/,
                              no trust
                             [2a00:1450:4864:20:0:0:0:331 listed in]
                             [list.dnswl.org]
  3.0 MANY_TO_CC             Sent to 10+ recipients
  0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
  0.0 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level
                             mail domains are different
 -0.0 SPF_PASS               SPF: sender matches SPF record
  0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
                             provider (efraim.flashner[at]gmail.com)
  0.0 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and
                             EnvelopeFrom freemail headers are
                             different
 -1.0 MAILING_LIST_MULTI     Multiple indicators imply a widely-seen list
                             manager


--be6ZRfFMsnnRi1UO
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, Mar 18, 2025 at 03:24:30PM +0800, Hilton Chain wrote:
> * guix/scripts/import/crate.scm (%options): Add =E2=80=98--lockfile=E2=80=
=99 option.
> * guix/scripts/import/crate.scm (show-help): Add it.
> (guix-import-crate): Use it.
> * doc/guix.texi (Invoking guix import): Document it.
> * tests/crate.scm (temp-file): New variable.
> ("crate-lockfile-import"): New test.
>=20
> Change-Id: I291478e04adf9f2df0bf216425a5e8aeba0bedd9
> ---
>  doc/guix.texi                 | 15 ++++++
>  guix/scripts/import/crate.scm | 58 +++++++++++++++++++----
>  tests/crate.scm               | 88 +++++++++++++++++++++++++++++++++++
>  3 files changed, 151 insertions(+), 10 deletions(-)
>=20
> diff --git a/doc/guix.texi b/doc/guix.texi
> index c20e1d7f9c..029c8cf59c 100644
> --- a/doc/guix.texi
> +++ b/doc/guix.texi
> @@ -14703,6 +14703,21 @@ Invoking guix import
>  If a crate dependency is not (yet) packaged, make the corresponding
>  input in @code{#:cargo-inputs} or @code{#:cargo-development-inputs} into
>  a comment.
> +@item --lockfile=3D@var{file}
> +@itemx -f @var{file}
> +When @option{--lockfile} is specified, importer will ignore other
> +options and won't output package definitions, instead generating source
> +definition for all dependencies in @var{file}, a @file{Cargo.lock} file.

When @option{--lockfile} is specified, the importer will ignore other
options and won't output package definitions, instead generating source
definitions for all dependencies in @var{file}, a @file{Cargo.lock} file.

> +For example:
> +
> +@example
> +guix import crate --lockfile=3D/path/to/Cargo.lock my-package
> +@end example
> +
> +generates sources from @file{/path/to/Cargo.lock}, and a list
> +@code{my-package-cargo-inputs} referencing these sources.  The generated
> +list is intended for package's base @code{inputs}, replacing
> +@code{#:cargo-inputs} and @code{#:cargo-development-inputs}.

generates sources from @file{/path/to/Cargo.lock} and a list
@code{my-package-cargo-inputs} referencing these sources.  The generated
list is intended for the package's @code{inputs}, replacing
@code{#:cargo-inputs} and @code{#:cargo-development-inputs}.

>  @end table
> =20
>  @item elm
> diff --git a/guix/scripts/import/crate.scm b/guix/scripts/import/crate.scm
> index 723cbb3665..3b536e135a 100644
> --- a/guix/scripts/import/crate.scm
> +++ b/guix/scripts/import/crate.scm
> @@ -25,11 +25,13 @@
>  (define-module (guix scripts import crate)
>    #:use-module (guix ui)
>    #:use-module (guix utils)
> +  #:use-module (guix read-print)
>    #:use-module (guix scripts)
>    #:use-module (guix import crate)
>    #:use-module (guix scripts import)
>    #:use-module (srfi srfi-1)
>    #:use-module (srfi srfi-11)
> +  #:use-module (srfi srfi-26)
>    #:use-module (srfi srfi-37)
>    #:use-module (ice-9 match)
>    #:use-module (ice-9 format)
> @@ -60,6 +62,9 @@ (define (show-help)
>                           sufficient package exists for it"))
>    (newline)
>    (display (G_ "
> +  -f, --lockfile=3DFILE    import dependencies from FILE, a 'Cargo.lock'=
 file"))
> +  (newline)
> +  (display (G_ "
>    -h, --help             display this help and exit"))
>    (display (G_ "
>    -V, --version          display version information and exit"))
> @@ -87,6 +92,9 @@ (define %options
>           (option '("mark-missing") #f #f
>                   (lambda (opt name arg result)
>                     (alist-cons 'mark-missing #t result)))
> +         (option '(#\f "lockfile") #f #t
> +                 (lambda (opt name arg result)
> +                   (alist-cons 'lockfile arg result)))
>           %standard-import-options))
> =20
>  =0C
> @@ -101,6 +109,8 @@ (define (guix-import-crate . args)
>                          #:build-options? #f))
> =20
>    (let* ((opts (parse-options))
> +         (lockfile (assoc-ref opts 'lockfile))
> +         (file-to-insert (assoc-ref opts 'file-to-insert))
>           (args (filter-map (match-lambda
>                               (('argument . value)
>                                value)
> @@ -111,16 +121,44 @@ (define (guix-import-crate . args)
>         (define-values (name version)
>           (package-name->name+version spec))
> =20
> -       (match (if (assoc-ref opts 'recursive)
> -                  (crate-recursive-import
> -                   name #:version version
> -                   #:recursive-dev-dependencies?
> -                   (assoc-ref opts 'recursive-dev-dependencies)
> -                   #:allow-yanked? (assoc-ref opts 'allow-yanked))
> -                  (crate->guix-package
> -                   name #:version version #:include-dev-deps? #t
> -                   #:allow-yanked? (assoc-ref opts 'allow-yanked)
> -                   #:mark-missing? (assoc-ref opts 'mark-missing)))
> +       (match (cond
> +               ((and=3D> lockfile
> +                       (lambda (file)
> +                         (or (file-exists? file)
> +                             (leave (G_ "file '~a' does not exist~%") fi=
le))))
> +                (let-values (((crate-definitions input-list)
> +                              (cargo-lock->definitions lockfile name)))
> +                  (if file-to-insert
> +                      ;; Adjusted from =E2=80=98--insert=E2=80=99 option=
 of guix-import.
> +                      (let ((term (second input-list)))
> +                        (begin
> +                          ;; Remove existing input list definition.
> +                          (and=3D> (find-definition-location file-to-ins=
ert term)
> +                                 delete-expression)
> +                          ;; Insert input list alphabetically.
> +                          (or (and=3D> (find-definition-insertion-locati=
on
> +                                      file-to-insert term)
> +                                     (cut insert-expression <> input-lis=
t))
> +                              (let ((port (open-file file-to-insert "a")=
))
> +                                (newline port)
> +                                (pretty-print-with-comments port input-l=
ist)
> +                                (newline port)
> +                                (newline port)
> +                                (close-port port))))
> +                        crate-definitions)
> +                      `(,@crate-definitions
> +                        ,input-list))))
> +               ((assoc-ref opts 'recursive)
> +                (crate-recursive-import
> +                 name #:version version
> +                 #:recursive-dev-dependencies?
> +                 (assoc-ref opts 'recursive-dev-dependencies)
> +                 #:allow-yanked? (assoc-ref opts 'allow-yanked)))
> +               (else
> +                (crate->guix-package
> +                 name #:version version #:include-dev-deps? #t
> +                 #:allow-yanked? (assoc-ref opts 'allow-yanked)
> +                 #:mark-missing? (assoc-ref opts 'mark-missing))))
>           ((or #f '())
>            (leave (G_ "failed to download meta-data for package '~a'~%")
>                   (if version
> diff --git a/tests/crate.scm b/tests/crate.scm
> index d0dc779cd2..d46f753f9c 100644
> --- a/tests/crate.scm
> +++ b/tests/crate.scm
> @@ -34,6 +34,7 @@ (define-module (test-crate)
>    #:use-module (gnu packages)
>    #:use-module (ice-9 iconv)
>    #:use-module (ice-9 match)
> +  #:use-module (srfi srfi-11)
>    #:use-module (srfi srfi-64))
> =20
> =20
> @@ -476,6 +477,9 @@ (define rust-leaf-bob-3.0.2-yanked
>      (description #f)
>      (license #f)))
> =20
> +(define temp-file
> +  (string-append "t-utils-" (number->string (getpid))))
> +
>  =0C
>  (test-begin "crate")
> =20
> @@ -1178,4 +1182,88 @@ (define rust-leaf-bob-3.0.2-yanked
>            (x
>             (pk 'fail (pretty-print-with-comments (current-output-port) x=
) #f)))))
> =20
> +=0C
> +(test-assert "crate-lockfile-import"
> +  (begin
> +    (call-with-output-file temp-file
> +      (lambda (port)
> +        (display "\
> +# This file is automatically @generated by Cargo.
> +# It is not intended for manual editing.
> +version =3D 3
> +
> +[[package]]
> +name =3D \"adler2\"
> +version =3D \"2.0.0\"
> +source =3D \"registry+https://github.com/rust-lang/crates.io-index\"
> +checksum =3D \"512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7=
d6e2627\"
> +
> +[[package]]
> +name =3D \"aho-corasick\"
> +version =3D \"1.1.3\"
> +source =3D \"registry+https://github.com/rust-lang/crates.io-index\"
> +checksum =3D \"8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f=
6bcb916\"
> +dependencies =3D [
> + \"memchr\",
> +]
> +
> +[[package]]
> +name =3D \"smithay\"
> +version =3D \"0.4.0\"
> +source =3D \"git+https://github.com/Smithay/smithay.git?rev=3D\
> +0cd3345c59f7cb139521f267956a1a4e33248393#\
> +0cd3345c59f7cb139521f267956a1a4e33248393\"
> +dependencies =3D [
> + \"appendlist\",
> +]
> +
> +[[package]]
> +name =3D \"test\"
> +version =3D \"25.2.0\"\n" port)))
> +    (mock
> +     ((guix scripts download) guix-download
> +      (lambda _
> +        (format #t "~a~%~a~%"
> +                "/gnu/store/in056fyrz6nvy3jpxrxglgj30g0lwniv-smithay-0cd=
3345"
> +                "191h87bpzg0l1ihfb4hmx00b86pfb5mwwc6s8i49al0vigc14l37")))
> +     (let-values
> +         (((crates-definitions input-list)
> +           (cargo-lock->definitions temp-file "test")))
> +       (and
> +        (match crates-definitions
> +          (((define 'rust-adler2-2.0.0
> +              (crate-source
> +               "adler2" "2.0.0"
> +               "09r6drylvgy8vv8k20lnbvwq8gp09h7smfn6h1rxsy15pgh629si"))
> +            (define 'rust-aho-corasick-1.1.3
> +              (crate-source
> +               "aho-corasick" "1.1.3"
> +               "05mrpkvdgp5d20y2p989f187ry9diliijgwrs254fs9s1m1x6q4f"))
> +            (define 'rust-smithay-0.4.0.0cd3345
> +              ($ <comment>
> +                 ";; TODO: Define standalone package if this is a worksp=
ace.\n"
> +                 #f)
> +              (origin
> +                (method git-fetch)
> +                (uri (git-reference
> +                      (url "https://github.com/Smithay/smithay.git")
> +                      (commit "0cd3345c59f7cb139521f267956a1a4e33248393"=
)))
> +                (file-name (git-file-name "rust-smithay" "0.4.0.0cd3345"=
))
> +                (sha256
> +                 (base32
> +                  "191h87bpzg0l1ihfb4hmx00b86pfb5mwwc6s8i49al0vigc14l37"=
)))))
> +           #t)
> +          (x
> +           (pk 'fail (pretty-print-with-comments (current-output-port) x=
) #f)))
> +        (match input-list
> +          ((define-public 'test-cargo-inputs
> +             (list rust-adler2-2.0.0
> +                   rust-aho-corasick-1.1.3
> +                   rust-smithay-0.4.0.0cd3345))
> +           #t)
> +          (x
> +           (pk 'fail x #f))))))))
> +
>  (test-end "crate")
> +
> +(false-if-exception (delete-file temp-file))
> --=20
> 2.48.1
>=20
>=20
>=20

--=20
Efraim Flashner   <efraim@HIDDEN>   =D7=90=D7=A4=D7=A8=D7=99=D7=9D =
=D7=A4=D7=9C=D7=A9=D7=A0=D7=A8
GPG key =3D A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted

--be6ZRfFMsnnRi1UO
Content-Type: application/pgp-signature; name=signature.asc

-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAmfZXdoACgkQQarn3Mo9
g1HoJRAAvP8FMuVlAzamq7gAKypld9q+zFVMegYf2SW/JFV02OhCMalGQ7kN4zKf
obZVnJFKFUdNuVXwd82GjUUGErRvqc1DO6tmrjQVqOP0w7d9OPWow6Ow6alBIPOy
AGg4LDNRpJaB4e2UetDqPxFqA5tCSMPmqhn1hyDkDNNvwKpd085e6IsQOPDMSVOu
GWdzFKxr8RX1Ib8E58R17OtfeWyEUIXtV3CR/8MaUHRcIYZiSUfkIMydo/1+vdqY
9p2i3MCC9Aws6nl5arUBtjh6YXq9368enEPyW5+TRpqxbX6d+DRfFfptgEkXbHVE
pHkvAq2RD91xFWfJgMd4TwQhBl3kkJeUc2D3fvh4mrctSgoK3JKYRJKLDR8/8d7t
9G/YxgP8uv/DoHAp7CoGhypowDFnBfbZOsxsZOSVpy7+4hVTZ+0RoQC7bD1X+NW5
O/bdwKs8FsIjvqBrxYnly+EAjWHhtUkzuGSjjfmekp4N59b5zUPiUmHY9SRnj2fV
k4HRHG5mR8+BdzrctRHvwAFuWcE/k4XtpXjKyGq7a42aXTJ/b/sGVrRFlus830m+
8qXzUpuVf8uUe+wFRbc/Uy1/eel1raR//w9jE1zWx4uhxOlWAS3EOVLHM8pQZ6+S
ycaPdtI1XDEa3MMJHRORVPtF33MyhkBpPFvy+sZedrgIDhWxpho=
=UbZt
-----END PGP SIGNATURE-----

--be6ZRfFMsnnRi1UO--




Information forwarded to guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 11:50:59 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 07:50:58 2025
Received: from localhost ([127.0.0.1]:37709 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuVT8-0000DJ-5y
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 07:50:58 -0400
Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:50459)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <efraim.flashner@HIDDEN>)
 id 1tuVSM-0008RP-Qx
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 07:50:10 -0400
Received: by mail-wr1-x431.google.com with SMTP id
 ffacd0b85a97d-391211ea598so3067789f8f.1
 for <77093 <at> debbugs.gnu.org>; Tue, 18 Mar 2025 04:50:02 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1742298597; x=1742903397; darn=debbugs.gnu.org;
 h=in-reply-to:content-disposition:mime-version:references
 :mail-followup-to:message-id:subject:cc:to:from:date:sender:from:to
 :cc:subject:date:message-id:reply-to;
 bh=ex/5iT5DZfdHj6nViwR8RR8i2A53wVAyPZ59NxtN/Iw=;
 b=FahPJXopdmVkRu8zcJ/hMwFYSQGeTouzLGytUcCoM0JQ9fpaEnOhGqOaaV387z1vyG
 GgyLNhYMfrXyERrOF/9XO2HpGTsA9Xl6Sp7rUFmnx8k4bBSDMXYrxALbZSgJtXlBouc3
 jj7YUTEGBsASeHQZHgjRoyu6wVEFEGrtcWAnCY93Mp3VV1OPo70ORyM0iEDd2uuqE9iG
 b0Hf9B2vWH+jMaTfuOvl1sQHWaXndvNvx5NL/ZRhyhGO8UJGEY5HlYAgzsOlaDOmjsRu
 49GWiWeXVMdlapaE3NQ3g+qRzu9Q9FNoraLtNaVjThkbN7l7bpeNhtyioBOXbf0UL3f1
 xpgQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1742298597; x=1742903397;
 h=in-reply-to:content-disposition:mime-version:references
 :mail-followup-to:message-id:subject:cc:to:from:date:sender
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=ex/5iT5DZfdHj6nViwR8RR8i2A53wVAyPZ59NxtN/Iw=;
 b=OM6GJc/E/5IvPD+WNg0I/Kl3xNE4Wel6K8IUIo+0vjIwBvb1BY/0g4P2RpYQx6RwHe
 UYKZ8DHwuiq5YSLoBk1wHzlkeY+SfnGTWL07I8RD8r0x5qyjiARk3eAUNnEoVqdarUdh
 hinlvAe7LUNDaXQ0PhYkOuaxXfmWg6HeMOjvd6qDCooKYPxmCyymIiPNTVJjZ2TI0Flj
 HTLBkDcfnZ3WAGWgz+GjOrGDD97PWid4YRR2AW64mDJolD9qmqAgEaerT5j7gloCEd69
 QgE9xkFuVFYGFWFw9gEfALAk07JxCfYd2heo8+/WFJeS9gmU8v6pfu9IkvPUTb2YetuJ
 D0NQ==
X-Gm-Message-State: AOJu0YzwQskim9L2jWNyXX1ZxWzYrMXOKUXoKiraradq/s6qfnSmDqvW
 +ClyOAfTe4HW3QwDSpLFZNUGqxxw8m/vf1yEvgiItS7WWl553X1y
X-Gm-Gg: ASbGncux6f1CIO/lBN2GA23jCvxtQ4Ij3mzTIqQ7JkI1I1g36aeTbYvEin/KFGKIuG6
 NcnO0TgfGFcQ5DEJOEu9D+TgT6B0fKYu69db6IUdsF/QLa8tZMgr/xROBF7JMSSxM5lqlk86mJJ
 veB1DGwYY2p4TziAMFCgFt4lCEIQdpz61Tbuj3kYtFf+/yfSf6yHcxJbZzotWl9LiI+aO1N1xnv
 0LB4v+nRJQ2SJOyL7RGfQF9W8WPeSmKlHhV/tCYa+is2cE0Y+yz1iUGdltgHXF4ySVTyE8hlya4
 vFBkrytBCYWBLevl7UQwCmpUqXxqDZHXa7/P6FlW12hBNA==
X-Google-Smtp-Source: AGHT+IFO8azRZCWwrSsdF0usg9r5Hu7vXN3oLICVlooSD9nEor5XS9PQWXShkEp9GbVvlG2KaOx17Q==
X-Received: by 2002:adf:e04d:0:b0:391:2d61:453f with SMTP id
 ffacd0b85a97d-3971ef3b428mr13098166f8f.24.1742298596032; 
 Tue, 18 Mar 2025 04:49:56 -0700 (PDT)
Received: from localhost ([188.120.128.147]) by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-395c8881213sm17488663f8f.42.2025.03.18.04.49.54
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 18 Mar 2025 04:49:55 -0700 (PDT)
Date: Tue, 18 Mar 2025 13:49:54 +0200
From: Efraim Flashner <efraim@HIDDEN>
To: Hilton Chain <hako@HIDDEN>
Subject: Re: [bug#77093] [PATCH rust-team 18/18] doc: Document lockfile
 importer based Rust packaging workflow.
Message-ID: <Z9ld4v5cAK2ocr-J@3900XT>
Mail-Followup-To: Efraim Flashner <efraim@HIDDEN>,
 Hilton Chain <hako@HIDDEN>, 77093 <at> debbugs.gnu.org,
 Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>,
 Maxim Cournoyer <maxim.cournoyer@HIDDEN>
References: <cover.1742281797.git.hako@HIDDEN>
 <7ffcf6a3f50491ea953731444de449dfd7cb8d39.1742281797.git.hako@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature"; boundary="W2bSyREB6g8+gDnK"
Content-Disposition: inline
In-Reply-To: <7ffcf6a3f50491ea953731444de449dfd7cb8d39.1742281797.git.hako@HIDDEN>
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-Spam-Score: 0.7 (/)
X-Debbugs-Envelope-To: 77093
Cc: Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, 77093 <at> debbugs.gnu.org,
 Maxim Cournoyer <maxim.cournoyer@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.3 (/)


--W2bSyREB6g8+gDnK
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, Mar 18, 2025 at 03:24:31PM +0800, Hilton Chain wrote:
> * doc/contributing.texi (Packaging Guidelines)[Rust Crates]: Update
> documentation.
>=20
> Change-Id: Ic0c6378cf5f5df97d6f8bdd040b486be62c7bddc
> ---
>  doc/contributing.texi | 415 +++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 390 insertions(+), 25 deletions(-)
>=20
> diff --git a/doc/contributing.texi b/doc/contributing.texi
> index ab4f30d54b..e7c5116a3d 100644
> --- a/doc/contributing.texi
> +++ b/doc/contributing.texi
> @@ -1600,34 +1600,399 @@ Rust Crates
>  @subsection Rust Crates
> =20
>  @cindex rust
> -Rust programs standing for themselves are named as any other package, us=
ing the
> -lowercase upstream name.
> +As currently there's no achievable way to reuse Rust packages as pre-com=
piled
> +inputs for other packages at a distribution scale, and our previous appr=
oach on
> +making all Rust dependencies as full packages doesn't cope well with Rust
> +ecosystem thus causing issues on both contribution and maintenance sides=
, we
> +have switched to a different packaging model.

I'm not sure the first paragraph is necessary.

> +
> +Rust programs (binary crates) and dependencies (library crates) are trea=
ted
> +separately.  We put main efforts into programs and only package Rust
> +dependencies as sources, utilizing automation with manual focus on unbun=
dling
> +vendored dependencies.  The following paragraphs will explain them and g=
ive
> +several examples.

Rust programs (binary crates) and dependencies (library crates) are treated
separately.  We put our main efforts into programs and only package Rust
dependencies as sources, utilizing automation with a manual focus on unbund=
ling
vendored dependencies.  The following paragraphs will explain them and give
several examples.

> +
> +Rust programs are treated like any other package and named using the low=
ercase
> +upstream name.  When using the Cargo build system (@pxref{Build Systems,
> +@code{cargo-build-system}}), Rust programs should have @code{#:install-s=
ource?}
> +argument set to @code{#f}, as this argument only makes sense to dependen=
cies.

argument set to @code{#f}, as this argument only makes sense for dependenci=
es.

> +When the package source is a Cargo workspace, @code{#:cargo-install-path=
s} must
> +be set to enable relevant support.
> +
> +Rust dependencies are managed in two modules:
> =20
> -To prevent namespace collisions we prefix all other Rust packages with t=
he
> -@code{rust-} prefix.  The name should be changed to lowercase as appropr=
iate and
> -dashes should remain in place.
> +@enumerate
> +@item
> +@code{(gnu packages rust-crates)}, storing source definitions imported f=
rom Rust
> +programs' @file{Cargo.lock} via the lockfile importer (@pxref{Invoking g=
uix
> +import, crate, @code{--lockfile=3D@var{file}}}).
> +
> +Imported definitions must be checked and have vendored sources unbundled=
 before
> +contributing to Guix.  Naturally, this module serves as a store for both=
 sources
> +and unbundling strategies.
> +
> +This module is managed by Rust team (@pxref{Teams}) to ensure there's al=
ways one

This module is managed by the Rust team (@pxref{Teams}) to ensure there's a=
lways one

> +version containing all changes from other branches, so that the maintain=
ed
> +version can be used directly in case of merge conflicts, thus coordinati=
on is
> +required for other committers to modify it.
> +
> +Guix source ships template @file{etc/teams/rust/rust-crates.tmpl} and cl=
eanup
> +script @file{etc/teams/rust/cleanup-crates.sh} for this moudle.

script @file{etc/teams/rust/cleanup-crates.sh} for this module.

> +
> +@item
> +@code{(gnu packages rust-sources)}, storing more complex definitions tha=
t need
> +to be full packages.  This includes Rust dependencies requiring external=
 inputs
> +to unbundle and Cargo workspaces.
> +
> +These dependencies should have @code{#:skip-build?} argument set to @cod=
e{#t}.

These dependencies should have the @code{#:skip-build?} argument set to @co=
de{#t}.

> +For Cargo workspaces, @code{#:cargo-package-crates} must be set.
> +
> +Since they are added manually, the following naming convention applies:
> +
> +To prevent namespace collisions they are named with @code{rust-} prefix.=
  The
> +name should be changed to lowercase as appropriate and dashes should rem=
ain in
> +place.
> =20
>  In the rust ecosystem it is common for multiple incompatible versions of=
 a
> -package to be used at any given time, so all package definitions should =
have a
> -versioned suffix.  The versioned suffix is the left-most non-zero digit =
(and
> -any leading zeros, of course).  This follows the ``caret'' version scheme
> -intended by Cargo.  Examples@: @code{rust-clap-2}, @code{rust-rand-0.6}.
> -
> -Because of the difficulty in reusing rust packages as pre-compiled input=
s for
> -other packages the Cargo build system (@pxref{Build Systems,
> -@code{cargo-build-system}}) presents the @code{#:cargo-inputs} and
> -@code{cargo-development-inputs} keywords as build system arguments.  It =
would be
> -helpful to think of these as similar to @code{propagated-inputs} and
> -@code{native-inputs}.  Rust @code{dependencies} and @code{build-dependen=
cies}
> -should go in @code{#:cargo-inputs}, and @code{dev-dependencies} should g=
o in
> -@code{#:cargo-development-inputs}.  If a Rust package links to other lib=
raries
> -then the standard placement in @code{inputs} and the like should be used.
> -
> -Care should be taken to ensure the correct version of dependencies are u=
sed; to
> -this end we try to refrain from skipping the tests or using @code{#:skip=
-build?}
> -when possible.  Of course this is not always possible, as the package ma=
y be
> -developed for a different Operating System, depend on features from the =
Nightly
> -Rust compiler, or the test suite may have atrophied since it was release=
d.
> +package to be used at any given time, so all dependencies should have a
> +versioned suffix.  The versioned suffix is the left-most non-zero digit =
(and any
> +leading zeros, of course).  This follows the ``caret'' version scheme in=
tended
> +by Cargo.  Examples@: @code{rust-clap-2}, @code{rust-rand-0.6}.
> +
> +In practice we are usually packaging development snapshots of Rust depen=
dencies
> +specifically for some Rust programs, and can't simply identity them by v=
ersion.
> +In this case we can use a @code{for-@var{program}} suffix.  Examples@:
> +@code{rust-pipewire-for-niri}, @code{rust-pubgrub-for-uv}.
> +@end enumerate
> +
> +Let's demonstrate the packaging workflow by examples, note that package-=
specific
> +issues are not involved here.
> +
> +In preparation, we'll adding the following packages to our environment:
> +
> +@example
> +guix shell rust rust:cargo cargo-audit cargo-license
> +@end example
> +
> +Example 1: @code{cargo-audit}, which is published on the crates.io Rust =
package
> +repository @uref{https://crates.io, crates.io}.
> +
> +@enumerate
> +@item
> +We can generate a draft definition via the crates.io importer (@pxref{In=
voking
> +guix import, crate}).  In the end we'll have the following definiton:
> +
> +@lisp
> +(define-public cargo-audit
> +  (package
> +    (name "cargo-audit")
> +    (version "0.21.2")
> +    (source
> +     (origin
> +       (method url-fetch)
> +       (uri (crate-uri "cargo-audit" version))
> +       (file-name (string-append name "-" version ".tar.gz"))
> +       (sha256
> +        (base32 "1a00yqpckkw86zh2hg7ra82c5fx0ird5766dyynimbvqiwg2ps0n"))=
))
> +    (build-system cargo-build-system)
> +    (arguments (list #:install-source? #f))
> +    (inputs (cargo-inputs 'cargo-audit))
> +    (home-page "https://rustsec.org/")
> +    (synopsis "Audit Cargo.lock for crates with security vulnerabilities=
")
> +    (description
> +     "This package provides a Cargo subcommand, @@command@{cargo audit@}=
, to
> +audit @@file@{Cargo.lock@} for crates with security vulnerabilities.")
> +    (license (list license:asl2.0 license:expat))))
> +@end lisp
> +
> +@code{cargo-inputs} is a procedure defined in @code{guix build-system ca=
rgo},
> +facilitating dependency modification.  @code{'cargo-audit} used here mus=
t be a
> +unique identifier, usually same to the program's variable name.
> +
> +@item
> +Unpack package source and navigate to the unpacked directory, then execu=
te the
> +following commands:
> +
> +@example
> +cargo generate-lockfile
> +cargo audit
> +cargo license
> +@end example
> +
> +@command{cargo generate-lockfile} updates dependencies to compatible ver=
sions,
> +@command{cargo audit} checks known vulnerabilities and @command{cargo li=
cense}
> +checks licenses of all dependencies.
> +
> +We must have an acceptable output of @command{cargo audit} and ensure all
> +dependencies are licensed with our supported licenses (@pxref{Defining P=
ackages,
> +@code{license}}).
> +
> +@item
> +Import dependencies from previously generated lockfile:
> +
> +@example
> +guix import --insert=3Dgnu/packages/rust-crates.scm \
> +    crate --lockfile=3D/path/to/Cargo.lock cargo-audit
> +@end example
> +
> +@code{cargo-audit} used here must be consistent with the identifier used=
 for
> +@code{cargo-inputs}.
> +
> +At this stage, @code{cargo-audit} is buildable.
> +
> +@item
> +Finally we'll unbundle vendored sources.  The lockfile importer inserts
> +@code{TODO:} comments to dependencies with high probability of bundled s=
ources.
> +@code{cargo-build-system} also performs additional check in its
> +@code{check-for-pregenerated-files} phase:
> +
> +@example
> +$ guix build cargo-audit
> +@dots{}
> +starting phase `check-for-pregenerated-files'
> +Searching for binary files...
> +./guix-vendor/rust-addr2line-0.21.0.tar.gz/rustfmt.toml
> +./guix-vendor/rust-arc-swap-1.7.1.tar.gz/rustfmt.toml
> +./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/dicti=
onary-rust
> +./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/dicti=
onary-rust-other
> +./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/lib.r=
s.zst
> +./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/long-=
window-size-lib.rs.zst
> +@dots{}
> +@end example
> +
> +Although dependencies in @code{(gnu packages rust-crates)} are not expor=
ted, we
> +can still select them in Guix command-line interface through expression:
> +
> +@example
> +guix build --expression=3D'(@@@@ (gnu packages rust-crates) rust-ring-0.=
17.14)'
> +@end example
> +
> +For most dependencies, a snippet is sufficient:
> +
> +@lisp
> +(define rust-bzip2-sys-0.1.13+1.0.8
> +  (crate-source "bzip2-sys" "0.1.13+1.0.8"
> +                "056c39pgjh4272bdslv445f5ry64xvb0f7nph3z7860ln8rzynr2"
> +                #:snippet
> +                '(begin
> +                   (delete-file-recursively "bzip2-1.0.8")
> +                   (delete-file "build.rs")
> +                   ;; Inspired by Debian's patch.
> +                   (with-output-to-file "build.rs"
> +                     (lambda _
> +                       (format #t "fn main() @{~@@
> +                        println!(\"cargo:rustc-link-lib=3Dbz2\");~@@
> +                        @}~%"))))))
> +@end lisp
> +
> +In a more complex case, where unbundling one dependency requires other p=
ackages,
> +we should package the dependency in @code{(gnu packages rust-sources)} f=
irst and
> +point the imported definition to a symbol with the same name.
> +
> +For example we have defined a @code{rust-ring-0.17} in @code{(gnu packag=
es
> +rust-sources)}, then the imported definition in @code{(gnu packages
> +rust-crates)} should be modified to point to it:
> +
> +@lisp
> +(define rust-ring-0.17.14 'rust-ring-0.17)
> +@end lisp
> +
> +When one dependency can be safely removed, modify it to @code{#f}.
> +
> +@lisp
> +(define rust-openssl-src-300.4.2+3.4.1 #f)
> +@end lisp
> +
> +Such modifications are processed by @code{cargo-inputs} procedure.
> +
> +@code{cargo-inputs} can also be configured by keywoard arguments
> +@code{#:crates-module} (default: @code{(gnu packages rust-crates)}, modu=
le to
> +resolve imported definitions) and @code{#:sources-module} (default: @cod=
e{(gnu
> +packages rust-sources)}, module to resolve modified symbols), which are =
useful
> +to maintain an independent channel.
> +@end enumerate
> +
> +Example 2: @code{niri}, which is not available on crates.io and depends =
on
> +development snapshots (also Cargo workspaces in this example).
> +
> +@enumerate
> +@item
> +As we can't ensure compatibility of a development snapshot, before execu=
ting
> +@command{cargo generate-lockfile}, we should modify @file{Cargo.toml} to=
 pin it
> +in a known working revision.
> +
> +To use our packaged development snapshots, it's also necessary to modify
> +@file{Cargo.toml} in build environment, the substitution pattern is
> +package-specific.
> +
> +@code{cargo-inputs} returns a list, all list operations apply to it too.
> +
> +@lisp
> +(define-public niri
> +  (package
> +   (name "niri")
> +   (version "25.02")
> +   (source (origin
> +             (method git-fetch)
> +             (uri (git-reference
> +                   (url "https://github.com/YaLTeR/niri")
> +                   (commit (string-append "v" version))))
> +             (file-name (git-file-name name version))
> +             (sha256
> +              (base32
> +               "0vzskaalcz6pcml687n54adjddzgf5r07gggc4fhfsa08h1wfd4r"))))
> +   (build-system cargo-build-system)
> +   (arguments
> +    (list #:install-source? #f
> +          #:phases
> +          #~(modify-phases %standard-phases
> +              (add-after 'unpack 'use-guix-vendored-dependencies
> +                (lambda _
> +                  (substitute* "Cargo.toml"
> +                    (("# version =3D.*")
> +                     "version =3D \"*\"")
> +                    (("git.*optional")
> +                     "version =3D \"*\", optional")
> +                    (("^git =3D .*")
> +                     "")))))))
> +   (native-inputs
> +    (list pkg-config))
> +   (inputs
> +    (cons* clang
> +           libdisplay-info
> +           libinput-minimal
> +           libseat
> +           libxkbcommon
> +           mesa
> +           pango
> +           pipewire
> +           wayland
> +           (cargo-inputs 'niri)))
> +   (home-page "https://github.com/YaLTeR/niri")
> +   (synopsis "Scrollable-tiling Wayland compositor")
> +   (description
> +    "Niri is a scrollable-tiling Wayland compositor which arranges windo=
ws in a
> +scrollable format.  It is considered stable for daily use and performs m=
ost
> +functions expected of a Wayland compositor.")
> +   (license license:gpl3)))
> +@end lisp
> +
> +@item
> +@code{niri} also has Cargo workspace dependencies.  When packaging a Car=
go
> +workspace, build argument @code{#:cargo-package-crates} is required.
> +
> +@lisp
> +(define-public rust-pipewire-for-niri
> +  (let ((commit "fd3d8f7861a29c2eeaa4c393402e013578bb36d9")
> +        (revision "0"))
> +    (package
> +      (name "rust-pipewire")
> +      (version (git-version "0.8.0" revision commit))
> +      (source
> +       (origin
> +         (method git-fetch)
> +         (uri (git-reference
> +               (url "https://gitlab.freedesktop.org/pipewire/pipewire-rs=
=2Egit")
> +               (commit commit)))
> +         (file-name (git-file-name name version))
> +         (sha256
> +          (base32 "1hzyhz7xg0mz8a5y9j6yil513p1m610q3j9pzf6q55vdh5mcn79v"=
))))
> +      (build-system cargo-build-system)
> +      (arguments
> +       (list #:skip-build? #t
> +             #:cargo-package-crates
> +             ''("libspa-sys" "libspa" "pipewire-sys" "pipewire")))
> +      (inputs (cargo-inputs 'rust-pipewire-for-niri))
> +      (home-page "https://pipewire.org/")
> +      (synopsis "Rust bindings for PipeWire")
> +      (description "This package provides Rust bindings for PipeWire.")
> +      (license license:expat))))
> +@end lisp
> +
> +Don't forget to modify all workspace members in @code{(gnu packages
> +rust-crates)}:
> +
> +@lisp
> +(define rust-pipewire-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
> +(define rust-pipewire-sys-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
> +@dots{}
> +(define rust-libspa-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
> +(define rust-libspa-sys-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
> +@end lisp
> +@end enumerate
> +
> +Example 3: @code{fish}, which combines two build systems.
> +
> +@enumerate
> +@item
> +When building Rust packages in other build systems, we need to add @code=
{rust}
> +and @code{rust:cargo} to @code{native-inputs}, import and use modules fr=
om both
> +build systems, and apply necessary build phases from @code{cargo-build-s=
ystem}.
> +
> +@lisp
> +(define-public fish
> +  (package
> +    (name "fish")
> +    (version "4.0.0")
> +    (source
> +     (origin
> +       (method url-fetch)
> +       (uri (string-append "https://github.com/fish-shell/fish-shell/"
> +                           "releases/download/" version "/"
> +                           "fish-" version ".tar.xz"))
> +       (sha256
> +        (base32 "1wv9kjwg6ax8m2f85i58l9f9cndshn1f15n8skc68w1mf3cmpnig"))=
))
> +    (build-system cmake-build-system)
> +    (inputs
> +     (cons* fish-foreign-env ncurses pcre2
> +            python                    ;for fish_config and manpage compl=
etions
> +            (cargo-inputs 'fish)))
> +    (native-inputs
> +     (list doxygen groff                ;for 'fish --help'
> +           pkg-config
> +           procps                       ;for the test suite
> +           rust
> +           `(,rust "cargo")))
> +    (arguments
> +     (list #:imported-modules
> +           (append %cargo-build-system-modules
> +                   %cmake-build-system-modules)
> +           #:modules
> +           (((guix build cargo-build-system) #:prefix cargo:)
> +            (guix build cmake-build-system)
> +            (guix build utils))
> +           #:phases
> +           #~(modify-phases %standard-phases
> +               (add-after 'unpack 'use-guix-vendored-dependencies
> +                 (lambda _
> +                   (substitute* "Cargo.toml"
> +                     (("git.*tag.*,")
> +                      "version =3D \"*\","))))
> +               (add-after 'unpack 'prepare-cargo-build-system
> +                 (lambda args
> +                   (for-each
> +                    (lambda (phase)
> +                      (format #t "Running cargo phase: ~a~%" phase)
> +                      (apply (assoc-ref cargo:%standard-phases phase)
> +                             args))
> +                    '(unpack-rust-crates
> +                      configure
> +                      check-for-pregenerated-files
> +                      patch-cargo-checksums)))))))
> +    (synopsis "The friendly interactive shell")
> +    (description
> +     "Fish (friendly interactive shell) is a shell focused on interactiv=
e use,
> +discoverability, and friendliness.  Fish has very user-friendly and powe=
rful
> +tab-completion, including descriptions of every completion, completion of
> +strings with wildcards, and many completions for specific commands.  It =
also
> +has extensive and discoverable help.  A special @@command@{help@} comman=
d gives
> +access to all the fish documentation in your web browser.  Other features
> +include smart terminal handling based on terminfo, an easy to search his=
tory,
> +and syntax highlighting.")
> +    (home-page "https://fishshell.com/")
> +    (license license:gpl2)))
> +@end lisp
> +@end enumerate
> =20
> =20
>  @node Elm Packages
> --=20
> 2.48.1
>=20
>=20
>=20
>=20

--=20
Efraim Flashner   <efraim@HIDDEN>   =D7=90=D7=A4=D7=A8=D7=99=D7=9D =
=D7=A4=D7=9C=D7=A9=D7=A0=D7=A8
GPG key =3D A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted

--W2bSyREB6g8+gDnK
Content-Type: application/pgp-signature; name=signature.asc

-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAmfZXeEACgkQQarn3Mo9
g1Hw3w/9Fky+46Zb1Pf7jrqBko78GxS06RMfF8nfZKzdHS9LQ6507q+z+lxLyl4k
3yn5+OP0guIj37x6NPfZXIx/y6x/LQn6Pe+uSxGhXLqZnkLRHLLely5+VcFl6eKN
tj57HSGe9aYRCcQMETDtD0PtqW4ymPUqfLsVolSXn/9NTWWRJrdqNJz2m+aGP9pu
kdYXSxMjfzVPN2Gc7z5Gl+dMP7hn7sEsYbZZjynYLR6VduAa1GOebqJoKRsgDqC1
XbQKK9L13+ff8ZK5yBESpD9dKdXkGsZm10V5vENmgByKR26EZcy0+5foPPtUfPTc
ZE9wuCfc0lHUGl6PLPxRxyYpqlBF6/cRjxkr/1Rags4Ty0vbX4Tg0f8vc/mQGv2p
6L4QODNH22Nh9lRUDJ6hkLYfifW+id1nDm5Lgtp+IJUW06K1sC5zjwuMxfCjzqu4
u/SW8YZilnvh1TFbaL0l5oUFBRwo9pAjIA/EaHGkehRm61AkPbtw6BG/hG5qTVkM
TVP1W+HgsSQtVlflfcyTWT2Vtm1qzYX01WSp/I8vhQlIBeURYeU53ED19u/b14F+
qvW9yheAwWHn8j6GtV1gKqIxabzLEnhw2QXCW4Hjw6Uq6Q/Z04CEZ3GSZ0jag3oN
gT4gkCQh7OFGz5J9Sn/li7/3/tvHgEoflYBob9FAKridpQfwubA=
=Fmof
-----END PGP SIGNATURE-----

--W2bSyREB6g8+gDnK--




Information forwarded to guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 11:50:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 07:50:50 2025
Received: from localhost ([127.0.0.1]:37707 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuVT5-0000Ci-85
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 07:50:50 -0400
Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:42236)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <efraim.flashner@HIDDEN>)
 id 1tuVS7-0008Om-TT
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 07:49:50 -0400
Received: by mail-wm1-x32e.google.com with SMTP id
 5b1f17b1804b1-43d0359b1fcso20884305e9.0
 for <77093 <at> debbugs.gnu.org>; Tue, 18 Mar 2025 04:49:47 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1742298582; x=1742903382; darn=debbugs.gnu.org;
 h=in-reply-to:content-disposition:mime-version:references
 :mail-followup-to:message-id:subject:cc:to:from:date:sender:from:to
 :cc:subject:date:message-id:reply-to;
 bh=FLKVHeRUQujm/DR0mDt0B+1VoReljUDRuaBJHS/LesM=;
 b=Bu9TYahnxLfiralbscqjQTroJYsgmoyed5ZWwDgTFdKdRgaHyHWLsTW5zXUW5gOed2
 Ujj5ZQNp9Zr70PnZQME/XPuwp2s47ud7ik/IPnr6dKEA6NF0lXRZOd+keJ0IzvduFwEI
 jEVw0IItqdgj24Pw6iX+Wp9JMclR4oUIArjnmqU/8eu1u3jgzdq/CzvJM+hb6HRftH24
 bE+RDL+Dx7w9vhPNs84ukUqnAJ95K+1uYU5F7g2JUb6r2XKxS+LLxnmI03A5RjO+MNXL
 BzZfqETmmtTiZ+xjbomXVvfuWBcCJAs3iKwWk1xiJatSiOiq/d4uD097P/iv4aHl8FWA
 Tqjg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1742298582; x=1742903382;
 h=in-reply-to:content-disposition:mime-version:references
 :mail-followup-to:message-id:subject:cc:to:from:date:sender
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=FLKVHeRUQujm/DR0mDt0B+1VoReljUDRuaBJHS/LesM=;
 b=Wc46DYtcFzBUCgII2QriuqcgcTrhR9q8BXNmZDNTkrOm35yXs/J5kxaAsbKKCZxUIE
 +y9qo5xgc9oYWTgA9Fxl4JK7hMYFZzSgX0E4iROxKNvvBm3pJfAg1taqdekPT8P9HC7S
 M4I4xgg/xrBY33xbk5L06nEgda+YFym/apsktzajGAQBqNKkCgqBc4P9kE/oNesVNCgA
 X4fxlbT4t28BrCLZ0/DRNFsPsTIQ8w/XAtOMSSg5gJV2P/MOSLlwIkDMaXitoa7bpP9C
 15R8/YK3l6HHdGWmrzanEJ46NmEVM4TZTVM9ocK9pSPTXBI1yhKw633lil/16s3Qa5uu
 eylg==
X-Gm-Message-State: AOJu0YzLy3HJt4PHjgrVJTcfGKAl6NsnysGcsomTQxlffzE86bSv+S1S
 us0o3d8KgkUhzPGUa/3+DQHcsBkm4V2HbGl+H//sp2IMPcw6njT8
X-Gm-Gg: ASbGncu5UnAdcAStpndPYWm/K3pBbkEmk1i0KY+6KgOBWgYsWkGvnAYxecAJW3xvWEm
 NioD7k4+zpUQTE0Rttw/VxgzRbSpTLRdaE/LL/qRXQOpJCzzensXB0r58+V5niire4R7Bfxp2wA
 4c39WRzKSI1HP8B31mN4HamB+Grcu/XBCeoTW836Dx205kegVxYf3UOYWaNl21ft2OZixoKqXgR
 hBURjC56jt3C/Ybj8s5h4rRkEIPfbssLPhlE6ttmF2WAPdSSvdaVGi6aH232UIBSpoc3Rpv1Bes
 ZiVpbdU60paqu4XfKcYoZlgM4HIynyNVAZ6Mi49qAh/A+Q==
X-Google-Smtp-Source: AGHT+IFQVieSkYcpUGni8rPUM4iuMsWzF4+UAVhKbkKscQir20a7Tl6zmXF9ttBpqBhZvFz7UtTkJQ==
X-Received: by 2002:a05:600c:a582:b0:43c:f509:2bbf with SMTP id
 5b1f17b1804b1-43d3ba0f49amr16007435e9.15.1742298581561; 
 Tue, 18 Mar 2025 04:49:41 -0700 (PDT)
Received: from localhost ([188.120.128.147]) by smtp.gmail.com with ESMTPSA id
 5b1f17b1804b1-43d200fad64sm132175395e9.25.2025.03.18.04.49.40
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 18 Mar 2025 04:49:41 -0700 (PDT)
Date: Tue, 18 Mar 2025 13:49:39 +0200
From: Efraim Flashner <efraim@HIDDEN>
To: Hilton Chain <hako@HIDDEN>
Subject: Re: [bug#77093] [PATCH rust-team 11/18] scripts: import: Support
 expressions defined by 'define.
Message-ID: <Z9ld074gGnMQrl-o@3900XT>
Mail-Followup-To: Efraim Flashner <efraim@HIDDEN>,
 Hilton Chain <hako@HIDDEN>, 77093 <at> debbugs.gnu.org,
 Christopher Baines <guix@HIDDEN>,
 Josselin Poiret <dev@HIDDEN>,
 Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>,
 Mathieu Othacehe <othacehe@HIDDEN>,
 Simon Tournier <zimon.toutoune@HIDDEN>,
 Tobias Geerinckx-Rice <me@HIDDEN>
References: <cover.1742281797.git.hako@HIDDEN>
 <c185c0310885a4fcce6df3bcf52bb2cd00abd79f.1742281797.git.hako@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature"; boundary="ijdv0h1BqYhH8f8j"
Content-Disposition: inline
In-Reply-To: <c185c0310885a4fcce6df3bcf52bb2cd00abd79f.1742281797.git.hako@HIDDEN>
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-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Josselin Poiret <dev@HIDDEN>, 77093 <at> debbugs.gnu.org,
 Simon Tournier <zimon.toutoune@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>,
 Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>,
 Tobias Geerinckx-Rice <me@HIDDEN>, Christopher Baines <guix@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


--ijdv0h1BqYhH8f8j
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, Mar 18, 2025 at 03:24:24PM +0800, Hilton Chain wrote:
> * guix/utils.scm (find-definition-location): New procedure.
> (find-definition-insertion-location): Define with it.
> * guix/scripts/import.scm (import-as-definitions, guix-import): Support
> expressions defined by 'define.
>=20
> Change-Id: I03118e1a3372028b4f0530964aba871b4a1a4d25
> ---
>  guix/scripts/import.scm | 20 +++++++++++++++-----
>  guix/utils.scm          | 27 +++++++++++++++++++--------
>  2 files changed, 34 insertions(+), 13 deletions(-)
>=20
> diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
> index 58a84d0db7..aaa3d26673 100644
> --- a/guix/scripts/import.scm
> +++ b/guix/scripts/import.scm
> @@ -30,6 +30,7 @@ (define-module (guix scripts import)
>    #:use-module (guix read-print)
>    #:use-module (guix utils)
>    #:use-module (srfi srfi-1)
> +  #:use-module (srfi srfi-26)
>    #:use-module (ice-9 format)
>    #:use-module (ice-9 match)
>    #:export (%standard-import-options
> @@ -83,7 +84,8 @@ (define (import-as-definitions importer args proc)
>          ((and expr (or ('package _ ...)
>                         ('let _ ...)))
>           (proc (package->definition expr)))
> -        ((and expr ('define-public _ ...))
> +        ((and expr (or ('define-public _ ...)
> +                       ('define _ ...)))
>           (proc expr))
>          ((expressions ...)
>           (for-each (lambda (expr)
> @@ -91,7 +93,8 @@ (define (import-as-definitions importer args proc)
>                         ((and expr (or ('package _ ...)
>                                        ('let _ ...)))
>                          (proc (package->definition expr)))
> -                       ((and expr ('define-public _ ...))
> +                       ((and expr (or ('define-public _ ...)
> +                                      ('define _ ...)))
>                          (proc expr))))
>                     expressions))
>          (x
> @@ -117,13 +120,20 @@ (define-command (guix-import . args)
>       (show-version-and-exit "guix import"))
>      ((or ("-i" file importer args ...)
>           ("--insert" file importer args ...))
> -     (let ((find-and-insert
> +     (let* ((definer?
> +              (cut member
> +                   <>
> +                   `(,@(if (member importer '("crate"))
> +                           '(define)
> +                           '())
> +                     define-public)))

This part above seems like it would break the option to use 'guix import
crate' with the --insert flag for "normal" packages.  I question how
useful it currently is in that scenario since we normally have to strip
the rust- prefix from those packages anyway.

> +            (find-and-insert
>               (lambda (expr)
>                 (match expr
> -                 (('define-public term _ ...)
> +                 (((? definer? definer) term _ ...)
>                    (let ((source-properties
>                            (find-definition-insertion-location
> -                            file term)))
> +                            file term #:definer definer)))
>                      (if source-properties
>                        (insert-expression source-properties expr)
>                        (let ((port (open-file file "a")))
> diff --git a/guix/utils.scm b/guix/utils.scm
> index c7c23d9d5b..77ec6d992a 100644
> --- a/guix/utils.scm
> +++ b/guix/utils.scm
> @@ -154,6 +154,7 @@ (define-module (guix utils)
>              edit-expression
>              delete-expression
>              insert-expression
> +            find-definition-location
>              find-definition-insertion-location
> =20
>              filtered-port
> @@ -520,24 +521,34 @@ (define (insert-expression source-properties expr)
>                     (string-append expr "\n\n" str))))
>      (edit-expression source-properties insert)))
> =20
> -(define (find-definition-insertion-location file term)
> -  "Search in FILE for a top-level public definition whose defined term
> -alphabetically succeeds TERM. Return the location if found, or #f
> -otherwise."
> -  (let ((search-term (symbol->string term)))
> +(define* (find-definition-location file term
> +                                   #:key (definer 'define-public)
> +                                   (pred string=3D))
> +  "Search in FILE for a top-level definition defined by DEFINER with def=
ined
> +term comparing to TERM through PRED.  Return the location if PRED return=
s #t,
> +or #f otherwise."
> +  (let ((search-term (symbol->string term))
> +        (definer? (cut eq? definer <>)))
>      (call-with-input-file file
>        (lambda (port)
>          (do ((syntax (read-syntax port)
>                       (read-syntax port)))
>            ((match (syntax->datum syntax)
> -             (('define-public current-term _ ...)
> -              (string> (symbol->string current-term)
> -                       search-term))
> +             (((? definer?) current-term _ ...)
> +              (pred (symbol->string current-term)
> +                    search-term))
>               ((? eof-object?) #t)
>               (_ #f))
>             (and (not (eof-object? syntax))
>                  (syntax-source syntax))))))))
> =20
> +(define* (find-definition-insertion-location file term
> +                                             #:key (definer 'define-publ=
ic))
> +  "Search in FILE for a top-level definition defined by DEFINER with def=
ined
> +term alphabetically succeeds TERM. Return the location if found, or #f
> +otherwise."
> +  (find-definition-location file term #:definer definer #:pred string>))
> +
>  =0C
>  ;;;
>  ;;; Keyword arguments.
> --=20
> 2.48.1
>=20
>=20
>=20
>=20

--=20
Efraim Flashner   <efraim@HIDDEN>   =D7=90=D7=A4=D7=A8=D7=99=D7=9D =
=D7=A4=D7=9C=D7=A9=D7=A0=D7=A8
GPG key =3D A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted

--ijdv0h1BqYhH8f8j
Content-Type: application/pgp-signature; name=signature.asc

-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAmfZXdMACgkQQarn3Mo9
g1E3FQ//QbOAL1wEReLnUk/4VFhx975M2YeAwbJpo+e/WcTDu/Q74eeGa6sMrPsb
SJ56PVvwesv27Br+CfijMIzUJ3/SPAHGXWqzFoZCLxsxTSr8E23BJrfxRIxkMl5O
B82LOmnupBFkC+gao+zSHw+p160z/xP0YZ1qjk7qlKjLGHzgU5kPlpfE42OLsAUl
TxVJxATVQYxk2NiAMF2E/xoRJU4MSz6cIxla9bNbWlQ9+Dlv1b5mBAaTSLPN073y
MDlCXaEIWzkC3N0YvF4v21caL89BAiTEGSBU/SVCYgy2lsbec+yU5yJlypNUvilM
nUgbz+dfawl07z5SE+XiouAnpqNsn3qAvIiS9boqFpH1TewC+bS2oQo5P8DY7fm6
PKZq8IqTgBKo9E+0AfBCQgVVdic7zUd+xIaYj5atsvFGAwQu7yimIGSjyHzxxfud
WATIQ57s0pXAaagWRt8z2DXkGJpl4i1Dr2uDmaWT+9tOy9tBmh+m8owbnf50D19O
PRfWSvBvEvKgBQSO2oz9wyXCNd83v2S1jU9RuHcTiND04zmo/boZKOEEu407epz/
V/8d7XaQ3UIyfwQEgbm6F7UREdJeFei4NxuVM3/GUdcy52JMRTfW/JtO1yJUdfy5
ueX1wRBwAoNfnpst0kLgvKM+KDpphBuSpAxYLfISUcLMYfjr364=
=KyRZ
-----END PGP SIGNATURE-----

--ijdv0h1BqYhH8f8j--




Information forwarded to guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 11:49:58 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 07:49:58 2025
Received: from localhost ([127.0.0.1]:37697 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuVSE-0008Qy-TB
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 07:49:57 -0400
Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:50409)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <efraim.flashner@HIDDEN>)
 id 1tuVS2-0008O0-7a
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 07:49:43 -0400
Received: by mail-wm1-x331.google.com with SMTP id
 5b1f17b1804b1-43690d4605dso22240925e9.0
 for <77093 <at> debbugs.gnu.org>; Tue, 18 Mar 2025 04:49:42 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1742298576; x=1742903376; darn=debbugs.gnu.org;
 h=in-reply-to:content-disposition:mime-version:references
 :mail-followup-to:message-id:subject:cc:to:from:date:sender:from:to
 :cc:subject:date:message-id:reply-to;
 bh=0dv22vAPX7FnkIgeLyLLZpRmicbQuDVGEIw4bRaLNuE=;
 b=fN3aaqKhfih4vz/Hn8EzkAro6Urrj4Qr30qeq/5BsqIjC0Jf5kWQclLQXoh+QguZzf
 RdNWStLwmsuTSokhr+SfiiV2RQaOuJ6gAPM1fVO8vgQz4iu8RJypSLfiLW5fbwc0WVRP
 0Lg6C+JCvrrGdA/tefb0d8V69Km36cy18rSDB9H5SDyWfsbvWQsaukBYZvIZyLOL8emU
 ZabvUwfcYN04YvXwU1R8eTftLS/+HUxTMRpgDXPZ7ufEgy27mvkXhQX0SsNcskM3kJw7
 Aft1ir3WUnCllakE5n9hu+XQ/ORk0qwzt0/wxmkthwgWW3Rs0IfMjhyn3A2ZaamG71RD
 eHRg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1742298576; x=1742903376;
 h=in-reply-to:content-disposition:mime-version:references
 :mail-followup-to:message-id:subject:cc:to:from:date:sender
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=0dv22vAPX7FnkIgeLyLLZpRmicbQuDVGEIw4bRaLNuE=;
 b=sgawt708epYWs+amchEp3J4wO1hCF3rxQnG/Mc0AicW5NnbBBgcscgpdQUdKkmviGS
 VqxDiZEd9dO8k3bGyAPuMUMLK3601iMz5RIFR6lN2zbK0p3UWjiTHDJJBGM7nZKOlkye
 oQHhjItQVvaKZ8K57QJ0LrDdcrZGyCfzKTRi0w9RYUjF4aCoeRnqvslCa0fQe3D38hor
 Jf0pzOQKgycPYMv4PoOy+jtMpMnvZG5d75eDdoMsGXuLJX7naxBPoJjdoBPJQcpmnCHE
 CNpyc2ZlpW/mjR3f9tZuwzghTBr9RwRsWD93HvZHwNSKF+MECf41V0+d3xJjLg3ESXRC
 zZmw==
X-Gm-Message-State: AOJu0Yy5YaLHfhh+xI56YfCyHNzWB8rSM2SyaHnb6Y5y1jnb51eljwPs
 z1m0EKWb8YEedpf9jW5ZzjsXe4tSe47HZd2QZJr1sHmESXmHTNN1
X-Gm-Gg: ASbGnctklsr5T1RAUeSCcjU/fW0LebgXrOM73TXjyC0DCXsnJRjr6585KVK3w2ja2QV
 AsbR8mRSJ1tx8YrnRacDWsL/bkdET4OIOKTtN1BaQAEesYLpHkX2CdZc01cA7DPk8LXE9H5ddwq
 bNxDwVY0gkeVCYoaZG6b9Tzd9OMwYtU48uQHvqINBwU5PBPIFIPmRR7f/MtPiguba/SZOXPTRN3
 0m4VUDR2nQdfWUIzviEdaVAy5mfR1VpmVunwT5yfhu8sv4ynl/XZs5qEtr4YBM9M7mvyf+jvMzj
 Abecyx9FKoyK0JYATy8tJM9NY21kOt8uhCImmYeFr+yL2w==
X-Google-Smtp-Source: AGHT+IESqt8hwV+ts6OwTzTmU8S6XZ9wWNHxziW7sL1gTwhbB/HA60iyUsdxnvxiEzXdEKIzfucjEQ==
X-Received: by 2002:a05:600c:3d14:b0:43d:45a:8fca with SMTP id
 5b1f17b1804b1-43d3ba3ce0emr21568205e9.30.1742298575645; 
 Tue, 18 Mar 2025 04:49:35 -0700 (PDT)
Received: from localhost ([188.120.128.147]) by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-395cb318a12sm17846742f8f.75.2025.03.18.04.49.34
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 18 Mar 2025 04:49:35 -0700 (PDT)
Date: Tue, 18 Mar 2025 13:49:33 +0200
From: Efraim Flashner <efraim@HIDDEN>
To: Hilton Chain <hako@HIDDEN>
Subject: Re: [bug#77093] [PATCH =?utf-8?Q?rust-team?=
 =?utf-8?Q?_10=2F18=5D_scripts=3A_import=3A_Add_two_newlines_for_=E2=80=98?=
 =?utf-8?B?LS1pbnNlcnTigJk=?= option.
Message-ID: <Z9ldzbgZMKVoa1Ed@3900XT>
Mail-Followup-To: Efraim Flashner <efraim@HIDDEN>,
 Hilton Chain <hako@HIDDEN>, 77093 <at> debbugs.gnu.org,
 Christopher Baines <guix@HIDDEN>,
 Josselin Poiret <dev@HIDDEN>,
 Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>,
 Mathieu Othacehe <othacehe@HIDDEN>,
 Simon Tournier <zimon.toutoune@HIDDEN>,
 Tobias Geerinckx-Rice <me@HIDDEN>
References: <cover.1742281797.git.hako@HIDDEN>
 <4e38cd180a457bcd8ca56b6a6ad58042cef81014.1742281797.git.hako@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature"; boundary="dGWrzSFOoMglSgc3"
Content-Disposition: inline
In-Reply-To: <4e38cd180a457bcd8ca56b6a6ad58042cef81014.1742281797.git.hako@HIDDEN>
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-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Josselin Poiret <dev@HIDDEN>, 77093 <at> debbugs.gnu.org,
 Simon Tournier <zimon.toutoune@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>,
 Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>,
 Tobias Geerinckx-Rice <me@HIDDEN>, Christopher Baines <guix@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


--dGWrzSFOoMglSgc3
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Is this only relevant for packages crated with 'guix import cargo'? If
so we should probably just change the importer to add a newline to the
misbehaving importer.

On Tue, Mar 18, 2025 at 03:24:23PM +0800, Hilton Chain wrote:
> For consistency with =E2=80=98insert-expression=E2=80=99.
>=20
> * guix/scripts/import.scm (guix-import): Add two newlines when inserting.
>=20
> Change-Id: I55b45ca137d175fdf6ee5c0bb2b6b1ca8385750d
> ---
>  guix/scripts/import.scm | 1 +
>  1 file changed, 1 insertion(+)
>=20
> diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
> index 4fad329cd3..58a84d0db7 100644
> --- a/guix/scripts/import.scm
> +++ b/guix/scripts/import.scm
> @@ -129,6 +129,7 @@ (define-command (guix-import . args)
>                        (let ((port (open-file file "a")))
>                          (pretty-print-with-comments port expr)
>                          (newline port)
> +                        (newline port)
>                          (close-port port)))))))))
>         (import-as-definitions importer args find-and-insert)))
>      ((importer args ...)
> --=20
> 2.48.1
>=20
>=20
>=20
>=20

--=20
Efraim Flashner   <efraim@HIDDEN>   =D7=90=D7=A4=D7=A8=D7=99=D7=9D =
=D7=A4=D7=9C=D7=A9=D7=A0=D7=A8
GPG key =3D A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted

--dGWrzSFOoMglSgc3
Content-Type: application/pgp-signature; name=signature.asc

-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAmfZXc0ACgkQQarn3Mo9
g1Gvxw//Yi3PpQXf4f6AABJuKk5xZD8UcX8x2OyASUA4gtYsfQB1LqrNen1LmbCt
zPojt7YD4nuihcEs8h+vNlWEmHC1nM/geY/JcL9+jE3yvWbQUXQM9JDvfcQ6zFA7
EpWk2bNW5GO9/mqd5TgRyMrQGilvx5b8Sko9TprcGvM/pH+rkeV5knxWOHEtY6Zs
shYGTA9r07SFyzquNn+e3nfLovMUvGY+g8904JHw77/jilxXMmw3I/IxYSICIrmV
q8TYYfGZDXz2EPSvawVMZtWN7mqPCorRGNXM8nJIjKw0NeHS/Od98BMsBOtsarSh
qdY0WJD49MKWg6grcTGlR6nb3P2cUyT+TCPXVIl/CyZpKjppr8lhFccyreeCVkEq
cEcF2Oaxn5XWQsTb08AIs9325J+kyiRuKvwqKcKCD91Ar30KYqHGNmVb/PZHoz8n
ei+n95pJqNmkyb+x/uxH5poElbGFw/0RC1Oyr5zhsULcIVRDMWeBdKY8VO24JRtR
2PM3XiLettxX81HP2JcYWvNx953m2EgAVnMTRVA42RiOImf0Yhgl+iSK6IyN/jhi
1xzmn8N1ZJETXmqxbJtQerSmHxubZUUwf89O5dZBwNDbn5MiZ61W2lzX8LLlVqf/
b0pd4jVg6N5E3rBvadyYD/iO9B2yDp7G6fD5Gsk3jPGNOx13SEk=
=tcf2
-----END PGP SIGNATURE-----

--dGWrzSFOoMglSgc3--




Information forwarded to guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 11:49:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 07:49:54 2025
Received: from localhost ([127.0.0.1]:37694 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuVSB-0008QO-7k
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 07:49:54 -0400
Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]:60584)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <efraim.flashner@HIDDEN>)
 id 1tuVRv-0008Mh-Tt
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 07:49:40 -0400
Received: by mail-wm1-x32f.google.com with SMTP id
 5b1f17b1804b1-43d0782d787so21930795e9.0
 for <77093 <at> debbugs.gnu.org>; Tue, 18 Mar 2025 04:49:35 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1742298570; x=1742903370; darn=debbugs.gnu.org;
 h=in-reply-to:content-disposition:mime-version:references
 :mail-followup-to:message-id:subject:cc:to:from:date:sender:from:to
 :cc:subject:date:message-id:reply-to;
 bh=IeCIro3JL030OMAtKbX53509fLGP/7hGwucZofyMLHc=;
 b=aW2rNs7sLGB6w4DPR0BHNY35jVTTz8o+DogPJ1zw0H74smknL9MbtJxdWbtJ+M8hCx
 T+zOQSfWfdQ9rNHfbJRublB5N1CjAmWKeKmXFyaxPW4AOhKapURoEC9NQQsWYJmm2xXL
 28wEekHoecljrj3c8wFWZVlPtL8D2um4LlU8hPF0img1SjgRsu/Lm+9uKXrWHXHUh6PC
 rF/DCxhOB+Ij4dFEFmJKqnKIeOeFLDfsX9ubHx5ZBFYDEUNxVRNC70ogjXJu9nBir+SZ
 g8AV8jAWJhcsG/9J6j8HxxU3ZxYKxU9XFzfqJFwclaTD6E1TDD7RHwWviawdy/5e0ZbV
 o7jg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1742298570; x=1742903370;
 h=in-reply-to:content-disposition:mime-version:references
 :mail-followup-to:message-id:subject:cc:to:from:date:sender
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=IeCIro3JL030OMAtKbX53509fLGP/7hGwucZofyMLHc=;
 b=X6q2ZCOPVz4xoIa1DmqQC4OdLm+QklXQNljv9TvMbufUo5tHGCj4If/F9q0xK0JUfg
 m2seN6Cf7xgQY0nfmRb+FuiZfJ5t7UElOZoTbSZmdJv3BynOhOxXinzGBqwNK4mFfBgr
 Cg+W/IrxFLPavrB13pHYBRTpQaSJp2JmTafErENsukFvlFwSN+JaJJy5eKXiOCCxpYYH
 QvkHem+fvEpYi7m7gXRA3NVekEXM5mtofI2ZM5a4SEbDlotiNWo6LqFAzVXu0gqKn4MQ
 FLEEpd0HdxCh+NyApZNuY2ZTzMGnmFQfkJiJUdPcdI5dyIWp31pTiSFrI0EY7YkJRAQ2
 KQ7Q==
X-Gm-Message-State: AOJu0YwNDxpcMzt7mjcGT6pSb5bevhf5/ruiYA/8n87pB3vkm3hfgGth
 cFbMClGfzWdT4wIHzZ0VqIfyyqTh1UoXV7E7tPHeW/OBBbUEdfkf
X-Gm-Gg: ASbGncukMLjwSvFSefrOAL2PyQGRd1/rKjCs09lhAI3zuwRlkkKggaQsvnCDHuCZukk
 vwYcFrV9GHsFOfHKyzHTulFCs7WlWeoME17K6xCTWuPEQ2q+gYIJCKX94HOBolez1sdmray9JXi
 YD363YnCFUwzU7HnAyoFG1aeXFZ5L6herKCFH3q1U+HF6qfguBlGJK/kduwSdnY8fLYJmrqHjrz
 38kfe45fYIoXZuc1ftRzXA7CV9NY/XZtcu85NwfA/XId3hRIoV6rmqySHnNYhAa6d5kcd6Q7alW
 B+POi5VW5zdeVEEqzuzMYskOrkKBZVWqRaTSOvg+TPiesg==
X-Google-Smtp-Source: AGHT+IFP9uyKZkal5q8CMoxld7RTeRtMqxWozeFGkNUEpCkTxM0rtWCMPAPqyIQ4z2EBcAPa/YZWug==
X-Received: by 2002:a05:600c:384c:b0:43d:b32:40aa with SMTP id
 5b1f17b1804b1-43d3b951a37mr17085305e9.3.1742298569390; 
 Tue, 18 Mar 2025 04:49:29 -0700 (PDT)
Received: from localhost ([188.120.128.147]) by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-395cb318a75sm18046871f8f.76.2025.03.18.04.49.28
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 18 Mar 2025 04:49:28 -0700 (PDT)
Date: Tue, 18 Mar 2025 13:49:27 +0200
From: Efraim Flashner <efraim@HIDDEN>
To: Hilton Chain <hako@HIDDEN>
Subject: Re: [bug#77093] [PATCH rust-team 04/18] build-system: cargo: Support
 installing Cargo workspace.
Message-ID: <Z9ldx1VzeYvJQCtm@3900XT>
Mail-Followup-To: Efraim Flashner <efraim@HIDDEN>,
 Hilton Chain <hako@HIDDEN>, 77093 <at> debbugs.gnu.org,
 Divya Ranjan Pattanaik <divya@HIDDEN>,
 Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>,
 Maxim Cournoyer <maxim.cournoyer@HIDDEN>,
 Steve George <steve@HIDDEN>
References: <cover.1742281797.git.hako@HIDDEN>
 <f9521627c5f774edcccd732ecc7f368375180b64.1742281797.git.hako@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature"; boundary="N2T/oEKzQ98/CX5X"
Content-Disposition: inline
In-Reply-To: <f9521627c5f774edcccd732ecc7f368375180b64.1742281797.git.hako@HIDDEN>
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-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Steve George <steve@HIDDEN>,
 Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>,
 Maxim Cournoyer <maxim.cournoyer@HIDDEN>, 77093 <at> debbugs.gnu.org,
 Divya Ranjan Pattanaik <divya@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


--N2T/oEKzQ98/CX5X
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

I don't love the name cargo-install-paths.  I had to build atuin to see
what it did.  The last few lines of the 'install phase:

   Compiling atuin-daemon v18.4.0 (/tmp/guix-build-atuin-18.4.0.drv-0/sourc=
e/crates/atuin-daemon)
   Compiling atuin v18.4.0 (/tmp/guix-build-atuin-18.4.0.drv-0/source/crate=
s/atuin)
    Finished `release` profile [optimized] target(s) in 22.73s
  Installing /gnu/store/yqfi454wkc1lv455m7n5i7l5lwn1la8v-atuin-18.4.0/bin/a=
tuin
   Installed package `atuin v18.4.0 (/tmp/guix-build-atuin-18.4.0.drv-0/sou=
rce/crates/atuin)` (executable `atuin`)
warning: be sure to add `/gnu/store/yqfi454wkc1lv455m7n5i7l5lwn1la8v-atuin-=
18.4.0/bin` to your PATH to be able to run the installed binaries

With #:cargo-install-paths removed I got an error that it was a virtual
manifest and to find the actual package.  Looking at the Cargo.toml I
don't see an obvious way to figure out which package(s) in the workspace
has an installable executable.

So obviously 'paths-to-installable-crates-in-the-worktree' is too long.
Looking at the code it's obvious how the name cargo-install-path came to
be.

On Tue, Mar 18, 2025 at 03:24:17PM +0800, Hilton Chain wrote:
> *guix/build-system/cargo.scm (cargo-build,cargo-cross-build)
> [#:cargo-install-paths]: New argument.
> * guix/build/cargo-build-system.scm (install): Use it.
> * doc/guix.texi (Build Systems)[cargo-build-system]: Document it.
>=20
> Change-Id: I74ed1972a5716da05afeac8edb2b0e4b6834bf40
> ---
>  doc/guix.texi                     |  5 ++++-
>  guix/build-system/cargo.scm       |  4 ++++
>  guix/build/cargo-build-system.scm | 17 +++++++++++++----
>  3 files changed, 21 insertions(+), 5 deletions(-)
>=20
> diff --git a/doc/guix.texi b/doc/guix.texi
> index 322512fd36..c20e1d7f9c 100644
> --- a/doc/guix.texi
> +++ b/doc/guix.texi
> @@ -9369,7 +9369,10 @@ Build Systems
>  names of library crates to package in @code{package} phase.  Specified
>  crates are packaged from left to right, in case there's dependency among
>  them.  For example, specifying @code{''("pcre2-sys" "pcre2")} will
> -package @code{"pcre2-sys"} first and then @code{"pcre2"}.
> +package @code{"pcre2-sys"} first and then @code{"pcre2"}.  Parameter
> +@code{#:cargo-install-paths} (default: @code{''()}) allows specifying
> +paths of binary crates to install in @code{install} phase,

paths of binary crates to install in the @code{install} phase,

> +@code{''("crates/atuin")}, for example.
>  @end defvar
> =20
>  @defvar chicken-build-system
> diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
> index 4f6d46e70c..4486c706a1 100644
> --- a/guix/build-system/cargo.scm
> +++ b/guix/build-system/cargo.scm
> @@ -96,6 +96,7 @@ (define* (cargo-build name inputs
>                        (cargo-test-flags ''())
>                        (cargo-package-crates ''())
>                        (cargo-package-flags ''("--no-metadata" "--no-veri=
fy"))
> +                      (cargo-install-paths ''())
>                        (features ''())
>                        (skip-build? #f)
>                        (parallel-build? #t)
> @@ -125,6 +126,7 @@ (define* (cargo-build name inputs
>                         #:cargo-test-flags #$(sexp->gexp cargo-test-flags)
>                         #:cargo-package-crates #$(sexp->gexp cargo-packag=
e-crates)
>                         #:cargo-package-flags #$(sexp->gexp cargo-package=
-flags)
> +                       #:cargo-install-paths #$(sexp->gexp cargo-install=
-paths)
>                         #:cargo-target #$(cargo-triplet system)
>                         #:features #$(sexp->gexp features)
>                         #:skip-build? #$skip-build?
> @@ -158,6 +160,7 @@ (define* (cargo-cross-build name
>                              (cargo-test-flags ''())
>                              (cargo-package-crates ''())
>                              (cargo-package-flags ''("--no-metadata" "--n=
o-verify"))
> +                            (cargo-install-paths ''())
>                              (cargo-target (cargo-triplet (or target syst=
em)))
>                              (features ''())
>                              (skip-build? #f)
> @@ -190,6 +193,7 @@ (define* (cargo-cross-build name
>                         #:cargo-test-flags #$(sexp->gexp cargo-test-flags)
>                         #:cargo-package-crates #$(sexp->gexp cargo-packag=
e-crates)
>                         #:cargo-package-flags #$(sexp->gexp cargo-package=
-flags)
> +                       #:cargo-install-paths #$(sexp->gexp cargo-install=
-paths)
>                         #:cargo-target #$(cargo-triplet (or target system=
))
>                         #:features #$(sexp->gexp features)
>                         #:skip-build? #$skip-build?
> diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-s=
ystem.scm
> index 001e9c7adc..bcee10837e 100644
> --- a/guix/build/cargo-build-system.scm
> +++ b/guix/build/cargo-build-system.scm
> @@ -384,6 +384,7 @@ (define* (install #:key
>                    skip-build?
>                    install-source?
>                    features
> +                  (cargo-install-paths '())
>                    #:allow-other-keys)
>    "Install a given Cargo package."
>    (let* ((out      (assoc-ref outputs "out"))
> @@ -398,10 +399,18 @@ (define* (install #:key
>      ;; Only install crates which include binary targets,
>      ;; otherwise cargo will raise an error.
>      (or skip-build?
> -        (not (has-executable-target?))
> -        (invoke "cargo" "install" "--offline" "--no-track"
> -                "--path" "." "--root" out
> -                "--features" (string-join features)))
> +        ;; NOTE: Cargo workspace installation support:
> +        ;; #:skip-build? #f + #:cargo-install-paths.
> +        (and (null? cargo-install-paths)
> +             (not (has-executable-target?)))
> +        (for-each
> +         (lambda (path)
> +           (invoke "cargo" "install" "--offline" "--no-track"
> +                   "--path" path "--root" out
> +                   "--features" (string-join features)))
> +         (if (null? cargo-install-paths)
> +             '(".")
> +             cargo-install-paths)))
> =20
>      (when install-source?
>        ;; Install crate tarballs and unpacked sources for later use.
> --=20
> 2.48.1
>=20
>=20
>=20

--=20
Efraim Flashner   <efraim@HIDDEN>   =D7=90=D7=A4=D7=A8=D7=99=D7=9D =
=D7=A4=D7=9C=D7=A9=D7=A0=D7=A8
GPG key =3D A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted

--N2T/oEKzQ98/CX5X
Content-Type: application/pgp-signature; name=signature.asc

-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAmfZXccACgkQQarn3Mo9
g1E/8w//T4WSbaxfCp6k3moLpDgLpstjKwBS1eDFEB0fN/afxakdR/lNrlF1Uwll
vCrgy7/h8PilvjAHqXQyeQmYur6WdgGgsOC+7dPaOo+1HHj+QTildOMGet22men2
ALHmevGzNEq5vtpeh/46vc6juwPEo7iP8z+xzLhZIAsDT8ZdYMRqA2mMRxlGdd8e
614v5hFwcZ0OB2govGmJMNSG0N/sDydY/nBpCWFb6k2YBmLppffDpv6jWivqFyJx
+QPpjUz1qctNmVp3g+/ShiFQWtBozwBbuO0RsnBUXJ7FMo9NN7fjD6yIg3XhCmga
Ar9rajjMwGQZhARZ4YFYbUhDRqndBqECcQrRZYBu8kEuQYj95KZbwuQVdz7bQGOH
gUN3FedUO2lUAVRf9bhbMEFv8XE6qgqrFF6zX4PUu2MZ7saUvaTdJTw/SB0gy7vL
1KQRlrNMyq4IfJwpejO2xntA+YSlwgLxKQS9hyalbwdCgSZmz08ptZ6nBn4eJ0XM
LJ8+4bySrftgaiyzGATkGVrvd7LVa7bUf2WDQ4WEvVbaiHxzImR7k8uKeqpIcGTm
SMMGb+BQYM4lathU+GnehzCHgYQ7Aakjwp6OOnF2W6GwvvoduGDFCpaWpWDLg4aN
bKyFGS0gI5UurReQTW+AjH0gbYNx5XVY0g9fmYD0eZ9a4B6aX6k=
=lG/r
-----END PGP SIGNATURE-----

--N2T/oEKzQ98/CX5X--




Information forwarded to guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 11:49:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 07:49:51 2025
Received: from localhost ([127.0.0.1]:37692 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuVS8-0008Pu-PY
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 07:49:51 -0400
Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:48196)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <efraim.flashner@HIDDEN>)
 id 1tuVRp-0008Lx-Op
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 07:49:33 -0400
Received: by mail-wm1-x335.google.com with SMTP id
 5b1f17b1804b1-4394345e4d5so23290965e9.0
 for <77093 <at> debbugs.gnu.org>; Tue, 18 Mar 2025 04:49:29 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1742298563; x=1742903363; darn=debbugs.gnu.org;
 h=in-reply-to:content-disposition:mime-version:references
 :mail-followup-to:message-id:subject:cc:to:from:date:sender:from:to
 :cc:subject:date:message-id:reply-to;
 bh=4QfhRt4uvpd5Va2mSA+wMC3P35zmxQW8fYjb0IJ9VWk=;
 b=M+/AjDdDgKPcOE4Tvh4/JV1lt2KqzxABs6U99DAdduXVdT9+dHtNKU5CdpFyCIhz8B
 hYWmjxX5Hn+5kX1H0U1S/LgiFI3D3HqgcU6iBNfJIMeVgXcIIXbIGjvTZePv+XbdS0EI
 7ailMNuGFia7sIYlJFRdK5wTU6tMxbvlYK757nngZCIusyros6HxrgG+zDLQJmLwrogy
 X93kOtGAuwyRFOOjkVwbLQzrciMBudph9+kxp6OnC+H5Awv/o9SQU6ui2mC5kFsl1NZx
 0GKEYO16iR33P4CbWykzR6zIp659QyJQVjKEatTzsxU7VI+PRvLodtSpfOK6lC78AgA/
 s+jg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1742298563; x=1742903363;
 h=in-reply-to:content-disposition:mime-version:references
 :mail-followup-to:message-id:subject:cc:to:from:date:sender
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=4QfhRt4uvpd5Va2mSA+wMC3P35zmxQW8fYjb0IJ9VWk=;
 b=NlePmbKR71JIJIKnT+cXBMWIPVZxIYpEgtrNy4G3aZWPJC/6yzTO/p8IvBdcIVVFi8
 I66SzAFzoWO8vmvgpAPBFDc8g6aU65IoRlOFIDiTGWLAoE88c1xM5oGYMHjG9sLP/b7n
 ACuDqvD3G7VxFCNZjVPUZla/gtkB8PpyuUDgJxSxZgUkKTv0korspWR1U2q1yY0G+5Pf
 qhFgCEI6zvil0EVk7hxfmU7bC/ZBAE0KEW6mCqXUHGtD3f891jXjnATq/ndWCLtIn8Dg
 DLW3CscAe6axvhP7u2XZc2Wx2AlLbgQbm6UrxozunhJtKwK8of/qWF4MwXFwaTdXb4WR
 d97g==
X-Gm-Message-State: AOJu0Yyme8xWZVhLAimnY33AzDbLmH+nwPhXBKpE5zlK9WNAq6Q0AyrJ
 qQA2kMBMCkZfJDnkgqI74L8EVX9GvlCepDBs5zBS7xZsizN1W4ft
X-Gm-Gg: ASbGncug/nZYu69+oZOZHEBiIhOpD35NwKO+X1yvhCIrwrdB+VoOtgh3aJI/eXAlSs2
 s1TkYWKGC4wiDFeUPWcHFqFZBgNKWbUO1oPCbr0db1m8Dsc1c5yaGLqevls8W2t6/RPnCtakzd6
 lWhwwNV88smWfWEmSOys5y7wxjDktRwccfM4edx6XA21n1xV359O3+Bo96R3I8indQPDJ+r4Ckp
 DT6B5Obfzk9VVC7aHkOdmep3yhSqQW3KEx7oUjmWdK++Ksmsf7vT/O/znSeocOT6c2sPi7DDjZg
 nOa/UjKPtgIft4rG0ECnEyXl1vpX9RL9aR+YQPRomLWx1M/H5W6TIvuk
X-Google-Smtp-Source: AGHT+IGKGU5a/Lsgz1Uf3ADM5FVLJRPFrCWKnCDf097u1ZZqO1wiHNOIlTBG9ZPWfDmHCwQ2CC9izw==
X-Received: by 2002:a05:600c:4fd3:b0:43c:f597:d565 with SMTP id
 5b1f17b1804b1-43d3b993db6mr21709585e9.12.1742298563105; 
 Tue, 18 Mar 2025 04:49:23 -0700 (PDT)
Received: from localhost ([188.120.128.147]) by smtp.gmail.com with ESMTPSA id
 5b1f17b1804b1-43d1fdda208sm134583245e9.6.2025.03.18.04.49.22
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 18 Mar 2025 04:49:22 -0700 (PDT)
Date: Tue, 18 Mar 2025 13:49:21 +0200
From: Efraim Flashner <efraim@HIDDEN>
To: Hilton Chain <hako@HIDDEN>
Subject: Re: [PATCH rust-team 08/18] build/cargo: Use system jemalloc.
Message-ID: <Z9ldwa9OgoIb-A2R@3900XT>
Mail-Followup-To: Efraim Flashner <efraim@HIDDEN>,
 Hilton Chain <hako@HIDDEN>, 77093 <at> debbugs.gnu.org
References: <cover.1742281797.git.hako@HIDDEN>
 <02e5f7ff3d45b516a797c3e68c257748336dbae2.1742281797.git.hako@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature"; boundary="tn1Awmv/RJMjCbdC"
Content-Disposition: inline
In-Reply-To: <02e5f7ff3d45b516a797c3e68c257748336dbae2.1742281797.git.hako@HIDDEN>
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-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: 77093 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


--tn1Awmv/RJMjCbdC
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

I'm not sure how I feel about this one.  On one hand the
unprefixed_malloc flag is definitely necessary.  On the other hand
sometimes we use libjemalloc.so and sometimes libjemalloc_pic.a, and I
don't remember when/why we use one over the other, other than "it just
works"

On Tue, Mar 18, 2025 at 03:24:21PM +0800, Hilton Chain wrote:
> From: Efraim Flashner <efraim@HIDDEN>
>=20
> * guix/build/cargo-build-system.scm (configure): Set environment variable=
s to
> use system jemalloc.
>=20
> Change-Id: Ibb1c025c7354ba2befd2770e3f1ccd785baa06c3
> Modified-by: Hilton Chain <hako@HIDDEN>
> ---
>  guix/build/cargo-build-system.scm | 6 ++++++
>  1 file changed, 6 insertions(+)
>=20
> diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-s=
ystem.scm
> index a1c4f556bb..b547421b88 100644
> --- a/guix/build/cargo-build-system.scm
> +++ b/guix/build/cargo-build-system.scm
> @@ -248,6 +248,12 @@ (define* (configure #:key inputs
>    (setenv "LIBSSH2_SYS_USE_PKG_CONFIG" "1")
>    (setenv "SODIUM_USE_PKG_CONFIG" "1")
>    (setenv "ZSTD_SYS_USE_PKG_CONFIG" "1")
> +  ;; This flag is needed when not using the bundled jemalloc.
> +  ;; https://github.com/tikv/jemallocator/issues/19
> +  (setenv "CARGO_FEATURE_UNPREFIXED_MALLOC_ON_SUPPORTED_PLATFORMS" "1")
> +  (when (assoc-ref inputs "jemalloc")
> +    (setenv "JEMALLOC_OVERRIDE"
> +            (string-append (assoc-ref inputs "jemalloc") "/lib/libjemall=
oc.so")))
>    (when (assoc-ref inputs "openssl")
>      (setenv "OPENSSL_DIR" (assoc-ref inputs "openssl")))
>    (when (assoc-ref inputs "gettext")
> --=20
> 2.48.1
>=20

--=20
Efraim Flashner   <efraim@HIDDEN>   =D7=90=D7=A4=D7=A8=D7=99=D7=9D =
=D7=A4=D7=9C=D7=A9=D7=A0=D7=A8
GPG key =3D A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted

--tn1Awmv/RJMjCbdC
Content-Type: application/pgp-signature; name=signature.asc

-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAmfZXcEACgkQQarn3Mo9
g1EAaBAAwAMtmoFZVNMW4O358iarwoirlWNFljvWa4mOpw02+x4ZWBWNLj+43HDy
f/UkTBApO14b1Pi35XqJToGtvtAdS9OBjtTd6N1AJ8xme3UeEYpwEmkXh+S5m4+N
fEMO9WzzB+eYBTuozsxTxrIeh9VneVCMAyupRMzEUxlErTZDc5VbYfEPw8F34Xsz
SjyctzMkBKG7CIIZV8028Xz2DCFgST6RmUohy969qcgXNNDGK0BU3kNMfi3pZC0Y
OdCnxSlCcD3U7nCX/WimBFuEw5NT51PNwXJ8kpF8N0UZkp3jXj9PUxpDJlrifvTf
1WGfhkbPnrGt0i3VL6MwW7gM8s32omjMv31CHcoEUM9xOGXe+4t6GpJounxxTkkL
M5TbYLjhRwQxQ4wy8DLYp4jfcc4O2lNJ6DGo5H3NcZR73WKansVFXc81Yz5IP8Uc
ZleuveRIJ45CHung3Krc5NW2HaIe8punJck7SMR3uJLvIASf7lEe0yNTPIxenIuP
7uZ0qYArylVeS4WzferB48lqcvZmVnik7df6btCEsfgIfZPfMR4U9pEhN3Ubt5+b
CLiD/zgcqenlOD8NmsaD2Bv8AqINPel3WqKGt8YRXDREj6aSNeLNtcJukrSiXZ3c
IxMxwn4kXjinWGak1yZ1dCrRuLvCfwJNWzjdoizVjaav+ZdfhtI=
=Xxms
-----END PGP SIGNATURE-----

--tn1Awmv/RJMjCbdC--




Information forwarded to guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 11:49:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 07:49:33 2025
Received: from localhost ([127.0.0.1]:37686 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuVRp-0008Me-Od
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 07:49:33 -0400
Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:50450)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <efraim.flashner@HIDDEN>)
 id 1tuVRk-0008LE-5r
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 07:49:27 -0400
Received: by mail-wr1-x431.google.com with SMTP id
 ffacd0b85a97d-391211ea598so3067278f8f.1
 for <77093 <at> debbugs.gnu.org>; Tue, 18 Mar 2025 04:49:24 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1742298558; x=1742903358; darn=debbugs.gnu.org;
 h=in-reply-to:content-disposition:mime-version:references
 :mail-followup-to:message-id:subject:cc:to:from:date:sender:from:to
 :cc:subject:date:message-id:reply-to;
 bh=j0Al9m0lmaIqvOfqwpYIA5G/L+lEu2oTEJonIfXs6vw=;
 b=Et6I5hqLNfm4nnSuTouqUUm4CYdbSgmUyPO5BHgMmK0JULqoWp0lR/xbN8hnLWHOMc
 JgTvnrIyCR1x0uNAhhrqDQ8+ziq6fqQgc3xhhAl6KJ2Y6KriNFDXLyfQ3MGCheNM0iDL
 gkC8gzk0KSELGAw8I4BE2X1wYqofMj0npB39GsDe4Qo8w0lMs4Mo/hbsVxKLX0k8Vbgg
 8/FPexB3i9UoBmywF48ALTySTPNstXTC8V9nO09Tf1HuVDwuU0rLoV3V6mUVVxgx8SAP
 n7rlGGnR8BcDoE7f7sDvDLAOPBOPoAmD7295zO2X95OJasdVAyfwjb0BF0I5sOuBG2j2
 hD6A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1742298558; x=1742903358;
 h=in-reply-to:content-disposition:mime-version:references
 :mail-followup-to:message-id:subject:cc:to:from:date:sender
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=j0Al9m0lmaIqvOfqwpYIA5G/L+lEu2oTEJonIfXs6vw=;
 b=j+I42TfqRZQJOiMXINQxfopY27j6abPz2IAMGANl+PuWcl+sZyDJS6D8YXDtMcCO1M
 WIPctq6HAarPHb4UnGJoCBzIf0RGc1Qdqye8+IvAKab9L2CwoICkdJkfHI3NAGWbmmfE
 Dt3JWBT6AvZCW7lF6b935/30YjSkrzhOWVLx1L5N5Kwy/ypttTtftDnvjS9rL6JVciMM
 JnZR/MEJ9UoZ/yu3XdRIG8yTXX/diu3YkmIPRSlRTEpCezBTb551nlTkVdX9MxiwZjsI
 ZpZ9s5+V11axNc8+TYVLJUVRiVZbRohdbivSYVWtlxl2/FGpzC3EI1HaXAIB91EIaRhW
 aYEA==
X-Gm-Message-State: AOJu0YyshDTMVlniPuKsZtLJh5PczRzHrqpnS22w89B6+XmI763uYpJo
 v11v9vUE/5N3rMrpiNxNKtBz6w/l7/4YAsvVpl0AcFtGUfDeHZlF
X-Gm-Gg: ASbGncuxWG+t9myqtaLwxKy15raCwdbl77j8PK972+gZNA76Fq48u+V7Kd+x390HSX1
 9Y+DsEMf2ykMK6O3AR10/bppAXCjQWQ+ZBRNG0Fv+fFu5d2ihTDoOrG6erpIkpVsvmFS+AgZorO
 UvbDblMup+IzElbvQRy/6oDb/LAME9ZqvGkWjgMsOV37c9jNgXR/SNt0Dp1gdFnI+zTNNRWNAfQ
 nNYFC/oF/sJX73jQcQkhUIYT2GLDgcFnjhiUp+csabLXNVrulLyc7nfBvOPP6pvmqofSxjggBnz
 OBiVRokg4ieS+53S1V3WDsv5Gb9QcpH4ya6DJ8vCpXTBIQ==
X-Google-Smtp-Source: AGHT+IGJpG2lE+s+ejFIyCywaCVp7WwWsY6KRoyYfr1wmN0qMjoWDDQdpbTDrj+FIUXilXLWapvDRw==
X-Received: by 2002:a5d:64e7:0:b0:391:29c0:83f5 with SMTP id
 ffacd0b85a97d-39720d47357mr16363097f8f.44.1742298557511; 
 Tue, 18 Mar 2025 04:49:17 -0700 (PDT)
Received: from localhost ([188.120.128.147]) by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-397f2837e61sm12556286f8f.97.2025.03.18.04.49.16
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 18 Mar 2025 04:49:16 -0700 (PDT)
Date: Tue, 18 Mar 2025 13:49:15 +0200
From: Efraim Flashner <efraim@HIDDEN>
To: Hilton Chain <hako@HIDDEN>
Subject: Re: [bug#77093] [PATCH rust-team 03/18] build-system: cargo: Support
 packaging Cargo workspace.
Message-ID: <Z9ldu8IeBWVna2xO@3900XT>
Mail-Followup-To: Efraim Flashner <efraim@HIDDEN>,
 Hilton Chain <hako@HIDDEN>, 77093 <at> debbugs.gnu.org,
 Divya Ranjan Pattanaik <divya@HIDDEN>,
 Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>,
 Maxim Cournoyer <maxim.cournoyer@HIDDEN>,
 Steve George <steve@HIDDEN>
References: <cover.1742281797.git.hako@HIDDEN>
 <0478229ef1b10a866b0c1cc9e33ec5bf27346d37.1742281797.git.hako@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature"; boundary="QRwpcsKec1gQHr7t"
Content-Disposition: inline
In-Reply-To: <0478229ef1b10a866b0c1cc9e33ec5bf27346d37.1742281797.git.hako@HIDDEN>
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-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Steve George <steve@HIDDEN>,
 Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>,
 Maxim Cournoyer <maxim.cournoyer@HIDDEN>, 77093 <at> debbugs.gnu.org,
 Divya Ranjan Pattanaik <divya@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


--QRwpcsKec1gQHr7t
Content-Type: multipart/mixed; boundary="5B9+4BrqY94GhHkI"
Content-Disposition: inline


--5B9+4BrqY94GhHkI
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

I've attached a diff that removes the need for RUSTC_BOOTSTRAP that
seems to work when I rebuilt rust-pubgrub.

Some links I followed:
https://doc.rust-lang.org/cargo/commands/cargo-publish.html#package-selecti=
on
https://github.com/rust-lang/cargo/issues/10948#issuecomment-1229236664
"One background knowledge: cargo publish is roughly `cargo package` +
call crates.io API."

Before and after:

(ins)efraim@3900XT ~/workspace/guix-rust-team$ tree /gnu/store/zk1n23l2wdca=
8snz1wqllmjxv83hccl5-rust-pubgrub-0.3.0-0.b70cf70 | head
/gnu/store/zk1n23l2wdca8snz1wqllmjxv83hccl5-rust-pubgrub-0.3.0-0.b70cf70
=E2=94=94=E2=94=80=E2=94=80 share
    =E2=94=9C=E2=94=80=E2=94=80 cargo
    =E2=94=82=C2=A0=C2=A0 =E2=94=9C=E2=94=80=E2=94=80 registry
    =E2=94=82=C2=A0=C2=A0 =E2=94=82=C2=A0=C2=A0 =E2=94=9C=E2=94=80=E2=94=80=
 pubgrub-0.3.0.crate
    =E2=94=82=C2=A0=C2=A0 =E2=94=82=C2=A0=C2=A0 =E2=94=94=E2=94=80=E2=94=80=
 version-ranges-0.1.1.crate
    =E2=94=82=C2=A0=C2=A0 =E2=94=94=E2=94=80=E2=94=80 src
    =E2=94=82=C2=A0=C2=A0     =E2=94=9C=E2=94=80=E2=94=80 pubgrub-0.3.0
    =E2=94=82=C2=A0=C2=A0     =E2=94=82=C2=A0=C2=A0 =E2=94=9C=E2=94=80=E2=
=94=80 benches
    =E2=94=82=C2=A0=C2=A0     =E2=94=82=C2=A0=C2=A0 =E2=94=82=C2=A0=C2=A0 =
=E2=94=9C=E2=94=80=E2=94=80 backtracking.rs
(ins)efraim@3900XT ~/workspace/guix-rust-team$ tree /gnu/store/9310sgn182cg=
qy4p1xkn2hi8x4wg0nn8-rust-pubgrub-0.3.0-0.b70cf70 | head
/gnu/store/9310sgn182cgqy4p1xkn2hi8x4wg0nn8-rust-pubgrub-0.3.0-0.b70cf70
=E2=94=94=E2=94=80=E2=94=80 share
    =E2=94=9C=E2=94=80=E2=94=80 cargo
    =E2=94=82=C2=A0=C2=A0 =E2=94=9C=E2=94=80=E2=94=80 registry
    =E2=94=82=C2=A0=C2=A0 =E2=94=82=C2=A0=C2=A0 =E2=94=9C=E2=94=80=E2=94=80=
 pubgrub-0.3.0.crate
    =E2=94=82=C2=A0=C2=A0 =E2=94=82=C2=A0=C2=A0 =E2=94=94=E2=94=80=E2=94=80=
 version-ranges-0.1.1.crate
    =E2=94=82=C2=A0=C2=A0 =E2=94=94=E2=94=80=E2=94=80 src
    =E2=94=82=C2=A0=C2=A0     =E2=94=9C=E2=94=80=E2=94=80 pubgrub-0.3.0
    =E2=94=82=C2=A0=C2=A0     =E2=94=82=C2=A0=C2=A0 =E2=94=9C=E2=94=80=E2=
=94=80 benches
    =E2=94=82=C2=A0=C2=A0     =E2=94=82=C2=A0=C2=A0 =E2=94=82=C2=A0=C2=A0 =
=E2=94=9C=E2=94=80=E2=94=80 backtracking.rs


On Tue, Mar 18, 2025 at 03:24:16PM +0800, Hilton Chain wrote:
> * guix/build-system/cargo.scm (cargo-build,cargo-cross-build)
> [#:cargo-package-crates]: New argument.
> * guix/build/cargo-build-system.scm (package): Use it.
> * doc/guix.texi (Build Systems)[cargo-build-system]: Document it.
>=20
> Change-Id: I45ccd95e90827d47127015cb0bda2d41f792335b
> ---
>  doc/guix.texi                     |  7 +++++++
>  guix/build-system/cargo.scm       |  4 ++++
>  guix/build/cargo-build-system.scm | 28 ++++++++++++++++++++++++++--
>  3 files changed, 37 insertions(+), 2 deletions(-)
>=20
> diff --git a/doc/guix.texi b/doc/guix.texi
> index 0ca109a214..322512fd36 100644
> --- a/doc/guix.texi
> +++ b/doc/guix.texi
> @@ -9363,6 +9363,13 @@ Build Systems
>  the binaries defined by the crate.  Unless @code{install-source? #f} is
>  defined it will also install a source crate repository of itself and unp=
acked
>  sources, to ease in future hacking on rust packages.
> +
> +This build system supports cargo workspaces.  Parameter
> +@code{#:cargo-package-crates} (default: @code{''()}) allows specifying
> +names of library crates to package in @code{package} phase.  Specified
> +crates are packaged from left to right, in case there's dependency among
> +them.  For example, specifying @code{''("pcre2-sys" "pcre2")} will
> +package @code{"pcre2-sys"} first and then @code{"pcre2"}.
>  @end defvar
> =20
>  @defvar chicken-build-system
> diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
> index 452f7f78d0..4f6d46e70c 100644
> --- a/guix/build-system/cargo.scm
> +++ b/guix/build-system/cargo.scm
> @@ -94,6 +94,7 @@ (define* (cargo-build name inputs
>                        (vendor-dir "guix-vendor")
>                        (cargo-build-flags ''("--release"))
>                        (cargo-test-flags ''())
> +                      (cargo-package-crates ''())
>                        (cargo-package-flags ''("--no-metadata" "--no-veri=
fy"))
>                        (features ''())
>                        (skip-build? #f)
> @@ -122,6 +123,7 @@ (define* (cargo-build name inputs
>                         #:vendor-dir #$vendor-dir
>                         #:cargo-build-flags #$(sexp->gexp cargo-build-fla=
gs)
>                         #:cargo-test-flags #$(sexp->gexp cargo-test-flags)
> +                       #:cargo-package-crates #$(sexp->gexp cargo-packag=
e-crates)
>                         #:cargo-package-flags #$(sexp->gexp cargo-package=
-flags)
>                         #:cargo-target #$(cargo-triplet system)
>                         #:features #$(sexp->gexp features)
> @@ -154,6 +156,7 @@ (define* (cargo-cross-build name
>                              (vendor-dir "guix-vendor")
>                              (cargo-build-flags ''("--release"))
>                              (cargo-test-flags ''())
> +                            (cargo-package-crates ''())
>                              (cargo-package-flags ''("--no-metadata" "--n=
o-verify"))
>                              (cargo-target (cargo-triplet (or target syst=
em)))
>                              (features ''())
> @@ -185,6 +188,7 @@ (define* (cargo-cross-build name
>                         #:vendor-dir #$vendor-dir
>                         #:cargo-build-flags #$(sexp->gexp cargo-build-fla=
gs)
>                         #:cargo-test-flags #$(sexp->gexp cargo-test-flags)
> +                       #:cargo-package-crates #$(sexp->gexp cargo-packag=
e-crates)
>                         #:cargo-package-flags #$(sexp->gexp cargo-package=
-flags)
>                         #:cargo-target #$(cargo-triplet (or target system=
))
>                         #:features #$(sexp->gexp features)
> diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-s=
ystem.scm
> index 58238992b8..001e9c7adc 100644
> --- a/guix/build/cargo-build-system.scm
> +++ b/guix/build/cargo-build-system.scm
> @@ -300,11 +300,16 @@ (define* (package #:key
>                    source
>                    skip-build?
>                    install-source?
> +                  (cargo-package-crates '())
>                    (cargo-package-flags '("--no-metadata" "--no-verify"))
> +                  (vendor-dir "guix-vendor")
>                    #:allow-other-keys)
>    "Run 'cargo-package' for a given Cargo package."
>    (if install-source?
> -    (if skip-build?
> +    ;; NOTE: Cargo workspace packaging support:
> +    ;; #:install-source? #t + #:cargo-package-crates.
> +    (if (and (null? cargo-package-crates)
> +             skip-build?)
>        (begin
>          (install-file source "target/package")
>          (with-directory-excursion "target/package"
> @@ -322,7 +327,26 @@ (define* (package #:key
>          ;;error: invalid inclusion of reserved file name Cargo.toml.orig=
 in package source
>          (when (file-exists? "Cargo.toml.orig")
>            (delete-file "Cargo.toml.orig"))
> -        (apply invoke `("cargo" "package" "--offline" ,@cargo-package-fl=
ags))
> +
> +        (if (null? cargo-package-crates)
> +            (apply invoke `("cargo" "package" "--offline" ,@cargo-packag=
e-flags))
> +            ;; Use unstable feature =E2=80=98--registry=E2=80=99.
> +            (begin
> +              (setenv "RUSTC_BOOTSTRAP" "1")
> +              (for-each
> +               (lambda (pkg)
> +                 (apply invoke "cargo" "package" "--offline" "--package"=
 pkg
> +                        "--registry" "crates-io" "-Z" "package-workspace"
> +                        cargo-package-flags)
> +                 (for-each
> +                  (lambda (crate)
> +                    (invoke "tar" "xzf" crate "-C" vendor-dir))
> +                  (begin
> +                    (delete-file-recursively "target/package/tmp-registr=
y")
> +                    (find-files "target/package" "\\.crate$")))
> +                 (patch-cargo-checksums #:vendor-dir vendor-dir))
> +               cargo-package-crates)
> +              (unsetenv "RUSTC_BOOTSTRAP")))
> =20
>          ;; Then unpack the crate, reset the timestamp of all contained f=
iles, and
>          ;; repack them.  This is necessary to ensure that they are repro=
ducible.
> --=20
> 2.48.1
>=20
>=20
>=20

--=20
Efraim Flashner   <efraim@HIDDEN>   =D7=90=D7=A4=D7=A8=D7=99=D7=9D =
=D7=A4=D7=9C=D7=A9=D7=A0=D7=A8
GPG key =3D A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted

--5B9+4BrqY94GhHkI
Content-Type: text/plain; charset=utf-8
Content-Disposition: attachment; filename=0003-no-unstable-flags
Content-Transfer-Encoding: quoted-printable

diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-sys=
tem.scm
index e0170d971f9..712e31a5206 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -352,23 +352,17 @@ (define* (package #:key
=20
         (if (null? cargo-package-crates)
             (apply invoke `("cargo" "package" "--offline" ,@cargo-package-=
flags))
-            ;; Use unstable feature =E2=80=98--registry=E2=80=99.
             (begin
-              (setenv "RUSTC_BOOTSTRAP" "1")
               (for-each
                (lambda (pkg)
                  (apply invoke "cargo" "package" "--offline" "--package" p=
kg
-                        "--registry" "crates-io" "-Z" "package-workspace"
                         cargo-package-flags)
                  (for-each
                   (lambda (crate)
                     (invoke "tar" "xzf" crate "-C" vendor-dir))
-                  (begin
-                    (delete-file-recursively "target/package/tmp-registry")
-                    (find-files "target/package" "\\.crate$")))
+                  (find-files "target/package" "\\.crate$"))
                  (patch-cargo-checksums #:vendor-dir vendor-dir))
-               cargo-package-crates)
-              (unsetenv "RUSTC_BOOTSTRAP")))
+               cargo-package-crates)))
=20
         ;; Then unpack the crate, reset the timestamp of all contained fil=
es, and
         ;; repack them.  This is necessary to ensure that they are reprodu=
cible.

--5B9+4BrqY94GhHkI--

--QRwpcsKec1gQHr7t
Content-Type: application/pgp-signature; name=signature.asc

-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAmfZXbcACgkQQarn3Mo9
g1FUqhAAjgxhl8q2BLNTByUXBJ2djC6BP0iXPT2EAv8z6MAV1gFwy8tjEVsLuqPl
IbpzAeIrUtbfh8ykNscFye4gp/IQhBqz0KTc82QIGaNi6RNwhKD9gBMNTRB6nPK9
M6UHtrWnNU0kaUHsiPLCsYvgylN7wm+/J7wQ331EGg6TA0uuYcppJ1O2HkCASsFE
IVT24USpjGn1noI1zwKVBEHGvjBJtVzTjnnLFlxinLJQqxAAZsZVcdhDbdz83RjN
aMwArf+ULciPm0vdokAJh3KfXKFfvdmD/3TCPZeo+W/X5VeFVq0QMD7IO8f3FsUN
QRt8QfIY82o/rStdDKj/uv0gLAFouLBqj3N+oNG2OR56ULNLv7lW3bp3GhEu1HGf
G7AzYqGRn1z/Rh0pYYO1ihuIYgqT5cjF0ssCQsbD6rsDzyMV50JXUe1oQY6sKYLb
q2vIjBDTcOsRWH7AKtQ3haJiFEOPCB7u9RDKHDQVWCTeLU4cS5lcuiX5HIr9vLDR
XkbPZ+uaMJCETQW3pSGHTY9NS0+EbbXk3uQgszCg8pEtqMZcP8wdJXJnQ80MNRrE
CLjSDOyGqWWQkyrl96o2uVcdAB/zc/m+AMj0jlrUp3GZVR/4NXQy8lv0TQfNdgCm
vDswYB3DuUnavuQRJKjQjXJSzk19KkuBGbsbwgK7lxnP6El7cgA=
=eqTz
-----END PGP SIGNATURE-----

--QRwpcsKec1gQHr7t--




Information forwarded to guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:27:07 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 03:27:06 2025
Received: from localhost ([127.0.0.1]:35945 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuRLq-0004nd-02
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:27:06 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:38534)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuRLR-0004jM-KF
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:26:41 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742282796;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=4DlctWhdQ7kh3mOvzpuhsSgzVoTDYuMUyORqz81LUTQ=;
 b=TmujlmKG6XUibcfxEuOlkQvt1PBYA3QzMYe3QA2flsg4O6n8SldUhei3B3kSfCJ6Oxz2Ug
 9+aRJ8Aepe10s3N0CjMFgiwxR2ubotM9wmsyVgtTb5ufaoPi9SobyK5SMWjl0kNO/t/tdm
 vC7ZdTEh/NsxEtZgQ6d5DYLevvwwsnyJKFw9EdddiojOKO6iLGXSdVfypni3XyATGpOqHE
 xLiyznkXiEXsQipKy5TIcGPhf2yGH/k6Hk+4AQ7sQsSD5ZDnXI91mFjoy1QdouboqLoLEf
 kxmK/bewZWJ87oZP9ueqqi8l2+TFpqkgSgWzf4zwjCuEho5grv7LSX/LPjpeyQ==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team 18/18] doc: Document lockfile importer based Rust
 packaging workflow.
Date: Tue, 18 Mar 2025 15:24:31 +0800
Message-ID: <7ffcf6a3f50491ea953731444de449dfd7cb8d39.1742281797.git.hako@HIDDEN>
In-Reply-To: <cover.1742281797.git.hako@HIDDEN>
References: <cover.1742281797.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Hilton Chain <hako@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.7 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.3 (/)

* doc/contributing.texi (Packaging Guidelines)[Rust Crates]: Update
documentation.

Change-Id: Ic0c6378cf5f5df97d6f8bdd040b486be62c7bddc
---
 doc/contributing.texi | 415 +++++++++++++++++++++++++++++++++++++++---
 1 file changed, 390 insertions(+), 25 deletions(-)

diff --git a/doc/contributing.texi b/doc/contributing.texi
index ab4f30d54b..e7c5116a3d 100644
--- a/doc/contributing.texi
+++ b/doc/contributing.texi
@@ -1600,34 +1600,399 @@ Rust Crates
 @subsection Rust Crates
 
 @cindex rust
-Rust programs standing for themselves are named as any other package, using the
-lowercase upstream name.
+As currently there's no achievable way to reuse Rust packages as pre-compiled
+inputs for other packages at a distribution scale, and our previous approach on
+making all Rust dependencies as full packages doesn't cope well with Rust
+ecosystem thus causing issues on both contribution and maintenance sides, we
+have switched to a different packaging model.
+
+Rust programs (binary crates) and dependencies (library crates) are treated
+separately.  We put main efforts into programs and only package Rust
+dependencies as sources, utilizing automation with manual focus on unbundling
+vendored dependencies.  The following paragraphs will explain them and give
+several examples.
+
+Rust programs are treated like any other package and named using the lowercase
+upstream name.  When using the Cargo build system (@pxref{Build Systems,
+@code{cargo-build-system}}), Rust programs should have @code{#:install-source?}
+argument set to @code{#f}, as this argument only makes sense to dependencies.
+When the package source is a Cargo workspace, @code{#:cargo-install-paths} must
+be set to enable relevant support.
+
+Rust dependencies are managed in two modules:
 
-To prevent namespace collisions we prefix all other Rust packages with the
-@code{rust-} prefix.  The name should be changed to lowercase as appropriate and
-dashes should remain in place.
+@enumerate
+@item
+@code{(gnu packages rust-crates)}, storing source definitions imported from Rust
+programs' @file{Cargo.lock} via the lockfile importer (@pxref{Invoking guix
+import, crate, @code{--lockfile=@var{file}}}).
+
+Imported definitions must be checked and have vendored sources unbundled before
+contributing to Guix.  Naturally, this module serves as a store for both sources
+and unbundling strategies.
+
+This module is managed by Rust team (@pxref{Teams}) to ensure there's always one
+version containing all changes from other branches, so that the maintained
+version can be used directly in case of merge conflicts, thus coordination is
+required for other committers to modify it.
+
+Guix source ships template @file{etc/teams/rust/rust-crates.tmpl} and cleanup
+script @file{etc/teams/rust/cleanup-crates.sh} for this moudle.
+
+@item
+@code{(gnu packages rust-sources)}, storing more complex definitions that need
+to be full packages.  This includes Rust dependencies requiring external inputs
+to unbundle and Cargo workspaces.
+
+These dependencies should have @code{#:skip-build?} argument set to @code{#t}.
+For Cargo workspaces, @code{#:cargo-package-crates} must be set.
+
+Since they are added manually, the following naming convention applies:
+
+To prevent namespace collisions they are named with @code{rust-} prefix.  The
+name should be changed to lowercase as appropriate and dashes should remain in
+place.
 
 In the rust ecosystem it is common for multiple incompatible versions of a
-package to be used at any given time, so all package definitions should have a
-versioned suffix.  The versioned suffix is the left-most non-zero digit (and
-any leading zeros, of course).  This follows the ``caret'' version scheme
-intended by Cargo.  Examples@: @code{rust-clap-2}, @code{rust-rand-0.6}.
-
-Because of the difficulty in reusing rust packages as pre-compiled inputs for
-other packages the Cargo build system (@pxref{Build Systems,
-@code{cargo-build-system}}) presents the @code{#:cargo-inputs} and
-@code{cargo-development-inputs} keywords as build system arguments.  It would be
-helpful to think of these as similar to @code{propagated-inputs} and
-@code{native-inputs}.  Rust @code{dependencies} and @code{build-dependencies}
-should go in @code{#:cargo-inputs}, and @code{dev-dependencies} should go in
-@code{#:cargo-development-inputs}.  If a Rust package links to other libraries
-then the standard placement in @code{inputs} and the like should be used.
-
-Care should be taken to ensure the correct version of dependencies are used; to
-this end we try to refrain from skipping the tests or using @code{#:skip-build?}
-when possible.  Of course this is not always possible, as the package may be
-developed for a different Operating System, depend on features from the Nightly
-Rust compiler, or the test suite may have atrophied since it was released.
+package to be used at any given time, so all dependencies should have a
+versioned suffix.  The versioned suffix is the left-most non-zero digit (and any
+leading zeros, of course).  This follows the ``caret'' version scheme intended
+by Cargo.  Examples@: @code{rust-clap-2}, @code{rust-rand-0.6}.
+
+In practice we are usually packaging development snapshots of Rust dependencies
+specifically for some Rust programs, and can't simply identity them by version.
+In this case we can use a @code{for-@var{program}} suffix.  Examples@:
+@code{rust-pipewire-for-niri}, @code{rust-pubgrub-for-uv}.
+@end enumerate
+
+Let's demonstrate the packaging workflow by examples, note that package-specific
+issues are not involved here.
+
+In preparation, we'll adding the following packages to our environment:
+
+@example
+guix shell rust rust:cargo cargo-audit cargo-license
+@end example
+
+Example 1: @code{cargo-audit}, which is published on the crates.io Rust package
+repository @uref{https://crates.io, crates.io}.
+
+@enumerate
+@item
+We can generate a draft definition via the crates.io importer (@pxref{Invoking
+guix import, crate}).  In the end we'll have the following definiton:
+
+@lisp
+(define-public cargo-audit
+  (package
+    (name "cargo-audit")
+    (version "0.21.2")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (crate-uri "cargo-audit" version))
+       (file-name (string-append name "-" version ".tar.gz"))
+       (sha256
+        (base32 "1a00yqpckkw86zh2hg7ra82c5fx0ird5766dyynimbvqiwg2ps0n"))))
+    (build-system cargo-build-system)
+    (arguments (list #:install-source? #f))
+    (inputs (cargo-inputs 'cargo-audit))
+    (home-page "https://rustsec.org/")
+    (synopsis "Audit Cargo.lock for crates with security vulnerabilities")
+    (description
+     "This package provides a Cargo subcommand, @@command@{cargo audit@}, to
+audit @@file@{Cargo.lock@} for crates with security vulnerabilities.")
+    (license (list license:asl2.0 license:expat))))
+@end lisp
+
+@code{cargo-inputs} is a procedure defined in @code{guix build-system cargo},
+facilitating dependency modification.  @code{'cargo-audit} used here must be a
+unique identifier, usually same to the program's variable name.
+
+@item
+Unpack package source and navigate to the unpacked directory, then execute the
+following commands:
+
+@example
+cargo generate-lockfile
+cargo audit
+cargo license
+@end example
+
+@command{cargo generate-lockfile} updates dependencies to compatible versions,
+@command{cargo audit} checks known vulnerabilities and @command{cargo license}
+checks licenses of all dependencies.
+
+We must have an acceptable output of @command{cargo audit} and ensure all
+dependencies are licensed with our supported licenses (@pxref{Defining Packages,
+@code{license}}).
+
+@item
+Import dependencies from previously generated lockfile:
+
+@example
+guix import --insert=gnu/packages/rust-crates.scm \
+    crate --lockfile=/path/to/Cargo.lock cargo-audit
+@end example
+
+@code{cargo-audit} used here must be consistent with the identifier used for
+@code{cargo-inputs}.
+
+At this stage, @code{cargo-audit} is buildable.
+
+@item
+Finally we'll unbundle vendored sources.  The lockfile importer inserts
+@code{TODO:} comments to dependencies with high probability of bundled sources.
+@code{cargo-build-system} also performs additional check in its
+@code{check-for-pregenerated-files} phase:
+
+@example
+$ guix build cargo-audit
+@dots{}
+starting phase `check-for-pregenerated-files'
+Searching for binary files...
+./guix-vendor/rust-addr2line-0.21.0.tar.gz/rustfmt.toml
+./guix-vendor/rust-arc-swap-1.7.1.tar.gz/rustfmt.toml
+./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/dictionary-rust
+./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/dictionary-rust-other
+./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/lib.rs.zst
+./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/long-window-size-lib.rs.zst
+@dots{}
+@end example
+
+Although dependencies in @code{(gnu packages rust-crates)} are not exported, we
+can still select them in Guix command-line interface through expression:
+
+@example
+guix build --expression='(@@@@ (gnu packages rust-crates) rust-ring-0.17.14)'
+@end example
+
+For most dependencies, a snippet is sufficient:
+
+@lisp
+(define rust-bzip2-sys-0.1.13+1.0.8
+  (crate-source "bzip2-sys" "0.1.13+1.0.8"
+                "056c39pgjh4272bdslv445f5ry64xvb0f7nph3z7860ln8rzynr2"
+                #:snippet
+                '(begin
+                   (delete-file-recursively "bzip2-1.0.8")
+                   (delete-file "build.rs")
+                   ;; Inspired by Debian's patch.
+                   (with-output-to-file "build.rs"
+                     (lambda _
+                       (format #t "fn main() @{~@@
+                        println!(\"cargo:rustc-link-lib=bz2\");~@@
+                        @}~%"))))))
+@end lisp
+
+In a more complex case, where unbundling one dependency requires other packages,
+we should package the dependency in @code{(gnu packages rust-sources)} first and
+point the imported definition to a symbol with the same name.
+
+For example we have defined a @code{rust-ring-0.17} in @code{(gnu packages
+rust-sources)}, then the imported definition in @code{(gnu packages
+rust-crates)} should be modified to point to it:
+
+@lisp
+(define rust-ring-0.17.14 'rust-ring-0.17)
+@end lisp
+
+When one dependency can be safely removed, modify it to @code{#f}.
+
+@lisp
+(define rust-openssl-src-300.4.2+3.4.1 #f)
+@end lisp
+
+Such modifications are processed by @code{cargo-inputs} procedure.
+
+@code{cargo-inputs} can also be configured by keywoard arguments
+@code{#:crates-module} (default: @code{(gnu packages rust-crates)}, module to
+resolve imported definitions) and @code{#:sources-module} (default: @code{(gnu
+packages rust-sources)}, module to resolve modified symbols), which are useful
+to maintain an independent channel.
+@end enumerate
+
+Example 2: @code{niri}, which is not available on crates.io and depends on
+development snapshots (also Cargo workspaces in this example).
+
+@enumerate
+@item
+As we can't ensure compatibility of a development snapshot, before executing
+@command{cargo generate-lockfile}, we should modify @file{Cargo.toml} to pin it
+in a known working revision.
+
+To use our packaged development snapshots, it's also necessary to modify
+@file{Cargo.toml} in build environment, the substitution pattern is
+package-specific.
+
+@code{cargo-inputs} returns a list, all list operations apply to it too.
+
+@lisp
+(define-public niri
+  (package
+   (name "niri")
+   (version "25.02")
+   (source (origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/YaLTeR/niri")
+                   (commit (string-append "v" version))))
+             (file-name (git-file-name name version))
+             (sha256
+              (base32
+               "0vzskaalcz6pcml687n54adjddzgf5r07gggc4fhfsa08h1wfd4r"))))
+   (build-system cargo-build-system)
+   (arguments
+    (list #:install-source? #f
+          #:phases
+          #~(modify-phases %standard-phases
+              (add-after 'unpack 'use-guix-vendored-dependencies
+                (lambda _
+                  (substitute* "Cargo.toml"
+                    (("# version =.*")
+                     "version = \"*\"")
+                    (("git.*optional")
+                     "version = \"*\", optional")
+                    (("^git = .*")
+                     "")))))))
+   (native-inputs
+    (list pkg-config))
+   (inputs
+    (cons* clang
+           libdisplay-info
+           libinput-minimal
+           libseat
+           libxkbcommon
+           mesa
+           pango
+           pipewire
+           wayland
+           (cargo-inputs 'niri)))
+   (home-page "https://github.com/YaLTeR/niri")
+   (synopsis "Scrollable-tiling Wayland compositor")
+   (description
+    "Niri is a scrollable-tiling Wayland compositor which arranges windows in a
+scrollable format.  It is considered stable for daily use and performs most
+functions expected of a Wayland compositor.")
+   (license license:gpl3)))
+@end lisp
+
+@item
+@code{niri} also has Cargo workspace dependencies.  When packaging a Cargo
+workspace, build argument @code{#:cargo-package-crates} is required.
+
+@lisp
+(define-public rust-pipewire-for-niri
+  (let ((commit "fd3d8f7861a29c2eeaa4c393402e013578bb36d9")
+        (revision "0"))
+    (package
+      (name "rust-pipewire")
+      (version (git-version "0.8.0" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://gitlab.freedesktop.org/pipewire/pipewire-rs.git")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32 "1hzyhz7xg0mz8a5y9j6yil513p1m610q3j9pzf6q55vdh5mcn79v"))))
+      (build-system cargo-build-system)
+      (arguments
+       (list #:skip-build? #t
+             #:cargo-package-crates
+             ''("libspa-sys" "libspa" "pipewire-sys" "pipewire")))
+      (inputs (cargo-inputs 'rust-pipewire-for-niri))
+      (home-page "https://pipewire.org/")
+      (synopsis "Rust bindings for PipeWire")
+      (description "This package provides Rust bindings for PipeWire.")
+      (license license:expat))))
+@end lisp
+
+Don't forget to modify all workspace members in @code{(gnu packages
+rust-crates)}:
+
+@lisp
+(define rust-pipewire-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
+(define rust-pipewire-sys-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
+@dots{}
+(define rust-libspa-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
+(define rust-libspa-sys-0.8.0.fd3d8f7 'rust-pipewire-for-niri)
+@end lisp
+@end enumerate
+
+Example 3: @code{fish}, which combines two build systems.
+
+@enumerate
+@item
+When building Rust packages in other build systems, we need to add @code{rust}
+and @code{rust:cargo} to @code{native-inputs}, import and use modules from both
+build systems, and apply necessary build phases from @code{cargo-build-system}.
+
+@lisp
+(define-public fish
+  (package
+    (name "fish")
+    (version "4.0.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://github.com/fish-shell/fish-shell/"
+                           "releases/download/" version "/"
+                           "fish-" version ".tar.xz"))
+       (sha256
+        (base32 "1wv9kjwg6ax8m2f85i58l9f9cndshn1f15n8skc68w1mf3cmpnig"))))
+    (build-system cmake-build-system)
+    (inputs
+     (cons* fish-foreign-env ncurses pcre2
+            python                    ;for fish_config and manpage completions
+            (cargo-inputs 'fish)))
+    (native-inputs
+     (list doxygen groff                ;for 'fish --help'
+           pkg-config
+           procps                       ;for the test suite
+           rust
+           `(,rust "cargo")))
+    (arguments
+     (list #:imported-modules
+           (append %cargo-build-system-modules
+                   %cmake-build-system-modules)
+           #:modules
+           (((guix build cargo-build-system) #:prefix cargo:)
+            (guix build cmake-build-system)
+            (guix build utils))
+           #:phases
+           #~(modify-phases %standard-phases
+               (add-after 'unpack 'use-guix-vendored-dependencies
+                 (lambda _
+                   (substitute* "Cargo.toml"
+                     (("git.*tag.*,")
+                      "version = \"*\","))))
+               (add-after 'unpack 'prepare-cargo-build-system
+                 (lambda args
+                   (for-each
+                    (lambda (phase)
+                      (format #t "Running cargo phase: ~a~%" phase)
+                      (apply (assoc-ref cargo:%standard-phases phase)
+                             args))
+                    '(unpack-rust-crates
+                      configure
+                      check-for-pregenerated-files
+                      patch-cargo-checksums)))))))
+    (synopsis "The friendly interactive shell")
+    (description
+     "Fish (friendly interactive shell) is a shell focused on interactive use,
+discoverability, and friendliness.  Fish has very user-friendly and powerful
+tab-completion, including descriptions of every completion, completion of
+strings with wildcards, and many completions for specific commands.  It also
+has extensive and discoverable help.  A special @@command@{help@} command gives
+access to all the fish documentation in your web browser.  Other features
+include smart terminal handling based on terminfo, an easy to search history,
+and syntax highlighting.")
+    (home-page "https://fishshell.com/")
+    (license license:gpl2)))
+@end lisp
+@end enumerate
 
 
 @node Elm Packages
-- 
2.48.1





Information forwarded to hako@HIDDEN, ludo@HIDDEN, maxim.cournoyer@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:27:02 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 03:27:01 2025
Received: from localhost ([127.0.0.1]:35943 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuRLm-0004mx-SF
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:27:01 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:45516)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuRLO-0004ik-7q
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:26:36 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742282792;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=tzUPHMCKd4bCn/uzXPa7fW2nAcwVEJtWe9fm8dlRU+w=;
 b=GWS75zlZYl8Q9y7VbyfJHwAbss9MaXO1qCTFg7H9vxaPpnd1u0BOmzVlUunrroTqH788Ad
 fcRpXnjRQgrrfI6vTGX9djLe7st7gSZYc3pU91VNan+wJdQhlQs72KDaQOIuBjIIl3lyqv
 gUqf5qSo+UzJdRIx0uXCrqISo5saBwQbo5tyyhulf9LP0++kllzegDTfS0ekBFRcx4LjdJ
 RGbzi4ddytBFRuErfLGmXf2XgQ04q6DO6mPepxCPHqOkCZaGreV84ma5GfPA5WwdprnC6f
 wy0vBB7pPIR/8fU8xTFBQ9BBM1ZJFyPiIk+q/uJUZqk0qzPzJvXNpoQ7dvC/VQ==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team 17/18] =?UTF-8?q?import:=20crate:=20Add=20?=
 =?UTF-8?q?=E2=80=98--lockfile=E2=80=99=20option.?=
Date: Tue, 18 Mar 2025 15:24:30 +0800
Message-ID: <9e07061c7a9a4dacaa437acca4d951047c599573.1742281797.git.hako@HIDDEN>
In-Reply-To: <cover.1742281797.git.hako@HIDDEN>
References: <cover.1742281797.git.hako@HIDDEN>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
X-Debbugs-Cc: Hilton Chain <hako@HIDDEN>, Christopher Baines <guix@HIDDEN>, Divya Ranjan Pattanaik <divya@HIDDEN>, Efraim Flashner <efraim@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Steve George <steve@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/scripts/import/crate.scm (%options): Add ‘--lockfile’ option.
* guix/scripts/import/crate.scm (show-help): Add it.
(guix-import-crate): Use it.
* doc/guix.texi (Invoking guix import): Document it.
* tests/crate.scm (temp-file): New variable.
("crate-lockfile-import"): New test.

Change-Id: I291478e04adf9f2df0bf216425a5e8aeba0bedd9
---
 doc/guix.texi                 | 15 ++++++
 guix/scripts/import/crate.scm | 58 +++++++++++++++++++----
 tests/crate.scm               | 88 +++++++++++++++++++++++++++++++++++
 3 files changed, 151 insertions(+), 10 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index c20e1d7f9c..029c8cf59c 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -14703,6 +14703,21 @@ Invoking guix import
 If a crate dependency is not (yet) packaged, make the corresponding
 input in @code{#:cargo-inputs} or @code{#:cargo-development-inputs} into
 a comment.
+@item --lockfile=@var{file}
+@itemx -f @var{file}
+When @option{--lockfile} is specified, importer will ignore other
+options and won't output package definitions, instead generating source
+definition for all dependencies in @var{file}, a @file{Cargo.lock} file.
+For example:
+
+@example
+guix import crate --lockfile=/path/to/Cargo.lock my-package
+@end example
+
+generates sources from @file{/path/to/Cargo.lock}, and a list
+@code{my-package-cargo-inputs} referencing these sources.  The generated
+list is intended for package's base @code{inputs}, replacing
+@code{#:cargo-inputs} and @code{#:cargo-development-inputs}.
 @end table
 
 @item elm
diff --git a/guix/scripts/import/crate.scm b/guix/scripts/import/crate.scm
index 723cbb3665..3b536e135a 100644
--- a/guix/scripts/import/crate.scm
+++ b/guix/scripts/import/crate.scm
@@ -25,11 +25,13 @@
 (define-module (guix scripts import crate)
   #:use-module (guix ui)
   #:use-module (guix utils)
+  #:use-module (guix read-print)
   #:use-module (guix scripts)
   #:use-module (guix import crate)
   #:use-module (guix scripts import)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-11)
+  #:use-module (srfi srfi-26)
   #:use-module (srfi srfi-37)
   #:use-module (ice-9 match)
   #:use-module (ice-9 format)
@@ -60,6 +62,9 @@ (define (show-help)
                          sufficient package exists for it"))
   (newline)
   (display (G_ "
+  -f, --lockfile=FILE    import dependencies from FILE, a 'Cargo.lock' file"))
+  (newline)
+  (display (G_ "
   -h, --help             display this help and exit"))
   (display (G_ "
   -V, --version          display version information and exit"))
@@ -87,6 +92,9 @@ (define %options
          (option '("mark-missing") #f #f
                  (lambda (opt name arg result)
                    (alist-cons 'mark-missing #t result)))
+         (option '(#\f "lockfile") #f #t
+                 (lambda (opt name arg result)
+                   (alist-cons 'lockfile arg result)))
          %standard-import-options))
 
 
@@ -101,6 +109,8 @@ (define (guix-import-crate . args)
                         #:build-options? #f))
 
   (let* ((opts (parse-options))
+         (lockfile (assoc-ref opts 'lockfile))
+         (file-to-insert (assoc-ref opts 'file-to-insert))
          (args (filter-map (match-lambda
                              (('argument . value)
                               value)
@@ -111,16 +121,44 @@ (define (guix-import-crate . args)
        (define-values (name version)
          (package-name->name+version spec))
 
-       (match (if (assoc-ref opts 'recursive)
-                  (crate-recursive-import
-                   name #:version version
-                   #:recursive-dev-dependencies?
-                   (assoc-ref opts 'recursive-dev-dependencies)
-                   #:allow-yanked? (assoc-ref opts 'allow-yanked))
-                  (crate->guix-package
-                   name #:version version #:include-dev-deps? #t
-                   #:allow-yanked? (assoc-ref opts 'allow-yanked)
-                   #:mark-missing? (assoc-ref opts 'mark-missing)))
+       (match (cond
+               ((and=> lockfile
+                       (lambda (file)
+                         (or (file-exists? file)
+                             (leave (G_ "file '~a' does not exist~%") file))))
+                (let-values (((crate-definitions input-list)
+                              (cargo-lock->definitions lockfile name)))
+                  (if file-to-insert
+                      ;; Adjusted from ‘--insert’ option of guix-import.
+                      (let ((term (second input-list)))
+                        (begin
+                          ;; Remove existing input list definition.
+                          (and=> (find-definition-location file-to-insert term)
+                                 delete-expression)
+                          ;; Insert input list alphabetically.
+                          (or (and=> (find-definition-insertion-location
+                                      file-to-insert term)
+                                     (cut insert-expression <> input-list))
+                              (let ((port (open-file file-to-insert "a")))
+                                (newline port)
+                                (pretty-print-with-comments port input-list)
+                                (newline port)
+                                (newline port)
+                                (close-port port))))
+                        crate-definitions)
+                      `(,@crate-definitions
+                        ,input-list))))
+               ((assoc-ref opts 'recursive)
+                (crate-recursive-import
+                 name #:version version
+                 #:recursive-dev-dependencies?
+                 (assoc-ref opts 'recursive-dev-dependencies)
+                 #:allow-yanked? (assoc-ref opts 'allow-yanked)))
+               (else
+                (crate->guix-package
+                 name #:version version #:include-dev-deps? #t
+                 #:allow-yanked? (assoc-ref opts 'allow-yanked)
+                 #:mark-missing? (assoc-ref opts 'mark-missing))))
          ((or #f '())
           (leave (G_ "failed to download meta-data for package '~a'~%")
                  (if version
diff --git a/tests/crate.scm b/tests/crate.scm
index d0dc779cd2..d46f753f9c 100644
--- a/tests/crate.scm
+++ b/tests/crate.scm
@@ -34,6 +34,7 @@ (define-module (test-crate)
   #:use-module (gnu packages)
   #:use-module (ice-9 iconv)
   #:use-module (ice-9 match)
+  #:use-module (srfi srfi-11)
   #:use-module (srfi srfi-64))
 
 
@@ -476,6 +477,9 @@ (define rust-leaf-bob-3.0.2-yanked
     (description #f)
     (license #f)))
 
+(define temp-file
+  (string-append "t-utils-" (number->string (getpid))))
+
 
 (test-begin "crate")
 
@@ -1178,4 +1182,88 @@ (define rust-leaf-bob-3.0.2-yanked
           (x
            (pk 'fail (pretty-print-with-comments (current-output-port) x) #f)))))
 
+
+(test-assert "crate-lockfile-import"
+  (begin
+    (call-with-output-file temp-file
+      (lambda (port)
+        (display "\
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = \"adler2\"
+version = \"2.0.0\"
+source = \"registry+https://github.com/rust-lang/crates.io-index\"
+checksum = \"512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627\"
+
+[[package]]
+name = \"aho-corasick\"
+version = \"1.1.3\"
+source = \"registry+https://github.com/rust-lang/crates.io-index\"
+checksum = \"8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916\"
+dependencies = [
+ \"memchr\",
+]
+
+[[package]]
+name = \"smithay\"
+version = \"0.4.0\"
+source = \"git+https://github.com/Smithay/smithay.git?rev=\
+0cd3345c59f7cb139521f267956a1a4e33248393#\
+0cd3345c59f7cb139521f267956a1a4e33248393\"
+dependencies = [
+ \"appendlist\",
+]
+
+[[package]]
+name = \"test\"
+version = \"25.2.0\"\n" port)))
+    (mock
+     ((guix scripts download) guix-download
+      (lambda _
+        (format #t "~a~%~a~%"
+                "/gnu/store/in056fyrz6nvy3jpxrxglgj30g0lwniv-smithay-0cd3345"
+                "191h87bpzg0l1ihfb4hmx00b86pfb5mwwc6s8i49al0vigc14l37")))
+     (let-values
+         (((crates-definitions input-list)
+           (cargo-lock->definitions temp-file "test")))
+       (and
+        (match crates-definitions
+          (((define 'rust-adler2-2.0.0
+              (crate-source
+               "adler2" "2.0.0"
+               "09r6drylvgy8vv8k20lnbvwq8gp09h7smfn6h1rxsy15pgh629si"))
+            (define 'rust-aho-corasick-1.1.3
+              (crate-source
+               "aho-corasick" "1.1.3"
+               "05mrpkvdgp5d20y2p989f187ry9diliijgwrs254fs9s1m1x6q4f"))
+            (define 'rust-smithay-0.4.0.0cd3345
+              ($ <comment>
+                 ";; TODO: Define standalone package if this is a workspace.\n"
+                 #f)
+              (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/Smithay/smithay.git")
+                      (commit "0cd3345c59f7cb139521f267956a1a4e33248393")))
+                (file-name (git-file-name "rust-smithay" "0.4.0.0cd3345"))
+                (sha256
+                 (base32
+                  "191h87bpzg0l1ihfb4hmx00b86pfb5mwwc6s8i49al0vigc14l37")))))
+           #t)
+          (x
+           (pk 'fail (pretty-print-with-comments (current-output-port) x) #f)))
+        (match input-list
+          ((define-public 'test-cargo-inputs
+             (list rust-adler2-2.0.0
+                   rust-aho-corasick-1.1.3
+                   rust-smithay-0.4.0.0cd3345))
+           #t)
+          (x
+           (pk 'fail x #f))))))))
+
 (test-end "crate")
+
+(false-if-exception (delete-file temp-file))
-- 
2.48.1





Information forwarded to hako@HIDDEN, guix@HIDDEN, divya@HIDDEN, efraim@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, maxim.cournoyer@HIDDEN, zimon.toutoune@HIDDEN, steve@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:26:59 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 03:26:58 2025
Received: from localhost ([127.0.0.1]:35941 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuRLk-0004mJ-1i
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:26:58 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:39306)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuRLK-0004i6-1a
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:26:32 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742282788;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=cf59W6KffTl6mWAaIPklzAyqdmp+Dj1qOd4/4qF6zPY=;
 b=hLlVxc9xVcS2+roUwi72g3u6l0rBij5Idy2XgSj/VuCjPDCQ8ZFBw4qtMTv+G8zwRVA3uz
 5gO2ALbv6Z2qWvfj0mS+paqlJ/bbOIxXU5/E+tI2DxicSgptbXA30ZsY+DMOoQ3SyISg32
 nkoTHAd1CS8n3u3NPk+um0+6hV9UdG+pKd+qD7s7xh/JqyddEKuofH9hoha/+v9AIJX8ws
 3KihWjq5E3SCoD82xO4IUann9E6ZtWAZocMExgECaK3uSJ/YlSY1zcR3FjMAS/tJsseSOj
 47iOQ9y7Q4gMjrenf9iTc35GXUkbBem54EWIlNkYl6ZP3WPWHWHUhib9MDoCfA==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team 16/18] import: crate: Add Cargo.lock parser.
Date: Tue, 18 Mar 2025 15:24:29 +0800
Message-ID: <62e0504e8c284b261d8d59b9b2ce73a64c279e71.1742281797.git.hako@HIDDEN>
In-Reply-To: <cover.1742281797.git.hako@HIDDEN>
References: <cover.1742281797.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Hilton Chain <hako@HIDDEN>,
 Divya Ranjan Pattanaik <divya@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>, Steve George <steve@HIDDEN>
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Murilo <murilo@HIDDEN>, Hilton Chain <hako@HIDDEN>,
 Luis Guilherme Coelho <lgcoelho@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/import/crate/cargo-lock.scm: New file.
* Makefile.am (MODULES): Regisiter it.
* guix/import/crate.scm (cargo-lock->definitions): New procedure.

Co-authored-by: Murilo <murilo@HIDDEN>
Co-authored-by: Luis Guilherme Coelho <lgcoelho@HIDDEN>
Change-Id: I95421e9e2ba11a671b4bc4e1323c6d31a1b012c5
---
 Makefile.am                      |   1 +
 guix/import/crate.scm            |  78 +++++++++++++++++++++++
 guix/import/crate/cargo-lock.scm | 105 +++++++++++++++++++++++++++++++
 3 files changed, 184 insertions(+)
 create mode 100644 guix/import/crate/cargo-lock.scm

diff --git a/Makefile.am b/Makefile.am
index 4091a52387..a04e461ea8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -295,6 +295,7 @@ MODULES =					\
   guix/import/cpan.scm				\
   guix/import/cran.scm				\
   guix/import/crate.scm				\
+  guix/import/crate/cargo-lock.scm		\
   guix/import/egg.scm   			\
   guix/import/elm.scm				\
   guix/import/elpa.scm   			\
diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index a6f247bbae..ef3a6d0b4b 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -9,6 +9,9 @@
 ;;; Copyright © 2023, 2024 David Elsing <david.elsing@HIDDEN>
 ;;; Copyright © 2024 Maxim Cournoyer <maxim.cournoyer@HIDDEN>
 ;;; Copyright © 2025 Herman Rimm <herman@HIDDEN>
+;;; Copyright © 2024 Murilo <murilo@HIDDEN>
+;;; Copyright © 2024-2025 Luis Guilherme Coelho <lgcoelho@HIDDEN>
+;;; Copyright © 2025 Hilton Chain <hako@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -26,12 +29,14 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (guix import crate)
+  #:use-module (guix base16)
   #:use-module (guix base32)
   #:use-module ((guix build-system cargo) #:hide (crate-source))
   #:use-module (guix diagnostics)
   #:use-module (gcrypt hash)
   #:use-module (guix http-client)
   #:use-module (guix i18n)
+  #:use-module (guix import crate cargo-lock)
   #:use-module (guix import json)
   #:use-module (guix import utils)
   #:use-module (guix memoization)
@@ -39,9 +44,11 @@ (define-module (guix import crate)
   #:use-module (guix read-print)
   #:use-module (guix upstream)
   #:use-module (guix utils)
+  #:use-module (guix scripts download)
   #:use-module (gnu packages)
   #:use-module (ice-9 match)
   #:use-module (ice-9 regex)
+  #:use-module (ice-9 textual-ports)
   #:use-module (json)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-2)
@@ -52,6 +59,7 @@ (define-module (guix import crate)
             guix-package->crate-name
             string->license
             crate-recursive-import
+            cargo-lock->definitions
             %crate-updater))
 
 
@@ -481,6 +489,76 @@ (define (guix-package->crate-name package)
     (match parts
       ((name _ ...) name))))
 
+
+;;;
+;;; Convert ‘Cargo.lock’ to Guix sources.
+;;;
+
+(define (cargo-lock->definitions lockfile package-name)
+  "Given LOCKFILE, a 'Cargo.lock' file, convert its content into source
+definitions.  Return a list of sources and 'PACKAGE-NAME-cargo-inputs', an input
+list referencing all imported sources."
+  (define (crate->definition crate)
+    (match crate
+      (('crate
+        ('crate-name name)
+        ('crate-version version)
+        ('crate-source _)
+        ('crate-checksum checksum))
+       `(define
+          ,(string->symbol
+            (string-append (crate-name->package-name name) "-" version))
+          ,@(if (or (string-suffix? "src" name)
+                    (string-suffix? "sys" name))
+                (list (comment ";; TODO: Check bundled sources.\n" #f))
+                '())
+          (crate-source ,name ,version
+                        ,(bytevector->nix-base32-string
+                          (base16-string->bytevector checksum)))))
+      ;; Git snapshot.
+      (('crate
+        ('crate-name name)
+        ('crate-version version)
+        ('crate-source source))
+       (begin
+         (let* ((src (string-split source (char-set #\+ #\? #\#)))
+                (url (second src))
+                (commit (last src))
+                (version (string-append version "." (string-take commit 7)))
+                (checksum
+                 (second
+                  (string-split
+                   (with-output-to-string
+                     (lambda _
+                       (guix-download "-g" url
+                                      (string-append "--commit=" commit))))
+                   #\newline))))
+           `(define
+              ,(string->symbol
+                (string-append (crate-name->package-name name) "-" version))
+              ,(comment
+                ";; TODO: Define standalone package if this is a workspace.\n"
+                #f)
+              (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url ,url)
+                      (commit ,commit)))
+                (file-name
+                 (git-file-name ,(crate-name->package-name name) ,version))
+                (sha256 (base32 ,checksum)))))))
+      ;; Workspace member.
+      (else #f)))
+
+  (let ((definitions
+          (filter-map crate->definition
+                      (cargo-lock-string->scm
+                       (call-with-input-file lockfile get-string-all)))))
+    (values definitions
+            `(define-public
+               ,(string->symbol (string-append package-name "-cargo-inputs"))
+               (list ,@(map second definitions))))))
+
 
 ;;;
 ;;; Updater
diff --git a/guix/import/crate/cargo-lock.scm b/guix/import/crate/cargo-lock.scm
new file mode 100644
index 0000000000..b8a6ab20c0
--- /dev/null
+++ b/guix/import/crate/cargo-lock.scm
@@ -0,0 +1,105 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2024 Murilo <murilo@HIDDEN>
+;;; Copyright © 2024 Luis Guilherme Coelho <lgcoelho@HIDDEN>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix import crate cargo-lock)
+  #:use-module (ice-9 peg)
+  #:export (cargo-lock-string->scm
+
+            crate-name
+            crate-version
+            crate-source
+            crate-checksum
+            crate-dependencies
+            cargo-lock))
+
+;;;
+;;; PEG parser for ‘Cargo.lock’.
+;;;
+
+(define (cargo-lock-string->scm str)
+  (peg:tree (search-for-pattern cargo-lock str)))
+
+;; Auxiliar peg patterns
+(define-peg-pattern numeric-char body
+  (range #\0 #\9))
+
+(define-peg-pattern lowercase-char body
+  (range #\a #\z))
+
+(define-peg-pattern uppercase-char body
+  (range #\A #\Z))
+
+(define-peg-pattern alphabetic-char body
+  (or lowercase-char uppercase-char))
+
+(define-peg-pattern alphanumeric-char body
+  (or alphabetic-char numeric-char))
+
+;; name
+(define-peg-pattern crate-name all
+  (+ (or "-" alphabetic-char
+         "_" numeric-char)))
+
+;; version
+(define-peg-pattern non-negative-integer body
+  (+ numeric-char))
+
+(define-peg-pattern crate-version all
+  (and non-negative-integer "."
+       non-negative-integer "."
+       non-negative-integer
+       (? (+ (or "-" lowercase-char
+                 "." uppercase-char
+                 "+" numeric-char "_")))))
+
+;; source
+(define-peg-pattern crate-source all
+  (and (or "registry" "git")
+       "+https://"
+       (+ (or "/" "." "?" "=" "-" "#" "_"
+              alphanumeric-char))))
+
+;; checksum
+(define-peg-pattern crate-checksum all
+  (+ (or lowercase-char numeric-char)))
+
+;; dependency specification
+(define-peg-pattern dependency-specification all
+  (and crate-name (? (and (ignore " ") crate-version))))
+
+;; dependencies
+(define-peg-pattern crate-dependencies all
+  (and (ignore "[\n")
+       (+ (and (ignore " \"")
+               (capture dependency-specification)
+               (ignore "\",\n")))
+       (ignore "]")))
+
+;; crates
+(define-peg-pattern crate all
+  (and (ignore "[[package]]\n")
+       (ignore "name = \"") (capture crate-name) (ignore "\"\n")
+       (ignore "version = \"") (capture crate-version) (ignore "\"\n")
+       (? (and (ignore "source = \"") (capture crate-source) (ignore "\"\n")))
+       (? (and (ignore "checksum = \"") (capture crate-checksum) (ignore "\"\n")))
+       (? (ignore (and "dependencies = " crate-dependencies "\n")))))
+
+;; Cargo.lock
+(define-peg-pattern cargo-lock all
+  (+ (and (ignore "\n") crate)))
-- 
2.48.1





Information forwarded to hako@HIDDEN, divya@HIDDEN, efraim@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:26:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 03:26:56 2025
Received: from localhost ([127.0.0.1]:35939 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuRLh-0004lw-7F
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:26:55 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:39294)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuRLF-0004h6-Hx
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:26:27 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742282784;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=cM5fQi5K4lwBJ78ozo82ZN0cgMrgMJeJ69wt4C0ZkjI=;
 b=ghbKCKSAFK4MEuFnbA37pvPg7pmwqGym4vbGYUPaf04El46EQlwze78RJMbeABo91oyYEL
 pjIIA0AiWW35Sjgmavvvjet2QBHQpvWMHPMwGzyQAFEBiZuBq0rDEjIBpLXSqGzXOKUAUK
 AeZR4Tt5MDxFcomZ8tlyV1c4Xoax0Rg5MEriWIk9ob2AnKpf3xrffNUu3cTvZThWQPu8LN
 KqpCWf12EbF55vpbxZ3DyUbCq1E5zMkD7JqVODO8zH4ZxYYDmihmsFouzhfO4IP1YXSoGG
 JDuI+oArt3C7wFTeKBXW5xZn0gszfOTO95T9Eq7EczZsU70HQMspG6wfI3+9sA==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team 15/18] =?UTF-8?q?build-system:=20cargo:=20Add=20?=
 =?UTF-8?q?=E2=80=98cargo-inputs=E2=80=99.?=
Date: Tue, 18 Mar 2025 15:24:28 +0800
Message-ID: <03e00920c3108fb1b26f528e64f4ca8d77780baf.1742281797.git.hako@HIDDEN>
In-Reply-To: <cover.1742281797.git.hako@HIDDEN>
References: <cover.1742281797.git.hako@HIDDEN>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
X-Debbugs-Cc: Hilton Chain <hako@HIDDEN>,
 Divya Ranjan Pattanaik <divya@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>, Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* gnu/packages/rust-crates.scm: New file.
* gnu/packages/rust-sources.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Regisiter them.
* guix/build-system/cargo.scm (crate-source,cargo-inputs): New procedures.
* guix/import/crate.scm: Hide ‘crate-source’ from (guix build-system cargo).
* etc/teams/rust/cleanup-crates.sh: New file.
* etc/teams/rust/rust-crates.tmpl: New file.

Change-Id: I2f2d705a3e376ed3c646f31b824052a2278d4fb3
---
 etc/teams/rust/cleanup-crates.sh | 38 +++++++++++++++++++++++++++
 etc/teams/rust/rust-crates.tmpl  | 42 +++++++++++++++++++++++++++++
 gnu/local.mk                     |  2 ++
 gnu/packages/rust-crates.scm     | 42 +++++++++++++++++++++++++++++
 gnu/packages/rust-sources.scm    | 29 ++++++++++++++++++++
 guix/build-system/cargo.scm      | 45 +++++++++++++++++++++++++++++++-
 guix/import/crate.scm            |  2 +-
 7 files changed, 198 insertions(+), 2 deletions(-)
 create mode 100755 etc/teams/rust/cleanup-crates.sh
 create mode 100644 etc/teams/rust/rust-crates.tmpl
 create mode 100644 gnu/packages/rust-crates.scm
 create mode 100644 gnu/packages/rust-sources.scm

diff --git a/etc/teams/rust/cleanup-crates.sh b/etc/teams/rust/cleanup-crates.sh
new file mode 100755
index 0000000000..cd4c2462b9
--- /dev/null
+++ b/etc/teams/rust/cleanup-crates.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+# GNU Guix --- Functional package management for GNU
+# Copyright © 2025 Hilton Chain <hako@HIDDEN>
+#
+# This file is part of GNU Guix.
+#
+# GNU Guix is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or (at
+# your option) any later version.
+#
+# GNU Guix is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+FILE=gnu/packages/rust-crates.scm
+PATTERN='^(define rust-'
+
+grep "$PATTERN" $FILE | cut -d' ' -f2 | while IFS= read -r crate
+do
+    if [ "$(grep -wc "$crate" $FILE)" -eq 1 ]; then
+        echo "\
+(begin
+  (use-modules (guix utils))
+  (let ((source-properties
+         (find-definition-location \"$FILE\" '$crate #:definer 'define)))
+    (and=> source-properties delete-expression)))" |
+            guix repl -t machine
+    fi
+done
+
+# Delete extra newlines.
+sed --in-place ':a;N;$!ba;s/\n\n\+/\n\n/g' $FILE
diff --git a/etc/teams/rust/rust-crates.tmpl b/etc/teams/rust/rust-crates.tmpl
new file mode 100644
index 0000000000..98053b7151
--- /dev/null
+++ b/etc/teams/rust/rust-crates.tmpl
@@ -0,0 +1,42 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2025 Hilton Chain <hako@HIDDEN>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages rust-crates)
+  #:use-module (guix gexp)
+  #:use-module (guix packages)
+  #:use-module (guix download)
+  #:use-module (guix git-download)
+  #:use-module (guix build-system cargo))
+
+;;;
+;;; This file is managed by ‘guix import’.  DO NOT add definitions manually.
+;;;
+
+;;;
+;;; Rust dependencies fetched from crates.io and non-workspace development
+;;; snapshots.
+;;;
+
+(define qqqq-separator 'begin-of-crates)
+
+(define ssss-separator 'end-of-crates)
+
+
+;;;
+;;; Cargo inputs.
+;;;
diff --git a/gnu/local.mk b/gnu/local.mk
index 02de02e65f..8d8bd6ebbe 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -616,6 +616,8 @@ GNU_SYSTEM_MODULES =				\
   %D%/packages/rush.scm				\
   %D%/packages/rust.scm				\
   %D%/packages/rust-apps.scm			\
+  %D%/packages/rust-crates.scm			\
+  %D%/packages/rust-sources.scm			\
   %D%/packages/samba.scm			\
   %D%/packages/sagemath.scm			\
   %D%/packages/sawfish.scm			\
diff --git a/gnu/packages/rust-crates.scm b/gnu/packages/rust-crates.scm
new file mode 100644
index 0000000000..98053b7151
--- /dev/null
+++ b/gnu/packages/rust-crates.scm
@@ -0,0 +1,42 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2025 Hilton Chain <hako@HIDDEN>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages rust-crates)
+  #:use-module (guix gexp)
+  #:use-module (guix packages)
+  #:use-module (guix download)
+  #:use-module (guix git-download)
+  #:use-module (guix build-system cargo))
+
+;;;
+;;; This file is managed by ‘guix import’.  DO NOT add definitions manually.
+;;;
+
+;;;
+;;; Rust dependencies fetched from crates.io and non-workspace development
+;;; snapshots.
+;;;
+
+(define qqqq-separator 'begin-of-crates)
+
+(define ssss-separator 'end-of-crates)
+
+
+;;;
+;;; Cargo inputs.
+;;;
diff --git a/gnu/packages/rust-sources.scm b/gnu/packages/rust-sources.scm
new file mode 100644
index 0000000000..bf9b91a671
--- /dev/null
+++ b/gnu/packages/rust-sources.scm
@@ -0,0 +1,29 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2025 Hilton Chain <hako@HIDDEN>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages rust-sources)
+  #:use-module (guix gexp)
+  #:use-module (guix packages)
+  #:use-module (guix download)
+  #:use-module (guix git-download)
+  #:use-module (guix build-system cargo))
+
+;;;
+;;; Cargo workspaces and Rust dependencies requiring external inputs to
+;;; unbundle.
+;;;
diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
index 7a07003262..47d4f10969 100644
--- a/guix/build-system/cargo.scm
+++ b/guix/build-system/cargo.scm
@@ -31,6 +31,7 @@ (define-module (guix build-system cargo)
   #:use-module (guix gexp)
   #:use-module (guix monads)
   #:use-module (guix packages)
+  #:use-module (guix download)
   #:use-module (guix platform)
   #:use-module (guix build-system)
   #:use-module (guix build-system gnu)
@@ -45,7 +46,9 @@ (define-module (guix build-system cargo)
             crate-url
             crate-url?
             crate-uri
-            crate-name->package-name))
+            crate-name->package-name
+            crate-source
+            cargo-inputs))
 
 (define %crate-base-url
   (make-parameter "https://crates.io"))
@@ -62,6 +65,46 @@ (define (crate-uri name version)
 (define (crate-name->package-name name)
   (downstream-package-name "rust-" name))
 
+(define* (crate-source name version hash #:key (patches '()) (snippet #f))
+  (origin
+    (method url-fetch)
+    (uri (crate-uri name version))
+    (file-name
+     (string-append (crate-name->package-name name) "-" version ".tar.gz"))
+    (sha256 (base32 hash))
+    (modules '((guix build utils)))
+    (patches patches)
+    (snippet snippet)))
+
+(define* (cargo-inputs name #:key (crates-module '(gnu packages rust-crates))
+                       (sources-module '(gnu packages rust-sources)))
+  "Given NAME, resolve input list 'NAME-cargo-inputs' in CRATES-MODULE, return
+its copy with #f removed and symbols resolved to variables defined in
+SOURCES-MODULE, if the list exists, otherwise return an empty list."
+  (let loop ((inputs
+              (catch #t
+                (lambda ()
+                  (module-ref (resolve-interface crates-module)
+                              (symbol-append name '-cargo-inputs)))
+                (const '())))
+             (result '()))
+    (if (null? inputs)
+        result
+        (match inputs
+          ((input . rest)
+           (loop rest
+                 (cond
+                  ;; #f, remove it.
+                  ((not input)
+                   result)
+                  ;; Symbol, resolve it in SOURCES-MODULE.
+                  ((symbol? input)
+                   (cons (module-ref (resolve-interface sources-module) input)
+                         result))
+                  ;; Else: no change.
+                  (else
+                   (cons input result)))))))))
+
 (define (default-rust target)
   "Return the default Rust package."
   ;; Lazily resolve the binding to avoid a circular dependency.
diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index 14e6e28c5b..a6f247bbae 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -27,7 +27,7 @@
 
 (define-module (guix import crate)
   #:use-module (guix base32)
-  #:use-module (guix build-system cargo)
+  #:use-module ((guix build-system cargo) #:hide (crate-source))
   #:use-module (guix diagnostics)
   #:use-module (gcrypt hash)
   #:use-module (guix http-client)
-- 
2.48.1





Information forwarded to hako@HIDDEN, divya@HIDDEN, efraim@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:26:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 03:26:53 2025
Received: from localhost ([127.0.0.1]:35937 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuRLg-0004ld-4Q
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:26:53 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:51946)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuRLB-0004ga-M4
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:26:22 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742282780;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=geOOtBEsBNx2ONmmiPLL/kMPcijDpsDJ3ulRZK3Fa/w=;
 b=QoSgfQxe8jPxOCzGdRxFZC7CqABcXmrCV2O931V0FaSaosD7lcXjtzGcj3EyBxNPnRB1mk
 l4hEYrvRNU6EDgGgbt6lQ8lLuVvJBQRLvWPcZmgDlKbzpxFjr2j/7pZ5UszNhmygj/uDcj
 w09SIdNT/RKta2VPK68cAeD0SvDxFWV9Cm+5dtJj8zfAaMr8OOX4RsuUO/c/IhOKIk4cI+
 Pe872gbJI61o5yMzibn7hAyAsKKbD1VnOjNWhe6E7HTfoInYoS/58KnGAJkds/QZG6f3+e
 8S9qtXo/z8YJE1qEnFQ1RHKRrY2U2Nmm3HyePNz62Oip8q+OZ79njce66WgWLA==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team 14/18] import: crate: crate-name->package-name: Move
 to (guix build-system cargo).
Date: Tue, 18 Mar 2025 15:24:27 +0800
Message-ID: <ccc3aed299cbb30c346e6a3ebc14e6c4d685562a.1742281797.git.hako@HIDDEN>
In-Reply-To: <cover.1742281797.git.hako@HIDDEN>
References: <cover.1742281797.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Hilton Chain <hako@HIDDEN>,
 Divya Ranjan Pattanaik <divya@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>, Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/import/crate.scm (crate-name->package-name): Move to...
* guix/build-system/cargo.scm (crate-name->package-name): ...here and export.

Change-Id: Ie9813179d6c40d159956cc1e2ae59a74dea0a42d
---
 guix/build-system/cargo.scm | 6 +++++-
 guix/import/crate.scm       | 5 -----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
index 4486c706a1..7a07003262 100644
--- a/guix/build-system/cargo.scm
+++ b/guix/build-system/cargo.scm
@@ -44,7 +44,8 @@ (define-module (guix build-system cargo)
             %crate-base-url
             crate-url
             crate-url?
-            crate-uri))
+            crate-uri
+            crate-name->package-name))
 
 (define %crate-base-url
   (make-parameter "https://crates.io"))
@@ -58,6 +59,9 @@ (define (crate-uri name version)
 to NAME and VERSION."
   (string-append crate-url name "/" version "/download"))
 
+(define (crate-name->package-name name)
+  (downstream-package-name "rust-" name))
+
 (define (default-rust target)
   "Return the default Rust package."
   ;; Lazily resolve the binding to avoid a circular dependency.
diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index 5a8caeb3e1..14e6e28c5b 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -481,10 +481,6 @@ (define (guix-package->crate-name package)
     (match parts
       ((name _ ...) name))))
 
-(define (crate-name->package-name name)
-  (downstream-package-name "rust-" name))
-
-
 
 ;;;
 ;;; Updater
@@ -528,4 +524,3 @@ (define %crate-updater
    (description "Updater for crates.io packages")
    (pred crate-package?)
    (import import-release)))
-
-- 
2.48.1





Information forwarded to hako@HIDDEN, divya@HIDDEN, efraim@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:26:52 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 03:26:52 2025
Received: from localhost ([127.0.0.1]:35935 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuRLf-0004lN-8r
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:26:52 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:45406)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuRL7-0004fy-QF
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:26:18 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742282776;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=5qQlcUDJKcIJRSsAYETyiYSl2VuOHkW+jrIWbdq138k=;
 b=ShrXe/vJRG+8s58sUY0py4enWpGLq3+Sb07jkBahF46m19P95MuG0QfI6wAHmWUBoXjV3D
 oeFp0nETZLfXmB9lFhN392MzDe8AXVYJKLH/PAZHzMbQVkV9C1c8n22tzMQ7m92JYsTKuH
 H9VCcK2L412UJ896YHRF8nrKXwrpsBKg21028TZUMCEkXXLK+CinC2fUV76pVOSH+7RLSx
 g7jvHagqUSlwHHG8X+jSZJ3CS68CwzxhuCJR43TKlOkiuBOKqeLp0ibrOdtOhjtpoox/2M
 TaBlth5Qpgvd58JqRKhpJkln14ziNtGGwxQ2snl2Hur3hRmI/YUoMwMiHBe8tg==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team 13/18] =?UTF-8?q?scripts:=20import:=20Skip=20exi?=
 =?UTF-8?q?sting=20definition=20for=20=E2=80=98--insert=E2=80=99=20option.?=
Date: Tue, 18 Mar 2025 15:24:26 +0800
Message-ID: <3ee5a87b5fafdd42516307d25f3dea62144781d4.1742281797.git.hako@HIDDEN>
In-Reply-To: <cover.1742281797.git.hako@HIDDEN>
References: <cover.1742281797.git.hako@HIDDEN>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
X-Debbugs-Cc: Hilton Chain <hako@HIDDEN>, Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/scripts/import.scm (guix-import): Skip existing definition for
‘--insert’ option.

Change-Id: I2c4242669f974b263a018ab0cf56538bd7c81d06
---
 guix/scripts/import.scm | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index 1b2c35f3b1..d8e1ed3e6f 100644
--- a/guix/scripts/import.scm
+++ b/guix/scripts/import.scm
@@ -137,16 +137,18 @@ (define-command (guix-import . args)
              (lambda (expr)
                (match expr
                  (((? definer? definer) term _ ...)
-                  (let ((source-properties
-                          (find-definition-insertion-location
+                  ;; Skip existing definition.
+                  (unless (find-definition-location file term #:definer definer)
+                    (let ((source-properties
+                           (find-definition-insertion-location
                             file term #:definer definer)))
-                    (if source-properties
-                      (insert-expression source-properties expr)
-                      (let ((port (open-file file "a")))
-                        (pretty-print-with-comments port expr)
-                        (newline port)
-                        (newline port)
-                        (close-port port)))))))))
+                      (if source-properties
+                          (insert-expression source-properties expr)
+                          (let ((port (open-file file "a")))
+                            (pretty-print-with-comments port expr)
+                            (newline port)
+                            (newline port)
+                            (close-port port))))))))))
        (import-as-definitions importer
                               (cons (string-append "--file-to-insert=" file)
                                     args)
-- 
2.48.1





Information forwarded to hako@HIDDEN, guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:26:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 03:26:51 2025
Received: from localhost ([127.0.0.1]:35933 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuRLe-0004lF-RN
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:26:51 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:51942)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuRL4-0004fj-KB
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:26:15 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742282773;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=CNgyHv90mI9Vh7ZD/xKVMWo0WFpglx6Sc5wNnUT5ayI=;
 b=U23p4hCHt0uVFByDj0ErM+NyiTE66vt+0R3esVq8MMPhesHF5mRcxqYQ6YCsn44bc7komk
 lMwPHOOf8ueML9/LcFVwEnm2IRU8k4yElZB8aboKXDl0vFUI/jkMU7aILp7gOK+DMSfoy8
 4KyP6jiiJQFmHYEXoDgF6ih6saGqD+styXEx1gzGo+xrZbovOkozznuKQIRKeI3CehndMu
 +dl7AnSohvu//ZVnMSpMtPgwx1kkLnQMaRFYHWL85GDA9peIyWcIyXSt0BR/wn0S6iaegz
 dhESGopEkwOUGzzCKv1AjN6f51ID0I03z82pBfWWGV46a71r+E1a6tsGcvVwtg==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team 12/18] scripts: import: Pass "--insert" to importers.
Date: Tue, 18 Mar 2025 15:24:25 +0800
Message-ID: <64fd1ae561f6d188d599c54fe57710caabacf759.1742281797.git.hako@HIDDEN>
In-Reply-To: <cover.1742281797.git.hako@HIDDEN>
References: <cover.1742281797.git.hako@HIDDEN>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
X-Debbugs-Cc: Hilton Chain <hako@HIDDEN>, Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

So that importers can adjust the file before inserting.

* guix/scripts/import.scm (%standard-import-options): Add ‘--file-to-insert’.
(guix-import): Pass it to importers when ‘--insert’ is set.

Change-Id: I8e7a18ee8e0f96d7fc5688a207a7a5390ad2fa30
---
 guix/scripts/import.scm | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index aaa3d26673..1b2c35f3b1 100644
--- a/guix/scripts/import.scm
+++ b/guix/scripts/import.scm
@@ -31,6 +31,7 @@ (define-module (guix scripts import)
   #:use-module (guix utils)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
+  #:use-module (srfi srfi-37)
   #:use-module (ice-9 format)
   #:use-module (ice-9 match)
   #:export (%standard-import-options
@@ -41,7 +42,12 @@ (define-module (guix scripts import)
 ;;; Command line options.
 ;;;
 
-(define %standard-import-options '())
+(define %standard-import-options
+  (list
+   ;; Hidden option for importer-specific file preprocessing.
+   (option '("file-to-insert") #f #t
+           (lambda (opt name arg result)
+             (alist-cons 'file-to-insert arg result)))))
 
 
 ;;;
@@ -141,7 +147,10 @@ (define-command (guix-import . args)
                         (newline port)
                         (newline port)
                         (close-port port)))))))))
-       (import-as-definitions importer args find-and-insert)))
+       (import-as-definitions importer
+                              (cons (string-append "--file-to-insert=" file)
+                                    args)
+                              find-and-insert)))
     ((importer args ...)
      (let ((print (lambda (expr)
                     (leave-on-EPIPE
-- 
2.48.1





Information forwarded to hako@HIDDEN, guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:26:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 03:26:50 2025
Received: from localhost ([127.0.0.1]:35931 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuRLe-0004l7-Ei
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:26:50 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:60898)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuRKx-0004eH-0H
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:26:08 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742282765;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=q8EtGgJNAcVCCAJm1iKNtDwPxS31GnBy41AJ8jW1jdQ=;
 b=OjA7pfqCMaKy+OtktgkAcdABZnhPHIF0q3dfH1mYIae3oAQEQ5GT7szzq1PwaDt8Gz71o/
 vcraSMatvQdCqVZgU01ETOLP2iMl34asf+hnrAPO/gtkJled5l/yrhxUErl02/VewcPjxq
 e+IMy5lW/il5WRnNOgP9GXZOnLya3IFgnfjtXNcnJu/mER+DMpMJsymd/ha41RA1B11C+N
 Afn0R7Jdj9gpphlQqoL9ZdmGMFUMt7lVTVn2Rrvxbe1NICcKw2yimmP8arjV4+fXfMfGcK
 xvmQffR1lpk2JXiIwz7RYXe2dbZ26PHGW8nmAWWmakVxcul7HCZmCsXfo8GVnQ==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team 10/18] =?UTF-8?q?scripts:=20import:=20Add=20two?=
 =?UTF-8?q?=20newlines=20for=20=E2=80=98--insert=E2=80=99=20option.?=
Date: Tue, 18 Mar 2025 15:24:23 +0800
Message-ID: <4e38cd180a457bcd8ca56b6a6ad58042cef81014.1742281797.git.hako@HIDDEN>
In-Reply-To: <cover.1742281797.git.hako@HIDDEN>
References: <cover.1742281797.git.hako@HIDDEN>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
X-Debbugs-Cc: Hilton Chain <hako@HIDDEN>, Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

For consistency with ‘insert-expression’.

* guix/scripts/import.scm (guix-import): Add two newlines when inserting.

Change-Id: I55b45ca137d175fdf6ee5c0bb2b6b1ca8385750d
---
 guix/scripts/import.scm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index 4fad329cd3..58a84d0db7 100644
--- a/guix/scripts/import.scm
+++ b/guix/scripts/import.scm
@@ -129,6 +129,7 @@ (define-command (guix-import . args)
                       (let ((port (open-file file "a")))
                         (pretty-print-with-comments port expr)
                         (newline port)
+                        (newline port)
                         (close-port port)))))))))
        (import-as-definitions importer args find-and-insert)))
     ((importer args ...)
-- 
2.48.1





Information forwarded to hako@HIDDEN, guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:26:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 03:26:50 2025
Received: from localhost ([127.0.0.1]:35929 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuRLc-0004kp-HZ
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:26:50 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:49398)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuRL0-0004fO-Cl
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:26:10 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742282769;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=+/srC+Epo38ycQfk6D22nsIOCLinapf8wmQlHm5t+vg=;
 b=UmtSNoWHFTnrTp24la7RmU9XCpsJiYfTB13simxF3whRInNcCy063jnijP9R53SaFlQ43h
 BX5Y3xW1xFSt1wPTDQkkMHxWMawC79D1KhYfZymv5v+ui0ilAGkgJkudwU0V29Ftg8aqAI
 0+FiTBO8ZmTtVxiWR5tI1DZ4dB2yzr2WiUm8RQQyyex0Lvz/Wwhavvlyi05Z7SbBJGvCBI
 OJ1oYW+iajrJTZfbCZj4Jv2KMZdqXv3MQu/nimPSszdq2wHxlt9GwJqao8b1+bsmc7qNgE
 yufa+KHuCrO5hbxq1hwqr4e20EaoyOgcdQaW2BuxtgN2yTRkWT6WCkABj+MXyg==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team 11/18] scripts: import: Support expressions defined
 by 'define.
Date: Tue, 18 Mar 2025 15:24:24 +0800
Message-ID: <c185c0310885a4fcce6df3bcf52bb2cd00abd79f.1742281797.git.hako@HIDDEN>
In-Reply-To: <cover.1742281797.git.hako@HIDDEN>
References: <cover.1742281797.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Hilton Chain <hako@HIDDEN>, Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/utils.scm (find-definition-location): New procedure.
(find-definition-insertion-location): Define with it.
* guix/scripts/import.scm (import-as-definitions, guix-import): Support
expressions defined by 'define.

Change-Id: I03118e1a3372028b4f0530964aba871b4a1a4d25
---
 guix/scripts/import.scm | 20 +++++++++++++++-----
 guix/utils.scm          | 27 +++++++++++++++++++--------
 2 files changed, 34 insertions(+), 13 deletions(-)

diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index 58a84d0db7..aaa3d26673 100644
--- a/guix/scripts/import.scm
+++ b/guix/scripts/import.scm
@@ -30,6 +30,7 @@ (define-module (guix scripts import)
   #:use-module (guix read-print)
   #:use-module (guix utils)
   #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-26)
   #:use-module (ice-9 format)
   #:use-module (ice-9 match)
   #:export (%standard-import-options
@@ -83,7 +84,8 @@ (define (import-as-definitions importer args proc)
         ((and expr (or ('package _ ...)
                        ('let _ ...)))
          (proc (package->definition expr)))
-        ((and expr ('define-public _ ...))
+        ((and expr (or ('define-public _ ...)
+                       ('define _ ...)))
          (proc expr))
         ((expressions ...)
          (for-each (lambda (expr)
@@ -91,7 +93,8 @@ (define (import-as-definitions importer args proc)
                        ((and expr (or ('package _ ...)
                                       ('let _ ...)))
                         (proc (package->definition expr)))
-                       ((and expr ('define-public _ ...))
+                       ((and expr (or ('define-public _ ...)
+                                      ('define _ ...)))
                         (proc expr))))
                    expressions))
         (x
@@ -117,13 +120,20 @@ (define-command (guix-import . args)
      (show-version-and-exit "guix import"))
     ((or ("-i" file importer args ...)
          ("--insert" file importer args ...))
-     (let ((find-and-insert
+     (let* ((definer?
+              (cut member
+                   <>
+                   `(,@(if (member importer '("crate"))
+                           '(define)
+                           '())
+                     define-public)))
+            (find-and-insert
              (lambda (expr)
                (match expr
-                 (('define-public term _ ...)
+                 (((? definer? definer) term _ ...)
                   (let ((source-properties
                           (find-definition-insertion-location
-                            file term)))
+                            file term #:definer definer)))
                     (if source-properties
                       (insert-expression source-properties expr)
                       (let ((port (open-file file "a")))
diff --git a/guix/utils.scm b/guix/utils.scm
index c7c23d9d5b..77ec6d992a 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -154,6 +154,7 @@ (define-module (guix utils)
             edit-expression
             delete-expression
             insert-expression
+            find-definition-location
             find-definition-insertion-location
 
             filtered-port
@@ -520,24 +521,34 @@ (define (insert-expression source-properties expr)
                    (string-append expr "\n\n" str))))
     (edit-expression source-properties insert)))
 
-(define (find-definition-insertion-location file term)
-  "Search in FILE for a top-level public definition whose defined term
-alphabetically succeeds TERM. Return the location if found, or #f
-otherwise."
-  (let ((search-term (symbol->string term)))
+(define* (find-definition-location file term
+                                   #:key (definer 'define-public)
+                                   (pred string=))
+  "Search in FILE for a top-level definition defined by DEFINER with defined
+term comparing to TERM through PRED.  Return the location if PRED returns #t,
+or #f otherwise."
+  (let ((search-term (symbol->string term))
+        (definer? (cut eq? definer <>)))
     (call-with-input-file file
       (lambda (port)
         (do ((syntax (read-syntax port)
                      (read-syntax port)))
           ((match (syntax->datum syntax)
-             (('define-public current-term _ ...)
-              (string> (symbol->string current-term)
-                       search-term))
+             (((? definer?) current-term _ ...)
+              (pred (symbol->string current-term)
+                    search-term))
              ((? eof-object?) #t)
              (_ #f))
            (and (not (eof-object? syntax))
                 (syntax-source syntax))))))))
 
+(define* (find-definition-insertion-location file term
+                                             #:key (definer 'define-public))
+  "Search in FILE for a top-level definition defined by DEFINER with defined
+term alphabetically succeeds TERM. Return the location if found, or #f
+otherwise."
+  (find-definition-location file term #:definer definer #:pred string>))
+
 
 ;;;
 ;;; Keyword arguments.
-- 
2.48.1





Information forwarded to hako@HIDDEN, guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:26:49 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 03:26:48 2025
Received: from localhost ([127.0.0.1]:35927 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuRLb-0004ka-L1
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:26:48 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:49384)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuRKt-0004dY-Rh
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:26:05 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742282762;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=0gATDkYY9+HlIpSIiMsJydmF48/8/FeFvqFI8MW5iOs=;
 b=Z8Id8bH3uHeakn/XgrZBY0RiQc0sR+UhzeaAdHmCSSj0fjX3U7hHXPsWVLSKuy5FdHCJvA
 sVs3DeyVVSBF6px0UqfC2jyiouYmERiQRGkOL2EVEDLWT712V5KdP9NxG9PW8rRPWmqyyQ
 2RHAf7uPNmDs+CTNLk1u6F89H1hlYGkBHV/To0axjO7psJ8eVqstGRSRbBBsruhnpEn55j
 5Xs/u+JFxcAKFjikskkq8/YfFuQ6go2qDMganbMN03Qg+Le8re1yi8/sHvUPLshDd13VyK
 WOwduHmUW/4ZivH+C2/G4OVqLGoyEGGysfzl9AnzJv+5eSZiAIpqY9T555khQQ==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team 09/18] =?UTF-8?q?scripts:=20import:=20Document?=
 =?UTF-8?q?=20argument=20for=20=E2=80=98--insert=E2=80=99=20option=20in=20?=
 =?UTF-8?q?help=20message.?=
Date: Tue, 18 Mar 2025 15:24:22 +0800
Message-ID: <b53e3a0b4b4b93d44f85a08b857116da687a3b3d.1742281797.git.hako@HIDDEN>
In-Reply-To: <cover.1742281797.git.hako@HIDDEN>
References: <cover.1742281797.git.hako@HIDDEN>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
X-Debbugs-Cc: Hilton Chain <hako@HIDDEN>, Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/scripts/import.scm (show-help): Add missing ‘FILE’.

Change-Id: I540d5feae3fe49c00e9bd6f7a8649ffe0d6e006d
---
 guix/scripts/import.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index bbf31baa15..4fad329cd3 100644
--- a/guix/scripts/import.scm
+++ b/guix/scripts/import.scm
@@ -69,7 +69,7 @@ (define (show-help)
   (display (G_ "
   -h, --help             display this help and exit"))
   (display (G_ "
-  -i, --insert           insert packages into file alphabetically"))
+  -i, --insert=FILE      insert packages into FILE alphabetically"))
   (display (G_ "
   -V, --version          display version information and exit"))
   (newline)
-- 
2.48.1





Information forwarded to hako@HIDDEN, guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:26:20 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 03:26:20 2025
Received: from localhost ([127.0.0.1]:35917 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuRLA-0004gN-18
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:26:20 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:35242)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuRKq-0004cq-3K
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:26:01 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742282758;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=JtVpmvUHYhzQ0fAuHdosNIoIUr6sCxjVGkZ4GtLjbU0=;
 b=IhuuDHNC70TWQ24sQjgHwDabX+Mrvt5YdvXdX9uMA7tu73YVqK/5ERbD6JxTbdRUcyCFXT
 o/z+vav4a0iEEL/8CGumWAT7w2cpAJ/b3mjEk2GO5RjHj9ZPeJmRITv2+ZBEV79vArQC8+
 JJlNAoXWDf8I0ji3pj0mURgatpnj4P3kC/YhXund91PR74rez+XB0GH77ytsXCc9sTqg1o
 xIozzmwGY/8NZGn3lyiJlFqrdWV2ifz/P/Ff5f203Pq2IxB/K/ixDlPm2liCj2DpimSFQF
 D8whyOKBmscAtBWKSmfmeU/g0e+dDfEoCYKx5KSsSb0+sGwAooGIO25dKysX/A==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team 08/18] build/cargo: Use system jemalloc.
Date: Tue, 18 Mar 2025 15:24:21 +0800
Message-ID: <02e5f7ff3d45b516a797c3e68c257748336dbae2.1742281797.git.hako@HIDDEN>
In-Reply-To: <cover.1742281797.git.hako@HIDDEN>
References: <cover.1742281797.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Hilton Chain <hako@HIDDEN>,
 Divya Ranjan Pattanaik <divya@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>, Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

From: Efraim Flashner <efraim@HIDDEN>

* guix/build/cargo-build-system.scm (configure): Set environment variables to
use system jemalloc.

Change-Id: Ibb1c025c7354ba2befd2770e3f1ccd785baa06c3
Modified-by: Hilton Chain <hako@HIDDEN>
---
 guix/build/cargo-build-system.scm | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index a1c4f556bb..b547421b88 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -248,6 +248,12 @@ (define* (configure #:key inputs
   (setenv "LIBSSH2_SYS_USE_PKG_CONFIG" "1")
   (setenv "SODIUM_USE_PKG_CONFIG" "1")
   (setenv "ZSTD_SYS_USE_PKG_CONFIG" "1")
+  ;; This flag is needed when not using the bundled jemalloc.
+  ;; https://github.com/tikv/jemallocator/issues/19
+  (setenv "CARGO_FEATURE_UNPREFIXED_MALLOC_ON_SUPPORTED_PLATFORMS" "1")
+  (when (assoc-ref inputs "jemalloc")
+    (setenv "JEMALLOC_OVERRIDE"
+            (string-append (assoc-ref inputs "jemalloc") "/lib/libjemalloc.so")))
   (when (assoc-ref inputs "openssl")
     (setenv "OPENSSL_DIR" (assoc-ref inputs "openssl")))
   (when (assoc-ref inputs "gettext")
-- 
2.48.1





Information forwarded to hako@HIDDEN, divya@HIDDEN, efraim@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:26:20 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 03:26:20 2025
Received: from localhost ([127.0.0.1]:35915 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuRL9-0004gG-FL
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:26:19 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:49244)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuRKm-0004c0-Dh
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:25:58 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742282754;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=Eoru8qBkNmnrq/dwzDTiX9NodZUnnbpQ/4ZEgXGajKo=;
 b=W91bGfmMPrQ5NzdqeVoVkanARHxEL9GcjKczanCn513fU/Pzogm44EtR4fUGJ1mtdHae6E
 QijWA9Zzh3S6a5/AyAbik3TXnVmofUJiglSaTzTwbwokVEKZbkYQJiyGBQtXWyjATsy4KA
 ngSHeV9RolJRKBLy0FN0Cfh4167xwSCJd9sPL3aGlfSesDvTenZRC4deV4s5DMaZAoyt4d
 8ZAKsnCYXnSMKg8Vk9YkzftLMWbBS/KqE7MiniS2YZYecH+Wr9xtZ5qqUmxM2/tYaAO4mW
 6UvLZYeeWGlle+hwWRQpwRL5SsQC4AjAflOHr88aAM70zvIT0qnF+Ov2kza1LA==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team 07/18] build/cargo: Support non-workspace directory
 source inputs.
Date: Tue, 18 Mar 2025 15:24:20 +0800
Message-ID: <823eafa55e3a10146e0433d099849369395d4771.1742281797.git.hako@HIDDEN>
In-Reply-To: <cover.1742281797.git.hako@HIDDEN>
References: <cover.1742281797.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Hilton Chain <hako@HIDDEN>,
 Divya Ranjan Pattanaik <divya@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>, Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/build/cargo-build-system.scm (single-crate?): New procedure.
(crate-src?): Support non-workspace directory source inputs.
(configure): Likewise.

Change-Id: If2bd318b44ed765baec69309f25d320edceee116
---
 guix/build/cargo-build-system.scm | 60 ++++++++++++++++++++-----------
 1 file changed, 39 insertions(+), 21 deletions(-)

diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index ea00ff3fbe..a1c4f556bb 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -33,6 +33,7 @@ (define-module (guix build cargo-build-system)
   #:use-module (ice-9 ftw)
   #:use-module (ice-9 format)
   #:use-module (ice-9 match)
+  #:use-module (ice-9 textual-ports)
   #:use-module (ice-9 threads)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
@@ -60,22 +61,35 @@ (define (has-executable-target?)
          (bin-dep? (lambda (dep) (find bin? (get-kinds dep)))))
     (find bin-dep? (manifest-targets))))
 
+(define (single-crate? dir)
+  "Check if directory DIR contains 'Cargo.toml' and is not a workspace."
+  (let ((manifest-file (in-vicinity dir "Cargo.toml")))
+    (and (file-exists? manifest-file)
+         (not (string-contains
+               (call-with-input-file manifest-file get-string-all)
+               "[workspace]")))))
+
 (define (crate-src? path)
   "Check if PATH refers to a crate source, namely a gzipped tarball with a
 Cargo.toml file present at its root."
-    (and (not (directory-exists? path)) ; not a tarball
-         (not (string-suffix? "py" path))   ; sanity-check.py
-         ;; First we print out all file names within the tarball to see if it
-         ;; looks like the source of a crate. However, the tarball will include
-         ;; an extra path component which we would like to ignore (since we're
-         ;; interested in checking if a Cargo.toml exists at the root of the
-         ;; archive, but not nested anywhere else). We do this by cutting up
-         ;; each output line and only looking at the second component. We then
-         ;; check if it matches Cargo.toml exactly and short circuit if it does.
-         (apply invoke (list "sh" "-c"
-                             (string-append "tar -tf " path
-                                            " | cut -d/ -f2"
-                                            " | grep -q '^Cargo.toml$'")))))
+  (if (directory-exists? path)
+      ;; The build system only handles sources containing single crate.
+      ;; Workspaces should be packaged into crates (via 'package phase)
+      ;; and used in inputs.
+      (single-crate? path)
+      (and (not (string-suffix? "py" path)) ;sanity-check.py
+           ;; First we print out all file names within the tarball to see
+           ;; if it looks like the source of a crate. However, the tarball
+           ;; will include an extra path component which we would like to
+           ;; ignore (since we're interested in checking if a Cargo.toml
+           ;; exists at the root of the archive, but not nested anywhere
+           ;; else). We do this by cutting up each output line and only
+           ;; looking at the second component. We then check if it matches
+           ;; Cargo.toml exactly and short circuit if it does.
+           (invoke "sh" "-c"
+                   (string-append "tar -tf " path
+                                  " | cut -d/ -f2"
+                                  " | grep -q '^Cargo.toml$'")))))
 
 (define* (unpack-rust-crates #:key inputs (vendor-dir "guix-vendor")
                              #:allow-other-keys)
@@ -159,14 +173,18 @@ (define* (configure #:key inputs
          (and (crate-src? path)
               ;; Gracefully handle duplicate inputs
               (not (file-exists? crate-dir))
-              (mkdir-p crate-dir)
-              ;; Cargo crates are simply gzipped tarballs but with a .crate
-              ;; extension. We expand the source to a directory name we control
-              ;; so that we can generate any cargo checksums.
-              ;; The --strip-components argument is needed to prevent creating
-              ;; an extra directory within `crate-dir`.
-              (format #t "Unpacking ~a~%" name)
-              (invoke "tar" "xf" path "-C" crate-dir "--strip-components" "1")))))
+              (if (directory-exists? path)
+                  (copy-recursively path crate-dir)
+                  (begin
+                    (mkdir-p crate-dir)
+                    ;; Cargo crates are simply gzipped tarballs but with a
+                    ;; .crate extension. We expand the source to a directory
+                    ;; name we control so that we can generate any cargo
+                    ;; checksums.  The --strip-components argument is needed to
+                    ;; prevent creating an extra directory within `crate-dir`.
+                    (format #t "Unpacking ~a~%" name)
+                    (invoke "tar" "xf" path "-C" crate-dir
+                            "--strip-components" "1")))))))
     inputs)
 
   ;; For cross-building
-- 
2.48.1





Information forwarded to hako@HIDDEN, divya@HIDDEN, efraim@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:26:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 03:26:19 2025
Received: from localhost ([127.0.0.1]:35912 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuRL9-0004gC-1m
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:26:19 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:33314)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuRKi-0004bU-L7
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:25:53 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742282751;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=oFWeP0nug616Yq+nBssd1YSzuePdivNKyqlL9v/aiAs=;
 b=frSJk7D14LrXDEN/fX2KzDOt5xnsvs7PSu28ARYllfXAf84mIa/dwOMVOwDO+n+p9s7vxG
 /NUmt12AR7Ghyt8eKkXo4GjzhBr5VME4kEX3R3mV+ziNknxywKb90PiZmzneJxrO0rgRIP
 MifHHbOHG0z/XiwJzIUTz9aIkbZKMF5NNYo3oj+YEezgRU6BEA9aTHKw9+Yy3LiAENmqvg
 BsQZBoCEO3Vyug7jwpUITTJ6hPj9nINOXSijrcINgfLRyTUJoR5lVRxmkxyGdg46ATlM8O
 51PcYni0ALMkppLBB+MIYwnQGwNCeL512781FMIlelyNvK+p/qfdL5yCcVJ9BQ==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team 06/18] build/cargo: Don't try to unpack
 sanity-check.py.
Date: Tue, 18 Mar 2025 15:24:19 +0800
Message-ID: <daffed5856abf262ac47bd47e527133d766f92bc.1742281797.git.hako@HIDDEN>
In-Reply-To: <cover.1742281797.git.hako@HIDDEN>
References: <cover.1742281797.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Hilton Chain <hako@HIDDEN>,
 Divya Ranjan Pattanaik <divya@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>, Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Efraim Flashner <efraim@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

From: Efraim Flashner <efraim@HIDDEN>

* guix/build/cargo-build-system.scm (crate-src?): Also don't try to
check python scripts for Cargo.toml.

Change-Id: I001a89b83d2e472706b1263007be45d1153c140f
---
 guix/build/cargo-build-system.scm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index fdc9ae89c8..ea00ff3fbe 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -64,6 +64,7 @@ (define (crate-src? path)
   "Check if PATH refers to a crate source, namely a gzipped tarball with a
 Cargo.toml file present at its root."
     (and (not (directory-exists? path)) ; not a tarball
+         (not (string-suffix? "py" path))   ; sanity-check.py
          ;; First we print out all file names within the tarball to see if it
          ;; looks like the source of a crate. However, the tarball will include
          ;; an extra path component which we would like to ignore (since we're
-- 
2.48.1





Information forwarded to hako@HIDDEN, divya@HIDDEN, efraim@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:26:18 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 03:26:18 2025
Received: from localhost ([127.0.0.1]:35909 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuRL7-0004fz-Vj
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:26:18 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:33306)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuRKe-0004b6-W7
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:25:50 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742282747;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=HtYEExicQh5Fb/O/ity8W3bnp/kwCs5U25QBUcMnorE=;
 b=VeLmxoWcqHj+rngBLQmpPQSfT/TUN9gW3+nuvCr7iCeHAxwce9Spf5qTthJ+QIE4n+u7BW
 4Ey8JLNKBujpO8r5uRA8OHDny6MV1Q48/dAV5sFREum1qo2358ZJHlJ31zEVh7uSt00SRT
 yJsTGAXEIVz6KZNotczUWWi2k8IFY9zQ5mzfxJ2pzBQceCRhH9Fh1Z0mLdJXd3cSu7mNh6
 9WV0+/1GRrSfpDn7YMneqYNTY8+nSvvyIg6ouVk/ef5O2ZI6eMHZ4BH6GwHN/lyRqXDzqg
 JcKtkXsqkwVmsnv+vXEEGylRsNPqZT7WJ8X2WPlLXLUB6pJlkUPKi1TMpfB5bw==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team 05/18] build/cargo: Set default value of arguments
 for build phases.
Date: Tue, 18 Mar 2025 15:24:18 +0800
Message-ID: <58d019ff3c92473fc9813ddcbdf6aaee536c60b7.1742281797.git.hako@HIDDEN>
In-Reply-To: <cover.1742281797.git.hako@HIDDEN>
References: <cover.1742281797.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Hilton Chain <hako@HIDDEN>,
 Divya Ranjan Pattanaik <divya@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>, Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

This makes it easier to use these phases in other bulid systems.

* guix/build/cargo-build-system.scm (unpack-rust-crates,configure,build,package)
(install): Set default value of arguments.

Change-Id: I1dde1b063d8eee57967903abd2fce94574211a0a
---
 guix/build/cargo-build-system.scm | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index bcee10837e..fdc9ae89c8 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -76,7 +76,8 @@ (define (crate-src? path)
                                             " | cut -d/ -f2"
                                             " | grep -q '^Cargo.toml$'")))))
 
-(define* (unpack-rust-crates #:key inputs vendor-dir #:allow-other-keys)
+(define* (unpack-rust-crates #:key inputs (vendor-dir "guix-vendor")
+                             #:allow-other-keys)
   (define (inputs->rust-inputs inputs)
     "Filter using the label part from INPUTS."
     (filter (lambda (input)
@@ -139,7 +140,7 @@ (define* (check-for-pregenerated-files #:key parallel-build? #:allow-other-keys)
 
 (define* (configure #:key inputs
                     target system
-                    cargo-target
+                    (cargo-target #f)
                     (vendor-dir "guix-vendor")
                     #:allow-other-keys)
   "Vendor Cargo.toml dependencies as guix inputs."
@@ -258,7 +259,7 @@ (define* (patch-cargo-checksums #:key
 
 (define* (build #:key
                 parallel-build?
-                skip-build?
+                (skip-build? #f)
                 (features '())
                 (cargo-build-flags '("--release"))
                 #:allow-other-keys)
@@ -298,8 +299,8 @@ (define* (check #:key
 
 (define* (package #:key
                   source
-                  skip-build?
-                  install-source?
+                  (skip-build? #f)
+                  (install-source? #t)
                   (cargo-package-crates '())
                   (cargo-package-flags '("--no-metadata" "--no-verify"))
                   (vendor-dir "guix-vendor")
@@ -381,9 +382,9 @@ (define* (package #:key
 (define* (install #:key
                   inputs
                   outputs
-                  skip-build?
-                  install-source?
-                  features
+                  (skip-build? #f)
+                  (install-source? #t)
+                  (features '())
                   (cargo-install-paths '())
                   #:allow-other-keys)
   "Install a given Cargo package."
-- 
2.48.1





Information forwarded to hako@HIDDEN, divya@HIDDEN, efraim@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:25:59 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 03:25:58 2025
Received: from localhost ([127.0.0.1]:35868 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuRKm-0004c9-IV
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:25:58 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:33298)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuRKc-0004ae-C9
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:25:48 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742282744;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=nu5Fq3O3l7S/8mex7Vy7MAjGDCPLGyv+RkJelUXlR28=;
 b=F4sxlH9nBKwNh5qRHD0evHgeExCInSZohlxOWf6VUnMSmTkTi9El+0PQ/NkfNeqps082CE
 lP2omh2VBxSOcOtJPAxD1sHdma4weeCyQ+cGF5M8q9Bml6q7L5b5BLdGYVmqqrwNHZvOJF
 nYe/aNoRbpDRDLfuF05j3GexF2bOh5x7rCB57MfIBnuNwBCRTQUVNiqkj0XmXvNr8tqPSJ
 8MibegZNbzqKZ7isXtz539dQ2yp8Dbf9/8lvqhLBF1VcQf0JJuixt40BMhpyHDrU4/yZMo
 bUNFgEiU0q2X25tE8ZgdO2JQzYi1OyKdClRjWYqP/a8czRv9kyThb83AmNfI8w==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team 04/18] build-system: cargo: Support installing Cargo
 workspace.
Date: Tue, 18 Mar 2025 15:24:17 +0800
Message-ID: <f9521627c5f774edcccd732ecc7f368375180b64.1742281797.git.hako@HIDDEN>
In-Reply-To: <cover.1742281797.git.hako@HIDDEN>
References: <cover.1742281797.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Hilton Chain <hako@HIDDEN>, Divya Ranjan Pattanaik <divya@HIDDEN>, Efraim Flashner <efraim@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>, Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

*guix/build-system/cargo.scm (cargo-build,cargo-cross-build)
[#:cargo-install-paths]: New argument.
* guix/build/cargo-build-system.scm (install): Use it.
* doc/guix.texi (Build Systems)[cargo-build-system]: Document it.

Change-Id: I74ed1972a5716da05afeac8edb2b0e4b6834bf40
---
 doc/guix.texi                     |  5 ++++-
 guix/build-system/cargo.scm       |  4 ++++
 guix/build/cargo-build-system.scm | 17 +++++++++++++----
 3 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 322512fd36..c20e1d7f9c 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -9369,7 +9369,10 @@ Build Systems
 names of library crates to package in @code{package} phase.  Specified
 crates are packaged from left to right, in case there's dependency among
 them.  For example, specifying @code{''("pcre2-sys" "pcre2")} will
-package @code{"pcre2-sys"} first and then @code{"pcre2"}.
+package @code{"pcre2-sys"} first and then @code{"pcre2"}.  Parameter
+@code{#:cargo-install-paths} (default: @code{''()}) allows specifying
+paths of binary crates to install in @code{install} phase,
+@code{''("crates/atuin")}, for example.
 @end defvar
 
 @defvar chicken-build-system
diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
index 4f6d46e70c..4486c706a1 100644
--- a/guix/build-system/cargo.scm
+++ b/guix/build-system/cargo.scm
@@ -96,6 +96,7 @@ (define* (cargo-build name inputs
                       (cargo-test-flags ''())
                       (cargo-package-crates ''())
                       (cargo-package-flags ''("--no-metadata" "--no-verify"))
+                      (cargo-install-paths ''())
                       (features ''())
                       (skip-build? #f)
                       (parallel-build? #t)
@@ -125,6 +126,7 @@ (define* (cargo-build name inputs
                        #:cargo-test-flags #$(sexp->gexp cargo-test-flags)
                        #:cargo-package-crates #$(sexp->gexp cargo-package-crates)
                        #:cargo-package-flags #$(sexp->gexp cargo-package-flags)
+                       #:cargo-install-paths #$(sexp->gexp cargo-install-paths)
                        #:cargo-target #$(cargo-triplet system)
                        #:features #$(sexp->gexp features)
                        #:skip-build? #$skip-build?
@@ -158,6 +160,7 @@ (define* (cargo-cross-build name
                             (cargo-test-flags ''())
                             (cargo-package-crates ''())
                             (cargo-package-flags ''("--no-metadata" "--no-verify"))
+                            (cargo-install-paths ''())
                             (cargo-target (cargo-triplet (or target system)))
                             (features ''())
                             (skip-build? #f)
@@ -190,6 +193,7 @@ (define* (cargo-cross-build name
                        #:cargo-test-flags #$(sexp->gexp cargo-test-flags)
                        #:cargo-package-crates #$(sexp->gexp cargo-package-crates)
                        #:cargo-package-flags #$(sexp->gexp cargo-package-flags)
+                       #:cargo-install-paths #$(sexp->gexp cargo-install-paths)
                        #:cargo-target #$(cargo-triplet (or target system))
                        #:features #$(sexp->gexp features)
                        #:skip-build? #$skip-build?
diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index 001e9c7adc..bcee10837e 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -384,6 +384,7 @@ (define* (install #:key
                   skip-build?
                   install-source?
                   features
+                  (cargo-install-paths '())
                   #:allow-other-keys)
   "Install a given Cargo package."
   (let* ((out      (assoc-ref outputs "out"))
@@ -398,10 +399,18 @@ (define* (install #:key
     ;; Only install crates which include binary targets,
     ;; otherwise cargo will raise an error.
     (or skip-build?
-        (not (has-executable-target?))
-        (invoke "cargo" "install" "--offline" "--no-track"
-                "--path" "." "--root" out
-                "--features" (string-join features)))
+        ;; NOTE: Cargo workspace installation support:
+        ;; #:skip-build? #f + #:cargo-install-paths.
+        (and (null? cargo-install-paths)
+             (not (has-executable-target?)))
+        (for-each
+         (lambda (path)
+           (invoke "cargo" "install" "--offline" "--no-track"
+                   "--path" path "--root" out
+                   "--features" (string-join features)))
+         (if (null? cargo-install-paths)
+             '(".")
+             cargo-install-paths)))
 
     (when install-source?
       ;; Install crate tarballs and unpacked sources for later use.
-- 
2.48.1





Information forwarded to hako@HIDDEN, divya@HIDDEN, efraim@HIDDEN, ludo@HIDDEN, maxim.cournoyer@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:25:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 03:25:56 2025
Received: from localhost ([127.0.0.1]:35866 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuRKl-0004bv-BR
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:25:56 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:41564)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuRKY-0004Zv-1U
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:25:46 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742282740;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=XfpoWRsU1ZYTnjvOxVq/KZehQ1kOyETb6xjxd2Z6avA=;
 b=Aq7LZkUiqkAYTrNBtUUTvhzFMQW/pUO5PyNmAiBRoPXoToPFl9D7mBZKyWx/KaZhl4oq4E
 FVnHzpIpfhWyJS7AMaN0RWtHvoy9YFBy7ZsIj/Mr4kVNXDRm9IqSdBD27/r5vtCAF92CHe
 f06JJsQG5QiXvlp5sj2yySfcXsMhBSDxxdjvURT8AZYPtzy6oo60LFWezBbTTflesC5DLl
 bpNlr0L+tFK5yUR/iCXcmNF1Nc9HDLMWwqovi4kV+qhzXKkV8WiRipapfIXBM7H2zVdOA2
 QTAM3orhWPTUff7yCV5gcMNzJJFHfuqI9o/AH7RKFJiBOqnNrSct82gdf31+iA==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team 03/18] build-system: cargo: Support packaging Cargo
 workspace.
Date: Tue, 18 Mar 2025 15:24:16 +0800
Message-ID: <0478229ef1b10a866b0c1cc9e33ec5bf27346d37.1742281797.git.hako@HIDDEN>
In-Reply-To: <cover.1742281797.git.hako@HIDDEN>
References: <cover.1742281797.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Hilton Chain <hako@HIDDEN>, Divya Ranjan Pattanaik <divya@HIDDEN>, Efraim Flashner <efraim@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>, Steve George <steve@HIDDEN>
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/build-system/cargo.scm (cargo-build,cargo-cross-build)
[#:cargo-package-crates]: New argument.
* guix/build/cargo-build-system.scm (package): Use it.
* doc/guix.texi (Build Systems)[cargo-build-system]: Document it.

Change-Id: I45ccd95e90827d47127015cb0bda2d41f792335b
---
 doc/guix.texi                     |  7 +++++++
 guix/build-system/cargo.scm       |  4 ++++
 guix/build/cargo-build-system.scm | 28 ++++++++++++++++++++++++++--
 3 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 0ca109a214..322512fd36 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -9363,6 +9363,13 @@ Build Systems
 the binaries defined by the crate.  Unless @code{install-source? #f} is
 defined it will also install a source crate repository of itself and unpacked
 sources, to ease in future hacking on rust packages.
+
+This build system supports cargo workspaces.  Parameter
+@code{#:cargo-package-crates} (default: @code{''()}) allows specifying
+names of library crates to package in @code{package} phase.  Specified
+crates are packaged from left to right, in case there's dependency among
+them.  For example, specifying @code{''("pcre2-sys" "pcre2")} will
+package @code{"pcre2-sys"} first and then @code{"pcre2"}.
 @end defvar
 
 @defvar chicken-build-system
diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
index 452f7f78d0..4f6d46e70c 100644
--- a/guix/build-system/cargo.scm
+++ b/guix/build-system/cargo.scm
@@ -94,6 +94,7 @@ (define* (cargo-build name inputs
                       (vendor-dir "guix-vendor")
                       (cargo-build-flags ''("--release"))
                       (cargo-test-flags ''())
+                      (cargo-package-crates ''())
                       (cargo-package-flags ''("--no-metadata" "--no-verify"))
                       (features ''())
                       (skip-build? #f)
@@ -122,6 +123,7 @@ (define* (cargo-build name inputs
                        #:vendor-dir #$vendor-dir
                        #:cargo-build-flags #$(sexp->gexp cargo-build-flags)
                        #:cargo-test-flags #$(sexp->gexp cargo-test-flags)
+                       #:cargo-package-crates #$(sexp->gexp cargo-package-crates)
                        #:cargo-package-flags #$(sexp->gexp cargo-package-flags)
                        #:cargo-target #$(cargo-triplet system)
                        #:features #$(sexp->gexp features)
@@ -154,6 +156,7 @@ (define* (cargo-cross-build name
                             (vendor-dir "guix-vendor")
                             (cargo-build-flags ''("--release"))
                             (cargo-test-flags ''())
+                            (cargo-package-crates ''())
                             (cargo-package-flags ''("--no-metadata" "--no-verify"))
                             (cargo-target (cargo-triplet (or target system)))
                             (features ''())
@@ -185,6 +188,7 @@ (define* (cargo-cross-build name
                        #:vendor-dir #$vendor-dir
                        #:cargo-build-flags #$(sexp->gexp cargo-build-flags)
                        #:cargo-test-flags #$(sexp->gexp cargo-test-flags)
+                       #:cargo-package-crates #$(sexp->gexp cargo-package-crates)
                        #:cargo-package-flags #$(sexp->gexp cargo-package-flags)
                        #:cargo-target #$(cargo-triplet (or target system))
                        #:features #$(sexp->gexp features)
diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index 58238992b8..001e9c7adc 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -300,11 +300,16 @@ (define* (package #:key
                   source
                   skip-build?
                   install-source?
+                  (cargo-package-crates '())
                   (cargo-package-flags '("--no-metadata" "--no-verify"))
+                  (vendor-dir "guix-vendor")
                   #:allow-other-keys)
   "Run 'cargo-package' for a given Cargo package."
   (if install-source?
-    (if skip-build?
+    ;; NOTE: Cargo workspace packaging support:
+    ;; #:install-source? #t + #:cargo-package-crates.
+    (if (and (null? cargo-package-crates)
+             skip-build?)
       (begin
         (install-file source "target/package")
         (with-directory-excursion "target/package"
@@ -322,7 +327,26 @@ (define* (package #:key
         ;;error: invalid inclusion of reserved file name Cargo.toml.orig in package source
         (when (file-exists? "Cargo.toml.orig")
           (delete-file "Cargo.toml.orig"))
-        (apply invoke `("cargo" "package" "--offline" ,@cargo-package-flags))
+
+        (if (null? cargo-package-crates)
+            (apply invoke `("cargo" "package" "--offline" ,@cargo-package-flags))
+            ;; Use unstable feature ‘--registry’.
+            (begin
+              (setenv "RUSTC_BOOTSTRAP" "1")
+              (for-each
+               (lambda (pkg)
+                 (apply invoke "cargo" "package" "--offline" "--package" pkg
+                        "--registry" "crates-io" "-Z" "package-workspace"
+                        cargo-package-flags)
+                 (for-each
+                  (lambda (crate)
+                    (invoke "tar" "xzf" crate "-C" vendor-dir))
+                  (begin
+                    (delete-file-recursively "target/package/tmp-registry")
+                    (find-files "target/package" "\\.crate$")))
+                 (patch-cargo-checksums #:vendor-dir vendor-dir))
+               cargo-package-crates)
+              (unsetenv "RUSTC_BOOTSTRAP")))
 
         ;; Then unpack the crate, reset the timestamp of all contained files, and
         ;; repack them.  This is necessary to ensure that they are reproducible.
-- 
2.48.1





Information forwarded to hako@HIDDEN, divya@HIDDEN, efraim@HIDDEN, ludo@HIDDEN, maxim.cournoyer@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:25:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 03:25:55 2025
Received: from localhost ([127.0.0.1]:35864 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuRKk-0004bk-Dz
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:25:55 -0400
Received: from mx.boiledscript.com ([88.99.243.112]:41554)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuRKV-0004Z5-6a
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:25:42 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742282737;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=tWCnhX4OoBIrcF5cBlDIauVuJiVPteEuBGDYdX+/oyI=;
 b=bT5M1EJ0Yh8tLnpS6Xxth+xzg35c+Tv9/j6VvIIoNOym8HnG4hXH4zSCLDLzGACdX/7uqt
 lFW//OB1cpXKvFYeoHdjCtngY/dmV2Z6w4tzYFQA6IhKWODuPZotUGq2pSCM7W8zhOsGbr
 AolCVIWaAGV4yqVJW8v3Q+19+Gfv7WdP+I9+40fCZM0+tiiORmeQbYec102A0S3HlcV0/U
 77SpX+dR0dWIE0Uu/+vfZCrFZxqCeRi2esgP8pJH3950/m+9pEJgvlVQocLNjfI++yGd1l
 gz3vZRhoJz78vnQkRl6skiY2pfE7LtE+HBvW5sNp7SSO3bajBotoRi6K7qfgjg==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team 02/18] build/cargo: Print out all non-empty binary
 files.
Date: Tue, 18 Mar 2025 15:24:15 +0800
Message-ID: <ab84d8151185aac6692999d1971c4fb9ee2c8191.1742281797.git.hako@HIDDEN>
In-Reply-To: <cover.1742281797.git.hako@HIDDEN>
References: <cover.1742281797.git.hako@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Hilton Chain <hako@HIDDEN>,
 Divya Ranjan Pattanaik <divya@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>, Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/build/cargo-build-system.scm (%standard-phases): Move
'unpack-rust-crates after 'unpack.
Move 'check-for-pregenerated-files after 'configure.
(check-for-pregenerated-files): Only check non-empty files.
Print out binary files.
Run in parallel.
Don't fail to keep compatibility for phase order change.

Change-Id: I0a332fe843e97687324bd908fa111422a63e475d
---
 guix/build/cargo-build-system.scm | 31 +++++++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index 41f54f42b7..58238992b8 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -29,9 +29,11 @@ (define-module (guix build cargo-build-system)
   #:use-module ((guix build utils) #:hide (delete))
   #:use-module (ice-9 popen)
   #:use-module (ice-9 rdelim)
+  #:use-module (ice-9 regex)
   #:use-module (ice-9 ftw)
   #:use-module (ice-9 format)
   #:use-module (ice-9 match)
+  #:use-module (ice-9 threads)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
   #:export (%standard-phases
@@ -111,12 +113,29 @@ (define* (unpack-rust-crates #:key inputs vendor-dir #:allow-other-keys)
 (define (rust-package? name)
   (string-prefix? "rust-" name))
 
-(define* (check-for-pregenerated-files #:rest _)
+(define* (check-for-pregenerated-files #:key parallel-build? #:allow-other-keys)
   "Check the source code for files which are known to generally be bundled
 libraries or executables."
-  (let ((pregenerated-files (find-files "." "\\.(a|dll|dylib|exe|lib)$")))
-    (when (not (null-list? pregenerated-files))
-      (error "Possible pre-generated files found:" pregenerated-files))))
+  (format #t "Searching for binary files...~%")
+  (let ((known-pattern (make-regexp "\\.(a|dll|dylib|exe|lib)$"))
+        (empty-file?
+         (lambda (filename)
+           (call-with-ascii-input-file filename
+             (lambda (p)
+               (eqv? #\0 (read-char p)))))))
+    (n-par-for-each
+     (if parallel-build?
+         (parallel-job-count)
+         1)
+     (lambda (file)
+       (unless (empty-file? file)
+         ;; Print out binary files.
+         (false-if-exception (invoke "grep" "-IL" "." file))
+         ;; Warn about known pre-generated files.
+         ;; Not failing here for compatibility with existing packages.
+         (when (regexp-exec known-pattern file)
+           (format #t "error: Possible pre-generated file found: ~a~%" file))))
+     (find-files "."))))
 
 (define* (configure #:key inputs
                     target system
@@ -380,8 +399,8 @@ (define %standard-phases
     (replace 'check check)
     (replace 'install install)
     (add-after 'build 'package package)
-    (add-after 'unpack 'check-for-pregenerated-files check-for-pregenerated-files)
-    (add-after 'check-for-pregenerated-files 'unpack-rust-crates unpack-rust-crates)
+    (add-after 'unpack 'unpack-rust-crates unpack-rust-crates)
+    (add-after 'configure 'check-for-pregenerated-files check-for-pregenerated-files)
     (add-after 'patch-generated-file-shebangs 'patch-cargo-checksums patch-cargo-checksums)))
 
 (define* (cargo-build #:key inputs (phases %standard-phases)
-- 
2.48.1





Information forwarded to hako@HIDDEN, divya@HIDDEN, efraim@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at 77093 <at> debbugs.gnu.org:


Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:25:38 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 03:25:38 2025
Received: from localhost ([127.0.0.1]:35857 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuRKT-0004Z7-Ul
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:25:38 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:46470)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuRKR-0004YQ-1S
 for 77093 <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:25:35 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742282733;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=fTJrKeLT9GSPYJTsuUaujgtn6qA4bB0llojftLqgAJM=;
 b=b7/g+ibWHvXhpUnpzttbkf6FJYNZVjwxskFtQFXhnCk/cZ86szVVA/dEk0dhOyxL3cJ7le
 q3ys8+05dw3JaXiPjyZ6a7TBs7ibkP7jt53oUHJlrm5je7vhdHwwI+kJYFsOPo1kCZpj7B
 GBP4KSyp1U/B9OtRUU32uLQBDV4fU1T9vo3UcBOTU6VUTnLv5BzMkO6ARE35gtWKoMbAZD
 iam9CwRTvMPLEwc0HWXJg3updFy5IuiLHgyZihDxCmKOLxhw4Lr0OBY7d4VYr5ZkJypyhn
 bq7wo33+8OAVVylVU0M20bIOK2iF6yFyZrUU7KUHjw8T2ZfEPZ7YeVDcPK2zjQ==
To: 77093 <at> debbugs.gnu.org
Subject: [PATCH rust-team 01/18] =?UTF-8?q?build/cargo:=20Pass=20=E2=80=98?=
 =?UTF-8?q?--offline=E2=80=99=20to=20cargo.?=
Date: Tue, 18 Mar 2025 15:24:14 +0800
Message-ID: <73db5916ba93efd5f30d9e45945a0ccff88c330f.1742281797.git.hako@HIDDEN>
In-Reply-To: <cover.1742281797.git.hako@HIDDEN>
References: <cover.1742281797.git.hako@HIDDEN>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
X-Debbugs-Cc: Hilton Chain <hako@HIDDEN>,
 Divya Ranjan Pattanaik <divya@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>, Steve George <steve@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77093
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

This will make error messages more helpful.

* guix/build/cargo-build-system.scm (build,check,package,install): Pass
‘--offline’ to cargo.

Change-Id: Ic95f603b793319f99c9c1fbce43f773bfc8126c0
---
 guix/build/cargo-build-system.scm | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index 5ef6b23abd..41f54f42b7 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -246,7 +246,7 @@ (define* (build #:key
   "Build a given Cargo package."
   (or skip-build?
       (apply invoke
-             `("cargo" "build"
+             `("cargo" "build" "--offline"
                ,@(if parallel-build?
                      (list "-j" (number->string (parallel-job-count)))
                      (list "-j" "1"))
@@ -264,7 +264,7 @@ (define* (check #:key
   "Run tests for a given Cargo package."
   (when tests?
     (apply invoke
-           `("cargo" "test"
+           `("cargo" "test" "--offline"
              ,@(if parallel-build?
                    (list "-j" (number->string (parallel-job-count)))
                    (list "-j" "1"))
@@ -303,7 +303,7 @@ (define* (package #:key
         ;;error: invalid inclusion of reserved file name Cargo.toml.orig in package source
         (when (file-exists? "Cargo.toml.orig")
           (delete-file "Cargo.toml.orig"))
-        (apply invoke `("cargo" "package" ,@cargo-package-flags))
+        (apply invoke `("cargo" "package" "--offline" ,@cargo-package-flags))
 
         ;; Then unpack the crate, reset the timestamp of all contained files, and
         ;; repack them.  This is necessary to ensure that they are reproducible.
@@ -356,7 +356,8 @@ (define* (install #:key
     ;; otherwise cargo will raise an error.
     (or skip-build?
         (not (has-executable-target?))
-        (invoke "cargo" "install" "--no-track" "--path" "." "--root" out
+        (invoke "cargo" "install" "--offline" "--no-track"
+                "--path" "." "--root" out
                 "--features" (string-join features)))
 
     (when install-source?
-- 
2.48.1





Information forwarded to hako@HIDDEN, divya@HIDDEN, efraim@HIDDEN, steve@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 18 Mar 2025 07:17:14 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 18 03:17:14 2025
Received: from localhost ([127.0.0.1]:35804 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tuRCI-0003Ef-DM
	for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:17:13 -0400
Received: from lists.gnu.org ([2001:470:142::17]:49616)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hako@HIDDEN>)
 id 1tuRCC-0003B7-P5
 for submit <at> debbugs.gnu.org; Tue, 18 Mar 2025 03:17:07 -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 <hako@HIDDEN>)
 id 1tuRBq-0005lj-UR
 for guix-patches@HIDDEN; Tue, 18 Mar 2025 03:16:44 -0400
Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <hako@HIDDEN>)
 id 1tuRBo-0006aE-Ir
 for guix-patches@HIDDEN; Tue, 18 Mar 2025 03:16:42 -0400
From: Hilton Chain <hako@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space;
 s=mail; t=1742282198;
 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:
 content-transfer-encoding:content-transfer-encoding;
 bh=Z7ET3TCSqHaPo0OlqqR02kkr4ni/rUMSudvgUZuS000=;
 b=c20WCGYAnNg40jbVkBsEe1020EcAgvM67BZnVoPc6CUQ8AJ0lZ2bGmVBm/wPOUN7XShmlm
 DC+oSj8SFTNiqH33jZ5rLAWdCT8PSdVjFgknHBnBepMCtSKG52KDjU1VQ8yrnlUsjcE0RE
 hmrVb9faibrInNz+4MTX99CnW1N4383nkGf1pQVCHBu4lOJW61mk+yLtYgjybQHNND3Dzj
 ypTqQNpQ7wbGoA4cOvO8QUGhZaodn6Z47RsAPwTeR+hOaeyZEkFg9V11aTl4Pwgx8jtYRb
 HEKpR38up4Ac1XtMAAEq1i6J86b8slwuDKEZ2OwMFLlhFPF1s7cw5AqjB1iNdQ==
To: guix-patches@HIDDEN
Subject: [PATCH rust-team 00/18] New Rust packaging workflow based on lockfile
 importer.
Date: Tue, 18 Mar 2025 15:16:05 +0800
Message-ID: <cover.1742281797.git.hako@HIDDEN>
MIME-Version: 1.0
X-MS-Reactions: disallow
Content-Type: text/plain; charset=UTF-8
X-Debbugs-Cc: Efraim Flashner <efraim@HIDDEN>,
 Felix Lechner <felix.lechner@HIDDEN>, Murilo <murilo@HIDDEN>,
 Simon Tournier <zimon.toutoune@HIDDEN>, Nicolas Graves <ngraves@HIDDEN>,
 Divya Ranjan Pattanaik <divya@HIDDEN>,
 Steve George <steve@HIDDEN>
X-Debbugs-Cc: Ludovic Courtès <ludo@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>
Content-Transfer-Encoding: 8bit
Received-SPF: pass client-ip=2a01:4f8:10b:392::42;
 envelope-from=hako@HIDDEN; helo=mx.boiledscript.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: submit
Cc: Hilton Chain <hako@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

Hi Guix!

This series:
* integrates cargo2guix (https://git.sr.ht/~look/cargo2guix) as a crate importer
  option, ‘-f / --lockfile=’.

* adds Cargo workspace support to cargo-build-system, via two new arguments:
  #:cargo-package-crates and #:cargo-install-paths.

* introduces a new Rust packaging workflow, as described in contributing.texi
  change.

This change is compatible with existing cargo-build-system users.

Thanks

Efraim Flashner (2):
  build/cargo: Don't try to unpack sanity-check.py.
  build/cargo: Use system jemalloc.

Hilton Chain (16):
  build/cargo: Pass ‘--offline’ to cargo.
  build/cargo: Print out all non-empty binary files.
  build-system: cargo: Support packaging Cargo workspace.
  build-system: cargo: Support installing Cargo workspace.
  build/cargo: Set default value of arguments for build phases.
  build/cargo: Support non-workspace directory source inputs.
  scripts: import: Document argument for ‘--insert’ option in help
    message.
  scripts: import: Add two newlines for ‘--insert’ option.
  scripts: import: Support expressions defined by 'define.
  scripts: import: Pass "--insert" to importers.
  scripts: import: Skip existing definition for ‘--insert’ option.
  import: crate: crate-name->package-name: Move to (guix build-system
    cargo).
  build-system: cargo: Add ‘cargo-inputs’.
  import: crate: Add Cargo.lock parser.
  import: crate: Add ‘--lockfile’ option.
  doc: Document lockfile importer based Rust packaging workflow.

 Makefile.am                       |   1 +
 doc/contributing.texi             | 415 ++++++++++++++++++++++++++++--
 doc/guix.texi                     |  25 ++
 etc/teams/rust/cleanup-crates.sh  |  38 +++
 etc/teams/rust/rust-crates.tmpl   |  42 +++
 gnu/local.mk                      |   2 +
 gnu/packages/rust-crates.scm      |  42 +++
 gnu/packages/rust-sources.scm     |  29 +++
 guix/build-system/cargo.scm       |  57 +++-
 guix/build/cargo-build-system.scm | 163 +++++++++---
 guix/import/crate.scm             |  81 +++++-
 guix/import/crate/cargo-lock.scm  | 105 ++++++++
 guix/scripts/import.scm           |  54 ++--
 guix/scripts/import/crate.scm     |  58 ++++-
 guix/utils.scm                    |  27 +-
 tests/crate.scm                   |  88 +++++++
 16 files changed, 1121 insertions(+), 106 deletions(-)
 create mode 100755 etc/teams/rust/cleanup-crates.sh
 create mode 100644 etc/teams/rust/rust-crates.tmpl
 create mode 100644 gnu/packages/rust-crates.scm
 create mode 100644 gnu/packages/rust-sources.scm
 create mode 100644 guix/import/crate/cargo-lock.scm


base-commit: b54a9ca849f013300c633fb79d80bc754f6b28a2
--
2.48.1




Acknowledgement sent to Hilton Chain <hako@HIDDEN>:
New bug report received and forwarded. Copy sent to ludo@HIDDEN, maxim.cournoyer@HIDDEN, guix-patches@HIDDEN. Full text available.
Report forwarded to ludo@HIDDEN, maxim.cournoyer@HIDDEN, guix-patches@HIDDEN:
bug#77093; Package guix-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 12 Apr 2025 13:00:04 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.