From patchwork Tue Mar 18 14:26:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40326 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 2CF0427BBE9; Tue, 18 Mar 2025 14:28:31 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id E7EDE27BBE2 for ; Tue, 18 Mar 2025 14:28:27 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuXvP-0004tR-95; Tue, 18 Mar 2025 10:28:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tuXvM-0004sO-UY for guix-patches@gnu.org; Tue, 18 Mar 2025 10:28:09 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tuXvM-0001Ka-KX for guix-patches@gnu.org; Tue, 18 Mar 2025 10:28:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=fTJrKeLT9GSPYJTsuUaujgtn6qA4bB0llojftLqgAJM=; b=moUEPry3aDxT5zhztcdSCcQ7EgMclLAE92ZqoCHIIUBKH1ovE20WokgquZRvHy5cdLs6BRyMa8sScJJFs9LENHB0D9FFm3RDTf304RMdqsZEHdSlbQWYoIOjXcTwNFhQyIdxIpSvlyuYq89vv9awdBZVSHto/ofEZOOr0D1+bY9H9kTPVasnzL2LCJVocwH7RS5HHzXioEvuVkn1nlomE/XoF4aMZbCWubvemEeNzh7F2pZKMPxwoUDYshskrtVrErrfu903GOZzcvXmt7aL4XUr5Dwt5p3ePgUpyBRNN01RJJyJbHtyHvFGnNJ+9J103FrnliMVTPEc9j3TCFLs+w==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuXvJ-0004Xg-8A; Tue, 18 Mar 2025 10:28:05 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v2 01/17] build/cargo: Pass =?utf-8?b?4oCYLS1vZmZsaW5l4oCZ?= to cargo. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: divya@subvertising.org, efraim@flashner.co.il, steve@futurile.net, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 14:28:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Efraim Flashner , Divya Ranjan Pattanaik , Efraim Flashner , Steve George X-Debbugs-Original-Xcc: Divya Ranjan Pattanaik , Efraim Flashner , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174230805017066 (code B ref 77093); Tue, 18 Mar 2025 14:28:04 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:27:30 +0000 Received: from localhost ([127.0.0.1]:41653 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuXuj-0004RC-VA for submit@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 ) id 1tuXuh-0004R1-TI for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 10:27:28 -0400 From: Hilton Chain 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== Date: Tue, 18 Mar 2025 22:26:44 +0800 Message-ID: <73db5916ba93efd5f30d9e45945a0ccff88c330f.1742306960.git.hako@ultrarare.space> In-Reply-To: References: MIME-Version: 1.0 X-MS-Reactions: disallow X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches 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? From patchwork Tue Mar 18 14:26:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40327 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id A487127BBEA; Tue, 18 Mar 2025 14:28:40 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 285F227BBE2 for ; Tue, 18 Mar 2025 14:28:40 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuXvV-0004uW-CT; Tue, 18 Mar 2025 10:28:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tuXvS-0004u9-V2 for guix-patches@gnu.org; Tue, 18 Mar 2025 10:28:15 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tuXvS-0001LG-Jr for guix-patches@gnu.org; Tue, 18 Mar 2025 10:28:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=tWCnhX4OoBIrcF5cBlDIauVuJiVPteEuBGDYdX+/oyI=; b=a9w+6+sUcjpOTPxwTlIeLgZyb6q2JDJdX4b5N2pI1ieC15N8IKcByfq1p7PsdESWKCocMRN4xzCP+9Skq1kK3N7sLCSASA8DlsVSsbiSvLDMclTonCSEBEt5EAox52cDzFa1ZE6ZNiIDG2GKdIZh79CJSFbxcp7ZqXonAX6FYEgxjQ9mQ8JasDoW9L7BAtoj32hlEJ+BjrKNv9bhM8e1ZboxbQWbnvU0hnMPtMUbBd19/K2WuT4hyBEiVyzYa4CyPOpNKZbo7XZU4pfG1kPSur+ynPxSZrRzsAcTyuvVFVglDQQ90htc0dFLIUyrRhNrjcOIZzfgGHqNwWQZJe/Bvw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuXvO-0004Ym-DA; Tue, 18 Mar 2025 10:28:10 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v2 02/17] build/cargo: Print out all non-empty binary files. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: divya@subvertising.org, efraim@flashner.co.il, steve@futurile.net, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 14:28:10 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Efraim Flashner , Divya Ranjan Pattanaik , Efraim Flashner , Steve George X-Debbugs-Original-Xcc: Divya Ranjan Pattanaik , Efraim Flashner , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174230807217305 (code B ref 77093); Tue, 18 Mar 2025 14:28:10 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:27:52 +0000 Received: from localhost ([127.0.0.1]:41664 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuXv2-0004UN-7O for submit@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 ) id 1tuXul-0004RA-AC for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 10:27:34 -0400 From: Hilton Chain 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== Date: Tue, 18 Mar 2025 22:26:45 +0800 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/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) From patchwork Tue Mar 18 14:26:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40334 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id D8E2C27BBEA; Tue, 18 Mar 2025 14:30:18 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 3FBCF27BBE2 for ; Tue, 18 Mar 2025 14:30:18 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuXws-0005aa-1O; Tue, 18 Mar 2025 10:29:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tuXwK-0005Eq-NG for guix-patches@gnu.org; Tue, 18 Mar 2025 10:29:14 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tuXwJ-0001Sf-UL; Tue, 18 Mar 2025 10:29:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=MBzb7Ibac3SmOWIkI8ON7GjHlsaB/193XKHyjTRQoqk=; b=eNUFdsyWK9R2a6RLQ2Be2ida9+fd4Qg7cjemWN0pN5z2he8uOME0I2lMGyoYFd0YHUPL1TQrtZYtTDF1DQEGE3SKEEAPvZGHBwbDAlq2WQch4aLRyq7hD2RZUaLmkf9H7G3Xb50FGPHDmrssm87GBQoHK/lw3RCGNM5Q3VLYAGkV3/hT5LRASyiDWSr0iSX+kxZlyPhJq+pwMuh/X1yDGbKdVW+TgHVqeE106v+qh8Qdm4wQFeLwmeK7zuqgZKhwb+1k0BnNzTwx6tol4X42plITIoFtncf9btAoKBf/RVguMrd5rjw9w2mpeQuEjj2bfrEZiv5v50DndseLI2m09A==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuXwH-0004hc-3C; Tue, 18 Mar 2025 10:29:05 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v2 03/17] build-system: cargo: Support packaging Cargo workspace. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: divya@subvertising.org, efraim@flashner.co.il, ludo@gnu.org, maxim.cournoyer@gmail.com, steve@futurile.net, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 14:29:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Efraim Flashner , Divya Ranjan Pattanaik , Efraim Flashner , Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer , Steve George X-Debbugs-Original-Xcc: Divya Ranjan Pattanaik , Efraim Flashner , Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174230810217673 (code B ref 77093); Tue, 18 Mar 2025 14:29:05 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:28:22 +0000 Received: from localhost ([127.0.0.1]:41688 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuXvY-0004ak-BU for submit@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 ) id 1tuXum-0004Rg-OD for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 10:27:37 -0400 From: Hilton Chain 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== Date: Tue, 18 Mar 2025 22:26:46 +0800 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/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. From patchwork Tue Mar 18 14:26:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40330 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 5E89927BBEA; Tue, 18 Mar 2025 14:29:36 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id D052E27BBE2 for ; Tue, 18 Mar 2025 14:29:35 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuXwg-0005R5-RO; Tue, 18 Mar 2025 10:29:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tuXwI-0005Eb-DI for guix-patches@gnu.org; Tue, 18 Mar 2025 10:29:12 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tuXwH-0001S5-Pa; Tue, 18 Mar 2025 10:29:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=FWpLZ+ufoQV1Ds7z8c897yBpgjk/6z32S6Qk4j1sjwo=; b=bw9/n/YHHy+gotXVFStK/fCqQtbH+Yckmv0ygdK9twxUl34Qgw1C7yHRn4FUqBQLALBGKhFocNibrll8eWuPBZ4OQHKdfDZKgUethsnWtqdPfXizjz5wgQA3uHYt9LspC3yJnNvE2xD0/fI25mlEYZXNQZMhLl5TkUAsLeCSWg8FlfKM+qisgat9Brt2LY20wFbfWzMoh4illJSPmoDZ1wamWylHYdMUFGackSA14Oj3GHucxCwyXgM+8kWpYawAv38SvSiA5+pXIWGt68Ch+LiUFTIdl45x/M34tAWPfwRJnJviqegZtZfs4WEjxI7dLOjCa/W7kU0ny9n9HbNtUw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuXwH-0004hl-Jl; Tue, 18 Mar 2025 10:29:05 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v2 04/17] build-system: cargo: Support installing Cargo workspace. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: divya@subvertising.org, efraim@flashner.co.il, ludo@gnu.org, maxim.cournoyer@gmail.com, steve@futurile.net, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 14:29:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Efraim Flashner , Divya Ranjan Pattanaik , Efraim Flashner , Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer , Steve George X-Debbugs-Original-Xcc: Divya Ranjan Pattanaik , Efraim Flashner , Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174230810417700 (code B ref 77093); Tue, 18 Mar 2025 14:29:05 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:28:24 +0000 Received: from localhost ([127.0.0.1]:41690 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuXva-0004ay-83 for submit@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 ) id 1tuXup-0004SK-Dg for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 10:27:37 -0400 From: Hilton Chain 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== Date: Tue, 18 Mar 2025 22:26:47 +0800 Message-ID: <131e76c748cd19bbda57ad11a4b83884b7eebf0e.1742306960.git.hako@ultrarare.space> In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches *guix/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. From patchwork Tue Mar 18 14:26:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40329 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 7628527BBEA; Tue, 18 Mar 2025 14:29:32 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 2E97327BBE9 for ; Tue, 18 Mar 2025 14:29:32 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuXwc-0005Na-UZ; Tue, 18 Mar 2025 10:29:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tuXwH-0005E4-1U for guix-patches@gnu.org; Tue, 18 Mar 2025 10:29:05 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tuXwG-0001Rk-Nb for guix-patches@gnu.org; Tue, 18 Mar 2025 10:29:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=lnQ3fNha3tTpiuYZ0UQT7xqK8VBIVtWVUs+XKQhkaWc=; b=ZrNlNx3S/3J3MByVhsanm9IiKDoKlvPbb+VzeNInjJKm3lqWX1q42ytw7AgbjhF9TiohtozJ05H7o9Bh0kFwAQ566AP+3wwALhk9cNnXbFGG1vRoIF/FiGTLTWW3461+gglUugctUSi8j/Tar/N2NAImXrkiDEaTOPgLzeN6E9mUINEnErny+98NVierW4Ot9oS250fIE/e2GY8yoczi2rsLU1LA+TPeTJlcdg8vEXlWxuNuKW/nZpm8Cpu9kxsJrvEl+zMBDTtKkPN65wzF5xryT3sTKhQ1wZqPhV53aR5jGaODpdQPIdXH+emL7XhOnhEzIJ3QktMIrlpPldqnTA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuXwG-0004hR-8P; Tue, 18 Mar 2025 10:29:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v2 05/17] build/cargo: Set default value of arguments for build phases. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: divya@subvertising.org, efraim@flashner.co.il, steve@futurile.net, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 14:29:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Efraim Flashner , Divya Ranjan Pattanaik , Efraim Flashner , Steve George X-Debbugs-Original-Xcc: Divya Ranjan Pattanaik , Efraim Flashner , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174230810017657 (code B ref 77093); Tue, 18 Mar 2025 14:29:04 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:28:20 +0000 Received: from localhost ([127.0.0.1]:41686 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuXvW-0004aM-1l for submit@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 ) id 1tuXus-0004Sf-4F for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 10:27:39 -0400 From: Hilton Chain 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== Date: Tue, 18 Mar 2025 22:26:48 +0800 Message-ID: <7a65eca436b0880f9cd829d3f3703696a08386df.1742306960.git.hako@ultrarare.space> In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches 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." From patchwork Tue Mar 18 14:26:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40332 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 9E04927BBEA; Tue, 18 Mar 2025 14:30:05 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 6EE6E27BBE2 for ; Tue, 18 Mar 2025 14:30:05 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuXwl-0005Vl-CX; Tue, 18 Mar 2025 10:29:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tuXwI-0005Eg-To for guix-patches@gnu.org; Tue, 18 Mar 2025 10:29:14 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tuXwI-0001SE-ER for guix-patches@gnu.org; Tue, 18 Mar 2025 10:29:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=/rzdlzWItiPgm9mMM9D4fKw9AdkNnt3Yvo2naRK6/Yg=; b=Oh1IlajY0CQCb5dTFDt5Q9vZHdpfbOcOE4rZLD048z0mqWOw9cdaWVJ9KD1jdwLKZTUctBXUHo1lxxhoCruUXOvhgtllQ44p8nR4wBrkpfOHM8+ZaChkM+EdqU4UlJSHwIZMnoSMfEyw8D2znrauL1Xo+wWa6imCN1EAtpduWtYZgA11GBa1zmmjfmbulTwjqwIseJldZtcy7UKabHyeQ2ICI0hJW3YiLtHwG/PC/JlVtLNwWlAkG/jpnoaTF3rvKca+ymC7wEbhdTEOAE+KtQWGKvo92qP8aWG5KdzGbNqXifwQqxvxBNhUKVtgEyvXpyG9k1fsSdhwuDneACovxQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuXwI-0004hw-4S; Tue, 18 Mar 2025 10:29:06 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v2 06/17] build/cargo: Don't try to unpack sanity-check.py. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: divya@subvertising.org, efraim@flashner.co.il, steve@futurile.net, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 14:29:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Efraim Flashner , Divya Ranjan Pattanaik , Efraim Flashner , Steve George X-Debbugs-Original-Xcc: Divya Ranjan Pattanaik , Efraim Flashner , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174230810617723 (code B ref 77093); Tue, 18 Mar 2025 14:29:06 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:28:26 +0000 Received: from localhost ([127.0.0.1]:41692 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuXvc-0004bO-5C for submit@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 ) id 1tuXuu-0004TE-GQ for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 10:27:41 -0400 From: Hilton Chain 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== Date: Tue, 18 Mar 2025 22:26:49 +0800 Message-ID: <61a9a8ca7dce12d0a05dc060ea891c5443648bcc.1742306960.git.hako@ultrarare.space> In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches From: Efraim Flashner * 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 From patchwork Tue Mar 18 14:26:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40333 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id F2C4027BBEA; Tue, 18 Mar 2025 14:30:15 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 59B1B27BBE2 for ; Tue, 18 Mar 2025 14:30:15 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuXwf-0005Qk-Q9; Tue, 18 Mar 2025 10:29:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tuXwJ-0005En-Lw for guix-patches@gnu.org; Tue, 18 Mar 2025 10:29:14 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tuXwI-0001SL-WC for guix-patches@gnu.org; Tue, 18 Mar 2025 10:29:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=tbbBEmq0fTJiCFdj43NMRydjWkPfzpnZqNYgFZF3pNU=; b=Kylg5n/HFO/WyJdMtGQjXKryCh8DZsF7V62APRyWXs/+DgvmLtchgeDCU0NYoWeFbZ8o8eH8qQAUZn5S81C8dAYRum0FvU7ZmcBbJoaFGadzXOicbah20yQMigXk2YD+WKUScyTt1TCrA8jMjauPCw3OiIsGbzS9I+E3kAqRI6d83E8bnNG8zWTGar93MxUhs+uDOdqaZwNgyWbVKPsrlBKqP6NXeAkRGFIjxEpCxhl0ALrLQqXHV9MwcoH+csDutkiEgmcNfB1WcKDpEdBY5vTKz1Cuss6Cb62KSgVUX9F8UVZVbutrpnPTNtXWDDa+x528BOKO/1WEK7Ai8FNXiw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuXwI-0004i6-Mk; Tue, 18 Mar 2025 10:29:06 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v2 07/17] build/cargo: Support non-workspace directory source inputs. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: divya@subvertising.org, efraim@flashner.co.il, steve@futurile.net, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 14:29:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Efraim Flashner , Divya Ranjan Pattanaik , Efraim Flashner , Steve George X-Debbugs-Original-Xcc: Divya Ranjan Pattanaik , Efraim Flashner , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174230810917759 (code B ref 77093); Tue, 18 Mar 2025 14:29:06 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:28:29 +0000 Received: from localhost ([127.0.0.1]:41694 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuXvd-0004bm-UE for submit@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 ) id 1tuXuy-0004Th-4q for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 10:27:44 -0400 From: Hilton Chain 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== Date: Tue, 18 Mar 2025 22:26:50 +0800 Message-ID: <61e545567eda8714f688c1f0655d72a2efbe2245.1742306960.git.hako@ultrarare.space> In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/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 From patchwork Tue Mar 18 14:26:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40331 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id D07C327BBEA; Tue, 18 Mar 2025 14:29:57 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 8FF3C27BBE2 for ; Tue, 18 Mar 2025 14:29:57 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuXwm-0005XM-KO; Tue, 18 Mar 2025 10:29:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tuXwP-0005Je-7h for guix-patches@gnu.org; Tue, 18 Mar 2025 10:29:18 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tuXwO-0001Tr-Tn; Tue, 18 Mar 2025 10:29:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=0gATDkYY9+HlIpSIiMsJydmF48/8/FeFvqFI8MW5iOs=; b=Aar1Ij3mrvROvjqbpovdfHoxrARpNT0rd5oaofHR4mfpYM/79LV7FNdQTmw5QZOYAVpUH+d15N5JoiWS5M9jJqmQWrQi7nrevp+vtMMDr40+EWT6gECuteBIJHMk05652haROYBh5kN/kSt+Pxqxuw99hx9+UJv8xU1Gx08md7fEcmpkJ0FKDOcz086+DA7eraq+iWe7hUlr1yPKPs1WlhllHj5g0XhRhgN7PFhMx2Ci3szs40NQ9/YyowesmCgKq7bKHd7rM6FNYWCWklzxaj3ZP1+TFUlEp3HIcT1XRn/ahToA6DiXka3gvdkDJOEnbad2+Qj5sxhrC50tINlSjA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuXwK-0004ig-Jo; Tue, 18 Mar 2025 10:29:08 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v2 08/17] scripts: import: Document argument for =?utf-8?b?4oCYLS1pbnNlcnTigJk=?= option in help message. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 14:29:08 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Efraim Flashner , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174230811117779 (code B ref 77093); Tue, 18 Mar 2025 14:29:08 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:28:31 +0000 Received: from localhost ([127.0.0.1]:41696 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuXvh-0004cL-1S for submit@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 ) id 1tuXv0-0004Ty-TF for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 10:27:47 -0400 From: Hilton Chain 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== Date: Tue, 18 Mar 2025 22:26:51 +0800 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-MS-Reactions: disallow X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/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) From patchwork Tue Mar 18 14:26:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40336 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 9972B27BBE2; Tue, 18 Mar 2025 14:30:47 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 9997D27BBE2 for ; Tue, 18 Mar 2025 14:30:46 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuXxO-00068i-3B; Tue, 18 Mar 2025 10:30:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tuXxG-000601-UY for guix-patches@gnu.org; Tue, 18 Mar 2025 10:30:09 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tuXxG-0001pp-KG; Tue, 18 Mar 2025 10:30:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=q8EtGgJNAcVCCAJm1iKNtDwPxS31GnBy41AJ8jW1jdQ=; b=hzjjP9s/jA+UEsjG+cwCb2oYCeVTmXYQaT5p0nbgJTMdylyOheMsO1gszY6rhMMdVTk/3kyfdLr2g6CmH/K14qg9SCah90ZjiZlU97g5nqF+wXBqYEvtFER8Yn6XYJdHJarLh33N68aEyWVgGEybNiIjyoBh4LjY7rPPn8C5kM/datucl4kaxbCcSrdX0KPCoMb4BKenUUAcquQcqai+8Cof99CINXQah028Q0mXrDd0Q7/utdHr9A8snFniYzZXGpwDbWKaYKXN4cBjpBa8m7R3DPWJakbb5P7beEBuyxRwScl5nn8FBDQylgvO3i2p+WOsOiNmEzAv8n2SBqMSpA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuXxD-0004qS-IK; Tue, 18 Mar 2025 10:30:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v2 09/17] scripts: import: Add two newlines for =?utf-8?b?4oCYLS1pbnNlcnTigJk=?= option. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 14:30:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Efraim Flashner , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174230815818214 (code B ref 77093); Tue, 18 Mar 2025 14:30:03 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:29:18 +0000 Received: from localhost ([127.0.0.1]:41733 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuXwT-0004jO-2S for submit@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 ) id 1tuXv3-0004UY-AT for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 10:27:51 -0400 From: Hilton Chain 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== Date: Tue, 18 Mar 2025 22:26:52 +0800 Message-ID: <11fef5174ac01e0da00318799b2cf10826d09d3c.1742306960.git.hako@ultrarare.space> In-Reply-To: References: MIME-Version: 1.0 X-MS-Reactions: disallow X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches 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 ...) From patchwork Tue Mar 18 14:26:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40335 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 391AB27BBE9; Tue, 18 Mar 2025 14:30:38 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 9F78427BBE2 for ; Tue, 18 Mar 2025 14:30:37 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuXxS-0006OL-Ji; Tue, 18 Mar 2025 10:30:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tuXxQ-0006GP-BF for guix-patches@gnu.org; Tue, 18 Mar 2025 10:30:16 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tuXxP-0001vl-O5; Tue, 18 Mar 2025 10:30:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=pEk75I1A9NmXZ9D/zh4q9scyVRAY149icZ/Q4bBikA8=; b=FeZAVV1Ks3eHRJMhzk1bhMzsYRk7Yh3YKo1TaO+4xN+K6p95MQqyNoLN/p0uRJzvSGlOJDVqB/yUPWKlRhPmUTUW1DWv2bZnXVOjeRxCUEzMAPi7i2QsJSShRJr/zctu5BU/DJ9RyAPAbabccAify+xlddD+5nZPZyPX+0Xe7lQVxR3unGeKpY/pTC6wdLHg3xfk1RTcm+ANbxAgUrNbf4/XZqTbQmuRGrYkjsRk8mew5ju94X8Z2meEthNwWX/B1YsxFeDtiPzqKPDmQBC1vHZRKWvMZyo2pKF/tZmpotR/mDahxyGiKd+w7heady6+TG0JDvsJ8anPRm2bgMYtTw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuXxP-0004v4-9O; Tue, 18 Mar 2025 10:30:15 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v2 10/17] scripts: import: Support expressions defined by 'define. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 14:30:14 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Efraim Flashner , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174230817118356 (code B ref 77093); Tue, 18 Mar 2025 14:30:14 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:29:31 +0000 Received: from localhost ([127.0.0.1]:41742 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuXwf-0004lj-Gg for submit@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 ) id 1tuXv5-0004Uv-Su for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 10:27:54 -0400 From: Hilton Chain 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== Date: Tue, 18 Mar 2025 22:26:53 +0800 Message-ID: <592685c77f24f1052112c00965c9fa1deeedaf33.1742306960.git.hako@ultrarare.space> In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/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. From patchwork Tue Mar 18 14:26:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40337 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 7F45727BBE9; Tue, 18 Mar 2025 14:30:49 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id A69CC27BBE2 for ; Tue, 18 Mar 2025 14:30:48 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuXxu-0006f7-PO; Tue, 18 Mar 2025 10:30:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tuXxc-0006QH-K9 for guix-patches@gnu.org; Tue, 18 Mar 2025 10:30:31 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tuXxU-0001xr-QB; Tue, 18 Mar 2025 10:30:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=jOiUGlxxPpFfGgx8EQ8JgogXc8eb5gPzD0mpj4FS+sQ=; b=n9zgLQuM4qzF47/8wKodmLWjDsvRZdSJgOUVz5rx3Czkpe4yz+jHfkWsjVhYsfkQKzP7op7hazOLsVF72XDHqPVw771Dxqd38InM6MpSb4fXCM+qxeaB7RU+dJcqQuFHEdHPrm9HcReTGEquwcK3pZFee7hSvDt53e++3qOeZYIM+dLEem+plT7CClXVWVS1q42gX6ECAUdmPp0AfhUIoM3vyhSixGYhOVz3UqSV0z1s/pqO5eTrrn3WVE5Q0IOznoooXVypq+JX3lcJ351RkR/3ZfcnoKAnL0qapya2uLF7kzEkyXK8vAWlOkbu7M3g6F21woff8jxlCz8WNzaWIw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuXxS-0004wS-0X; Tue, 18 Mar 2025 10:30:18 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v2 11/17] scripts: import: Pass "--insert" to importers. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 14:30:17 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Efraim Flashner , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174230817218373 (code B ref 77093); Tue, 18 Mar 2025 14:30:17 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:29:32 +0000 Received: from localhost ([127.0.0.1]:41744 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuXwh-0004m6-4F for submit@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 ) id 1tuXv8-0004VT-Di for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 10:27:55 -0400 From: Hilton Chain 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== Date: Tue, 18 Mar 2025 22:26:54 +0800 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-MS-Reactions: disallow X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches 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 From patchwork Tue Mar 18 14:26:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40342 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 9BA6627BBEA; Tue, 18 Mar 2025 14:31:24 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 64BE027BBE2 for ; Tue, 18 Mar 2025 14:31:24 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuXyL-0007E7-2B; Tue, 18 Mar 2025 10:31:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tuXxb-0006QA-Mb for guix-patches@gnu.org; Tue, 18 Mar 2025 10:30:30 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tuXxX-0001xz-8f; Tue, 18 Mar 2025 10:30:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=WGvHTrbjVrTWfbllNr3p4AZWghFWH2g/oDoIhRm6W2s=; b=ltFquoZpRox6WrRahbabCp2Ruaa2IlKqk7F3DHO8jo5vwXi3+/Xw1VXGS8lEyPcjX0EyyiBqrhGqgliSx23en27U9+ruWIbi9EFz8/X6PDD/9o+eGZk5u2QXWl5kBPNqMEN9t7pYMdkHKhBM/g+OPt8QZqvm++Cj53pd8Rr0ojlii44GgmKsAl1Bt/uefCOfSsbqUhGA8oxeURA5xN8O1XzdAmiDbo1YxFvnslelEKtQ04jqiOh4lSvbLH56JL3/MntwMD6gKXTTFgIedloEyMzXGqRjAmrWmJUedlo874jzAj2zMxOuwtht8Us0b7vK40JiqtPZ/tzxLOOkapu+XQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuXxU-0004xL-Bb; Tue, 18 Mar 2025 10:30:20 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v2 12/17] scripts: import: Skip existing definition for =?utf-8?b?4oCYLS1pbnNlcnTigJk=?= option. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 14:30:20 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Efraim Flashner , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174230818218453 (code B ref 77093); Tue, 18 Mar 2025 14:30:20 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:29:42 +0000 Received: from localhost ([127.0.0.1]:41746 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuXwq-0004nP-CO for submit@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 ) id 1tuXvA-0004W2-Sk for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 10:27:57 -0400 From: Hilton Chain 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== Date: Tue, 18 Mar 2025 22:26:55 +0800 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-MS-Reactions: disallow X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/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) From patchwork Tue Mar 18 14:26:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40343 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 420AC27BBEA; Tue, 18 Mar 2025 14:31:26 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id EEF3B27BBE2 for ; Tue, 18 Mar 2025 14:31:25 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuXyK-0007An-Is; Tue, 18 Mar 2025 10:31:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tuXxb-0006Q8-LA for guix-patches@gnu.org; Tue, 18 Mar 2025 10:30:30 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tuXxX-0001xy-5e for guix-patches@gnu.org; Tue, 18 Mar 2025 10:30:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=s7xZt4cQLBfnnSWkcwL6+4CaT6WsRgs4zxV7rKgM8RE=; b=PkY65wcuwJmruzuhd5Nlcm2OuaG1zgfi96/VQJzB1ZEefQ1vYE+ZGlh0OjsQvHZEtWmik3A2RCsollHOswV6QppIddL9gEPu2jxA3rrOfNAD0Y1fZxWaL/zv98QYpl/w5tlDprlxvPB2Dc53Mkvu1qQoA/C/2I+2KRsnL89rQu755+aEnG475+xS4CJ0m+3sRbf9BznNo4y/5/+JXsekZZC1bObXPbZ9U7u8FqJTR7wmzEAzgk5+DtsD332nEwCwl+h5segLmyS41S1KLycNywvDqc3IGKG/BP4iXXlc5zy0376XphpgusERf2c6k7F6PiFYrhRj31EqzKAkEJtabw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuXxW-0004yT-Mt; Tue, 18 Mar 2025 10:30:22 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v2 13/17] import: crate: crate-name->package-name: Move to (guix build-system cargo). Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: divya@subvertising.org, efraim@flashner.co.il, steve@futurile.net, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 14:30:22 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Efraim Flashner , Divya Ranjan Pattanaik , Efraim Flashner , Steve George X-Debbugs-Original-Xcc: Divya Ranjan Pattanaik , Efraim Flashner , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174230818218460 (code B ref 77093); Tue, 18 Mar 2025 14:30:22 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:29:42 +0000 Received: from localhost ([127.0.0.1]:41748 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuXwr-0004na-LK for submit@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 ) id 1tuXvD-0004WO-71 for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 10:28:00 -0400 From: Hilton Chain 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== Date: Tue, 18 Mar 2025 22:26:56 +0800 Message-ID: <68e9dbe1fba53dc68b274d78b7ee084db36c0f77.1742306960.git.hako@ultrarare.space> In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/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))) - From patchwork Tue Mar 18 14:26:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40339 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 24C9927BBEA; Tue, 18 Mar 2025 14:30:57 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 2414827BBE2 for ; Tue, 18 Mar 2025 14:30:56 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuXxv-0006gL-4d; Tue, 18 Mar 2025 10:30:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tuXxG-0005zF-8m for guix-patches@gnu.org; Tue, 18 Mar 2025 10:30:09 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tuXxF-0001ji-Qc for guix-patches@gnu.org; Tue, 18 Mar 2025 10:30:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=E7TeCgPqwH4icNChpfIeEaQGrQC116WRgTGHhGN25w0=; b=CcgKuwjlbI/JDZx5nroIYEgrj9QevoqgB2+CQr+4au3AkQFbPSI9OyPV1Zs0dV9PIiiRITDvHZIEjb3VmfZJUGOPtgoHuaIB6yH89jqOg9pfYjEd/+pBZ0Sm6RObYK44NJePFjzZsDVkB2NO7uADtLCyQibPfRhCZoHikv2ctA62q+hVEYy00BaV9JVvln9tDEIX5qH40X8U/SPDObVr+QqImdlN20QidR5gG1475eIr34GTo5y1s772nPvpZbO1Z75cMoiQsxYwkEx4oSPS+pYhbjdV+A+YmJiRFf8hP7LFSjgYwpxRfQgeavWT9lexpGfdDK392OAVho6FqJbaTw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuXxF-0004r7-8j; Tue, 18 Mar 2025 10:30:05 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v2 14/17] build-system: cargo: Add =?utf-8?b?4oCYY2FyZ28taW5wdXRz4oCZLg==?= Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: divya@subvertising.org, efraim@flashner.co.il, steve@futurile.net, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 14:30:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Efraim Flashner , Divya Ranjan Pattanaik , Efraim Flashner , Steve George X-Debbugs-Original-Xcc: Divya Ranjan Pattanaik , Efraim Flashner , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174230816118241 (code B ref 77093); Tue, 18 Mar 2025 14:30:04 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:29:21 +0000 Received: from localhost ([127.0.0.1]:41735 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuXwU-0004jj-EA for submit@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 ) id 1tuXvF-0004Wt-S0 for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 10:28:06 -0400 From: Hilton Chain 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== Date: Tue, 18 Mar 2025 22:26:57 +0800 Message-ID: <647adc3bc797d6c8d86b9d35ff2eb1f03a1db32d.1742306960.git.hako@ultrarare.space> In-Reply-To: References: MIME-Version: 1.0 X-MS-Reactions: disallow X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * 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 +# +# 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 . + +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 +;;; +;;; 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 . + +(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 +;;; +;;; 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 . + +(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 +;;; +;;; 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 . + +(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) From patchwork Tue Mar 18 14:26:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40338 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 4BD0527BBE2; Tue, 18 Mar 2025 14:30:50 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 8041E27BBEA for ; Tue, 18 Mar 2025 14:30:47 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuXxO-0006AM-8p; Tue, 18 Mar 2025 10:30:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tuXxI-00062R-VJ for guix-patches@gnu.org; Tue, 18 Mar 2025 10:30:11 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tuXxI-0001uY-I2 for guix-patches@gnu.org; Tue, 18 Mar 2025 10:30:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=XTHL2+Dc8FXC/fJ5wbbmDsUrkjMdqma1fsZgBXba7iQ=; b=HpzbFuaCLMlnbHYZGxKU1YfhdW9Pe9eJtcazPRYXyS8O3XIPJxaF7vErv2kMs1ZV2BXegqzOVhZe/jl/qajjxl0UmxlaM5q/8uSKK/msoiIV6WUnixpURGRr/cKlFjb2VDYG8YJPJWizwosHyLIklG3QVWYrLOi62ygvkqpxues3/F3EK0NxT6gnU8tPb5UB0skdYnG5dxahsFGDhsOLY71AoktcwK2yh3lsDErdijam5G6pj5vHQoGIhDLfe2PERSVG++LdB3cV4eKj5SHJT5IYbmYbNyEh65EBnHq3ToO4MtHIVu8L7kgZjDw8qELZF0loWlCJiGFQrsNIoTyK5g==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuXxI-0004rv-0X; Tue, 18 Mar 2025 10:30:08 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v2 15/17] import: crate: Add Cargo.lock parser. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: divya@subvertising.org, efraim@flashner.co.il, steve@futurile.net, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 14:30:07 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Murilo , Hilton Chain , Efraim Flashner , Luis Guilherme Coelho , Divya Ranjan Pattanaik , Efraim Flashner , Steve George X-Debbugs-Original-Xcc: Divya Ranjan Pattanaik , Efraim Flashner , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174230816418284 (code B ref 77093); Tue, 18 Mar 2025 14:30:07 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:29:24 +0000 Received: from localhost ([127.0.0.1]:41738 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuXwX-0004kA-Ii for submit@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 ) id 1tuXvJ-0004XX-8H for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 10:28:09 -0400 From: Hilton Chain 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== Date: Tue, 18 Mar 2025 22:26:58 +0800 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-MS-Reactions: disallow X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/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 Co-authored-by: Luis Guilherme Coelho 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 ;;; Copyright © 2024 Maxim Cournoyer ;;; Copyright © 2025 Herman Rimm +;;; Copyright © 2024 Murilo +;;; Copyright © 2024-2025 Luis Guilherme Coelho +;;; Copyright © 2025 Hilton Chain ;;; ;;; This file is part of GNU Guix. ;;; @@ -26,12 +29,14 @@ ;;; along with GNU Guix. If not, see . (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 +;;; Copyright © 2024 Luis Guilherme Coelho +;;; +;;; 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 . + +(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))) From patchwork Tue Mar 18 14:26:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40340 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id D51E227BBE9; Tue, 18 Mar 2025 14:30:58 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id EAA8B27BBE2 for ; Tue, 18 Mar 2025 14:30:57 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuXxv-0006cm-EK; Tue, 18 Mar 2025 10:30:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tuXxQ-0006HX-MU for guix-patches@gnu.org; Tue, 18 Mar 2025 10:30:16 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tuXxQ-0001w8-4H; Tue, 18 Mar 2025 10:30:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=NMsWPuSK7R0bwF3Y+WIV3Ki4xiumhf538WeEtRM3dR4=; b=KYOZl6jpkrAtYwZZiMB/01sF5Ey2njnf7kMRQa3HYWwKOLG8LAmr0wdZ/cFxQo/K3bghTzgUDrq5IQnolE006kQQfZ6HkPyUwl9EeRs7yJUbJlTX3d9TAx/P3PJq83D/GitYNL9fNefx5J30a5KpT79GrVW2cv/nGC6sVE4kEkyyPH5X8eJh+aELd7ER4dB+ExVroKYlqPcg8FFh3CnNBNomEzmuNNcsdPMVEZg4ZZxWeNX+V4gpUZdnGBRSUCJBIad2PYVnTkW6PvuS4XK5HuJbhQ5R5Z8gvgW9jgAtCPdoCvi9JM20wRNLIrfjv239qMmwjPVJmsEcRmAVNu/0PQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuXxL-0004tg-EB; Tue, 18 Mar 2025 10:30:11 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v2 16/17] import: crate: Add =?utf-8?b?4oCYLS1sb2NrZmlsZeKAmQ==?= option. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, divya@subvertising.org, efraim@flashner.co.il, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, maxim.cournoyer@gmail.com, zimon.toutoune@gmail.com, steve@futurile.net, me@tobias.gr, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 14:30:11 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Efraim Flashner , Christopher Baines , Divya Ranjan Pattanaik , Efraim Flashner , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Maxim Cournoyer , Simon Tournier , Steve George , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Divya Ranjan Pattanaik , Efraim Flashner , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Maxim Cournoyer , Simon Tournier , Steve George , Tobias Geerinckx-Rice Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174230816918333 (code B ref 77093); Tue, 18 Mar 2025 14:30:11 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:29:29 +0000 Received: from localhost ([127.0.0.1]:41740 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuXwa-0004kq-1J for submit@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 ) id 1tuXvL-0004Y3-OA for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 10:28:11 -0400 From: Hilton Chain 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== Date: Tue, 18 Mar 2025 22:26:59 +0800 Message-ID: <2cdc1f3f422de5c16aa0b653d4a740867a4e2cee.1742306960.git.hako@ultrarare.space> In-Reply-To: References: MIME-Version: 1.0 X-MS-Reactions: disallow X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/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 + ($ + ";; 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)) From patchwork Tue Mar 18 14:27:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40341 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id B0EAE27BBEA; Tue, 18 Mar 2025 14:31:20 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED,URIBL_SBL_A autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 292DA27BBE2 for ; Tue, 18 Mar 2025 14:31:17 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuXyN-0007Hh-5n; Tue, 18 Mar 2025 10:31:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tuXxb-0006Q9-Mf for guix-patches@gnu.org; Tue, 18 Mar 2025 10:30:30 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tuXxY-0001y4-FZ; Tue, 18 Mar 2025 10:30:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=fYh+Bj/HtW5J1+1CPK1CvQMLgPhMjNp3CvRauv6IPNA=; b=Oh8Oqe9cGgRbrOYDu8YJcmo8UTOAFC+kt5CgwdgY1BwZJ3PkmIk8B97XnocpU33c1KJJ0dm3mXV3/gi7fYQ88RcxVZPpYHgT4MHBD2/Cza6LoKxzK4kiHIwyn9Mg+J1x9vsBOd2AO57kACH6PZqmlYciWNOmddUj5GNobA0kUyVvTQi9NbsYaBcZtg1ehV9+mZkzKBVUUsoohn1+EX7kjnBq2sPxkoaj3LqMfeme3kt6qi9NhZeqaf/0VPkdMARRLNNf2z2hWY0V4jy32L2gW5emjqh6IkNtp2wX8Mny4JjnkjOKxjXbUjF7oXupnK28QiO9aZYNg3IDV/hYRRKzWA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuXxY-0004yj-8e; Tue, 18 Mar 2025 10:30:24 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v2 17/17] doc: Document lockfile importer based Rust packaging workflow. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: ludo@gnu.org, maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 14:30:24 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Efraim Flashner , Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer X-Debbugs-Original-Xcc: Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174230818518470 (code B ref 77093); Tue, 18 Mar 2025 14:30:24 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:29:45 +0000 Received: from localhost ([127.0.0.1]:41750 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuXws-0004nh-7W for submit@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 ) id 1tuXvO-0004Yb-8M for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 10:28:17 -0400 From: Hilton Chain 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== Date: Tue, 18 Mar 2025 22:27:00 +0800 Message-ID: <613319a41cd8d7823cb1d0aa6cc710cf24239a6b.1742306960.git.hako@ultrarare.space> In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * 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