[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#51838] [PATCH v9 05/41] guix: node-build-system: Add 'delete-depend
From: |
Philip McGrath |
Subject: |
[bug#51838] [PATCH v9 05/41] guix: node-build-system: Add 'delete-dependencies' helper function. |
Date: |
Sat, 8 Jan 2022 03:41:53 -0500 |
Many node packages currently skip the configure phase, because they lack
both dependencies and a convenient way to build without all of them, e.g.
for the purposes of bootstrapping. This patch adds a big hammer to flatten
these nails.
* guix/build/node-build-system.scm (delete-dependencies): New variable.
Co-authored-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
---
guix/build/node-build-system.scm | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index ee3442e9e4..e37a0f7b44 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -2,7 +2,7 @@
;;; Copyright © 2015 David Thompson <davet@gnu.org>
;;; Copyright © 2016, 2020 Jelle Licht <jlicht@fsfe.org>
;;; Copyright © 2019, 2021 Timothy Sample <samplet@ngyro.com>
-;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
+;;; Copyright © 2021, 2022 Philip McGrath <philip@philipmcgrath.com>
;;; Copyright © 2021 Liliana Marie Prikler <liliana.prikler@gmail.com>
;;;
;;; This file is part of GNU Guix.
@@ -25,11 +25,13 @@ (define-module (guix build node-build-system)
#:use-module (guix build utils)
#:use-module (guix build json)
#:use-module (ice-9 ftw)
+ #:use-module (ice-9 regex)
#:use-module (ice-9 match)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-71)
#:export (%standard-phases
with-atomic-json-file-replacement
+ delete-dependencies
node-build))
(define (with-atomic-json-file-replacement file proc)
@@ -187,6 +189,27 @@ (define resolve-dependencies
(@)))))
#t)
+(define (delete-dependencies absent)
+ "Rewrite 'package.json' to allow the build to proceed without packages
+listed in ABSENT, a list of strings naming npm packages.
+
+To prevent the deleted dependencies from being reintroduced, use this function
+only after the 'patch-dependencies' phase."
+ (define delete-from-jsobject
+ (match-lambda
+ (('@ . alist)
+ (cons '@ (filter (match-lambda
+ ((k . _)
+ (not (member k absent))))
+ alist)))))
+
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (jsobject-update*
+ pkg-meta
+ `("devDependencies" ,delete-from-jsobject (@))
+ `("dependencies" ,delete-from-jsobject (@))))))
+
(define* (delete-lockfiles #:key inputs #:allow-other-keys)
"Delete 'package-lock.json', 'yarn.lock', and 'npm-shrinkwrap.json', if they
exist."
--
2.32.0
- [bug#51838] [PATCH v8 00/41] guix: node-build-system: Support compiling add-ons with node-gyp., (continued)
[bug#51838] [PATCH v8 00/41] guix: node-build-system: Support compiling add-ons with node-gyp., Philip McGrath, 2022/01/07
- [bug#51838] [PATCH v8 00/41] guix: node-build-system: Support compiling add-ons with node-gyp., Liliana Marie Prikler, 2022/01/07
- [bug#51838] [PATCH v8 00/41] guix: node-build-system: Support compiling add-ons with node-gyp., Philip McGrath, 2022/01/07
- [bug#51838] [PATCH v9 00/41] guix: node-build-system: Support compiling add-ons with node-gyp., Philip McGrath, 2022/01/08
- [bug#51838] [PATCH v9 01/41] guix: node-build-system: Add delete-lockfiles phase., Philip McGrath, 2022/01/08
- [bug#51838] [PATCH v9 02/41] guix: node-build-system: Add implicit libuv input., Philip McGrath, 2022/01/08
- [bug#51838] [PATCH v9 03/41] guix: node-build-system: Add JSON utilities., Philip McGrath, 2022/01/08
- [bug#51838] [PATCH v9 13/41] gnu: node-semver: Use 'delete-dependencies'., Philip McGrath, 2022/01/08
- [bug#51838] [PATCH v9 05/41] guix: node-build-system: Add 'delete-dependencies' helper function.,
Philip McGrath <=
- [bug#51838] [PATCH v9 06/41] gnu: node-semver-bootstrap: Use 'delete-dependencies'., Philip McGrath, 2022/01/08
- [bug#51838] [PATCH v9 09/41] gnu: node-debug-bootstrap: Use 'delete-dependencies'., Philip McGrath, 2022/01/08
- [bug#51838] [PATCH v9 17/41] gnu: node-irc: Use 'delete-dependencies'., Philip McGrath, 2022/01/08
- [bug#51838] [PATCH v9 08/41] gnu: node-binary-search-bootstrap: Use 'delete-dependencies'., Philip McGrath, 2022/01/08
- [bug#51838] [PATCH v9 16/41] gnu: node-irc-colors: Use 'delete-dependencies'., Philip McGrath, 2022/01/08
- [bug#51838] [PATCH v9 10/41] gnu: node-llparse-builder-bootstrap: Use 'delete-dependencies'., Philip McGrath, 2022/01/08
- [bug#51838] [PATCH v9 04/41] guix: node-build-system: Add avoid-node-gyp-rebuild phase., Philip McGrath, 2022/01/08
- [bug#51838] [PATCH v9 07/41] gnu: node-ms-bootstrap: Use 'delete-dependencies'., Philip McGrath, 2022/01/08
- [bug#51838] [PATCH v9 18/41] gnu: Add node-inherits., Philip McGrath, 2022/01/08
- [bug#51838] [PATCH v9 11/41] gnu: node-llparse-frontend-bootstrap: Use 'delete-dependencies'., Philip McGrath, 2022/01/08