From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id kLXwN7vwu2EyMgEAgWs5BA (envelope-from ) for ; Fri, 17 Dec 2021 03:06:51 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id 2BK5M7vwu2GDTgAA1q6Kng (envelope-from ) for ; Fri, 17 Dec 2021 02:06:51 +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 8B83F1B5A5 for ; Fri, 17 Dec 2021 03:06:51 +0100 (CET) Received: from localhost ([::1]:53280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1my2e2-00055m-QG for larch@yhetil.org; Thu, 16 Dec 2021 21:06:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54572) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1my2cW-00039t-HX for guix-patches@gnu.org; Thu, 16 Dec 2021 21:05:17 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:53990) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1my2cK-0007YO-3h for guix-patches@gnu.org; Thu, 16 Dec 2021 21:05:12 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1my2cJ-00055r-Ua for guix-patches@gnu.org; Thu, 16 Dec 2021 21:05:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#51838] [PATCH v5 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: Fri, 17 Dec 2021 02:05: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 Cc: Timothy Sample , Pierre Langlois , Jelle Licht , Philip McGrath , Liliana Marie Prikler Received: via spool by 51838-submit@debbugs.gnu.org id=B51838.163970667119416 (code B ref 51838); Fri, 17 Dec 2021 02:05:03 +0000 Received: (at 51838) by debbugs.gnu.org; 17 Dec 2021 02:04:31 +0000 Received: from localhost ([127.0.0.1]:37279 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1my2bn-000532-3n for submit@debbugs.gnu.org; Thu, 16 Dec 2021 21:04:31 -0500 Received: from mail-qk1-f175.google.com ([209.85.222.175]:33486) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1my2bd-00052A-MB for 51838@debbugs.gnu.org; Thu, 16 Dec 2021 21:04:22 -0500 Received: by mail-qk1-f175.google.com with SMTP id de30so848435qkb.0 for <51838@debbugs.gnu.org>; Thu, 16 Dec 2021 18:04:21 -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=ofj5f41WUr2qAmebZULIlZn7/9H/dArRRzaaH6zxQ3o=; b=M3nTIAIvyIkD/TGPp9syx/jbLVYhThnU35k11lEBPEsLfSheX33KyNO6Cmj8LTkB6z wvlCCPghkm4uaH+cUeAsJIQ/BY5ouesPokW/RZhaRt6gFagF7iUpZ4OxIiguLGSLBe68 f7GEllaB/dNfwvHVlyjg3Deg5q2LS1PghAjSCqLXUyOx3iUSg+scUayBZ2G4icKjgBbe 6QJLi6vpmaV3P1WxDXS9QDN52F8MvxfjQLu69jktg+As4en/3ZNdXE+RdTn1zfX6GzGS TpiBQlcPUC0hATgT+pHRb/PqsTcb2SU87Od6s3bEkXOpv4+87CCktXfeJ0zNJ66Q8lqK 16Lw== 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=ofj5f41WUr2qAmebZULIlZn7/9H/dArRRzaaH6zxQ3o=; b=lbNT0pW8JgJ5ydLrdCA5ERkbmPk579h2KDa8fn/kVVEJZgDuW6icxvyVARPalXQfsN 6W7UMS6ObDp8fgk1EPfrnSl/S3+ieHOQVBv56gW2VDmCQo+UbcIyY7Sw+ZEtasIXpXgz eoeUAqs2Lf8wqNK/sX9cXhEdk3Kv8ioFs4ovgRbbSMA4Ivr5ixTlHZ/a4s2E7Z7p65Dp 91ubv65tXLLgkAnPBOtyrw4i3TAfDGaurSkT+JKn/bjNSnSg6bOuNJWmettqQjw1KUc5 tmZwGGarAA+k7SjEpWuV04nQww+UFWkxjh85gQH8jximiEeqZ5cx33GM3wpZZ4tjmTNA yWrA== X-Gm-Message-State: AOAM533LSXPUg1Cmjzd4P8qNkYEqcqxvolHJltgQvki3FUaPU4pGsDzO 427YpZDTqEqBMgUUwmTGedrGbYNFu1tyWHgqdE4= X-Google-Smtp-Source: ABdhPJzPMZDctv91yRM0gSmL9avGTqk2eW7X4/2A265+iICMV5dWiOOgVpzLhZQsc+x30/xAMJ5nQw== X-Received: by 2002:a37:502:: with SMTP id 2mr533448qkf.701.1639706656142; Thu, 16 Dec 2021 18:04:16 -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 k23sm5249952qtm.49.2021.12.16.18.04.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Dec 2021 18:04:15 -0800 (PST) From: Philip McGrath Date: Thu, 16 Dec 2021 21:02:47 -0500 Message-Id: <20211217020325.520821-8-philip@philipmcgrath.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211217020325.520821-1-philip@philipmcgrath.com> References: <20211213060107.129223-1-philip@philipmcgrath.com> <20211217020325.520821-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 X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1639706811; 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=ofj5f41WUr2qAmebZULIlZn7/9H/dArRRzaaH6zxQ3o=; b=Ix+yJYWbdrse8a6N9Pa+ZN0e7SC0XHXZsZeRuNhnparswFcjr8AQMpHviiIVn3F3xZ8ymZ RY7x3egYDTGbP3Tjy5lPgzcFLcuNRZ9NZaQ5mZHTEA0DBdoL7ILjioc4FwS19V501ga5YA TObueeo+81su9LvIWwx6kozRL4T6eGo+Omfs+iS3E2kqmk6vQWA7o5vcELGIMjm+nSa+RT Et1WkGRw2Wj90mq+zcKecBl+S25Lgz4xGBOUQ1rgVdpyVB+QbIzxG3TqHCL7YozD8OJUGZ +PkqAkZG0+lyYKHxS28seCnk9023BTAunVwc3I5Q5cWeZCvexZqvk3htzuT57g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1639706811; a=rsa-sha256; cv=none; b=pPSTKt4hbBkr74/sP1niu8Ob+lOIu8Wgwww9IfWiTGcaoBWuuP+YweadaKV/tNT+E70RmV N/wES8oih1hkCfFPwTGMs+JsHAQBCMXCOuuUh+3REIIAaCKbVTC/IL21MpUzCHF5Ad9WTP o3JgNtGSLZF52r686l+kmYiGEsTXmMhIUZyyha3QLB7Zdl71hqBYObGQLLEOePq9mVHAVu kPLOhLg2pNijgAZqoiMdCDwfBqBzNjf4Bk8MtwJMsPBoIW0kZcd9ArbXh4dlY9DHgX36Ut HLcO449/awdBRcFEtXYQY/5Uh3HokQ6oupMVWSyUMLqKeZN5NA6IHJ4TOlDFKQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=M3nTIAIv; 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.49 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=M3nTIAIv; 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: 8B83F1B5A5 X-Spam-Score: -0.49 X-Migadu-Scanner: scn0.migadu.com X-TUID: 7+3/VpL+Xbzk * 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 735f8dd06e..330d10dca5 100644 --- a/guix/build-system/node.scm +++ b/guix/build-system/node.scm @@ -47,6 +47,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." @@ -77,6 +78,7 @@ (define* (node-build name inputs (test-target "test") (tests? #t) (phases '%standard-phases) + (absent-dependencies ''()) (outputs '("out")) (search-paths '()) (system (%current-system)) @@ -84,7 +86,21 @@ (define* (node-build 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 (with-imported-modules imported-modules #~(begin @@ -96,6 +112,7 @@ (define builder #:test-target #$test-target #:tests? #$tests? #:phases #$phases + #:absent-dependencies #$absent-dependencies #:outputs #$(outputs->gexp outputs) #:search-paths '#$(sexp->gexp (map search-path-specification->sexp 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