From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 4LVvCa/itmEpSQEAgWs5BA (envelope-from ) for ; Mon, 13 Dec 2021 07:05:35 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id UCwQBa/itmHkWwAAbx9fmQ (envelope-from ) for ; Mon, 13 Dec 2021 06:05:35 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 653FC2C589 for ; Mon, 13 Dec 2021 07:05:34 +0100 (CET) Received: from localhost ([::1]:43934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mweSr-00047s-G5 for larch@yhetil.org; Mon, 13 Dec 2021 01:05:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40716) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mweQT-0000th-Ga for guix-patches@gnu.org; Mon, 13 Dec 2021 01:03:05 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:42163) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mweQT-00075W-7I for guix-patches@gnu.org; Mon, 13 Dec 2021 01:03:05 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mweQT-0002S3-24 for guix-patches@gnu.org; Mon, 13 Dec 2021 01:03:05 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#51838] [PATCH v4 07/45] guix: node-build-system: Add #:absent-dependencies argument. Resent-From: Philip McGrath Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 13 Dec 2021 06:03:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51838 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51838@debbugs.gnu.org Cc: Timothy Sample , Pierre Langlois , Jelle Licht , Philip McGrath , Liliana Marie Prikler Received: via spool by 51838-submit@debbugs.gnu.org id=B51838.16393753809350 (code B ref 51838); Mon, 13 Dec 2021 06:03:05 +0000 Received: (at 51838) by debbugs.gnu.org; 13 Dec 2021 06:03:00 +0000 Received: from localhost ([127.0.0.1]:53700 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mweQO-0002Qf-3D for submit@debbugs.gnu.org; Mon, 13 Dec 2021 01:03:00 -0500 Received: from mail-ua1-f47.google.com ([209.85.222.47]:34626) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mweQH-0002Pw-HR for 51838@debbugs.gnu.org; Mon, 13 Dec 2021 01:02:58 -0500 Received: by mail-ua1-f47.google.com with SMTP id n6so27363793uak.1 for <51838@debbugs.gnu.org>; Sun, 12 Dec 2021 22:02:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philipmcgrath.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1mbu81k4yDaew4+7r6xEYK266/gywq2rhdqVXPIlqZ4=; b=gDzar9Ez1n4TvxsuJX3nqDCWc5jD3ZfosenEnhWTlHhqHwHWOuV4ek3Z51TKn5/gBn MrPUO7mkWbsJIVaZnxhSsxrjXNUtOtWY4n7G1sLUc4eBANkvV04ovnexuUKhoF79lJRd 0a3neIa4T1m07Gq1mBSAydXUnRWqZHg1g3fHdWJPcpyfdhWlSmqjlPgO9J7uDlml/3iW o1AkZMZrrfJrxKPXv+BAAPvn7RoUGnD83Jy9+8/SdkVEkzaG5cWZ1nTa9e+j+oYXZXBQ 7sFYYKgkGqalXt4c93SpKleiI4xTStO5MgBIYoKiTkb/BzDh2YFXejeBOum6fZJTUTFg Gimw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1mbu81k4yDaew4+7r6xEYK266/gywq2rhdqVXPIlqZ4=; b=nR1DcgGxtK89p56R8iyryPVtFBO0CCgxe64QNvU8bB5MaanBe1TTAOTwCLNKaSfyKT 9zIL0p7/pAy+fScES4YH+1bgqiSnRzqDPUVMT1fauQEVl5lLJJPXA9CJtr3S0ely4KRx BG6gX24iXiKelvnjRQPuj2Ztzf5VwUsZd0Xh4F5OepNO/2t5l0OdqibgeSj3KGGxhV5O TvEtDPSru6anxkBMW6i9rJvqOLJki3zqxggHbanD4azmlt0ZLTu98yEysVbLRX2UIM8F JAeDX6UzkbMGaYQjAWscsb/vjdYNv8OYs6/ISJCe8hEBRD2nzw66cu32JYUsgi05C5ZQ ufCA== X-Gm-Message-State: AOAM530mYjfxdED4AtB32sqxctwEBdcHLzXMZBYK4OT4AGF2LgCLBQ9j 2iJnc7yU/09lYvDGcd8ummTUyk+WL1YWcpwWMrg= X-Google-Smtp-Source: ABdhPJzYfFYbFw7gfrdHfGco6lII2f9UlTutL13mTwPG5rDHsTd4twhhYARkFEzSWGanXFASgLvAHw== X-Received: by 2002:a67:6187:: with SMTP id v129mr25741160vsb.68.1639375368066; Sun, 12 Dec 2021 22:02:48 -0800 (PST) Received: from localhost (c-73-125-89-242.hsd1.fl.comcast.net. [73.125.89.242]) by smtp.gmail.com with ESMTPSA id bj50sm3721776vkb.7.2021.12.12.22.02.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 12 Dec 2021 22:02:47 -0800 (PST) From: Philip McGrath Date: Mon, 13 Dec 2021 01:00:29 -0500 Message-Id: <20211213060107.129223-8-philip@philipmcgrath.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211213060107.129223-1-philip@philipmcgrath.com> References: <46a042bc08eb72a068b1e8c69bfe28cf2d4b2e53.camel@gmail.com> <20211208202838.752542-1-philip@philipmcgrath.com> <20211208202838.752542-5-philip@philipmcgrath.com> <877dc924h7.fsf@gmx.com> <5c62c3ce-dd50-5dcd-00ed-ff1524be4e0b@philipmcgrath.com> <20211213060107.129223-1-philip@philipmcgrath.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1639375534; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=1mbu81k4yDaew4+7r6xEYK266/gywq2rhdqVXPIlqZ4=; b=nFUqcdGhPcJIZWnWE4I2NF/iMXFx9cDJLoSCCtXR3b+01fTQPEceEX4BQbwnUWPhgf2JBx bShxhebp89gH40j5DrXqKGCBqxBB7zFHbj5JzUCQZKJZC1+XsCmLzYECaGTPhmoYS9y091 9QY99gjFL9hOLBzgKzA6GGhpWapRq/7uTkGGqdmiiN0AyqTDoj75aSX84BeVxeB0pt3h2z /cfTJBMn4puIo+4cgR/3y9gMrrKyzV8jlJ30+oXgCPOupB+wBDJZYv33yjokhBRWW3K9sO GVR9hVJmMX1lUeheislUwg3ep+cEqRoesQvNUYnLYIvHI3j0EFcSgbTBvkrQ3Q== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1639375534; a=rsa-sha256; cv=none; b=HTh3QcUoDS2BuvXEnaCrH3/sYzBhitQs8TG2YGLav7yuBI2q4DFt9v4q5aP4ZV9L9okaZq AM2c/0+PcTu5u/ikjMhCg+sfEe5i8/EqXrJoY8XzVUKEGPiq/h3r/ZRd2JWjqJ0YYm9txF wG7LjV0WZ273gj23w5eth3/yO1UXx7NLHoaG2mZKRXwCdrkCBSonoqSruryDnbz33t5fte lU+u3g7DF7qXBlZMpk3apG8qWD+uApOz2b2e9oUiA5CaBQG8vqLEyAy1dORoiArPLBJJvX oWmubp6ufLdbTgkqT6PWYD6RgUjnkOl90IDRH3+1RIe2DQI/k9w6lZS3YizgIw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=gDzar9Ez; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 1.03 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=gDzar9Ez; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 653FC2C589 X-Spam-Score: 1.03 X-Migadu-Scanner: scn1.migadu.com X-TUID: X7A04Z1/19lQ * guix/build-system/node.scm (lower, node-build): Add optional argument #:absent-dependencies with default of ''(). Pass it on to the build-side code. * guix/build/node-build-system.scm (patch-dependencies): Respect the #:absent-dependencies argument, removing specified npm packages from the "dependencies" or "devDependencies" tables in "package.json". --- guix/build-system/node.scm | 19 ++++++++++++++++++- guix/build/node-build-system.scm | 7 +++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/guix/build-system/node.scm b/guix/build-system/node.scm index 98f63f87ef..4f437f9c0d 100644 --- a/guix/build-system/node.scm +++ b/guix/build-system/node.scm @@ -44,6 +44,7 @@ (define (default-node) (define* (lower name #:key source inputs native-inputs outputs system target (node (default-node)) + (absent-dependencies ''()) #:allow-other-keys #:rest arguments) "Return a bag for NAME." @@ -73,6 +74,7 @@ (define* (node-build store name inputs (tests? #t) (phases '(@ (guix build node-build-system) %standard-phases)) + (absent-dependencies ''()) (outputs '("out")) (search-paths '()) (system (%current-system)) @@ -80,7 +82,21 @@ (define* (node-build store name inputs (imported-modules %node-build-system-modules) (modules '((guix build node-build-system) (guix build utils)))) - "Build SOURCE using NODE and INPUTS." + "Build SOURCE using NODE and INPUTS. + +The builder will remove Node.js packages listed in ABSENT-DEPENCENCIES from +the 'package.json' file's 'dependencies' and 'devDependencies' tables. This +mechanism can be used both avoid dependencies we don't want (e.g. optional +features that would increase closure size) and to work around dependencies +that haven't been packaged for Guix yet (e.g. test utilities)." + ;; Before #:absent-dependencies existed, this scenario was often handled by + ;; deleting the 'configure phase. Using #:absent-dependencies, instead, + ;; retains the check that no dependencies are silently missing and other + ;; actions performed by 'npm install', such as building native + ;; addons. Having an explicit list of absent dependencies in the package + ;; definition should also facilitate future maintenence: for example, if we + ;; add a package for a test framework, it should be easy to find all the + ;; other packages that use it and enable their tests. (define builder `(begin (use-modules ,@modules) @@ -94,6 +110,7 @@ (define builder #:test-target ,test-target #:tests? ,tests? #:phases ,phases + #:absent-dependencies ,absent-dependencies #:outputs %outputs #:search-paths ',(map search-path-specification->sexp search-paths) diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm index b74e593838..892104b6d2 100644 --- a/guix/build/node-build-system.scm +++ b/guix/build/node-build-system.scm @@ -69,7 +69,8 @@ (define (list-modules directory) input-paths) index)) -(define* (patch-dependencies #:key inputs #:allow-other-keys) +(define* (patch-dependencies #:key inputs absent-dependencies + #:allow-other-keys) (define index (index-modules (map cdr inputs))) @@ -86,7 +87,9 @@ (define (resolve-dependencies meta-alist meta-key) (('@ . orig-deps) (fold (match-lambda* (((key . value) acc) - (acons key (hash-ref index key value) acc))) + (if (member key absent-dependencies) + acc + (acons key (hash-ref index key value) acc)))) '() orig-deps)))) -- 2.32.0