From patchwork Mon Mar 24 07:29:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Graves X-Patchwork-Id: 40769 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 1B33227BBE9; Mon, 24 Mar 2025 07:30: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 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 6842227BBE2 for ; Mon, 24 Mar 2025 07:30:58 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1twcGG-0004rA-5a; Mon, 24 Mar 2025 03:30:16 -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 1twcG5-0004dW-1x for guix-patches@gnu.org; Mon, 24 Mar 2025 03:30: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 1twcG4-0002zm-Or for guix-patches@gnu.org; Mon, 24 Mar 2025 03:30: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=Bi53LHbN0mrkiLKLTvA9+SShiWqrdBWDQ1ttIctZhY8=; b=eHpsq2+nqzmC73Htf0uI60ehi9bhhV3nXETdywYWEOk7dDSs87Mjkeoh2IJOu2ZxDGx8VMWWePG7sKLziUHr7CCB/Jixep5uIe8WE1aib0tEbgh5RbLVJ/k/D85Ehj4AXARmKdf6l9soOv1uUdBC7DyMiuM+Jf0hyQILErAR2vRFs6Wb5PSnc0+zqTupSPOgnuNdaYB+PqGWyylC/rQ3XPOhtgepYVXwxJCBowoRK/l6YHErjuOYNDohIsUU1MGN2RldNQA/9YNjJEkE8WgsrW0Mk/7Jv/HJiElHA1PADli+Mwbfleb3VWJZneVaUXNiPHEVPCMY6NF8iPoK/gCy+Q==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1twcG4-0005V8-Ia for guix-patches@gnu.org; Mon, 24 Mar 2025 03:30:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77231] [PATCH 4/6] build-system/node: Add phase 'delete-unwanted-dev-dependencies. Resent-From: Nicolas Graves Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 24 Mar 2025 07:30:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77231 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77231@debbugs.gnu.org Cc: jelle.licht@fsfe.org, Nicolas Graves Received: via spool by 77231-submit@debbugs.gnu.org id=B77231.174280138221038 (code B ref 77231); Mon, 24 Mar 2025 07:30:04 +0000 Received: (at 77231) by debbugs.gnu.org; 24 Mar 2025 07:29:42 +0000 Received: from localhost ([127.0.0.1]:53981 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twcFh-0005TA-Rd for submit@debbugs.gnu.org; Mon, 24 Mar 2025 03:29:42 -0400 Received: from 3.mo563.mail-out.ovh.net ([46.105.40.8]:52149) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twcFY-0005SC-VG for 77231@debbugs.gnu.org; Mon, 24 Mar 2025 03:29:35 -0400 Received: from director4.derp.mail-out.ovh.net (director4.derp.mail-out.ovh.net [79.137.60.37]) by mo563.mail-out.ovh.net (Postfix) with ESMTPS id 4ZLl6z2Nkfz1TR1; Mon, 24 Mar 2025 07:29:31 +0000 (UTC) Received: from director4.derp.mail-out.ovh.net (director4.derp.mail-out.ovh.net. [127.0.0.1]) by director4.derp.mail-out.ovh.net (inspect_sender_mail_agent) with SMTP for <77231@debbugs.gnu.org>; Mon, 24 Mar 2025 07:29:31 +0000 (UTC) Received: from mta2.priv.ovhmail-u1.ea.mail.ovh.net (unknown [10.110.101.155]) by director4.derp.mail-out.ovh.net (Postfix) with ESMTPS id 4ZLl6z218fzy9s; Mon, 24 Mar 2025 07:29:31 +0000 (UTC) Received: from ngraves.fr (unknown [10.1.6.0]) by mta2.priv.ovhmail-u1.ea.mail.ovh.net (Postfix) with ESMTPSA id C829CBA3DFF; Mon, 24 Mar 2025 07:29:30 +0000 (UTC) Authentication-Results: garm.ovh; auth=pass (GARM-101G00450a46136-82c3-44dc-b478-2554db22a900, AEA14DA1325383AAD40887B56448FDDF9DC3A193) smtp.auth=ngraves@ngraves.fr X-OVh-ClientIp: 90.92.117.144 Date: Mon, 24 Mar 2025 08:29:15 +0100 Message-ID: <20250324072925.19588-4-ngraves@ngraves.fr> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250324072925.19588-1-ngraves@ngraves.fr> References: <20250324072925.19588-1-ngraves@ngraves.fr> MIME-Version: 1.0 X-Ovh-Tracer-Id: 710161367317603042 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduheeludejucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefpihgtohhlrghsucfirhgrvhgvshcuoehnghhrrghvvghssehnghhrrghvvghsrdhfrheqnecuggftrfgrthhtvghrnhepleffjeetueethfefkeffffefvddukeejkefgleduiedthfekvefhiedvhfffgeegnecukfhppeduvdejrddtrddtrddupdeltddrledvrdduudejrddugeegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpehnghhrrghvvghssehnghhrrghvvghsrdhfrhdpnhgspghrtghpthhtohepfedprhgtphhtthhopeejjedvfeduseguvggssghughhsrdhgnhhurdhorhhgpdhrtghpthhtohepjhgvlhhlvgdrlhhitghhthesfhhsfhgvrdhorhhgpdhrtghpthhtohepnhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrpdfovfetjfhoshhtpehmohehieefmgdpmhhouggvpehsmhhtphhouhht DKIM-Signature: a=rsa-sha256; bh=Bi53LHbN0mrkiLKLTvA9+SShiWqrdBWDQ1ttIctZhY8=; c=relaxed/relaxed; d=ngraves.fr; h=From; s=ovhmo4487190-selector1; t=1742801371; v=1; b=dy+qVL+AYHcxqHvBNyygIg3srWvas3NXBtG2Ek/Qwikl6TmfAsILXyzWp6oMQTooj9fmt4/u 4YYYqnYtOTVfLZX3bVNlPCZ9g4pG6cDi5ZtisJ9Hn4LVxUIORnzL+YZxtzA5ngSEzbHXy7pH7BU D4Z3iaJBV3EF0gi3yYl2CrVJMEfu14iFsmamIlUisegnttvdvDqH4AAUm15gy+JCieHCLHyqDen ar7XGQsHWYKpBNW/5pmkrFldGdfDTcWixGhychnwb3nu9rPmI9E28roxNLGzcqUBhjoFgfgsNo4 iNwk5XFhuPkdzvxsaSDHTsG570tzdW1mMT6IlIdZcMVJQ== 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/node-build-system.scm (npm-ignored-inputs): New variable. (delete-dependencies): Extend procedure to accept a filtering procedure. (delete-unwanted-dev-dependencies): Define new phase to ignore all npm-ignored-inputs systematically. (%standard-phases): Add it here. --- guix/build/node-build-system.scm | 39 ++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm index 05940bc997..50e023b3ca 100644 --- a/guix/build/node-build-system.scm +++ b/guix/build/node-build-system.scm @@ -29,6 +29,7 @@ (define-module (guix build node-build-system) #:use-module (ice-9 match) #:use-module (json) #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) #:use-module (srfi srfi-71) #:export (%standard-phases delete-dependencies @@ -37,9 +38,21 @@ (define-module (guix build node-build-system) modify-json modify-json-fields node-build + npm-ignored-inputs replace-fields with-atomic-json-file-replacement)) +(define npm-ignored-inputs + (list + (list "aud" "nsp" ; passed end-of-life + "covert" ; code coverage + "auto-changelog" "npmignore" "evalmd" ; development tools + "eclint" "eslint" "prettier-standard" "standard" ; lint + "in-publish" "np" "safe-publish-latest") ; upload integration tools + ;; Second value is a list of prefixes to ignore + ;; Handy for personal configs and extensions of ignored inputs + (list "@ljharb/" "eslint-"))) + (define* (assoc-ref* alist key #:optional default) "Like assoc-ref, but return DEFAULT instead of #f if no value exists." (match (assoc key alist) @@ -100,7 +113,7 @@ (define* (modify-json #:key (file "package.json") #:rest all-arguments) modifications)) file))) -(define (delete-dependencies dependencies-to-remove) +(define (delete-dependencies predicate-or-dependencies) "Rewrite 'package.json' to allow the build to proceed without packages listed in 'dependencies-to-remove', a list of strings naming npm packages. @@ -114,9 +127,13 @@ (define (delete-dependencies dependencies-to-remove) dependency-key (lambda (dependencies) (remove - (lambda (dependency) - (member (car dependency) dependencies-to-remove)) - dependencies)))) + (match predicate-or-dependencies + ((? procedure? predicate) + predicate) + ((? list? dependencies-to-remove) + (lambda (dependency) + (member (car dependency) dependencies-to-remove)))) + dependencies)))) pkg-meta (list "devDependencies" @@ -399,11 +416,25 @@ (define scripts "echo Guix: avoiding node-gyp rebuild")) out))))) +(define delete-unwanted-dev-dependencies + (lambda* args + (modify-json + (delete-dependencies + (lambda (input) + (match npm-ignored-inputs + (((ignored ...) (prefixes ...) . ()) + (or (member (car input) ignored) + (any (cut string-prefix? <> (car input)) + prefixes))) + (_ #f))))))) + (define %standard-phases (modify-phases gnu:%standard-phases (add-after 'unpack 'set-home set-home) (add-before 'configure 'patch-dependencies patch-dependencies) (add-after 'patch-dependencies 'delete-lockfiles delete-lockfiles) + (add-after 'patch-dependencies 'delete-unwanted-dev-dependencies + delete-unwanted-dev-dependencies) (replace 'configure configure) (replace 'build build) (replace 'check check)