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 QKavKJ8VsWFVCQAAgWs5BA (envelope-from ) for ; Wed, 08 Dec 2021 21:29:19 +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 YKxWJJ8VsWGPEwAAbx9fmQ (envelope-from ) for ; Wed, 08 Dec 2021 20:29:19 +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 472FD8DE8 for ; Wed, 8 Dec 2021 21:29:19 +0100 (CET) Received: from localhost ([::1]:43526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mv3Z0-0005TG-Fj for larch@yhetil.org; Wed, 08 Dec 2021 15:29:18 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52600) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mv3Yn-0005PK-F9 for guix-patches@gnu.org; Wed, 08 Dec 2021 15:29:05 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:58248) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mv3Yn-0000Bf-50 for guix-patches@gnu.org; Wed, 08 Dec 2021 15:29:05 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mv3Yl-0005q9-V9 for guix-patches@gnu.org; Wed, 08 Dec 2021 15:29:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#51838] [PATCH v3 06/43] guix: node-build-system: Add #:absent-dependencies argument. Resent-From: Philip McGrath Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 08 Dec 2021 20:29:03 +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 Received: via spool by 51838-submit@debbugs.gnu.org id=B51838.163899533722365 (code B ref 51838); Wed, 08 Dec 2021 20:29:03 +0000 Received: (at 51838) by debbugs.gnu.org; 8 Dec 2021 20:28:57 +0000 Received: from localhost ([127.0.0.1]:41547 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mv3Ye-0005oZ-Qt for submit@debbugs.gnu.org; Wed, 08 Dec 2021 15:28:57 -0500 Received: from mail-ua1-f45.google.com ([209.85.222.45]:35782) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mv3YZ-0005my-Ot for 51838@debbugs.gnu.org; Wed, 08 Dec 2021 15:28:52 -0500 Received: by mail-ua1-f45.google.com with SMTP id l24so6960083uak.2 for <51838@debbugs.gnu.org>; Wed, 08 Dec 2021 12:28:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philipmcgrath.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=kRfIOss//yVYHJCk72noI69K5G/UElqL3t+RrsJb1eQ=; b=Jj/w0o1Gmts7xhNLMzLvoqnvuSVBubF5CKewnB1KNm7SHRa1wLa5XHCRSH3TLmp2g0 gliiP4/dUGCCvMHg1OmQupJb9hcTDsN7K2wwF/1jVWEGZzyD2QdCcpZJCbe1Wez5q/9u V6ZLn1pkaQLU2aqchh8V3NC5SpTLtXKAFAjzbxifqzVK/fWxqGIypqLK5EK1PQP7Ibwq I28keDajvSa6UURfGEX7R5mceUUMHPms9FlKXVvSmtTDU7YEICw56SedJwkE8xBXlmgW JWN8J1t/7q55dIItwHIv/ssYRFSqZ+lI7xL2BmXhEGmNW7aFugfBjdASdnCSJhJ8vpNI dqrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kRfIOss//yVYHJCk72noI69K5G/UElqL3t+RrsJb1eQ=; b=IkltfgT6Z3vTjM4pt23+3VNSMNE/BQ34l18PoY4MHdGndy/TUbgjqvzVv1sUztKsoI 1YVmFM4Dl11GUT/b2JxQNyylebTEkrMkwAnPVvOA436OFVtGfn4/p8PUMLEZ0XhqGgJQ 90MO9w/Jlfr1VhhcITy/gzop2SEnjpcE8fWKokdrG7ZVIGbo+ArxlHm8VN3U23z+Fql/ XNrj8APny+gnat2cRUvLI4GFzJRMF2HzdpPAvZ0aBC1qbbUXzarYnFRlvU28SHqvhgpw aLCQ0TmCRUxtnPECXvoZDplQUVvAXcxE2Gr0QMElM2Aukw57aU+ezi/Db3+WwNaU95x/ Alhw== X-Gm-Message-State: AOAM530JMYBRFT0kWcDQoeejCzh/WH9lk6QjzDrYiTkGJEUA+NouxxAy n2qkqFyR3WTuFkAPohtk0yltVCNUMtAyWJjVqbI= X-Google-Smtp-Source: ABdhPJz4CNuJ+iEd8FRDyUwokeLmcCrzd9tzdEiNFWW6titjZfkX/5KKO6SW0V3ozE4Qo8HDq3NjLQ== X-Received: by 2002:ab0:2983:: with SMTP id u3mr11275502uap.35.1638995326104; Wed, 08 Dec 2021 12:28:46 -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 6sm2531581vkq.23.2021.12.08.12.28.45 for <51838@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 08 Dec 2021 12:28:45 -0800 (PST) From: Philip McGrath Date: Wed, 8 Dec 2021 15:28:01 -0500 Message-Id: <20211208202838.752542-7-philip@philipmcgrath.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211208202838.752542-1-philip@philipmcgrath.com> References: <46a042bc08eb72a068b1e8c69bfe28cf2d4b2e53.camel@gmail.com> <20211208202838.752542-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=1638995359; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=kRfIOss//yVYHJCk72noI69K5G/UElqL3t+RrsJb1eQ=; b=KKirAuel91paz/M0RRBXrsUYfDHEeU5VSMmOHQ6JOsncItSjPKz8FXPEd6uCSiH6bC6O6C s4GA7OS0FrA1SR/YJXekCfPaEQCpoNdubSD1cTIy+VzyTqfgBFFWKy0dTYZ0ewBb7/WhFZ 8kUa6jlzRy5u9sGstd409wv86up/lCcxAgKkbWw9p5A2L6s6uxf1OjtM52J3ozUZUQU+54 pgBoD29bN1DXfZUzC0RvUQNUfCWHoLo8lG+DmVcu3ix7cnF30Ij1m10fCRvYyMhryuI2ic GPUOTqVRTXBwSnkihYEBKQqZLiDNmo8Y1IRyRlGwwwBs+a7SyVAyz8MZED1uCQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1638995359; a=rsa-sha256; cv=none; b=AV3ZE1JA1ErfhzKR6Qp4cvds8vwi3qUk8S7w4xhUvIaHlV17+S9HYyaNJcLJhoArd4Qi5E +szSvpxQaDuq52/A2nmSXCaRgH3hkhyOXf8FO1VsKLKOJWVRFRTvpzolcmhU5g73ADk/aI qY1p22ykydGTR9uUn6SjR6UAMd0odIjdRFj5JaoNqxgOy5Mxh4u+UxCb3NTeOU9WDE8cbe FuZNlL6lg2jPUuC3Noa0vUh3rgOv6eteOtc+iaizaH2+WnqCdjE5+537dQnWiuW6vjaSFY C6H13cJz4F3a5f1G8gWVcwF/fO+BBJmGuJQfzdbGkA2jpIwZ7JmYUENeAII3oQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b="Jj/w0o1G"; 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: -0.45 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b="Jj/w0o1G"; 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: 472FD8DE8 X-Spam-Score: -0.45 X-Migadu-Scanner: scn1.migadu.com X-TUID: tZ1eKMh2/hHw * 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 6fade54670..249b3deee6 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