From patchwork Mon Feb 17 23:43:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Graves X-Patchwork-Id: 38802 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 5361727BBEA; Mon, 17 Feb 2025 23:49:59 +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=-6.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,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 CAF9827BBE2 for ; Mon, 17 Feb 2025 23:49:58 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tkArM-0004o9-IH; Mon, 17 Feb 2025 18:49:08 -0500 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 1tkArJ-0004me-O3 for guix-patches@gnu.org; Mon, 17 Feb 2025 18:49:06 -0500 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 1tkArJ-0005EN-EE for guix-patches@gnu.org; Mon, 17 Feb 2025 18:49:05 -0500 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=gkTexoAelNKp2uQ9cGmW5wSEeFpaj1pbgaaqcbZZLkE=; b=XqTobgD8Y0OcIyAa+MlmaNR5llEhbceRMOdWQls3g+i4f4oX2s2dcViAzPYgk+/m/YW1/DSDo0JjR0fA+Keg2gDdDT/pOEfJmCeUNXbNnkBIHgI9GUa31Vun+guBKTwFhcN8FygH8ClIpQGGBoohn7v0BQkfLD5rSV7qGniD/2bHh0yNgg08/TE4EGwb3ncwbScK7WjK1oWaoHnxLZQAyM1SBV0TfDIwnuAAb7y+C7Zs1SLw1lx/a+E+i45pa7MHMYZ4JF4eTET+tldacT1qUhJyTpARy6bMQbKAt5ack50vJGD4yn/3cQPsLr34NMPgUBqSVTYNSRkB/pkhNnaIhQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tkArJ-0007Pn-7n for guix-patches@gnu.org; Mon, 17 Feb 2025 18:49:05 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#74900] [PATCH v2 5/6] build-system/tree-sitter: Switch to (json). Resent-From: Nicolas Graves Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 17 Feb 2025 23:49:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74900 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74900@debbugs.gnu.org Cc: Nicolas Graves , jlicht@fsfe.org, d.khodabakhsh@gmail.com Received: via spool by 74900-submit@debbugs.gnu.org id=B74900.173983613628417 (code B ref 74900); Mon, 17 Feb 2025 23:49:05 +0000 Received: (at 74900) by debbugs.gnu.org; 17 Feb 2025 23:48:56 +0000 Received: from localhost ([127.0.0.1]:51177 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tkAr9-0007O7-Di for submit@debbugs.gnu.org; Mon, 17 Feb 2025 18:48:56 -0500 Received: from 8.mo576.mail-out.ovh.net ([46.105.56.233]:34287) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tkAqo-0007Lg-OS for 74900@debbugs.gnu.org; Mon, 17 Feb 2025 18:48:36 -0500 Received: from director1.ghost.mail-out.ovh.net (unknown [10.109.148.6]) by mo576.mail-out.ovh.net (Postfix) with ESMTP id 4YxfVn1FQ5z1wMX for <74900@debbugs.gnu.org>; Mon, 17 Feb 2025 23:48:33 +0000 (UTC) Received: from ghost-submission-5b5ff79f4f-k5f24 (unknown [10.110.164.228]) by director1.ghost.mail-out.ovh.net (Postfix) with ESMTPS id BB80A1FD7F; Mon, 17 Feb 2025 23:48:32 +0000 (UTC) Received: from ngraves.fr ([37.59.142.107]) by ghost-submission-5b5ff79f4f-k5f24 with ESMTPSA id g4HbJdDKs2cshh8AqZ2JJA (envelope-from ); Mon, 17 Feb 2025 23:48:32 +0000 Authentication-Results: garm.ovh; auth=pass (GARM-107S001153f58b5-a54d-4e93-90e4-4bb217cbff00, C3652AECFC9F6A3CBC46B0867312B59102225E78) smtp.auth=ngraves@ngraves.fr X-OVh-ClientIp: 90.92.117.144 Date: Tue, 18 Feb 2025 00:43:56 +0100 Message-ID: <20250217234823.10533-6-ngraves@ngraves.fr> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250217234823.10533-1-ngraves@ngraves.fr> References: <20250217234823.10533-1-ngraves@ngraves.fr> MIME-Version: 1.0 X-Ovh-Tracer-Id: 14614462266034807522 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdehleejjecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomheppfhitgholhgrshcuifhrrghvvghsuceonhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrqeenucggtffrrghtthgvrhhnpeelffejteeutefhfeekfffffedvudekjeekgfeludeitdfhkeevhfeivdfhffeggeenucfkphepuddvjedrtddrtddruddpledtrdelvddruddujedrudeggedpfeejrdehledrudegvddruddtjeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduvdejrddtrddtrddupdhmrghilhhfrhhomhepnhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrpdhnsggprhgtphhtthhopedupdhrtghpthhtohepjeegledttdesuggvsggsuhhgshdrghhnuhdrohhrghdpoffvtefjohhsthepmhhoheejiegmpdhmohguvgepshhmthhpohhuth DKIM-Signature: a=rsa-sha256; bh=gkTexoAelNKp2uQ9cGmW5wSEeFpaj1pbgaaqcbZZLkE=; c=relaxed/relaxed; d=ngraves.fr; h=From; s=ovhmo4487190-selector1; t=1739836113; v=1; b=2ezXZOYVWxAIPbf8TG1IBiel3X5RcFNswIK1ymVrpAmZnJD/P7sjg6EX7Hfzyt7V372N0jxO GEDeIuGoiUJwM1Qnbde0VmHwCD7eoXIARKxsLPAAdedKLrHSSM0SIFdmoNSPwh/Ik9TKKVNBBgr GV5UZ+DAK4bp9Fuxh0zXtgHcJBEGIVSsf6YgicQ/7PFZpmtnmA/4z25r52YFBH+nv/8sUOPqtFY ANeyOptI3CMe1P3tOGuGyOKC3Ltt9Qp42cRdwSbJzXeFfB67Gi+TNSaA7hjt9ixYVwB7uFdOmZl vSCsSLqWFZ2HwxXHMKHxJpFWHbp1wjmIN3ZuOCaQqlpBw== 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: , Reply-to: Nicolas Graves X-ACL-Warn: , Nicolas Graves via Guix-patches X-Patchwork-Original-From: Nicolas Graves via Guix-patches via From: Nicolas Graves 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/tree-sitter-build-system.scm (patch-dependencies, install): Switch from (guix build json) to (json). --- guix/build/tree-sitter-build-system.scm | 44 +++++++++++-------------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/guix/build/tree-sitter-build-system.scm b/guix/build/tree-sitter-build-system.scm index 4106728bdf..1fe2601dd7 100644 --- a/guix/build/tree-sitter-build-system.scm +++ b/guix/build/tree-sitter-build-system.scm @@ -18,10 +18,10 @@ (define-module (guix build tree-sitter-build-system) #:use-module ((guix build node-build-system) #:prefix node:) - #:use-module (guix build json) #:use-module (guix build utils) #:use-module (ice-9 match) #:use-module (ice-9 regex) + #:use-module (json) #:use-module (srfi srfi-1) #:export (%standard-phases tree-sitter-build)) @@ -47,28 +47,24 @@ (define* (patch-dependencies #:key inputs #:allow-other-keys) "Rewrite dependencies in 'package.json'. We remove all runtime dependencies and replace development dependencies with tree-sitter grammar node modules." - (define (rewrite package.json) - (map (match-lambda - (("dependencies" @ . _) - '("dependencies" @)) - (("devDependencies" @ . _) - `("devDependencies" @ - ,@(filter-map (match-lambda - ((key . directory) - (let ((node-module - (string-append directory - "/lib/node_modules/" - key))) - (and (directory-exists? node-module) - `(,key . ,node-module))))) - (alist-delete "node" inputs)))) - (other other)) - package.json)) - - (node:with-atomic-json-file-replacement "package.json" - (match-lambda - (('@ . package.json) - (cons '@ (rewrite package.json)))))) + (node:with-atomic-json-file-replacement + (lambda (pkg-meta-alist) + (map (match-lambda + (("dependencies" dependencies ...) + '("dependencies")) + (("devDependencies" dev-dependencies ...) + `("devDependencies" + ,@(filter-map (match-lambda + ((key . directory) + (let ((node-module + (string-append directory + "/lib/node_modules/" + key))) + (and (directory-exists? node-module) + `(,key . ,node-module))))) + (alist-delete "node" inputs)))) + (other other)) + pkg-meta-alist)))) ;; FIXME: The node build-system's configure phase does not support ;; cross-compiling so we re-define it. @@ -99,7 +95,7 @@ (define* (install #:key target grammar-directories outputs #:allow-other-keys) (define (compile-language dir) (with-directory-excursion dir (let ((lang (assoc-ref (call-with-input-file "src/grammar.json" - read-json) + json->scm) "name")) (source-file (lambda (path) (if (file-exists? path)