[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-depen
From: |
Philip McGrath |
Subject: |
[bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument. |
Date: |
Thu, 16 Dec 2021 21:02:47 -0500 |
* 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
- [bug#51838] [PATCH v5 04/45] gnu: node: Add an npmrc file to set nodedir., (continued)
- [bug#51838] [PATCH v5 04/45] gnu: node: Add an npmrc file to set nodedir., Philip McGrath, 2021/12/16
- [bug#51838] [PATCH v5 10/45] gnu: node-binary-search-bootstrap: Use #:absent-dependencies., Philip McGrath, 2021/12/16
- [bug#51838] [PATCH v5 06/45] guix: node-build-system: Refactor patch-dependencies phase., Philip McGrath, 2021/12/16
- [bug#51838] [PATCH v5 06/45] guix: node-build-system: Refactor patch-dependencies phase., Liliana Marie Prikler, 2021/12/16
- [bug#51838] [PATCH v5 06/45] guix: node-build-system: Refactor patch-dependencies phase., Philip McGrath, 2021/12/18
- [bug#51838] [PATCH v5 06/45] guix: node-build-system: Refactor patch-dependencies phase., Liliana Marie Prikler, 2021/12/18
- [bug#51838] [PATCH v5 06/45] guix: node-build-system: Refactor patch-dependencies phase., Timothy Sample, 2021/12/18
- [bug#51838] [PATCH v5 06/45] guix: node-build-system: Refactor patch-dependencies phase., Philip McGrath, 2021/12/20
- [bug#51838] [PATCH v5 06/45] guix: node-build-system: Refactor patch-dependencies phase., Liliana Marie Prikler, 2021/12/20
- [bug#51838] [PATCH v5 06/45] guix: node-build-system: Refactor patch-dependencies phase., Philip McGrath, 2021/12/20
- [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument.,
Philip McGrath <=
- [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument., Liliana Marie Prikler, 2021/12/16
- [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument., Timothy Sample, 2021/12/17
- [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument., Liliana Marie Prikler, 2021/12/17
- [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument., Timothy Sample, 2021/12/17
- [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument., Liliana Marie Prikler, 2021/12/18
- [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument., Philip McGrath, 2021/12/18
- [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument., Liliana Marie Prikler, 2021/12/18
- [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument., Philip McGrath, 2021/12/18
- [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument., Liliana Marie Prikler, 2021/12/18
- [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument., Philip McGrath, 2021/12/20