* [bug#51838] [PATCH v4 01/45] gnu: node: Avoid duplicating build phases.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 02/45] gnu: node: Update to 10.24.1 for bootstrapping Philip McGrath
` (44 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node.scm (node)[arguments]: Split 'patch-files phase
into 'patch-hardcoded-program-references and
'delete-problematic-tests. Adapt 'patch-hardcoded-program-references
and 'configure to work unmodified on node-lts, but don't try to
share 'delete-problematic-tests, because those details seem to change
too much between node versions.
(node, node-lts)[inputs]: Use bash-minimal rather than bash.
(node-lts)[arguments]: Inherit 'patch-hardcoded-program-references,
and 'configure phases from the bootstrap node.
Remove the 'patch-files phase, keeping its remaining
non-inherited work in a new 'replace-llhttp-sources phase.
---
gnu/packages/node.scm | 105 +++++++++++++-----------------------------
1 file changed, 32 insertions(+), 73 deletions(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index dccf871d2c..7ebbbc3060 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -9,6 +9,7 @@
;;; Copyright © 2020, 2021 Pierre Langlois <pierre.langlois@gmx.com>
;;; Copyright © 2020 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
+;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -105,14 +106,22 @@ (define-public node
#:test-target "test-ci-js"
#:phases
(modify-phases %standard-phases
- (add-before 'configure 'patch-files
+ (add-before 'configure 'patch-hardcoded-program-references
(lambda* (#:key inputs #:allow-other-keys)
+
;; Fix hardcoded /bin/sh references.
- (substitute* '("lib/child_process.js"
- "lib/internal/v8_prof_polyfill.js"
- "test/parallel/test-child-process-spawnsync-shell.js"
- "test/parallel/test-stdio-closed.js"
- "test/sequential/test-child-process-emfile.js")
+ (substitute*
+ (let ((common
+ '("lib/child_process.js"
+ "lib/internal/v8_prof_polyfill.js"
+ "test/parallel/test-child-process-spawnsync-shell.js"
+ "test/parallel/test-stdio-closed.js"
+ "test/sequential/test-child-process-emfile.js"))
+ ;; not in bootstap node:
+ (sigxfsz "test/parallel/test-fs-write-sigxfsz.js"))
+ (if (file-exists? sigxfsz)
+ (cons sigxfsz common)
+ common))
(("'/bin/sh'")
(string-append "'" (assoc-ref inputs "bash") "/bin/sh'")))
@@ -122,7 +131,10 @@ (define-public node
"test/parallel/test-child-process-exec-env.js")
(("'/usr/bin/env'")
(string-append "'" (assoc-ref inputs "coreutils")
- "/bin/env'")))
+ "/bin/env'")))))
+ (add-after 'patch-hardcoded-program-references
+ 'delete-problematic-tests
+ (lambda* (#:key inputs #:allow-other-keys)
;; FIXME: These tests fail in the build container, but they don't
;; seem to be indicative of real problems in practice.
@@ -217,9 +229,13 @@ (define-public node
(setenv "CXX" ,(cxx-for-target))
(setenv "PKG_CONFIG" ,(pkg-config-for-target))
(apply invoke
- (string-append (assoc-ref (or native-inputs inputs)
- "python")
- "/bin/python")
+ (let ((python
+ (string-append (assoc-ref (or native-inputs inputs)
+ "python")
+ "/bin/python")))
+ (if (file-exists? python)
+ python
+ (string-append python "3")))
"configure" flags))))
(add-after 'patch-shebangs 'patch-npm-shebang
(lambda* (#:key outputs #:allow-other-keys)
@@ -256,7 +272,7 @@ (define-public node
(variable "NODE_PATH")
(files '("lib/node_modules")))))
(inputs
- `(("bash" ,bash)
+ `(("bash" ,bash-minimal)
("coreutils" ,coreutils)
("c-ares" ,c-ares)
("http-parser" ,http-parser)
@@ -712,66 +728,8 @@ (define-public node-lts
libuv "/lib:"
zlib "/lib"
"'],"))))))
- (replace 'configure
- ;; Node's configure script is actually a python script, so we can't
- ;; run it with bash.
- (lambda* (#:key outputs (configure-flags '()) native-inputs inputs
- #:allow-other-keys)
- (let* ((prefix (assoc-ref outputs "out"))
- (xflags ,(if (%current-target-system)
- `'("--cross-compiling"
- ,(string-append
- "--dest-cpu="
- (match (%current-target-system)
- ((? (cut string-prefix? "arm" <>))
- "arm")
- ((? (cut string-prefix? "aarch64" <>))
- "arm64")
- ((? (cut string-prefix? "i686" <>))
- "ia32")
- ((? (cut string-prefix? "x86_64" <>))
- "x64")
- ((? (cut string-prefix? "powerpc64" <>))
- "ppc64")
- (_ "unsupported"))))
- ''()))
- (flags (cons
- (string-append "--prefix=" prefix)
- (append xflags configure-flags))))
- (format #t "build directory: ~s~%" (getcwd))
- (format #t "configure flags: ~s~%" flags)
- ;; Node's configure script expects the CC environment variable to
- ;; be set.
- (setenv "CC_host" "gcc")
- (setenv "CXX_host" "g++")
- (setenv "CC" ,(cc-for-target))
- (setenv "CXX" ,(cxx-for-target))
- (setenv "PKG_CONFIG" ,(pkg-config-for-target))
- (apply invoke
- (string-append (assoc-ref (or native-inputs inputs)
- "python")
- "/bin/python3")
- "configure" flags))))
- (replace 'patch-files
+ (replace 'delete-problematic-tests
(lambda* (#:key inputs #:allow-other-keys)
- ;; Fix hardcoded /bin/sh references.
- (substitute* '("lib/child_process.js"
- "lib/internal/v8_prof_polyfill.js"
- "test/parallel/test-child-process-spawnsync-shell.js"
- "test/parallel/test-fs-write-sigxfsz.js"
- "test/parallel/test-stdio-closed.js"
- "test/sequential/test-child-process-emfile.js")
- (("'/bin/sh'")
- (string-append "'" (assoc-ref inputs "bash") "/bin/sh'")))
-
- ;; Fix hardcoded /usr/bin/env references.
- (substitute* '("test/parallel/test-child-process-default-options.js"
- "test/parallel/test-child-process-env.js"
- "test/parallel/test-child-process-exec-env.js")
- (("'/usr/bin/env'")
- (string-append "'" (assoc-ref inputs "coreutils")
- "/bin/env'")))
-
;; FIXME: These tests fail in the build container, but they don't
;; seem to be indicative of real problems in practice.
(for-each delete-file
@@ -810,8 +768,9 @@ (define-public node-lts
;; TODO: Regenerate certs instead.
(for-each delete-file
'("test/parallel/test-tls-passphrase.js"
- "test/parallel/test-tls-server-verify.js"))
-
+ "test/parallel/test-tls-server-verify.js"))))
+ (add-after 'delete-problematic-tests 'replace-llhttp-sources
+ (lambda* (#:key inputs #:allow-other-keys)
;; Replace pre-generated llhttp sources
(let ((llhttp (assoc-ref inputs "llhttp")))
(copy-file (string-append llhttp "/src/llhttp.c")
@@ -838,7 +797,7 @@ (define-public node-lts
("python" ,python)
("util-linux" ,util-linux)))
(inputs
- `(("bash" ,bash)
+ `(("bash" ,bash-minimal)
("coreutils" ,coreutils)
("c-ares" ,c-ares-for-node)
("icu4c" ,icu4c-67)
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 02/45] gnu: node: Update to 10.24.1 for bootstrapping.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 01/45] gnu: node: Avoid duplicating build phases Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 03/45] gnu: node: Patch shebangs in node_modules Philip McGrath
` (43 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node.scm (node): Update to 10.24.1.
---
gnu/packages/node.scm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 7ebbbc3060..71b66774a6 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -57,14 +57,14 @@ (define-module (gnu packages node)
(define-public node
(package
(name "node")
- (version "10.24.0")
+ (version "10.24.1")
(source (origin
(method url-fetch)
(uri (string-append "https://nodejs.org/dist/v" version
"/node-v" version ".tar.xz"))
(sha256
(base32
- "1k1srdis23782hnd1ymgczs78x9gqhv77v0am7yb54gqcspp70hm"))
+ "032801kg24j04xmf09m0vxzlcz86sv21s24lv9l4cfv08k1c4byp"))
(modules '((guix build utils)))
(snippet
`(begin
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 03/45] gnu: node: Patch shebangs in node_modules.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 01/45] gnu: node: Avoid duplicating build phases Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 02/45] gnu: node: Update to 10.24.1 for bootstrapping Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 04/45] gnu: node: Add an npmrc file to set nodedir Philip McGrath
` (42 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node.scm (node)[arguments]: Replace 'patch-npm-shebang
and 'patch-node-shebang with a new 'patch-nested-shebangs that also
handles node-gyp and other shebangs under "/lib/node_modules".
[inputs]: Add Python for node-gyp as "python-for-target".
(node-lts)[inputs]: Likewise.
(libnode)[arguments]: Adjust to delete 'patch-nested-shebangs rather
than 'patch-npm-shebang and 'patch-node-shebang.
---
gnu/packages/node.scm | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 71b66774a6..a57a74fb81 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -237,21 +237,20 @@ (define-public node
python
(string-append python "3")))
"configure" flags))))
- (add-after 'patch-shebangs 'patch-npm-shebang
- (lambda* (#:key outputs #:allow-other-keys)
- (let* ((bindir (string-append (assoc-ref outputs "out")
- "/bin"))
- (npm (string-append bindir "/npm"))
- (target (readlink npm)))
- (with-directory-excursion bindir
- (patch-shebang target (list bindir))))))
- (add-after 'install 'patch-node-shebang
- (lambda* (#:key outputs #:allow-other-keys)
- (let* ((bindir (string-append (assoc-ref outputs "out")
- "/bin"))
- (npx (readlink (string-append bindir "/npx"))))
- (with-directory-excursion bindir
- (patch-shebang npx (list bindir)))))))))
+ (add-after 'patch-shebangs 'patch-nested-shebangs
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let* ((prefix (assoc-ref outputs "out"))
+ (path (map (lambda (dir)
+ (string-append dir "/bin"))
+ (list prefix
+ (assoc-ref inputs "python-for-target")))))
+ (for-each
+ (lambda (file)
+ (patch-shebang file path))
+ (find-files (string-append prefix "/lib/node_modules")
+ (lambda (file stat)
+ (executable-file? file))
+ #:stat lstat))))))))
(native-inputs
`(;; Runtime dependencies for binaries used as a bootstrap.
("c-ares" ,c-ares)
@@ -274,6 +273,7 @@ (define-public node
(inputs
`(("bash" ,bash-minimal)
("coreutils" ,coreutils)
+ ("python-for-target" ,python-wrapper) ;; for node-gyp (supports python3)
("c-ares" ,c-ares)
("http-parser" ,http-parser)
("icu4c" ,icu4c)
@@ -799,6 +799,7 @@ (define-public node-lts
(inputs
`(("bash" ,bash-minimal)
("coreutils" ,coreutils)
+ ("python-for-target" ,python-wrapper) ;; for node-gyp (supports python3)
("c-ares" ,c-ares-for-node)
("icu4c" ,icu4c-67)
("libuv" ,libuv-for-node)
@@ -817,5 +818,4 @@ (define-public libnode
`(cons* "--shared" "--without-npm" ,flags))
((#:phases phases '%standard-phases)
`(modify-phases ,phases
- (delete 'patch-npm-shebang)
- (delete 'patch-node-shebang)))))))
+ (delete 'patch-nested-shebangs)))))))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 04/45] gnu: node: Add an npmrc file to set nodedir.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (2 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 03/45] gnu: node: Patch shebangs in node_modules Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 05/45] guix: node-build-system: Add delete-lockfiles phase Philip McGrath
` (41 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node.scm (node, node-lts)[arguments]: Add a phase
'install-npmrc to create a "built-in" npmrc file that configures
"nodedir" to point to the output store path.
(libnode)[arguments]: Delete the 'install-npmrc phase.
---
gnu/packages/node.scm | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index a57a74fb81..346cbd488d 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -250,7 +250,24 @@ (define-public node
(find-files (string-append prefix "/lib/node_modules")
(lambda (file stat)
(executable-file? file))
- #:stat lstat))))))))
+ #:stat lstat)))))
+ (add-after 'install 'install-npmrc
+ ;; Note: programs like node-gyp only receive these values if
+ ;; they are started via `npm` or `npx`.
+ ;; See: https://github.com/nodejs/node-gyp#npm-configuration
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out")))
+ (with-output-to-file
+ ;; Use the config file "primarily for distribution
+ ;; maintainers" rather than "{prefix}/etc/npmrc",
+ ;; especially because node-build-system uses --prefix
+ ;; to install things to their store paths:
+ (string-append out "/lib/node_modules/npm/npmrc")
+ (lambda ()
+ ;; Tell npm (mostly node-gyp) where to find our
+ ;; installed headers so it doesn't try to
+ ;; download them from the internet:
+ (format #t "nodedir=~a\n" out)))))))))
(native-inputs
`(;; Runtime dependencies for binaries used as a bootstrap.
("c-ares" ,c-ares)
@@ -818,4 +835,5 @@ (define-public libnode
`(cons* "--shared" "--without-npm" ,flags))
((#:phases phases '%standard-phases)
`(modify-phases ,phases
+ (delete 'install-npmrc)
(delete 'patch-nested-shebangs)))))))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 05/45] guix: node-build-system: Add delete-lockfiles phase.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (3 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 04/45] gnu: node: Add an npmrc file to set nodedir Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 06/45] guix: node-build-system: Refactor patch-dependencies phase Philip McGrath
` (40 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* guix/build/node-build-system.scm (delete-lockfiles): New function.
Remove 'package-lock.json', 'yarn.lock', and 'npm-shrinkwrap.json',
if they exist. Because these files specify both exact dependency
versions and integrity hashes, they only cause problems for Guix.
(%standard-phases): Add 'delete-lockfiles' after 'patch-dependencies'.
---
guix/build/node-build-system.scm | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index 70a367618e..dcaa719f40 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -96,6 +96,17 @@ (define (resolve-dependencies package-meta meta-key)
(write-json package-meta out))))
#t)
+(define* (delete-lockfiles #:key inputs #:allow-other-keys)
+ "Delete 'package-lock.json', 'yarn.lock', and 'npm-shrinkwrap.json', if they
+exist."
+ (for-each (lambda (pth)
+ (when (file-exists? pth)
+ (delete-file pth)))
+ '("package-lock.json"
+ "yarn.lock"
+ "npm-shrinkwrap.json"))
+ #t)
+
(define* (configure #:key outputs inputs #:allow-other-keys)
(let ((npm (string-append (assoc-ref inputs "node") "/bin/npm")))
(invoke npm "--offline" "--ignore-scripts" "install")
@@ -146,6 +157,7 @@ (define %standard-phases
(modify-phases gnu:%standard-phases
(add-after 'unpack 'set-home set-home)
(add-before 'configure 'patch-dependencies patch-dependencies)
+ (add-after 'patch-dependencies 'delete-lockfiles delete-lockfiles)
(replace 'configure configure)
(replace 'build build)
(replace 'check check)
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 06/45] guix: node-build-system: Refactor patch-dependencies phase.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (4 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 05/45] guix: node-build-system: Add delete-lockfiles phase Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 07/45] guix: node-build-system: Add #:absent-dependencies argument Philip McGrath
` (39 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* guix/build/node-build-system.scm (patch-dependencies): Strictly
follow the linearity rules for `assoc-set!` and friends.
Clarify the types of the arguments to and return value from the
internal helper function `resolve-dependencies`.
---
guix/build/node-build-system.scm | 53 ++++++++++++++++++++++----------
1 file changed, 36 insertions(+), 17 deletions(-)
diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index dcaa719f40..b74e593838 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -73,26 +73,45 @@ (define* (patch-dependencies #:key inputs #:allow-other-keys)
(define index (index-modules (map cdr inputs)))
- (define (resolve-dependencies package-meta meta-key)
- (fold (lambda (key+value acc)
- (match key+value
- ('@ acc)
- ((key . value) (acons key (hash-ref index key value) acc))))
- '()
- (or (assoc-ref package-meta meta-key) '())))
+ (define (resolve-dependencies meta-alist meta-key)
+ ;; Given:
+ ;; - The alist from "package.json", with the '@ unwrapped
+ ;; - A string key, like "dependencies"
+ ;; Returns: an alist (without a wrapping '@) like the entry in
+ ;; meta-alist for meta-key, but with dependencies supplied
+ ;; by Guix packages mapped to the absolute store paths to use.
+ (match (assoc-ref meta-alist meta-key)
+ (#f
+ '())
+ (('@ . orig-deps)
+ (fold (match-lambda*
+ (((key . value) acc)
+ (acons key (hash-ref index key value) acc)))
+ '()
+ orig-deps))))
(with-atomic-file-replacement "package.json"
(lambda (in out)
- (let ((package-meta (read-json in)))
- (assoc-set! package-meta "dependencies"
- (append
- '(@)
- (resolve-dependencies package-meta "dependencies")
- (resolve-dependencies package-meta "peerDependencies")))
- (assoc-set! package-meta "devDependencies"
- (append
- '(@)
- (resolve-dependencies package-meta "devDependencies")))
+ ;; It is unsafe to rely on 'assoc-set!' to update an
+ ;; existing assosciation list variable:
+ ;; see 'info "(guile)Adding or Setting Alist Entries"'.
+ (let* ((package-meta (read-json in))
+ (alist (match package-meta
+ ((@ . alist) alist)))
+ (alist
+ (assoc-set!
+ alist "dependencies"
+ (append
+ '(@)
+ (resolve-dependencies alist "dependencies")
+ (resolve-dependencies alist "peerDependencies"))))
+ (alist
+ (assoc-set!
+ alist "devDependencies"
+ (append
+ '(@)
+ (resolve-dependencies alist "devDependencies"))))
+ (package-meta (cons '@ alist)))
(write-json package-meta out))))
#t)
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 07/45] guix: node-build-system: Add #:absent-dependencies argument.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (5 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 06/45] guix: node-build-system: Refactor patch-dependencies phase Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 08/45] gnu: node-semver-bootstrap: Use #:absent-dependencies Philip McGrath
` (38 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* 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
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 08/45] gnu: node-semver-bootstrap: Use #:absent-dependencies.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (6 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 07/45] guix: node-build-system: Add #:absent-dependencies argument Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 09/45] gnu: node-ms-bootstrap: " Philip McGrath
` (37 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node.scm (node-semver-bootstrap)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node.scm | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 346cbd488d..0c33c6906e 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -333,9 +333,8 @@ (define-public node-semver-bootstrap
(arguments
`(#:node ,node-bootstrap
#:tests? #f
- #:phases
- (modify-phases %standard-phases
- (delete 'configure))))
+ #:absent-dependencies
+ '("tap")))
(home-page "https://github.com/npm/node-semver")
(properties '((hidden? . #t)))
(synopsis "Parses semantic versions strings")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 09/45] gnu: node-ms-bootstrap: Use #:absent-dependencies.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (7 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 08/45] gnu: node-semver-bootstrap: Use #:absent-dependencies Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 10/45] gnu: node-binary-search-bootstrap: " Philip McGrath
` (36 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node.scm (node-ms-bootstrap)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node.scm | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 0c33c6906e..f2dfa1476b 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -361,9 +361,12 @@ (define-public node-ms-bootstrap
(arguments
`(#:node ,node-bootstrap
#:tests? #f
- #:phases
- (modify-phases %standard-phases
- (delete 'configure))))
+ #:absent-dependencies
+ `("eslint"
+ "expect.js"
+ "husky"
+ "lint-staged"
+ "mocha")))
(home-page "https://github.com/zeit/ms#readme")
(properties '((hidden? . #t)))
(synopsis "Tiny millisecond conversion utility")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 10/45] gnu: node-binary-search-bootstrap: Use #:absent-dependencies.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (8 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 09/45] gnu: node-ms-bootstrap: " Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 11/45] gnu: node-debug-bootstrap: " Philip McGrath
` (35 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node.scm (node-binary-search-bootstrap)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node.scm | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index f2dfa1476b..b9f6e181b6 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -392,9 +392,9 @@ (define-public node-binary-search-bootstrap
(arguments
`(#:node ,node-bootstrap
#:tests? #f
- #:phases
- (modify-phases %standard-phases
- (delete 'configure))))
+ #:absent-dependencies
+ `("chai"
+ "mocha")))
(home-page "https://github.com/darkskyapp/binary-search#readme")
(properties '((hidden? . #t)))
(synopsis "Tiny binary search function with comparators")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 11/45] gnu: node-debug-bootstrap: Use #:absent-dependencies.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (9 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 10/45] gnu: node-binary-search-bootstrap: " Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 12/45] gnu: node-llparse-builder-bootstrap: " Philip McGrath
` (34 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node.scm (node-debug-bootstrap)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node.scm | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index b9f6e181b6..b605442f64 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -419,9 +419,18 @@ (define-public node-debug-bootstrap
(arguments
`(#:node ,node-bootstrap
#:tests? #f
- #:phases
- (modify-phases %standard-phases
- (delete 'configure))))
+ #:absent-dependencies
+ `("brfs"
+ "browserify"
+ "coveralls"
+ "istanbul"
+ "karma"
+ "karma-browserify"
+ "karma-chrome-launcher"
+ "karma-mocha"
+ "mocha"
+ "mocha-lcov-reporter"
+ "xo")))
(inputs `(("node-ms" ,node-ms-bootstrap)))
(home-page "https://github.com/visionmedia/debug#readme")
(properties '((hidden? . #t)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 12/45] gnu: node-llparse-builder-bootstrap: Use #:absent-dependencies.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (10 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 11/45] gnu: node-debug-bootstrap: " Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 13/45] gnu: node-llparse-frontend-bootstrap: " Philip McGrath
` (33 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node.scm (node-llparse-builder-bootstrap)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node.scm | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index b605442f64..2dddea8239 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -482,9 +482,15 @@ (define-public node-llparse-builder-bootstrap
(arguments
`(#:node ,node-bootstrap
#:tests? #f
+ #:absent-dependencies
+ `("@types/mocha"
+ "@types/node"
+ "mocha"
+ "ts-node"
+ "tslint"
+ "typescript")
#:phases
(modify-phases %standard-phases
- (delete 'configure)
(replace 'build
(lambda* (#:key inputs #:allow-other-keys)
(let ((esbuild (string-append (assoc-ref inputs "esbuild")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 13/45] gnu: node-llparse-frontend-bootstrap: Use #:absent-dependencies.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (11 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 12/45] gnu: node-llparse-builder-bootstrap: " Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 14/45] gnu: node-llparse-bootstrap: " Philip McGrath
` (32 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node.scm (node-llparse-frontend-bootstrap)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node.scm | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 2dddea8239..c429495955 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -544,9 +544,16 @@ (define-public node-llparse-frontend-bootstrap
(arguments
`(#:node ,node-bootstrap
#:tests? #f
+ #:absent-dependencies
+ `("@types/debug"
+ "@types/mocha"
+ "@types/node"
+ "mocha"
+ "ts-node"
+ "tslint"
+ "typescript")
#:phases
(modify-phases %standard-phases
- (delete 'configure)
(replace 'build
(lambda* (#:key inputs #:allow-other-keys)
(let ((esbuild (string-append (assoc-ref inputs "esbuild")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 14/45] gnu: node-llparse-bootstrap: Use #:absent-dependencies.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (12 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 13/45] gnu: node-llparse-frontend-bootstrap: " Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 15/45] gnu: node-semver: " Philip McGrath
` (31 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node.scm (node-llparse-bootstrap)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node.scm | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index c429495955..2baa382cd9 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -606,9 +606,18 @@ (define-public node-llparse-bootstrap
(arguments
`(#:node ,node-bootstrap
#:tests? #f
+ #:absent-dependencies
+ `("@types/debug"
+ "@types/mocha"
+ "@types/node"
+ "esm"
+ "llparse-test-fixture"
+ "mocha"
+ "ts-node"
+ "tslint"
+ "typescript")
#:phases
(modify-phases %standard-phases
- (delete 'configure)
(replace 'build
(lambda* (#:key inputs #:allow-other-keys)
(let ((esbuild (string-append (assoc-ref inputs "esbuild")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 15/45] gnu: node-semver: Use #:absent-dependencies.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (13 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 14/45] gnu: node-llparse-bootstrap: " Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 16/45] gnu: node-wrappy: " Philip McGrath
` (30 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node-xyz.scm (node-semver)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node-xyz.scm | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 98c611f227..93a033d33e 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -289,11 +289,10 @@ (define-public node-semver
"06biknqb05r9xsmcflm3ygh50pjvdk84x6r79w43kmck4fn3qn5p"))))
(build-system node-build-system)
(arguments
- '(#:tests? #f ; FIXME: Tests depend on node-tap
- #:phases
- (modify-phases %standard-phases
- ;; The only dependency to check for is tap, which we don't have.
- (delete 'configure))))
+ '(#:absent-dependencies
+ '("tap")
+ ;; FIXME: Tests depend on node-tap
+ #:tests? #f))
(home-page "https://github.com/npm/node-semver")
(synopsis "Parses semantic versions strings")
(description
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 16/45] gnu: node-wrappy: Use #:absent-dependencies.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (14 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 15/45] gnu: node-semver: " Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 17/45] gnu: node-once: " Philip McGrath
` (29 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node-xyz.scm (node-wrappy)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node-xyz.scm | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 93a033d33e..77577cb315 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -316,10 +316,8 @@ (define-public node-wrappy
(build-system node-build-system)
(arguments
'(#:tests? #f ; FIXME: Tests depend on node-tap
- #:phases
- (modify-phases %standard-phases
- ;; The only dependency to check for is tap, which we don't have.
- (delete 'configure))))
+ #:absent-dependencies
+ '("tap")))
(home-page "https://github.com/npm/wrappy")
(synopsis "Callback wrapping utility")
(description "@code{wrappy} is a utility for Node.js to wrap callbacks.")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 17/45] gnu: node-once: Use #:absent-dependencies.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (15 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 16/45] gnu: node-wrappy: " Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 18/45] gnu: node-irc-colors: " Philip McGrath
` (28 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node-xyz.scm (node-once)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node-xyz.scm | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 77577cb315..eb071320cd 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -338,13 +338,10 @@ (define-public node-once
"1z8dcbf28dqdcp4wb0c53wrs90a07nkrax2c9kk26dsk1dhrnxav"))))
(build-system node-build-system)
(arguments
- '(#:tests? #f ; FIXME: tests depend on node-tap
- #:phases
- (modify-phases %standard-phases
- ;; The default configure phase fails due to tap being missing, as we do
- ;; not have tap packaged yet. It is used only for tests. This package
- ;; still works as a dependency of node-glob and node-inflight.
- (delete 'configure))))
+ '(#:absent-dependencies
+ '("tap")
+ ;; FIXME: Tests depend on node-tap
+ #:tests? #f))
(inputs
`(("node-wrappy" ,node-wrappy)))
(home-page "https://github.com/isaacs/once")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 18/45] gnu: node-irc-colors: Use #:absent-dependencies.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (16 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 17/45] gnu: node-once: " Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 19/45] gnu: node-irc: " Philip McGrath
` (27 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node-xyz.scm (node-irc-colors)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node-xyz.scm | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index eb071320cd..9646c14243 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -367,12 +367,10 @@ (define-public node-irc-colors
"0q3y34rbnlc55jcakmdxkicwazyvyph9r6gaf6hi8k7wj2nfwfli"))))
(build-system node-build-system)
(arguments
- '(#:tests? #f ; FIXME: tests depend on node-istanbul
- #:phases
- (modify-phases %standard-phases
- ;; The default configure phase fails due to various packages
- ;; being missing, as we don't have them packaged yet.
- (delete 'configure))))
+ '(#:absent-dependencies
+ `("istanbul"
+ "vows")
+ #:tests? #f))
(home-page "https://github.com/fent/irc-colors.js")
(synopsis "Node.js module providing color and formatting for IRC")
(description "@code{node-irc-colors} is a Node.js module that
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 19/45] gnu: node-irc: Use #:absent-dependencies.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (17 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 18/45] gnu: node-irc-colors: " Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 20/45] guix: node-build-system: Add implicit libuv input Philip McGrath
` (26 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node-xyz.scm (node-irc)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node-xyz.scm | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 9646c14243..998d0a9a90 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -394,12 +394,12 @@ (define-public node-irc
"1ln4qfx20jbwg4cp8lp0vf27m5281z2sz16d15xd6150n26cbi4x"))))
(build-system node-build-system)
(arguments
- '(#:tests? #f ; FIXME: tests depend on node-faucet
- #:phases
- (modify-phases %standard-phases
- ;; The default configure phase fails due to various packages
- ;; being missing, as we don't have them packaged yet.
- (delete 'configure))))
+ '(#:absent-dependencies
+ `("ansi-color"
+ "faucet"
+ "jscs"
+ "tape")
+ #:tests? #f))
(inputs
`(("node-irc-colors" ,node-irc-colors)))
(home-page "https://github.com/martynsmith/node-irc")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 20/45] guix: node-build-system: Add implicit libuv input.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (18 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 19/45] gnu: node-irc: " Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 21/45] guix: node-build-system: Add avoid-node-gyp-rebuild phase Philip McGrath
` (25 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* guix/build-system/node.scm (lower): Add the version of libuv
used as an input to the #:node package as an additional implicit
input, so that packages needing libuv always get the correct version.
---
guix/build-system/node.scm | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/guix/build-system/node.scm b/guix/build-system/node.scm
index 4f437f9c0d..179da65ee8 100644
--- a/guix/build-system/node.scm
+++ b/guix/build-system/node.scm
@@ -1,6 +1,8 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016 Jelle Licht <jlicht@fsfe.org>
;;; Copyright © 2019 Timothy Sample <samplet@ngyro.com>
+;;; Copyright © 2021 Pierre Langlois <pierre.langlois@gmx.com>
+;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -59,10 +61,15 @@ (define private-keywords
`(("source" ,source))
'())
,@inputs
-
;; Keep the standard inputs of 'gnu-build-system'.
,@(standard-packages)))
(build-inputs `(("node" ,node)
+ ;; Many packages with native addons need
+ ;; libuv headers. The libuv version must
+ ;; be exactly the same as for the node
+ ;; package we are adding implicitly,
+ ;; so we take care of adding libuv, too.
+ ("libuv" ,@(assoc-ref (package-inputs node) "libuv"))
,@native-inputs))
(outputs outputs)
(build node-build)
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 21/45] guix: node-build-system: Add avoid-node-gyp-rebuild phase.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (19 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 20/45] guix: node-build-system: Add implicit libuv input Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 22/45] gnu: Add node-inherits Philip McGrath
` (24 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* guix/build/node-build-system.scm (avoid-node-gyp-rebuild): New
function. Override the default install script for packages with
native addons to prevent it from attempting to write to the store
when such packages are used.
(%standard-phases): Add 'avoid-node-gyp-rebuild' after 'install'.
---
guix/build/node-build-system.scm | 59 +++++++++++++++++++++++++++++++-
1 file changed, 58 insertions(+), 1 deletion(-)
diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index 892104b6d2..f9ca515d58 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -175,6 +175,62 @@ (define* (install #:key outputs inputs #:allow-other-keys)
"install" "../package.tgz")
#t))
+(define* (avoid-node-gyp-rebuild #:key outputs #:allow-other-keys)
+ "Adjust the installed 'package.json' to remove an 'install' script that
+would try to run 'node-gyp rebuild'."
+ ;; We want to take advantage of `npm install`'s automatic support for
+ ;; building native addons with node-gyp: in particular, it helps us avoid
+ ;; hard-coding the specifics of how npm's internal copy of node-gyp is
+ ;; currently packaged. However, the mechanism by which the automatic support
+ ;; is implemented causes problems for us.
+ ;;
+ ;; If a package contains a 'binding.gyp' file and does not define an
+ ;; 'install' or 'preinstall' script, 'npm install' runs a default install
+ ;; script consisting of 'node-gyp rebuild'. In our 'install' phase, this
+ ;; implicit 'install' script, if it is applicable, is explicitly added to
+ ;; the "package.json" file. However, if another Guix package were to use a
+ ;; Node.js package with such an 'install' script, the dependent package's
+ ;; build process would fail, because 'node-gyp rebuild' would try to write
+ ;; to the store.
+ ;;
+ ;; Here, if the installed "package.json" defines scripts.install as
+ ;; "node-gyp rebuild", we replace it with a no-op. Importantly, deleting the
+ ;; install script definition would not be enough, because the default
+ ;; install script would cause the same problem.
+ ;;
+ ;; For further details, see:
+ ;; - https://docs.npmjs.com/cli/v8/configuring-npm/package-json#default-values
+ ;; - https://docs.npmjs.com/cli/v8/using-npm/scripts#best-practices
+ (let* ((package.json (string-append
+ (assoc-ref outputs "out")
+ "/lib/node_modules/"
+ (match (call-with-input-file "package.json" read-json)
+ (('@ . alist)
+ (assoc-ref alist "name")))
+ "/package.json"))
+ (meta-alist (match (call-with-input-file package.json read-json)
+ (('@ . alist)
+ alist)))
+ (scripts-alist (match (assoc-ref meta-alist "scripts")
+ (('@ . alist)
+ alist)
+ (#f
+ #f))))
+ (when (and scripts-alist
+ (equal? "node-gyp rebuild" (assoc-ref scripts-alist "install")))
+ (call-with-output-file package.json
+ (lambda (out)
+ (write-json
+ (cons '@ (assoc-set!
+ meta-alist
+ "scripts"
+ (cons '@ (assoc-set!
+ scripts-alist
+ "install"
+ "echo Guix: avoiding node-gyp rebuild"))))
+ out))))
+ #t))
+
(define %standard-phases
(modify-phases gnu:%standard-phases
(add-after 'unpack 'set-home set-home)
@@ -184,7 +240,8 @@ (define %standard-phases
(replace 'build build)
(replace 'check check)
(add-before 'install 'repack repack)
- (replace 'install install)))
+ (replace 'install install)
+ (add-after 'install 'avoid-node-gyp-rebuild avoid-node-gyp-rebuild)))
(define* (node-build #:key inputs (phases %standard-phases)
#:allow-other-keys #:rest args)
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 22/45] gnu: Add node-inherits.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (20 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 21/45] guix: node-build-system: Add avoid-node-gyp-rebuild phase Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 23/45] gnu: Add node-safe-buffer Philip McGrath
` (23 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-inherits): New variable.
---
gnu/packages/node-xyz.scm | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 998d0a9a90..9d8bf27852 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -3,6 +3,7 @@
;;; Copyright © 2020 Giacomo Leidi <goodoldpaul@autistici.org>
;;; Copyright © 2021 Noisytoot <noisytoot@disroot.org>
;;; Copyright © 2021 Charles <charles.b.jackson@protonmail.com>
+;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -352,6 +353,35 @@ (define-public node-once
if desired.")
(license license:isc)))
+(define-public node-inherits
+ (package
+ (name "node-inherits")
+ (version "2.0.4")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/isaacs/inherits")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0cpsr5yqwkxpbbbbl0rwk4mcby6zbx841k2zb4c3gb1579i5wq9p"))))
+ (build-system node-build-system)
+ (arguments
+ '(#:absent-dependencies
+ '("tap")
+ ;; FIXME: Tests depend on node-tap
+ #:tests? #f))
+ (home-page
+ "https://github.com/isaacs/inherits")
+ (synopsis
+ "Browser-friendly inheritance Node.js")
+ (description
+ "Browser-friendly inheritance fully compatible with standard Node.js
+@code{inherits()}.")
+ (license license:isc)))
+
(define-public node-irc-colors
(package
(name "node-irc-colors")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 23/45] gnu: Add node-safe-buffer.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (21 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 22/45] gnu: Add node-inherits Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 24/45] gnu: Add node-string-decoder Philip McGrath
` (22 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-safe-buffer): New variable.
---
gnu/packages/node-xyz.scm | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 9d8bf27852..6dff0ddba5 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -382,6 +382,34 @@ (define-public node-inherits
@code{inherits()}.")
(license license:isc)))
+(define-public node-safe-buffer
+ (package
+ (name "node-safe-buffer")
+ (version "5.2.1")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/feross/safe-buffer")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0r26m0nl41h90ihnl2xf0cqs6z9z7jb87dl5j8yqb7887r9jlbpi"))))
+ (build-system node-build-system)
+ (arguments
+ '(#:absent-dependencies
+ '("tape"
+ "standard")
+ #:tests? #f))
+ (home-page
+ "https://github.com/feross/safe-buffer")
+ (synopsis "Safer Node.js Buffer API")
+ (description "A safe drop-in replacement the Node.js @code{Buffer} API
+that works in all versions of Node.js, using the built-in implementation when
+available.")
+ (license license:expat)))
+
(define-public node-irc-colors
(package
(name "node-irc-colors")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 24/45] gnu: Add node-string-decoder.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (22 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 23/45] gnu: Add node-safe-buffer Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 25/45] gnu: Add node-readable-stream Philip McGrath
` (21 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-string-decoder): New variable.
---
gnu/packages/node-xyz.scm | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 6dff0ddba5..c6cce64f7d 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -410,6 +410,40 @@ (define-public node-safe-buffer
available.")
(license license:expat)))
+(define-public node-string-decoder
+ (package
+ (name "node-string-decoder")
+ (version "1.3.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/nodejs/string_decoder")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0xxvyya9fl9rlkqwmxzqzbz4rdr3jgw4vf37hff7cgscxkhg266k"))))
+ (build-system node-build-system)
+ (arguments
+ '(#:absent-dependencies
+ '("tap"
+ "core-util-is"
+ "babel-polyfill")
+ ;; FIXME: Tests depend on node-tap
+ #:tests? #f))
+ (inputs
+ `(("node-safe-buffer" ,node-safe-buffer)
+ ("node-inherits" ,node-inherits)))
+ (home-page
+ "https://github.com/nodejs/string_decoder")
+ (synopsis
+ "Node.js core @code{string_decoder} for userland")
+ (description
+ "This package is a mirror of the @code{string_decoder} implementation in
+Node-core.")
+ (license license:expat)))
+
(define-public node-irc-colors
(package
(name "node-irc-colors")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 25/45] gnu: Add node-readable-stream.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (23 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 24/45] gnu: Add node-string-decoder Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 26/45] gnu: Add node-nan Philip McGrath
` (20 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-readable-stream): New variable.
---
gnu/packages/node-xyz.scm | 54 +++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index c6cce64f7d..3e06413908 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -444,6 +444,60 @@ (define-public node-string-decoder
Node-core.")
(license license:expat)))
+(define-public node-readable-stream
+ (package
+ (name "node-readable-stream")
+ (version "3.6.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/nodejs/readable-stream")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0ybl4cdgsm9c5jq3xq8s01201jk8w0yakh63hlclsfbcdfqhd9ri"))))
+ (build-system node-build-system)
+ (arguments
+ `(#:absent-dependencies
+ `("@babel/cli"
+ "@babel/core"
+ "@babel/polyfill"
+ "@babel/preset-env"
+ "airtap"
+ "assert"
+ "bl"
+ "deep-strict-equal"
+ "events.once"
+ "glob"
+ "gunzip-maybe"
+ "hyperquest"
+ "lolex"
+ "nyc"
+ "pump"
+ "rimraf"
+ "tap"
+ "tape"
+ "tar-fs"
+ "util-promisify")
+ #:tests? #f))
+ (inputs
+ `(("node-util-deprecate" ,node-util-deprecate)
+ ("node-string-decoder" ,node-string-decoder)
+ ("node-inherits" ,node-inherits)))
+ (home-page
+ "https://github.com/nodejs/readable-stream")
+ (synopsis
+ "Node.js core streams for userland")
+ (description
+ "This package is a mirror of the streams implementations in Node.js.
+
+If you want to guarantee a stable streams base, regardless of what version of
+Node you (or the users of your libraries) are using, use
+@code{readable-stream} only and avoid the @code{stream} module in Node-core.")
+ (license license:expat)))
+
(define-public node-irc-colors
(package
(name "node-irc-colors")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 26/45] gnu: Add node-nan.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (24 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 25/45] gnu: Add node-readable-stream Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 27/45] gnu: Add node-openzwave-shared Philip McGrath
` (19 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-nan): New variable.
---
gnu/packages/node-xyz.scm | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 3e06413908..43cf9fe660 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -553,3 +553,42 @@ (define-public node-irc
(description "@code{node-irc} is an IRC client library for Node.js.
It has functions for joining, parting, talking, and many other IRC commands.")
(license license:gpl3+)))
+
+(define-public node-nan
+ (package
+ (name "node-nan")
+ (version "2.15.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/nodejs/nan")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "18xslh9va5ld872scrp5y4251ax9s3c6qh0lnl1200lpzbsxy7yd"))))
+ (build-system node-build-system)
+ (arguments
+ `(#:absent-dependencies
+ '("bindings"
+ "commander"
+ "glob"
+ "request"
+ "node-gyp" ;; would be needed for tests
+ "tap"
+ "xtend")
+ ;; tests need tap and other dependencies
+ #:tests? #f))
+ (inputs
+ `(("readable-stream" ,node-readable-stream)))
+ (home-page "https://github.com/nodejs/nan")
+ (synopsis "Native Abstractions for Node.js")
+ (description "Native Abstractions for Node.js (``NaN'') provides a header
+file filled with macro and utility goodness for making add-on development for
+Node.js easier across versions. The goal of this project is to store all logic
+necessary to develop native Node.js addons without having to inspect
+@code{NODE_MODULE_VERSION} and get yourself into a macro-tangle.
+
+This project also contains some helper utilities that make addon development a
+bit more pleasant.")
+ (license license:expat)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 27/45] gnu: Add node-openzwave-shared.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (25 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 26/45] gnu: Add node-nan Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 28/45] gnu: Add node-addon-api Philip McGrath
` (18 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/zwave.scm (node-openzwave-shared): New variable.
---
gnu/packages/zwave.scm | 69 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 69 insertions(+)
diff --git a/gnu/packages/zwave.scm b/gnu/packages/zwave.scm
index 2019ec32df..feecf51e9c 100644
--- a/gnu/packages/zwave.scm
+++ b/gnu/packages/zwave.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -21,11 +22,14 @@ (define-module (gnu packages zwave)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix git-download)
#:use-module (guix build-system gnu)
+ #:use-module (guix build-system node)
#:use-module (gnu packages)
#:use-module (gnu packages base)
+ #:use-module (gnu packages node-xyz)
#:use-module (gnu packages libusb)
#:use-module (gnu packages linux)
#:use-module (gnu packages perl)
+ #:use-module (gnu packages python)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages xml))
@@ -88,3 +92,68 @@ (define-public open-zwave
and respond to devices on a Z-Wave network, without requiring in-depth
knowledge of the Z-Wave protocol.")
(license license:lgpl3+)))
+
+(define-public node-openzwave-shared
+ (package
+ (name "node-openzwave-shared")
+ (version "1.7.2")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/OpenZWave/node-openzwave-shared")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1bqqy12dzqj05j9wsh50dmn84dddmhz0gjzvd3y20z4hpy1v8rsc"))))
+ (inputs
+ `(("open-zwave" ,open-zwave)
+ ("node-nan" ,node-nan)))
+ (native-inputs
+ `(("which" ,which)
+ ("python" ,python)
+ ("pkg-config" ,pkg-config)))
+ (build-system node-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (replace 'build
+ ;; For some reason, `npm install` doesn't build
+ ;; the addon automatically, so we do it explicitly here.
+ ;; We go through `npx` so the npmrc file sets the
+ ;; configuration up properly.
+ (lambda* (#:key inputs #:allow-other-keys)
+ (define node-dir
+ (assoc-ref inputs "node"))
+ (invoke (string-append node-dir "/bin/npx")
+ "--call"
+ (string-append
+ node-dir
+ "/lib/node_modules/npm/bin/node-gyp-bin/node-gyp"
+ " "
+ "rebuild")))))))
+ (home-page "https://github.com/OpenZWave/node-openzwave-shared")
+ (synopsis "Node.js bindings for OpenZWave")
+ (description
+ "With the @code{node-openzwave-shared} package, you can easily control
+and manage your Z-Wave devices (lights, dimmers, blinds, you name it) from
+within Node.js applications. This library also supports secure
+devices (e.g. door locks) that require encryption. All widely used Node.js
+versions are supported with the help of @code{node-nan}.
+
+This library is currently able to:
+@itemize @bullet
+@item
+scan a Z-Wave network and report on connected devices;
+@item
+write values to Z-Wave nodes;
+@item
+monitor the network for changes;
+@item
+heal nodes and/or the network; and
+@item
+perform management tasks: add or remove nodes, replace failed nodes,
+manage their group associations, etc.
+@end itemize")
+ (license license:isc)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 28/45] gnu: Add node-addon-api.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (26 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 27/45] gnu: Add node-openzwave-shared Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 29/45] gnu: Add node-sqlite3 Philip McGrath
` (17 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-addon-api): New variable.
---
gnu/packages/node-xyz.scm | 63 +++++++++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 43cf9fe660..c7bc660134 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -22,6 +22,9 @@
(define-module (gnu packages node-xyz)
#:use-module ((guix licenses) #:prefix license:)
+ #:use-module (gnu packages sqlite)
+ #:use-module (gnu packages python)
+ #:use-module (guix gexp)
#:use-module (guix packages)
#:use-module (guix git-download)
#:use-module (guix build-system node))
@@ -592,3 +595,63 @@ (define-public node-nan
This project also contains some helper utilities that make addon development a
bit more pleasant.")
(license license:expat)))
+
+(define-public node-addon-api
+ (package
+ (name "node-addon-api")
+ (version "4.2.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/nodejs/node-addon-api")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "1bhvfi2m9nxfz418s619914vmidcnrzbjv6l9nid476c3zlpazch"))))
+ (inputs
+ `(("python" ,python)
+ ("node-safe-buffer" ,node-safe-buffer)))
+ (build-system node-build-system)
+ (arguments
+ `(#:absent-dependencies
+ `("benchmark"
+ "bindings"
+ "clang-format"
+ "eslint"
+ "eslint-config-semistandard"
+ "eslint-config-standard"
+ "eslint-plugin-import"
+ "eslint-plugin-node"
+ "eslint-plugin-promise"
+ "fs-extra"
+ "path"
+ "pre-commit")
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'skip-js-tests
+ ;; We can't run the js-based tests,
+ ;; but we can still do the C++ parts
+ (lambda args
+ (substitute* "package.json"
+ (("\"test\": \"node test\"")
+ "\"test\": \"echo stopping after pretest on Guix\"")))))))
+ (home-page "https://github.com/nodejs/node-addon-api")
+ (synopsis "Node.js API (Node-API) header-only C++ wrappers")
+ (description "This module contains header-only C++ wrapper classes which
+simplify the use of the C based Node-API provided by Node.js when using C++.
+It provides a C++ object model and exception handling semantics with low
+overhead.
+
+Node-API is an ABI stable C interface provided by Node.js for building native
+addons. It is intended to insulate native addons from changes in the
+underlying JavaScript engine and allow modules compiled for one version to run
+on later versions of Node.js without recompilation. The @code{node-addon-api}
+module, which is not part of Node.js, preserves the benefits of the Node-API
+as it consists only of inline code that depends only on the stable API
+provided by Node-API.
+
+It is important to remember that @emph{other} Node.js interfaces such as
+@code{libuv} (included in a project via @code{#include <uv.h>}) are not
+ABI-stable across Node.js major versions.")
+ (license license:expat)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 29/45] gnu: Add node-sqlite3.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (27 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 28/45] gnu: Add node-addon-api Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 30/45] gnu: Add node-file-uri-to-path Philip McGrath
` (16 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-sqlite3): New variable.
---
gnu/packages/node-xyz.scm | 132 ++++++++++++++++++++++++++++++++++++++
1 file changed, 132 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index c7bc660134..d1bb236186 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -655,3 +655,135 @@ (define-public node-addon-api
@code{libuv} (included in a project via @code{#include <uv.h>}) are not
ABI-stable across Node.js major versions.")
(license license:expat)))
+
+(define-public node-sqlite3
+ (package
+ (name "node-sqlite3")
+ (version "5.0.2")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/mapbox/node-sqlite3")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "0sbbzzli282nxyfha10zx0k5m8hdp0sf3ipl59khjb7wm449j86h"))
+ (snippet
+ (with-imported-modules '((guix build utils))
+ #~(begin
+ (use-modules (guix build utils))
+ ;; unbundle sqlite
+ (for-each delete-file-recursively
+ (find-files "deps"
+ (lambda (pth stat)
+ (gzip-file? pth)))))))))
+ (inputs
+ `(("node-addon-api" ,node-addon-api)
+ ("python" ,python)
+ ("sqlite" ,sqlite)))
+ (build-system node-build-system)
+ (arguments
+ `(#:tests?
+ #f ; FIXME: tests depend on node-mocha
+ #:modules
+ ((guix build node-build-system)
+ (guix build json)
+ (srfi srfi-1)
+ (ice-9 match)
+ (guix build utils))
+ #:absent-dependencies
+ `(;; Normally, this is "built" using @mapbox/node-pre-gyp,
+ ;; which publishes or downloads pre-built binaries
+ ;; or falls back to building from source.
+ ;; Here, we patch out all of that and just build directly.
+ ;; It would be better to patch a version of @mapbox/node-pre-gyp
+ ;; that always builds from source, as Debian does,
+ ;; but there are a number of dependencies that need
+ ;; to be packaged or removed.
+ "@mapbox/node-pre-gyp"
+ "node-pre-gyp" ;; deprecated name still used in some places
+ "aws-sdk"
+ "@mapbox/cloudfriend"
+ ;; Confusingly, this is only a dependency because of
+ ;; @mapbox/node-pre-gyp: with that removed,
+ ;; npm will use its own copy:
+ "node-gyp"
+ ;; These we'd like, we just don't have them yet:
+ "eslint"
+ "mocha")
+ #:phases
+ (modify-phases %standard-phases
+ (add-before 'configure 'npm-config-sqlite
+ ;; We need this step even if we do replace @mapbox/node-pre-gyp
+ ;; because the package expects to build its bundled sqlite
+ (lambda* (#:key inputs #:allow-other-keys)
+ (setenv "npm_config_sqlite" (assoc-ref inputs "sqlite"))))
+ (add-after 'install 'patch-binding-path
+ ;; We replace a file that dynamic searches for the addon using
+ ;; node-pre-gyp (which we don't have) with a version that
+ ;; simply uses the path to the addon we built directly.
+ ;; The exact path is supposed to depend on things like the
+ ;; architecture and napi_build_version, so, to avoid having
+ ;; hard-code the details accurately, we do this after the addon
+ ;; has been built so we can just find where it ended up.
+ (lambda* (#:key outputs #:allow-other-keys)
+ (with-directory-excursion
+ (string-append (assoc-ref outputs "out")
+ "/lib/node_modules/sqlite3/lib")
+ (match (find-files "binding" "\\.node$")
+ ((rel-path)
+ (with-atomic-file-replacement "sqlite3-binding.js"
+ (lambda (in out)
+ (format out "var binding = require('./~a');\n" rel-path)
+ (display "module.exports = exports = binding;\n" out))))))))
+ (add-after 'patch-dependencies 'avoid-node-pre-gyp
+ (lambda args
+ ;; We need to patch .npmignore before the 'repack phase
+ ;; so that the built addon is installed with in the package.
+ ;; (Upstream assumes node-pre-gyp will download a pre-built
+ ;; version when this package is installed.)
+ (substitute* ".npmignore"
+ (("lib/binding")
+ "#lib/binding # <- patched for Guix"))
+ ;; We need to remove the install script from "package.json",
+ ;; as it would try to use node-pre-gyp and would block the
+ ;; automatic building performed by `npm install`.
+ (with-atomic-file-replacement "package.json"
+ (lambda (in out)
+ (let* ((js (read-json in))
+ (alist (match js
+ (('@ . alist) alist)))
+ (scripts-alist (match (assoc-ref alist "scripts")
+ (('@ . alist) alist)))
+ (scripts-alist
+ ;; install script would use node-pre-gyp
+ (assoc-remove! scripts-alist "install"))
+ (alist
+ (assoc-set! alist "scripts" (cons '@ scripts-alist)))
+ (binary-alist (match (assoc-ref alist "binary")
+ (('@ . alist) alist)))
+ (js (cons '@ alist)))
+ ;; When it builds from source, node-pre-gyp supplies
+ ;; module_name and module_path based on the entries under
+ ;; "binary" from "package.json", so this package's
+ ;; "binding.gyp" doesn't define them. Thus, we also need
+ ;; to supply them. The GYP_DEFINES environment variable
+ ;; turns out to be the easiest way to make sure they are
+ ;; propagated from npm to node-gyp to gyp.
+ (setenv "GYP_DEFINES"
+ (string-append
+ "module_name="
+ (assoc-ref binary-alist "module_name")
+ " "
+ "module_path="
+ (assoc-ref binary-alist "module_path")))
+ (write-json js
+ out)))))))))
+ (home-page "https://github.com/mapbox/node-sqlite3")
+ (synopsis "Asynchronous, non-blocking SQLite3 bindings for Node.js")
+ (description
+ "The Node.js add-on @code{node-sqlite3} provides a set of a asynchronous,
+non-blocking bindings for SQLite3, written in modern C++ and tested for memory
+leaks.")
+ (license license:bsd-3)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 30/45] gnu: Add node-file-uri-to-path.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (28 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 29/45] gnu: Add node-sqlite3 Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 31/45] gnu: Add node-bindings Philip McGrath
` (15 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-file-uri-to-path): New variable.
---
gnu/packages/node-xyz.scm | 55 +++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index d1bb236186..bdfe71a1f3 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -24,6 +24,7 @@ (define-module (gnu packages node-xyz)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (gnu packages sqlite)
#:use-module (gnu packages python)
+ #:use-module (gnu packages web)
#:use-module (guix gexp)
#:use-module (guix packages)
#:use-module (guix git-download)
@@ -787,3 +788,57 @@ (define-public node-sqlite3
non-blocking bindings for SQLite3, written in modern C++ and tested for memory
leaks.")
(license license:bsd-3)))
+
+(define-public node-file-uri-to-path
+ (package
+ (name "node-file-uri-to-path")
+ (version "2.0.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/TooTallNate/file-uri-to-path")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "08l779az44czm12xdhgcrnzpqw34s59hbrlfphs7g9y2k26drqav"))))
+ (native-inputs
+ `(("esbuild" ,esbuild)))
+ (build-system node-build-system)
+ (arguments
+ `(#:absent-dependencies
+ `("@types/mocha"
+ "@types/node"
+ "@typescript-eslint/eslint-plugin"
+ "@typescript-eslint/parser"
+ "cpy-cli"
+ "eslint"
+ "eslint-config-airbnb"
+ "eslint-config-prettier"
+ "eslint-import-resolver-typescript"
+ "eslint-plugin-import"
+ "eslint-plugin-jsx-a11y"
+ "eslint-plugin-react"
+ "mocha"
+ "rimraf"
+ "typescript")
+ #:phases
+ (modify-phases %standard-phases
+ (replace 'build
+ (lambda* (#:key inputs native-inputs #:allow-other-keys)
+ (copy-recursively "src" "dist")
+ (invoke (string-append
+ (assoc-ref (or native-inputs inputs) "esbuild")
+ "/bin/esbuild")
+ "dist/index.ts"
+ "--outfile=dist/src/index.js"
+ "--format=cjs"
+ "--sourcemap"
+ "--platform=node"))))
+ #:tests? #f))
+ (home-page "https://github.com/TooTallNate/file-uri-to-path")
+ (synopsis "Convert a @code{file:} URI to a file path")
+ (description "This package provides a function to convert a @code{file:}
+URI to a file path. It accepts a @code{file:} URI and returns a file path
+suitable for use with the @code{fs} module functions.")
+ (license license:expat)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 31/45] gnu: Add node-bindings.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (29 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 30/45] gnu: Add node-file-uri-to-path Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 32/45] gnu: Add node-segfault-handler Philip McGrath
` (14 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-bindings): New variable.
---
gnu/packages/node-xyz.scm | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index bdfe71a1f3..021bc81403 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -842,3 +842,29 @@ (define-public node-file-uri-to-path
URI to a file path. It accepts a @code{file:} URI and returns a file path
suitable for use with the @code{fs} module functions.")
(license license:expat)))
+
+(define-public node-bindings
+ (package
+ (name "node-bindings")
+ (version "1.5.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/TooTallNate/node-bindings")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "100gp6kpjvd4j1dqnp0sbjr1hqx5mz7r61q9qy527jyhk9mj47wk"))))
+ (inputs
+ `(("node-file-uri-to-path" ,node-file-uri-to-path)))
+ (build-system node-build-system)
+ (arguments
+ ;; there are no tests
+ `(#:tests? #f))
+ (home-page "https://github.com/TooTallNate/node-bindings")
+ (synopsis "Help for loading your native module's @code{.node} file")
+ (description "This is a helper module for authors of Node.js native addon
+modules. It is basically the ``swiss army knife'' of @code{require()}ing your
+native module's @code{.node} file.")
+ (license license:expat)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 32/45] gnu: Add node-segfault-handler.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (30 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 31/45] gnu: Add node-bindings Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 33/45] gnu: Add node-ms Philip McGrath
` (13 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-segfault-handler): New variable.
---
gnu/packages/node-xyz.scm | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 021bc81403..b63cd46fdd 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -868,3 +868,33 @@ (define-public node-bindings
modules. It is basically the ``swiss army knife'' of @code{require()}ing your
native module's @code{.node} file.")
(license license:expat)))
+
+(define-public node-segfault-handler
+ (package
+ (name "node-segfault-handler")
+ (version "1.3.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/ddopson/node-segfault-handler")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "07nbw35wvrr18kmh8f388v4k5mpjgyy0260bx0xzjdv795i3xvfv"))))
+ (native-inputs
+ `(("python" ,python)))
+ (inputs
+ `(("node-bindings" ,node-bindings)
+ ("node-nan" ,node-nan)))
+ (build-system node-build-system)
+ (arguments
+ ;; there are no tests
+ `(#:tests? #f))
+ (home-page "https://github.com/ddopson/node-segfault-handler")
+ (synopsis "Catches @code{SIGSEGV} and prints diagnostic information")
+ (description "This package is a tool for debugging Node.js C/C++ native
+code modules and getting stack traces when things go wrong. If a
+@code{SIGSEGV} signal is raised, the module will print a native stack trace to
+both @code{STDERR} and to a timestamped file.")
+ (license license:bsd-3)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 33/45] gnu: Add node-ms.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (31 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 32/45] gnu: Add node-segfault-handler Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 34/45] gnu: Add node-debug Philip McGrath
` (12 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-ms): New variable.
---
gnu/packages/node-xyz.scm | 43 +++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index b63cd46fdd..82ac537133 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -898,3 +898,46 @@ (define-public node-segfault-handler
@code{SIGSEGV} signal is raised, the module will print a native stack trace to
both @code{STDERR} and to a timestamped file.")
(license license:bsd-3)))
+
+(define-public node-ms
+ (package
+ (name "node-ms")
+ (version "2.1.3")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/vercel/ms")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "1l74kmmwffmzdz38lli0v5mdb9p9jmsjxpb48ncknqw2n74cgf08"))))
+ (build-system node-build-system)
+ (arguments
+ `(#:absent-dependencies
+ `("eslint"
+ "expect.js"
+ "husky"
+ "lint-staged"
+ "mocha"
+ "prettier")
+ #:tests? #f))
+ (home-page "https://github.com/vercel/ms")
+ (synopsis "Tiny millisecond conversion utility")
+ (description "Use this package to easily convert various time formats to
+milliseconds.
+
+Features:
+@itemize @bullet
+@item
+Works both in Node.js and in the browser.
+@item
+If a number is supplied to @code{ms}, a string with a unit is returned.
+@item
+If a string that contains the number is supplied, it returns it as a
+number (e.g. it returns @code{100} for @code{'100'}).
+@item
+If you pass a string with a number and a valid unit, the number of
+equivalent milliseconds is returned.
+@end itemize")
+ (license license:expat)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 34/45] gnu: Add node-debug.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (32 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 33/45] gnu: Add node-ms Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 35/45] gnu: Add node-serialport-binding-abstract Philip McGrath
` (11 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-debug): New variable.
---
gnu/packages/node-xyz.scm | 42 +++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 82ac537133..782c66e160 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -941,3 +941,45 @@ (define-public node-ms
equivalent milliseconds is returned.
@end itemize")
(license license:expat)))
+
+(define-public node-debug
+ (package
+ (name "node-debug")
+ (version "4.3.3")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/debug-js/debug")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "0ji0dmdl2xkgxqxvd6xjy7k3mmknmhvqjgc40vyly9ka1mpf20vb"))))
+ (inputs
+ `(("node-ms" ,node-ms)))
+ (build-system node-build-system)
+ (arguments
+ `(#:absent-dependencies
+ `("brfs"
+ "browserify"
+ "coveralls"
+ "istanbul"
+ "karma"
+ "karma-browserify"
+ "karma-chrome-launcher"
+ "karma-mocha"
+ "mocha"
+ "mocha-lcov-reporter"
+ "xo"
+ "supports-color")
+ #:tests? #f))
+ (home-page "https://github.com/debug-js/debug")
+ (synopsis "Lightweight debugging utility for Node.js and the browser")
+ (description "A tiny JavaScript debugging utility modelled after Node.js
+core's debugging technique. orks in Node.js and web browsers.
+
+The @code{debug} module exposes a function; simply pass this function the name
+of your module, and it will return a decorated version of @code{console.error}
+for you to pass debug statements to. This will allow you to toggle the debug
+output for different parts of your module as well as the module as a whole.")
+ (license license:expat)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 35/45] gnu: Add node-serialport-binding-abstract.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (33 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 34/45] gnu: Add node-debug Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 36/45] gnu: Add node-serialport-parser-delimiter Philip McGrath
` (10 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-binding-abstract): New variable.
---
gnu/packages/node-xyz.scm | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 782c66e160..d821790ecb 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -983,3 +983,37 @@ (define-public node-debug
for you to pass debug statements to. This will allow you to toggle the debug
output for different parts of your module as well as the module as a whole.")
(license license:expat)))
+
+(define-public node-serialport-binding-abstract
+ (package
+ (name "node-serialport-binding-abstract")
+ (version "9.2.3")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/serialport/node-serialport")
+ (commit "v9.2.7")))
+ (file-name (git-file-name "serialport-monorepo" version))
+ (sha256
+ (base32 "0x7zm59a5ff5yygjyw15xs3r5m3rb8av1yfrh4snn44mrwq87yg8"))))
+ (inputs
+ `(("node-debug" ,node-debug)))
+ (build-system node-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/binding-abstract"))))
+ #:tests? #f))
+ (home-page "https://serialport.io")
+ (synopsis "Abstract base class for Node SerialPort bindings")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+This package provides the @code{AbstractBinding} class, the base for all Node
+SerialPort bindings. You wouldn't use this class directly, but instead extend
+it to make a new binding for a different platform or underling technology.")
+ (license license:expat)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 36/45] gnu: Add node-serialport-parser-delimiter.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (34 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 35/45] gnu: Add node-serialport-binding-abstract Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:00 ` [bug#51838] [PATCH v4 37/45] gnu: Add node-serialport-parser-readling Philip McGrath
` (9 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-parser-delimiter): New
variable.
---
gnu/packages/node-xyz.scm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index d821790ecb..4e69fd146f 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1017,3 +1017,25 @@ (define-public node-serialport-binding-abstract
SerialPort bindings. You wouldn't use this class directly, but instead extend
it to make a new binding for a different platform or underling technology.")
(license license:expat)))
+
+(define-public node-serialport-parser-delimiter
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-parser-delimiter")
+ (version "9.2.4")
+ (inputs `())
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/parser-delimiter"))))
+ #:tests? #f))
+ (synopsis "Node SerialPort parser to split data on a delimiter")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+Parsers are used to take raw binary data and transform them into usable
+messages. This package provides @code{Delimiter}, a parser that emits data
+each time a specified byte sequence is received.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 37/45] gnu: Add node-serialport-parser-readling.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (35 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 36/45] gnu: Add node-serialport-parser-delimiter Philip McGrath
@ 2021-12-13 6:00 ` Philip McGrath
2021-12-13 6:01 ` [bug#51838] [PATCH v4 38/45] gnu: Add node-serialport-bindings Philip McGrath
` (8 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:00 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-parser-readline): New
variable.
---
gnu/packages/node-xyz.scm | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 4e69fd146f..873e0f9a39 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1039,3 +1039,27 @@ (define-public node-serialport-parser-delimiter
Parsers are used to take raw binary data and transform them into usable
messages. This package provides @code{Delimiter}, a parser that emits data
each time a specified byte sequence is received.")))
+
+(define-public node-serialport-parser-readline
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-parser-readline")
+ (version "9.2.4")
+ (inputs
+ `(("node-serialport-parser-delimiter"
+ ,node-serialport-parser-delimiter)))
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/parser-readline"))))
+ #:tests? #f))
+ (synopsis "Node SerialPort parser to split data on newlines")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+Parsers are used to take raw binary data and transform them into usable
+messages. This package provides @code{Readline}, a parser that emits data
+after a (configurable) newline delimiter is received.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 38/45] gnu: Add node-serialport-bindings.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (36 preceding siblings ...)
2021-12-13 6:00 ` [bug#51838] [PATCH v4 37/45] gnu: Add node-serialport-parser-readling Philip McGrath
@ 2021-12-13 6:01 ` Philip McGrath
2021-12-13 6:01 ` [bug#51838] [PATCH v4 39/45] gnu: Add node-serialport-parser-regex Philip McGrath
` (7 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:01 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-bindings): New variable.
---
gnu/packages/node-xyz.scm | 56 +++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 873e0f9a39..9ee33c7402 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1063,3 +1063,59 @@ (define-public node-serialport-parser-readline
Parsers are used to take raw binary data and transform them into usable
messages. This package provides @code{Readline}, a parser that emits data
after a (configurable) newline delimiter is received.")))
+
+(define-public node-serialport-bindings
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-bindings")
+ (version "9.2.7")
+ (native-inputs
+ `(("python" ,python)))
+ (inputs
+ `(("node-nan" ,node-nan)
+ ("node-bindings" ,node-bindings)
+ ("node-serialport-binding-abstract" ,node-serialport-binding-abstract)
+ ("node-serialport-parser-readline" ,node-serialport-parser-readline)
+ ("node-debug" ,node-debug)))
+ (arguments
+ `(#:absent-dependencies
+ `("prebuild-install"
+ ;; devDependencies
+ "@serialport/binding-mock"
+ "node-abi")
+ #:modules
+ ((guix build node-build-system)
+ (guix build json)
+ (srfi srfi-1)
+ (ice-9 match)
+ (guix build utils))
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/bindings")))
+ (add-after 'chdir 'avoid-prebuild-install
+ (lambda args
+ (with-atomic-file-replacement "package.json"
+ (lambda (in out)
+ (match (read-json in)
+ (('@ . meta-alist)
+ (match (assoc-ref meta-alist "scripts")
+ (('@ . scripts-alist)
+ (write-json
+ (cons '@ (assoc-set!
+ meta-alist
+ "scripts"
+ (cons '@ (assoc-remove! scripts-alist
+ "install"))))
+ out))))))))))
+ #:tests? #f))
+ (synopsis "Abstract base class for Node SerialPort bindings")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+This package provides the @code{Binding} class, which uses a native addon to
+talk to the underlying system. You never have to use @code{Binding} objects
+directly. There is also a @code{MockBinding} available (but not yet packaged
+for Guix) to assist with testing.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 39/45] gnu: Add node-serialport-parser-regex.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (37 preceding siblings ...)
2021-12-13 6:01 ` [bug#51838] [PATCH v4 38/45] gnu: Add node-serialport-bindings Philip McGrath
@ 2021-12-13 6:01 ` Philip McGrath
2021-12-13 6:01 ` [bug#51838] [PATCH v4 40/45] gnu: Add node-serialport-parser-ready Philip McGrath
` (6 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:01 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-parser-regex): New variable.
---
gnu/packages/node-xyz.scm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 9ee33c7402..f8c6cce95c 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1119,3 +1119,25 @@ (define-public node-serialport-bindings
talk to the underlying system. You never have to use @code{Binding} objects
directly. There is also a @code{MockBinding} available (but not yet packaged
for Guix) to assist with testing.")))
+
+(define-public node-serialport-parser-regex
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-parser-regex")
+ (version "9.2.4")
+ (inputs `())
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/parser-regex"))))
+ #:tests? #f))
+ (synopsis "Node SerialPort parser to split data on a regular expression")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+Parsers are used to take raw binary data and transform them into usable
+messages. This package provides @code{Regex}, a parser that uses a regular
+expression to split the incoming text.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 40/45] gnu: Add node-serialport-parser-ready.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (38 preceding siblings ...)
2021-12-13 6:01 ` [bug#51838] [PATCH v4 39/45] gnu: Add node-serialport-parser-regex Philip McGrath
@ 2021-12-13 6:01 ` Philip McGrath
2021-12-13 6:01 ` [bug#51838] [PATCH v4 41/45] gnu: Add node-serialport-parser-inter-byte-timeout Philip McGrath
` (5 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:01 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-parser-ready): New variable.
---
gnu/packages/node-xyz.scm | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index f8c6cce95c..8cc4efeed8 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1141,3 +1141,26 @@ (define-public node-serialport-parser-regex
Parsers are used to take raw binary data and transform them into usable
messages. This package provides @code{Regex}, a parser that uses a regular
expression to split the incoming text.")))
+
+(define-public node-serialport-parser-ready
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-parser-ready")
+ (version "9.2.4")
+ (inputs `())
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/parser-ready"))))
+ #:tests? #f))
+ (synopsis "Node SerialPort parser to wait for specified byte sequence")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+Parsers are used to take raw binary data and transform them into usable
+messages. This package provides @code{Ready}, a parser that waits for a
+specified sequence of ``ready'' bytes before emitting a ready event and
+emitting data events.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 41/45] gnu: Add node-serialport-parser-inter-byte-timeout.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (39 preceding siblings ...)
2021-12-13 6:01 ` [bug#51838] [PATCH v4 40/45] gnu: Add node-serialport-parser-ready Philip McGrath
@ 2021-12-13 6:01 ` Philip McGrath
2021-12-13 6:01 ` [bug#51838] [PATCH v4 42/45] gnu: Add node-serialport-parser-cctalk Philip McGrath
` (4 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:01 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm
(node-serialport-parser-inter-byte-timeout): New variable.
---
gnu/packages/node-xyz.scm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 8cc4efeed8..3df6c37584 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1164,3 +1164,25 @@ (define-public node-serialport-parser-ready
messages. This package provides @code{Ready}, a parser that waits for a
specified sequence of ``ready'' bytes before emitting a ready event and
emitting data events.")))
+
+(define-public node-serialport-parser-inter-byte-timeout
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-parser-inter-byte-timeout")
+ (version "9.2.4")
+ (inputs `())
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/parser-inter-byte-timeout"))))
+ #:tests? #f))
+ (synopsis "Node SerialPort parser to detect pauses in data")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+Parsers are used to take raw binary data and transform them into usable
+messages. This package provides @code{InterByteTimeout}, a parser that emits
+data if there is a pause between packets for the specified amount of time.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 42/45] gnu: Add node-serialport-parser-cctalk.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (40 preceding siblings ...)
2021-12-13 6:01 ` [bug#51838] [PATCH v4 41/45] gnu: Add node-serialport-parser-inter-byte-timeout Philip McGrath
@ 2021-12-13 6:01 ` Philip McGrath
2021-12-13 6:01 ` [bug#51838] [PATCH v4 43/45] gnu: Add node-serialport-parser-byte-length Philip McGrath
` (3 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:01 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-parser-cctalk): New variable.
---
gnu/packages/node-xyz.scm | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 3df6c37584..00d5cb7665 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1186,3 +1186,26 @@ (define-public node-serialport-parser-inter-byte-timeout
Parsers are used to take raw binary data and transform them into usable
messages. This package provides @code{InterByteTimeout}, a parser that emits
data if there is a pause between packets for the specified amount of time.")))
+
+(define-public node-serialport-parser-cctalk
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-parser-cctalk")
+ (version "9.2.4")
+ (inputs `())
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/parser-cctalk"))))
+ #:tests? #f))
+ (synopsis "Node SerialPort parser for the ccTalk protocol")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+Parsers are used to take raw binary data and transform them into usable
+messages. This package provides @code{CCTalk}, which emits packets for the
+ccTalk protocol (an open standard for currency detectors) as they are
+received.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 43/45] gnu: Add node-serialport-parser-byte-length.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (41 preceding siblings ...)
2021-12-13 6:01 ` [bug#51838] [PATCH v4 42/45] gnu: Add node-serialport-parser-cctalk Philip McGrath
@ 2021-12-13 6:01 ` Philip McGrath
2021-12-13 6:01 ` [bug#51838] [PATCH v4 44/45] gnu: Add node-serialport-stream Philip McGrath
` (2 subsequent siblings)
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:01 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-parser-byte-length): New
variable.
---
gnu/packages/node-xyz.scm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 00d5cb7665..3a4d155b02 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1209,3 +1209,25 @@ (define-public node-serialport-parser-cctalk
messages. This package provides @code{CCTalk}, which emits packets for the
ccTalk protocol (an open standard for currency detectors) as they are
received.")))
+
+(define-public node-serialport-parser-byte-length
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-parser-byte-length")
+ (version "9.2.4")
+ (inputs `())
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/parser-byte-length"))))
+ #:tests? #f))
+ (synopsis "Node SerialPort parser for fixed-length buffers")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+Parsers are used to take raw binary data and transform them into usable
+messages. This package provides @code{ByteLength}, a parser that emits data
+as a buffer every time a specified number of bytes are received.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 44/45] gnu: Add node-serialport-stream.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (42 preceding siblings ...)
2021-12-13 6:01 ` [bug#51838] [PATCH v4 43/45] gnu: Add node-serialport-parser-byte-length Philip McGrath
@ 2021-12-13 6:01 ` Philip McGrath
2021-12-13 6:01 ` [bug#51838] [PATCH v4 45/45] gnu: Add node-serialport Philip McGrath
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:01 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-stream): New variable.
---
gnu/packages/node-xyz.scm | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 3a4d155b02..271082ce5b 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1231,3 +1231,30 @@ (define-public node-serialport-parser-byte-length
Parsers are used to take raw binary data and transform them into usable
messages. This package provides @code{ByteLength}, a parser that emits data
as a buffer every time a specified number of bytes are received.")))
+
+(define-public node-serialport-stream
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-stream")
+ (version "9.2.4")
+ (inputs
+ `(("node-debug" ,node-debug)))
+ (arguments
+ `(#:absent-dependencies
+ `(;; devDependencies
+ "@serialport/binding-mock")
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/stream"))))
+ #:tests? #f))
+ (synopsis "Node.js stream interface for Node SerialPort")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+This package provides an interface for using Node SerialPort bindings via the
+Node.js Stream API. The stream is a duplex stream, allowing for reading and
+writing. It has additional methods for managing the SerialPort
+connection.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v4 45/45] gnu: Add node-serialport.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (43 preceding siblings ...)
2021-12-13 6:01 ` [bug#51838] [PATCH v4 44/45] gnu: Add node-serialport-stream Philip McGrath
@ 2021-12-13 6:01 ` Philip McGrath
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
45 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-13 6:01 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport): New variable.
---
gnu/packages/node-xyz.scm | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 271082ce5b..92e16f2dc6 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1258,3 +1258,36 @@ (define-public node-serialport-stream
Node.js Stream API. The stream is a duplex stream, allowing for reading and
writing. It has additional methods for managing the SerialPort
connection.")))
+
+(define-public node-serialport
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport")
+ (version "9.2.7")
+ (inputs
+ `(("node-serialport-bindings" ,node-serialport-bindings)
+ ("node-serialport-parser-delimiter" ,node-serialport-parser-delimiter)
+ ("node-serialport-parser-readline" ,node-serialport-parser-readline)
+ ("node-serialport-parser-regex" ,node-serialport-parser-regex)
+ ("node-serialport-parser-ready" ,node-serialport-parser-ready)
+ ("node-serialport-parser-inter-byte-timeout"
+ ,node-serialport-parser-inter-byte-timeout)
+ ("node-serialport-parser-cctalk" ,node-serialport-parser-cctalk)
+ ("node-serialport-parser-byte-length"
+ ,node-serialport-parser-byte-length)
+ ("node-serialport-stream" ,node-serialport-stream)
+ ("node-debug" ,node-debug)))
+ (arguments
+ `(#:absent-dependencies
+ `("@serialport/binding-mock")
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/serialport"))))
+ #:tests? #f))
+ (synopsis "Node.js package to access serial ports")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. This package is the recommended entry point for most
+projects. It combines a high-level Node.js stream interface with a useful
+default set of parsers and bindings.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp.
2021-12-13 6:00 ` [bug#51838] [PATCH v4 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (44 preceding siblings ...)
2021-12-13 6:01 ` [bug#51838] [PATCH v4 45/45] gnu: Add node-serialport Philip McGrath
@ 2021-12-17 2:02 ` Philip McGrath
2021-12-17 2:02 ` [bug#51838] [PATCH v5 01/45] gnu: node: Avoid duplicating build phases Philip McGrath
` (44 more replies)
45 siblings, 45 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:02 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
Since core-updates-frozen was merged, I've rebased on the latest master and
adjusted these packages to use "new-style" inputs. So, here is v5 (also at
at <https://gitlab.com/philip1/guix-patches/-/tags/guix-issue-51838-v5>).
-Philip
Philip McGrath (45):
gnu: node: Avoid duplicating build phases.
gnu: node: Update to 10.24.1 for bootstrapping.
gnu: node: Patch shebangs in node_modules.
gnu: node: Add an npmrc file to set nodedir.
guix: node-build-system: Add delete-lockfiles phase.
guix: node-build-system: Refactor patch-dependencies phase.
guix: node-build-system: Add #:absent-dependencies argument.
gnu: node-semver-bootstrap: Use #:absent-dependencies.
gnu: node-ms-bootstrap: Use #:absent-dependencies.
gnu: node-binary-search-bootstrap: Use #:absent-dependencies.
gnu: node-debug-bootstrap: Use #:absent-dependencies.
gnu: node-llparse-builder-bootstrap: Use #:absent-dependencies.
gnu: node-llparse-frontend-bootstrap: Use #:absent-dependencies.
gnu: node-llparse-bootstrap: Use #:absent-dependencies.
gnu: node-semver: Use #:absent-dependencies.
gnu: node-wrappy: Use #:absent-dependencies.
gnu: node-once: Use #:absent-dependencies.
gnu: node-irc-colors: Use #:absent-dependencies.
gnu: node-irc: Use #:absent-dependencies.
guix: node-build-system: Add implicit libuv input.
guix: node-build-system: Add avoid-node-gyp-rebuild phase.
gnu: Add node-inherits.
gnu: Add node-safe-buffer.
gnu: Add node-string-decoder.
gnu: Add node-readable-stream.
gnu: Add node-nan.
gnu: Add node-openzwave-shared.
gnu: Add node-addon-api.
gnu: Add node-sqlite3.
gnu: Add node-file-uri-to-path.
gnu: Add node-bindings.
gnu: Add node-segfault-handler.
gnu: Add node-ms.
gnu: Add node-debug.
gnu: Add node-serialport-binding-abstract.
gnu: Add node-serialport-parser-delimiter.
gnu: Add node-serialport-parser-readline.
gnu: Add node-serialport-bindings.
gnu: Add node-serialport-parser-regex.
gnu: Add node-serialport-parser-ready.
gnu: Add node-serialport-parser-inter-byte-timeout.
gnu: Add node-serialport-parser-cctalk.
gnu: Add node-serialport-parser-byte-length.
gnu: Add node-serialport-stream.
gnu: Add node-serialport.
gnu/packages/node-xyz.scm | 919 ++++++++++++++++++++++++++++++-
gnu/packages/node.scm | 232 ++++----
gnu/packages/zwave.scm | 66 +++
guix/build-system/node.scm | 28 +-
guix/build/node-build-system.scm | 129 ++++-
5 files changed, 1220 insertions(+), 154 deletions(-)
--
2.32.0
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 01/45] gnu: node: Avoid duplicating build phases.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
@ 2021-12-17 2:02 ` Philip McGrath
2021-12-17 2:02 ` [bug#51838] [PATCH v5 02/45] gnu: node: Update to 10.24.1 for bootstrapping Philip McGrath
` (43 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:02 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node.scm (node)[arguments]: Split 'patch-files phase
into 'patch-hardcoded-program-references and
'delete-problematic-tests. Adapt 'patch-hardcoded-program-references
and 'configure to work unmodified on node-lts, but don't try to
share 'delete-problematic-tests, because those details seem to change
too much between node versions.
(node, node-lts)[inputs]: Use bash-minimal rather than bash.
(node-lts)[arguments]: Inherit 'patch-hardcoded-program-references,
and 'configure phases from the bootstrap node.
Remove the 'patch-files phase, keeping its remaining
non-inherited work in a new 'replace-llhttp-sources phase.
---
gnu/packages/node.scm | 107 ++++++++++++++----------------------------
1 file changed, 35 insertions(+), 72 deletions(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 6b543acf6f..1635df5b1a 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -10,6 +10,7 @@
;;; Copyright © 2020 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
;;; Copyright © 2021 Guillaume Le Vaillant <glv@posteo.net>
+;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -106,14 +107,22 @@ (define-public node
#:test-target "test-ci-js"
#:phases
(modify-phases %standard-phases
- (add-before 'configure 'patch-files
+ (add-before 'configure 'patch-hardcoded-program-references
(lambda* (#:key inputs #:allow-other-keys)
+
;; Fix hardcoded /bin/sh references.
- (substitute* '("lib/child_process.js"
- "lib/internal/v8_prof_polyfill.js"
- "test/parallel/test-child-process-spawnsync-shell.js"
- "test/parallel/test-stdio-closed.js"
- "test/sequential/test-child-process-emfile.js")
+ (substitute*
+ (let ((common
+ '("lib/child_process.js"
+ "lib/internal/v8_prof_polyfill.js"
+ "test/parallel/test-child-process-spawnsync-shell.js"
+ "test/parallel/test-stdio-closed.js"
+ "test/sequential/test-child-process-emfile.js"))
+ ;; not in bootstap node:
+ (sigxfsz "test/parallel/test-fs-write-sigxfsz.js"))
+ (if (file-exists? sigxfsz)
+ (cons sigxfsz common)
+ common))
(("'/bin/sh'")
(string-append "'" (assoc-ref inputs "bash") "/bin/sh'")))
@@ -123,7 +132,10 @@ (define-public node
"test/parallel/test-child-process-exec-env.js")
(("'/usr/bin/env'")
(string-append "'" (assoc-ref inputs "coreutils")
- "/bin/env'")))
+ "/bin/env'")))))
+ (add-after 'patch-hardcoded-program-references
+ 'delete-problematic-tests
+ (lambda* (#:key inputs #:allow-other-keys)
;; FIXME: These tests fail in the build container, but they don't
;; seem to be indicative of real problems in practice.
@@ -218,9 +230,16 @@ (define-public node
(setenv "CXX" ,(cxx-for-target))
(setenv "PKG_CONFIG" ,(pkg-config-for-target))
(apply invoke
- (search-input-file (or native-inputs inputs)
- "/bin/python")
- "configure" flags))))
+ (let ((inpts (or native-inputs inputs)))
+ (with-exception-handler
+ (lambda (e)
+ (if (search-error? e)
+ (search-input-file inpts "/bin/python3")
+ (raise-exception e)))
+ (lambda ()
+ (search-input-file inpts "/bin/python"))))
+ "configure"
+ flags))))
(add-after 'patch-shebangs 'patch-npm-shebang
(lambda* (#:key outputs #:allow-other-keys)
(let* ((bindir (string-append (assoc-ref outputs "out")
@@ -256,7 +275,7 @@ (define-public node
(variable "NODE_PATH")
(files '("lib/node_modules")))))
(inputs
- (list bash
+ (list bash-minimal
coreutils
c-ares
http-parser
@@ -705,65 +724,8 @@ (define-public node-lts
libuv "/lib:"
zlib "/lib"
"'],"))))))
- (replace 'configure
- ;; Node's configure script is actually a python script, so we can't
- ;; run it with bash.
- (lambda* (#:key outputs (configure-flags '()) native-inputs inputs
- #:allow-other-keys)
- (let* ((prefix (assoc-ref outputs "out"))
- (xflags ,(if (%current-target-system)
- `'("--cross-compiling"
- ,(string-append
- "--dest-cpu="
- (match (%current-target-system)
- ((? (cut string-prefix? "arm" <>))
- "arm")
- ((? (cut string-prefix? "aarch64" <>))
- "arm64")
- ((? (cut string-prefix? "i686" <>))
- "ia32")
- ((? (cut string-prefix? "x86_64" <>))
- "x64")
- ((? (cut string-prefix? "powerpc64" <>))
- "ppc64")
- (_ "unsupported"))))
- ''()))
- (flags (cons
- (string-append "--prefix=" prefix)
- (append xflags configure-flags))))
- (format #t "build directory: ~s~%" (getcwd))
- (format #t "configure flags: ~s~%" flags)
- ;; Node's configure script expects the CC environment variable to
- ;; be set.
- (setenv "CC_host" "gcc")
- (setenv "CXX_host" "g++")
- (setenv "CC" ,(cc-for-target))
- (setenv "CXX" ,(cxx-for-target))
- (setenv "PKG_CONFIG" ,(pkg-config-for-target))
- (apply invoke
- (search-input-file (or native-inputs inputs)
- "/bin/python3")
- "configure" flags))))
- (replace 'patch-files
+ (replace 'delete-problematic-tests
(lambda* (#:key inputs #:allow-other-keys)
- ;; Fix hardcoded /bin/sh references.
- (substitute* '("lib/child_process.js"
- "lib/internal/v8_prof_polyfill.js"
- "test/parallel/test-child-process-spawnsync-shell.js"
- "test/parallel/test-fs-write-sigxfsz.js"
- "test/parallel/test-stdio-closed.js"
- "test/sequential/test-child-process-emfile.js")
- (("'/bin/sh'")
- (string-append "'" (assoc-ref inputs "bash") "/bin/sh'")))
-
- ;; Fix hardcoded /usr/bin/env references.
- (substitute* '("test/parallel/test-child-process-default-options.js"
- "test/parallel/test-child-process-env.js"
- "test/parallel/test-child-process-exec-env.js")
- (("'/usr/bin/env'")
- (string-append "'" (assoc-ref inputs "coreutils")
- "/bin/env'")))
-
;; FIXME: These tests fail in the build container, but they don't
;; seem to be indicative of real problems in practice.
(for-each delete-file
@@ -802,8 +764,9 @@ (define-public node-lts
;; TODO: Regenerate certs instead.
(for-each delete-file
'("test/parallel/test-tls-passphrase.js"
- "test/parallel/test-tls-server-verify.js"))
-
+ "test/parallel/test-tls-server-verify.js"))))
+ (add-after 'delete-problematic-tests 'replace-llhttp-sources
+ (lambda* (#:key inputs #:allow-other-keys)
;; Replace pre-generated llhttp sources
(let ((llhttp (assoc-ref inputs "llhttp")))
(copy-file (string-append llhttp "/src/llhttp.c")
@@ -830,7 +793,7 @@ (define-public node-lts
python
util-linux))
(inputs
- (list bash
+ (list bash-minimal
coreutils
c-ares-for-node
icu4c-67
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 02/45] gnu: node: Update to 10.24.1 for bootstrapping.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
2021-12-17 2:02 ` [bug#51838] [PATCH v5 01/45] gnu: node: Avoid duplicating build phases Philip McGrath
@ 2021-12-17 2:02 ` Philip McGrath
2021-12-17 2:02 ` [bug#51838] [PATCH v5 03/45] gnu: node: Patch shebangs in node_modules Philip McGrath
` (42 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:02 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node.scm (node): Update to 10.24.1.
---
gnu/packages/node.scm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 1635df5b1a..d433118213 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -58,14 +58,14 @@ (define-module (gnu packages node)
(define-public node
(package
(name "node")
- (version "10.24.0")
+ (version "10.24.1")
(source (origin
(method url-fetch)
(uri (string-append "https://nodejs.org/dist/v" version
"/node-v" version ".tar.xz"))
(sha256
(base32
- "1k1srdis23782hnd1ymgczs78x9gqhv77v0am7yb54gqcspp70hm"))
+ "032801kg24j04xmf09m0vxzlcz86sv21s24lv9l4cfv08k1c4byp"))
(modules '((guix build utils)))
(snippet
`(begin
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 03/45] gnu: node: Patch shebangs in node_modules.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
2021-12-17 2:02 ` [bug#51838] [PATCH v5 01/45] gnu: node: Avoid duplicating build phases Philip McGrath
2021-12-17 2:02 ` [bug#51838] [PATCH v5 02/45] gnu: node: Update to 10.24.1 for bootstrapping Philip McGrath
@ 2021-12-17 2:02 ` Philip McGrath
2021-12-17 2:02 ` [bug#51838] [PATCH v5 04/45] gnu: node: Add an npmrc file to set nodedir Philip McGrath
` (41 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:02 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node.scm (node)[arguments]: Replace 'patch-npm-shebang
and 'patch-node-shebang with a new 'patch-nested-shebangs that also
handles node-gyp and other shebangs under "/lib/node_modules".
[inputs]: Add Python for node-gyp as "python-for-target".
(node-lts)[inputs]: Likewise.
(libnode)[arguments]: Adjust to delete 'patch-nested-shebangs rather
than 'patch-npm-shebang and 'patch-node-shebang.
---
gnu/packages/node.scm | 42 +++++++++++++++++++++++++-----------------
1 file changed, 25 insertions(+), 17 deletions(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index d433118213..3bd98c715e 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -105,6 +105,11 @@ (define-public node
;; Run only the CI tests. The default test target requires additional
;; add-ons from NPM that are not distributed with the source.
#:test-target "test-ci-js"
+ #:modules
+ ((guix build gnu-build-system)
+ (guix build utils)
+ (srfi srfi-1)
+ (ice-9 match))
#:phases
(modify-phases %standard-phases
(add-before 'configure 'patch-hardcoded-program-references
@@ -240,21 +245,23 @@ (define-public node
(search-input-file inpts "/bin/python"))))
"configure"
flags))))
- (add-after 'patch-shebangs 'patch-npm-shebang
- (lambda* (#:key outputs #:allow-other-keys)
- (let* ((bindir (string-append (assoc-ref outputs "out")
- "/bin"))
- (npm (string-append bindir "/npm"))
- (target (readlink npm)))
- (with-directory-excursion bindir
- (patch-shebang target (list bindir))))))
- (add-after 'install 'patch-node-shebang
- (lambda* (#:key outputs #:allow-other-keys)
- (let* ((bindir (string-append (assoc-ref outputs "out")
- "/bin"))
- (npx (readlink (string-append bindir "/npx"))))
- (with-directory-excursion bindir
- (patch-shebang npx (list bindir)))))))))
+ (add-after 'patch-shebangs 'patch-nested-shebangs
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ ;; Based on the implementation of patch-shebangs
+ ;; from (guix build gnu-build-system).
+ (let ((path (append-map (match-lambda
+ ((_ . dir)
+ (list (string-append dir "/bin")
+ (string-append dir "/sbin")
+ (string-append dir "/libexec"))))
+ (append outputs inputs))))
+ (for-each
+ (lambda (file)
+ (patch-shebang file path))
+ (find-files (search-input-directory outputs "lib/node_modules")
+ (lambda (file stat)
+ (executable-file? file))
+ #:stat lstat))))))))
(native-inputs
`(;; Runtime dependencies for binaries used as a bootstrap.
("c-ares" ,c-ares)
@@ -283,6 +290,7 @@ (define-public node
libuv
`(,nghttp2 "lib")
openssl
+ python-wrapper ;; for node-gyp (supports python3)
zlib))
(synopsis "Evented I/O for V8 JavaScript")
(description "Node.js is a platform built on Chrome's JavaScript runtime
@@ -802,6 +810,7 @@ (define-public node-lts
brotli
`(,nghttp2 "lib")
openssl
+ python-wrapper ;; for node-gyp (supports python3)
zlib))))
(define-public libnode
@@ -813,5 +822,4 @@ (define-public libnode
`(cons* "--shared" "--without-npm" ,flags))
((#:phases phases '%standard-phases)
`(modify-phases ,phases
- (delete 'patch-npm-shebang)
- (delete 'patch-node-shebang)))))))
+ (delete 'patch-nested-shebangs)))))))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 04/45] gnu: node: Add an npmrc file to set nodedir.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (2 preceding siblings ...)
2021-12-17 2:02 ` [bug#51838] [PATCH v5 03/45] gnu: node: Patch shebangs in node_modules Philip McGrath
@ 2021-12-17 2:02 ` Philip McGrath
2021-12-17 2:02 ` [bug#51838] [PATCH v5 05/45] guix: node-build-system: Add delete-lockfiles phase Philip McGrath
` (40 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:02 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node.scm (node, node-lts)[arguments]: Add a phase
'install-npmrc to create a "built-in" npmrc file that configures
"nodedir" to point to the output store path.
(libnode)[arguments]: Delete the 'install-npmrc phase.
---
gnu/packages/node.scm | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 3bd98c715e..51a393caab 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -261,7 +261,24 @@ (define-public node
(find-files (search-input-directory outputs "lib/node_modules")
(lambda (file stat)
(executable-file? file))
- #:stat lstat))))))))
+ #:stat lstat)))))
+ (add-after 'install 'install-npmrc
+ ;; Note: programs like node-gyp only receive these values if
+ ;; they are started via `npm` or `npx`.
+ ;; See: https://github.com/nodejs/node-gyp#npm-configuration
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out")))
+ (with-output-to-file
+ ;; Use the config file "primarily for distribution
+ ;; maintainers" rather than "{prefix}/etc/npmrc",
+ ;; especially because node-build-system uses --prefix
+ ;; to install things to their store paths:
+ (string-append out "/lib/node_modules/npm/npmrc")
+ (lambda ()
+ ;; Tell npm (mostly node-gyp) where to find our
+ ;; installed headers so it doesn't try to
+ ;; download them from the internet:
+ (format #t "nodedir=~a\n" out)))))))))
(native-inputs
`(;; Runtime dependencies for binaries used as a bootstrap.
("c-ares" ,c-ares)
@@ -822,4 +839,5 @@ (define-public libnode
`(cons* "--shared" "--without-npm" ,flags))
((#:phases phases '%standard-phases)
`(modify-phases ,phases
+ (delete 'install-npmrc)
(delete 'patch-nested-shebangs)))))))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 05/45] guix: node-build-system: Add delete-lockfiles phase.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (3 preceding siblings ...)
2021-12-17 2:02 ` [bug#51838] [PATCH v5 04/45] gnu: node: Add an npmrc file to set nodedir Philip McGrath
@ 2021-12-17 2:02 ` Philip McGrath
2021-12-17 2:02 ` [bug#51838] [PATCH v5 06/45] guix: node-build-system: Refactor patch-dependencies phase Philip McGrath
` (39 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:02 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* guix/build/node-build-system.scm (delete-lockfiles): New function.
Remove 'package-lock.json', 'yarn.lock', and 'npm-shrinkwrap.json',
if they exist. Because these files specify both exact dependency
versions and integrity hashes, they only cause problems for Guix.
(%standard-phases): Add 'delete-lockfiles' after 'patch-dependencies'.
---
guix/build/node-build-system.scm | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index 70a367618e..dcaa719f40 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -96,6 +96,17 @@ (define (resolve-dependencies package-meta meta-key)
(write-json package-meta out))))
#t)
+(define* (delete-lockfiles #:key inputs #:allow-other-keys)
+ "Delete 'package-lock.json', 'yarn.lock', and 'npm-shrinkwrap.json', if they
+exist."
+ (for-each (lambda (pth)
+ (when (file-exists? pth)
+ (delete-file pth)))
+ '("package-lock.json"
+ "yarn.lock"
+ "npm-shrinkwrap.json"))
+ #t)
+
(define* (configure #:key outputs inputs #:allow-other-keys)
(let ((npm (string-append (assoc-ref inputs "node") "/bin/npm")))
(invoke npm "--offline" "--ignore-scripts" "install")
@@ -146,6 +157,7 @@ (define %standard-phases
(modify-phases gnu:%standard-phases
(add-after 'unpack 'set-home set-home)
(add-before 'configure 'patch-dependencies patch-dependencies)
+ (add-after 'patch-dependencies 'delete-lockfiles delete-lockfiles)
(replace 'configure configure)
(replace 'build build)
(replace 'check check)
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 06/45] guix: node-build-system: Refactor patch-dependencies phase.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (4 preceding siblings ...)
2021-12-17 2:02 ` [bug#51838] [PATCH v5 05/45] guix: node-build-system: Add delete-lockfiles phase Philip McGrath
@ 2021-12-17 2:02 ` Philip McGrath
2021-12-17 4:29 ` Liliana Marie Prikler
2021-12-17 2:02 ` [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument Philip McGrath
` (38 subsequent siblings)
44 siblings, 1 reply; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:02 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* guix/build/node-build-system.scm (patch-dependencies): Strictly
follow the linearity rules for `assoc-set!` and friends.
Clarify the types of the arguments to and return value from the
internal helper function `resolve-dependencies`.
---
guix/build/node-build-system.scm | 53 ++++++++++++++++++++++----------
1 file changed, 36 insertions(+), 17 deletions(-)
diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index dcaa719f40..b74e593838 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -73,26 +73,45 @@ (define* (patch-dependencies #:key inputs #:allow-other-keys)
(define index (index-modules (map cdr inputs)))
- (define (resolve-dependencies package-meta meta-key)
- (fold (lambda (key+value acc)
- (match key+value
- ('@ acc)
- ((key . value) (acons key (hash-ref index key value) acc))))
- '()
- (or (assoc-ref package-meta meta-key) '())))
+ (define (resolve-dependencies meta-alist meta-key)
+ ;; Given:
+ ;; - The alist from "package.json", with the '@ unwrapped
+ ;; - A string key, like "dependencies"
+ ;; Returns: an alist (without a wrapping '@) like the entry in
+ ;; meta-alist for meta-key, but with dependencies supplied
+ ;; by Guix packages mapped to the absolute store paths to use.
+ (match (assoc-ref meta-alist meta-key)
+ (#f
+ '())
+ (('@ . orig-deps)
+ (fold (match-lambda*
+ (((key . value) acc)
+ (acons key (hash-ref index key value) acc)))
+ '()
+ orig-deps))))
(with-atomic-file-replacement "package.json"
(lambda (in out)
- (let ((package-meta (read-json in)))
- (assoc-set! package-meta "dependencies"
- (append
- '(@)
- (resolve-dependencies package-meta "dependencies")
- (resolve-dependencies package-meta "peerDependencies")))
- (assoc-set! package-meta "devDependencies"
- (append
- '(@)
- (resolve-dependencies package-meta "devDependencies")))
+ ;; It is unsafe to rely on 'assoc-set!' to update an
+ ;; existing assosciation list variable:
+ ;; see 'info "(guile)Adding or Setting Alist Entries"'.
+ (let* ((package-meta (read-json in))
+ (alist (match package-meta
+ ((@ . alist) alist)))
+ (alist
+ (assoc-set!
+ alist "dependencies"
+ (append
+ '(@)
+ (resolve-dependencies alist "dependencies")
+ (resolve-dependencies alist "peerDependencies"))))
+ (alist
+ (assoc-set!
+ alist "devDependencies"
+ (append
+ '(@)
+ (resolve-dependencies alist "devDependencies"))))
+ (package-meta (cons '@ alist)))
(write-json package-meta out))))
#t)
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 06/45] guix: node-build-system: Refactor patch-dependencies phase.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 06/45] guix: node-build-system: Refactor patch-dependencies phase Philip McGrath
@ 2021-12-17 4:29 ` Liliana Marie Prikler
2021-12-18 17:03 ` Philip McGrath
0 siblings, 1 reply; 458+ messages in thread
From: Liliana Marie Prikler @ 2021-12-17 4:29 UTC (permalink / raw)
To: Philip McGrath, 51838; +Cc: Timothy Sample, Pierre Langlois, Jelle Licht
Hi,
Am Donnerstag, dem 16.12.2021 um 21:02 -0500 schrieb Philip McGrath:
> * guix/build/node-build-system.scm (patch-dependencies): Strictly
> follow the linearity rules for `assoc-set!` and friends.
> Clarify the types of the arguments to and return value from the
> internal helper function `resolve-dependencies`.
> [...]
> - (define (resolve-dependencies package-meta meta-key)
> - (fold (lambda (key+value acc)
> - (match key+value
> - ('@ acc)
> - ((key . value) (acons key (hash-ref index key value)
> acc))))
> - '()
> - (or (assoc-ref package-meta meta-key) '())))
> + (define (resolve-dependencies meta-alist meta-key)
> + ;; Given:
> + ;; - The alist from "package.json", with the '@ unwrapped
> + ;; - A string key, like "dependencies"
> + ;; Returns: an alist (without a wrapping '@) like the entry in
> + ;; meta-alist for meta-key, but with dependencies supplied
> + ;; by Guix packages mapped to the absolute store paths to use.
> + (match (assoc-ref meta-alist meta-key)
> + (#f
> + '())
> + (('@ . orig-deps)
> + (fold (match-lambda*
> + (((key . value) acc)
> + (acons key (hash-ref index key value) acc)))
> + '()
> + orig-deps))))
>
> (with-atomic-file-replacement "package.json"
> (lambda (in out)
> - (let ((package-meta (read-json in)))
> - (assoc-set! package-meta "dependencies"
> - (append
> - '(@)
> - (resolve-dependencies package-meta
> "dependencies")
> - (resolve-dependencies package-meta
> "peerDependencies")))
> - (assoc-set! package-meta "devDependencies"
> - (append
> - '(@)
> - (resolve-dependencies package-meta
> "devDependencies")))
> + ;; It is unsafe to rely on 'assoc-set!' to update an
> + ;; existing assosciation list variable:
> + ;; see 'info "(guile)Adding or Setting Alist Entries"'.
> + (let* ((package-meta (read-json in))
> + (alist (match package-meta
> + ((@ . alist) alist)))
> + (alist
> + (assoc-set!
> + alist "dependencies"
> + (append
> + '(@)
> + (resolve-dependencies alist "dependencies")
> + (resolve-dependencies alist "peerDependencies"))))
> + (alist
> + (assoc-set!
> + alist "devDependencies"
> + (append
> + '(@)
> + (resolve-dependencies alist "devDependencies"))))
> + (package-meta (cons '@ alist)))
> (write-json package-meta out))))
> #t)
The Guix codebase is generally not the place to play around with
destructive semantics. If you can avoid assoc-set!, I think you ought
to, especially if it helps making a two-step process into a single-step
one. Anything I'm missing here?
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 06/45] guix: node-build-system: Refactor patch-dependencies phase.
2021-12-17 4:29 ` Liliana Marie Prikler
@ 2021-12-18 17:03 ` Philip McGrath
2021-12-18 17:52 ` Liliana Marie Prikler
0 siblings, 1 reply; 458+ messages in thread
From: Philip McGrath @ 2021-12-18 17:03 UTC (permalink / raw)
To: Liliana Marie Prikler, 51838; +Cc: Timothy Sample, Pierre Langlois, Jelle Licht
Hi,
On 12/16/21 23:29, Liliana Marie Prikler wrote:
> Hi,
>
> Am Donnerstag, dem 16.12.2021 um 21:02 -0500 schrieb Philip McGrath:
>> * guix/build/node-build-system.scm (patch-dependencies): Strictly
>> follow the linearity rules for `assoc-set!` and friends.
>> Clarify the types of the arguments to and return value from the
>> internal helper function `resolve-dependencies`.
>> [...]
>> - (define (resolve-dependencies package-meta meta-key)
>> - (fold (lambda (key+value acc)
>> - (match key+value
>> - ('@ acc)
>> - ((key . value) (acons key (hash-ref index key value)
>> acc))))
>> - '()
>> - (or (assoc-ref package-meta meta-key) '())))
>> + (define (resolve-dependencies meta-alist meta-key)
>> + ;; Given:
>> + ;; - The alist from "package.json", with the '@ unwrapped
>> + ;; - A string key, like "dependencies"
>> + ;; Returns: an alist (without a wrapping '@) like the entry in
>> + ;; meta-alist for meta-key, but with dependencies supplied
>> + ;; by Guix packages mapped to the absolute store paths to use.
>> + (match (assoc-ref meta-alist meta-key)
>> + (#f
>> + '())
>> + (('@ . orig-deps)
>> + (fold (match-lambda*
>> + (((key . value) acc)
>> + (acons key (hash-ref index key value) acc)))
>> + '()
>> + orig-deps))))
>>
>> (with-atomic-file-replacement "package.json"
>> (lambda (in out)
>> - (let ((package-meta (read-json in)))
>> - (assoc-set! package-meta "dependencies"
>> - (append
>> - '(@)
>> - (resolve-dependencies package-meta
>> "dependencies")
>> - (resolve-dependencies package-meta
>> "peerDependencies")))
>> - (assoc-set! package-meta "devDependencies"
>> - (append
>> - '(@)
>> - (resolve-dependencies package-meta
>> "devDependencies")))
>> + ;; It is unsafe to rely on 'assoc-set!' to update an
>> + ;; existing assosciation list variable:
>> + ;; see 'info "(guile)Adding or Setting Alist Entries"'.
>> + (let* ((package-meta (read-json in))
>> + (alist (match package-meta
>> + ((@ . alist) alist)))
>> + (alist
>> + (assoc-set!
>> + alist "dependencies"
>> + (append
>> + '(@)
>> + (resolve-dependencies alist "dependencies")
>> + (resolve-dependencies alist "peerDependencies"))))
>> + (alist
>> + (assoc-set!
>> + alist "devDependencies"
>> + (append
>> + '(@)
>> + (resolve-dependencies alist "devDependencies"))))
>> + (package-meta (cons '@ alist)))
>> (write-json package-meta out))))
>> #t)
> The Guix codebase is generally not the place to play around with
> destructive semantics. If you can avoid assoc-set!, I think you ought
> to, especially if it helps making a two-step process into a single-step
> one. Anything I'm missing here?
I agree that assoc-set! is best avoided. (I am a Racketeer: we don't
mutate pairs.) However, this code was already using assoc-set!: the
change in this patch is merely to use it correctly.
AFAIK neither `info "(guile)Association Lists"` nor SRFI-1 (`info
"(guile)SRFI-1 Association Lists"`) provide a non-destructive assoc-set
operation. Note in particular that acons and alist-cons do not work,
since they don't remove existing entries for the same key: they would
result in duplicate keys being written to the JSON object. (In theory,
this has undefined semantics; in practice, I believe Node.js would use
the wrong entry.)
Of course, I know how to write a little library of purely functional
association list operations---but that seems vastly out of scope for
this patch series (which has already grown quite large). Furthermore, if
we were going to make such changes, I think it might be better to change
the representation of JSON objects to use a real immutable dictionary
type, probably VHash (though it looks like those would still need
missing functions, at which point a wrapper type that validated keys and
maintained a consistent hash-proc might be even better). Alternatively
we could use guile-json, which at least avoids the need for improper
alists to disambiguate objects from arrays, but we would have to address
the issues in Guix commit a4bb18921099b2ec8c1699e08a73ca0fa78d0486.
All of that reinforces my sense that we should not try to change this here.
-Philip
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 06/45] guix: node-build-system: Refactor patch-dependencies phase.
2021-12-18 17:03 ` Philip McGrath
@ 2021-12-18 17:52 ` Liliana Marie Prikler
2021-12-18 18:59 ` Timothy Sample
2021-12-20 18:03 ` Philip McGrath
0 siblings, 2 replies; 458+ messages in thread
From: Liliana Marie Prikler @ 2021-12-18 17:52 UTC (permalink / raw)
To: Philip McGrath, 51838; +Cc: Timothy Sample, Pierre Langlois, Jelle Licht
Hi,
Am Samstag, dem 18.12.2021 um 12:03 -0500 schrieb Philip McGrath:
> [...]
>
> > The Guix codebase is generally not the place to play around with
> > destructive semantics. If you can avoid assoc-set!, I think you
> > ought to, especially if it helps making a two-step process into a
> > single-step one. Anything I'm missing here?
>
> I agree that assoc-set! is best avoided. (I am a Racketeer: we don't
> mutate pairs.) However, this code was already using assoc-set!: the
> change in this patch is merely to use it correctly.
>
> AFAIK neither `info "(guile)Association Lists"` nor SRFI-1 (`info
> "(guile)SRFI-1 Association Lists"`) provide a non-destructive assoc-
> set operation. Note in particular that acons and alist-cons do not
> work, since they don't remove existing entries for the same key: they
> would result in duplicate keys being written to the JSON object. (In
> theory this has undefined semantics; in practice, I believe Node.js
> would use the wrong entry.)
>
> Of course, I know how to write a little library of purely functional
> association list operations---but that seems vastly out of scope for
> this patch series (which has already grown quite large). Furthermore,
> if we were going to make such changes, I think it might be better to
> change the representation of JSON objects to use a real immutable
> dictionary type, probably VHash (though it looks like those would
> still need missing functions, at which point a wrapper type that
> validated keys and maintained a consistent hash-proc might be even
> better). Alternatively we could use guile-json, which at least avoids
> the need for improper alists to disambiguate objects from arrays, but
> we would have to address the issues in Guix commit
> a4bb18921099b2ec8c1699e08a73ca0fa78d0486.
>
> All of that reinforces my sense that we should not try to change this
> here.
I think you misread me here. One thing that's bugging me is that you
(just like whoever wrote this before) strip the @ only to reintroduce
it. I think it'd be better if (resolve-dependencies) simply took a
list and the let-block deconstructed the json.
As for the package-meta -> package-meta conversion, imo that could
perfectly be done with match or SXML transformation. WDYT?
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 06/45] guix: node-build-system: Refactor patch-dependencies phase.
2021-12-18 17:52 ` Liliana Marie Prikler
@ 2021-12-18 18:59 ` Timothy Sample
2021-12-20 18:03 ` Philip McGrath
1 sibling, 0 replies; 458+ messages in thread
From: Timothy Sample @ 2021-12-18 18:59 UTC (permalink / raw)
To: Liliana Marie Prikler; +Cc: 51838, Pierre Langlois, Jelle Licht, Philip McGrath
Hi Liliana,
Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
> Am Samstag, dem 18.12.2021 um 12:03 -0500 schrieb Philip McGrath:
>
>> All of that reinforces my sense that we should not try to change this
>> here.
>
> I think you misread me here. One thing that's bugging me is that you
> (just like whoever wrote this before) strip the @ only to reintroduce
> it. I think it'd be better if (resolve-dependencies) simply took a
> list and the let-block deconstructed the json.
>
> As for the package-meta -> package-meta conversion, imo that could
> perfectly be done with match or SXML transformation. WDYT?
I think that, as a patch, this is a clear improvement over the existing
code. Is it perfect yet? Maybe not. Further improvements can always
be made. The NPM package set is small enough that build system changes
can be committed directly to master. Each of the three of us has spent
more time writing about it than it would take to reimplement it! :)
To me, it would be unwise to hold back this series because one of the
patches replaces ugly and broken mutations with merely ugly mutations.
-- Tim
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 06/45] guix: node-build-system: Refactor patch-dependencies phase.
2021-12-18 17:52 ` Liliana Marie Prikler
2021-12-18 18:59 ` Timothy Sample
@ 2021-12-20 18:03 ` Philip McGrath
2021-12-20 19:54 ` Liliana Marie Prikler
1 sibling, 1 reply; 458+ messages in thread
From: Philip McGrath @ 2021-12-20 18:03 UTC (permalink / raw)
To: Liliana Marie Prikler, 51838; +Cc: Timothy Sample, Pierre Langlois, Jelle Licht
Hi,
On 12/18/21 12:52, Liliana Marie Prikler wrote:
> Hi,
>
> Am Samstag, dem 18.12.2021 um 12:03 -0500 schrieb Philip McGrath:
>> [...]
>>
>>> The Guix codebase is generally not the place to play around with
>>> destructive semantics. If you can avoid assoc-set!, I think you
>>> ought to, especially if it helps making a two-step process into a
>>> single-step one. Anything I'm missing here?
>>
>> I agree that assoc-set! is best avoided. (I am a Racketeer: we don't
>> mutate pairs.) However, this code was already using assoc-set!: the
>> change in this patch is merely to use it correctly.
>>
>> AFAIK neither `info "(guile)Association Lists"` nor SRFI-1 (`info
>> "(guile)SRFI-1 Association Lists"`) provide a non-destructive assoc-
>> set operation. Note in particular that acons and alist-cons do not
>> work, since they don't remove existing entries for the same key: they
>> would result in duplicate keys being written to the JSON object. (In
>> theory this has undefined semantics; in practice, I believe Node.js
>> would use the wrong entry.)
>>
>> Of course, I know how to write a little library of purely functional
>> association list operations---but that seems vastly out of scope for
>> this patch series (which has already grown quite large). Furthermore,
>> if we were going to make such changes, I think it might be better to
>> change the representation of JSON objects to use a real immutable
>> dictionary type, probably VHash (though it looks like those would
>> still need missing functions, at which point a wrapper type that
>> validated keys and maintained a consistent hash-proc might be even
>> better). Alternatively we could use guile-json, which at least avoids
>> the need for improper alists to disambiguate objects from arrays, but
>> we would have to address the issues in Guix commit
>> a4bb18921099b2ec8c1699e08a73ca0fa78d0486.
>>
>> All of that reinforces my sense that we should not try to change this
>> here.
> I think you misread me here. One thing that's bugging me is that you
> (just like whoever wrote this before) strip the @ only to reintroduce
> it. I think it'd be better if (resolve-dependencies) simply took a
> list and the let-block deconstructed the json.
>
> As for the package-meta -> package-meta conversion, imo that could
> perfectly be done with match or SXML transformation. WDYT?
>
I definitely am not understanding what you have in mind here. When you
write "strip the @", I'm not sure what you're referring to, because
there are multiple "@" tags here, one beginning each JSON object. (Maybe
this is obvious, but it hadn't been obvious to me.) So, the (guix build
json) representation of a "package.json" file might look like this:
```
`(@ ("name" . "apple")
("version" . "1.0")
("dependencies". (@ ("banana" . "*")
("pear" . "*")))
("devDependencies" . (@ ("peach" . "*")
("orange" . "*")))
("peerDependencies" . (@ ("node-gyp" . "7.x")))
("peerDependenciesMeta" . (@ ("node-gyp" . (@ ("optional" . #t)))))
("optionalDependencies" . (@ ("node-gyp" . "7.x"))))
```
An unfortunate consequence of this representation is that JSON objects
are not usable directly as association lists: some procedures expecting
association lists seem to silently ignore the non-pair at the head of
the list, but I don't think that's guaranteed, and other procedures just
don't work. In particular, `append` applied to two JSON objects does not
produce a JSON object, even ignoring the problem of duplicate keys.
Given that the current code adds "peerDependencies" as additional
"dependencies", the choice (as I see it) is between the current
approach, in which `resolve-dependencies` returns genuine association
lists and the `let*` block turns them JSON objects, or changing
`resolve-dependencies` to return JSON objects and implementing
`json-object-append`, which doesn't seem obviously better, unless it
were part of broader changes. (As an aside, I am not convinced that the
current handling of "peerDependencies" is right, but I think
reevaluating that behavior is out of scope for this patch series, and
particularly for this patch, in which, as Tim said in
<https://issues.guix.gnu.org/51838#234>, my goal was merely to make the
use of `assoc-set!` safe.)
I definitely think the broader situation should be improved!
But I think those improvements are out of scope for this patch series.
It seems like much more discussion would be needed on what the
improvements should be, and potentially coordination with other users of
(guix build json). Personally, I'd want to represent JSON objects with a
real immutable dictionary type that gave us more guarantees about
correctness by construction. If we continue with tagged association
lists, we should write a little library of purely functional operations
on JSON objects. But that all seems very far afield.
-Philip
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 06/45] guix: node-build-system: Refactor patch-dependencies phase.
2021-12-20 18:03 ` Philip McGrath
@ 2021-12-20 19:54 ` Liliana Marie Prikler
2021-12-21 3:40 ` Philip McGrath
0 siblings, 1 reply; 458+ messages in thread
From: Liliana Marie Prikler @ 2021-12-20 19:54 UTC (permalink / raw)
To: Philip McGrath, 51838; +Cc: Timothy Sample, Pierre Langlois, Jelle Licht
Hi,
Am Montag, dem 20.12.2021 um 13:03 -0500 schrieb Philip McGrath:
> I definitely am not understanding what you have in mind here. When
> you write "strip the @", I'm not sure what you're referring to,
> because there are multiple "@" tags here, one beginning each JSON
> object. (Maybe this is obvious, but it hadn't been obvious to me.)
I'm referring to this part:
> + (define (resolve-dependencies meta-alist meta-key)
> + ;; Given:
> + ;; - The alist from "package.json", with the '@ unwrapped
> + ;; - A string key, like "dependencies"
> + ;; Returns: an alist (without a wrapping '@) like the entry in
> + ;; meta-alist for meta-key, but with dependencies supplied
> + ;; by Guix packages mapped to the absolute store paths to use.
> + (match (assoc-ref meta-alist meta-key)
> + (#f
> + '())
> + (('@ . orig-deps)
> + (fold (match-lambda*
> + (((key . value) acc)
> + (acons key (hash-ref index key value) acc)))
> + '()
> + orig-deps))))
You could simply write the function s.t. (resolve-dependencies DEPS)
takes an alist and then produces an alist of resolved dependencies.
Because you don't, you need to code around that quirk down in the file
replacements. You can safely access the dependencies using
(or (and=> (assoc "dependencies" json) cddr) '())
in the calling code. If you replace "dependencies" by a generic KEY,
you can also outline that into a helper function.
> So, the (guix build json) representation of a "package.json" file
> might look like this:
>
> ```
> `(@ ("name" . "apple")
> ("version" . "1.0")
> ("dependencies". (@ ("banana" . "*")
> ("pear" . "*")))
> ("devDependencies" . (@ ("peach" . "*")
> ("orange" . "*")))
> ("peerDependencies" . (@ ("node-gyp" . "7.x")))
> ("peerDependenciesMeta" . (@ ("node-gyp" . (@ ("optional" .
> #t)))))
> ("optionalDependencies" . (@ ("node-gyp" . "7.x"))))
> ```
Note that '("dependencies" . (@ ("banana" . "long") ("pear" . "*"))) is
equal to '("dependencies" @ ("banana" . "long") ("pear" . "juicy")).
> An unfortunate consequence of this representation is that JSON
> objects are not usable directly as association lists: some procedures
> expecting association lists seem to silently ignore the non-pair at
> the head of the list, but I don't think that's guaranteed, and other
> procedures just don't work.
There are sloppy variants of the assoc functions, but again, you are
looking at this from the wrong angle. Just ignore that you have a JSON
object and pass the alist to resolve-dependencies, then reconstruct a
JSON object from the result. ezpz
> In particular, `append` applied to two JSON objects does not produce
> a JSON object, even ignoring the problem of duplicate keys.
I think we can ignore that for now, but if it bugs you you can convert
to hash table and back or at least assert that the keys are unique.
> Given that the current code adds "peerDependencies" as additional
> "dependencies", the choice (as I see it) is between the current
> approach, in which `resolve-dependencies` returns genuine association
> lists and the `let*` block turns them JSON objects, or changing
> `resolve-dependencies` to return JSON objects and implementing
> `json-object-append`, which doesn't seem obviously better, unless it
> were part of broader changes.
The return value of resolve-dependencies is okay imo. It's the calling
convention that is not.
> (As an aside, I am not convinced that the current handling of
> "peerDependencies" is right, but I think reevaluating that behavior
> is out of scope for this patch series, and particularly for this
> patch, in which, as Tim said in
> <https://issues.guix.gnu.org/51838#234>, my goal was merely to make
> the use of `assoc-set!` safe.)
I agree that we can ignore the semantics of peerDependencies for now
and we may even be able to look aside the use of assoc-set! (although
for the purpose of making it easier for the user to rewrite those files
on their own as I laid out before, it might still make sense to drop
that use regardless, leading by example).
> But I think those improvements are out of scope for this patch
> series.
I don't. Particularly, the current implementation quirks appear to be
the sole reason you came up with the solution of #:absent-dependencies,
which for the record I still disagree with. We can lay down a better
foundation to rewrite JSON data in node-build-system and should export
functions that are necessary to do so in build-side code if they're not
already part of core guile or other imports.
> It seems like much more discussion would be needed on what the
> improvements should be, and potentially coordination with other users
> of (guix build json). Personally, I'd want to represent JSON objects
> with a real immutable dictionary type that gave us more guarantees
> about correctness by construction. If we continue with tagged
> association lists, we should write a little library of purely
> functional operations on JSON objects. But that all seems very far
> afield.
I'll have to say non sequitur to that. The functionality we require to
efficiently rewrite JSON can perfectly be built on top of (a)list
primitives and pattern matching, both of which are available to be used
in build-side code. We could even throw in SXML if we needed, not that
we do. There is really no need to code up yet another set of JSON
primitives just to write "hello, world".
If you absolutely require it, though:
(define json-object->alist cdr)
(define (alist->json-object alist) (cons '@ alist))
Magic.
Cheers
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 06/45] guix: node-build-system: Refactor patch-dependencies phase.
2021-12-20 19:54 ` Liliana Marie Prikler
@ 2021-12-21 3:40 ` Philip McGrath
0 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-21 3:40 UTC (permalink / raw)
To: Liliana Marie Prikler, 51838; +Cc: Timothy Sample, Pierre Langlois, Jelle Licht
Hi Liliana,
On 12/20/21 14:54, Liliana Marie Prikler wrote:
> Hi,
>
> Am Montag, dem 20.12.2021 um 13:03 -0500 schrieb Philip McGrath:
>> I definitely am not understanding what you have in mind here. When
>> you write "strip the @", I'm not sure what you're referring to,
>> because there are multiple "@" tags here, one beginning each JSON
>> object. (Maybe this is obvious, but it hadn't been obvious to me.)
> I'm referring to this part:
>> + (define (resolve-dependencies meta-alist meta-key)
>> + ;; Given:
>> + ;; - The alist from "package.json", with the '@ unwrapped
>> + ;; - A string key, like "dependencies"
>> + ;; Returns: an alist (without a wrapping '@) like the entry in
>> + ;; meta-alist for meta-key, but with dependencies supplied
>> + ;; by Guix packages mapped to the absolute store paths to use.
>> + (match (assoc-ref meta-alist meta-key)
>> + (#f
>> + '())
>> + (('@ . orig-deps)
>> + (fold (match-lambda*
>> + (((key . value) acc)
>> + (acons key (hash-ref index key value) acc)))
>> + '()
>> + orig-deps))))
> You could simply write the function s.t. (resolve-dependencies DEPS)
> takes an alist and then produces an alist of resolved dependencies.
> Because you don't, you need to code around that quirk down in the file
> replacements. You can safely access the dependencies using
> (or (and=> (assoc "dependencies" json) cddr) '())
> in the calling code. If you replace "dependencies" by a generic KEY,
> you can also outline that into a helper function.
>
>> An unfortunate consequence of this representation is that JSON
>> objects are not usable directly as association lists: some procedures
>> expecting association lists seem to silently ignore the non-pair at
>> the head of the list, but I don't think that's guaranteed, and other
>> procedures just don't work.
> There are sloppy variants of the assoc functions, but again, you are
> looking at this from the wrong angle. Just ignore that you have a JSON
> object and pass the alist to resolve-dependencies, then reconstruct a
> JSON object from the result. ezpz
To check my understanding, are you saying you'd like the code to look
like this? (n.b. not tested)
```
(define* (patch-dependencies #:key inputs #:allow-other-keys)
(define index (index-modules (map cdr inputs)))
(define (resolve-dependencies orig-deps)
(fold (match-lambda*
(((key . value) acc)
(acons key (hash-ref index key value) acc)))
'()
orig-deps))
(define (lookup-deps-alist meta-alist meta-key)
(match (assoc-ref meta-alist meta-key)
(#f
'())
(('@ . deps)
deps)))
(with-atomic-file-replacement "package.json"
(lambda (in out)
(let* ((package-meta (read-json in))
(alist (match package-meta
((@ . alist) alist)))
(alist
(assoc-set!
alist "dependencies"
(cons '@ (resolve-dependencies
(append
(lookup-deps-alist alist "dependencies")
(lookup-deps-alist alist "peerDependencies"))))))
(alist
(assoc-set!
alist "devDependencies"
(cons '@ (resolve-dependencies
(lookup-deps-alist alist "devDependencies")))))
(package-meta (cons '@ alist)))
(write-json package-meta out))))
#t)
```
I wouldn't have messed with it if I'd found it this way, but to me it
does not seem obviously better. In particular, I think any benefit of
simplifying `resolve-dependencies` is outweighed by `lookup-deps-alist`
conflating looking up the key in the given alist with unwrapping the
result, if there is one.
Just to be explicit, your much more elegant code with `match-lambda`
from above:
> (map (match-lambda
> (('dependencies '@ . DEPENDENCIES)
> (filter away unwanted dependencies))
> (('devDependencies '@ . DEPENDENCIES)
> (same))
> (otherwise otherwise))
> json)))))
wouldn't quite be enough here: it's possible for the "dependencies" key
to be absent but the "peerDependencies" key to be present, in which
case, to preserve the current behavior, we still need to add the
filtered/rewritten "peerDependencies" as "dependencies".
>> But I think those improvements are out of scope for this patch
>> series.
> I don't. Particularly, the current implementation quirks appear to be
> the sole reason you came up with the solution of #:absent-dependencies,
> which for the record I still disagree with. We can lay down a better
> foundation to rewrite JSON data in node-build-system and should export
> functions that are necessary to do so in build-side code if they're not
> already part of core guile or other imports.
I think the current implementation quirks have almost nothing to do with
my reasoning for #:absent-dependencies.
It's probably true that, if it were more convenient to write phases
transforming "package.json" generally, I probably wouldn't have looked
into why so many existing packages were deleting the configure
phase---but I think it's probably also true that, if that had been the
case, those packages wouldn't currently be deleting the configure phase.
Part of my point is that, even if those utility functions did exist, I
would still advocate for #:absent-dependencies. Jelle's latest email
covers much of my reasoning, particularly this:
On 12/20/21 18:10, Jelle Licht wrote:
> Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
>> That is the point, but please don't add a function called "make-delete-
>> dependencies-phase". We have lambda. We can easily add with-atomic-
>> json-replacement. We can also add a "delete-dependencies" function
>> that takes a json and a list of dependencies if you so want.
>>
>> So in short
>>
>> (add-after 'patch-dependencies 'drop-junk
>> (lambda _
>> (with-atomic-json-replacement "package.json"
>> (lambda (json) (delete-dependencies json '("node-tap"))))))
>>
>> would be the "verbose" style of disabling a list of dependencies.
>>
>
> I think you are _really_ underestimating how many packages will need a
> phase like this in the future. I would agree with this approach if it
> were only needed incidentally, similar to the frequency of patching
> version requirements in setup.py or requirements.txt for python
> packages.
>
> Pretty much everything except the '("node-tap") list will be identical
> between packages; how do you propose we reduce this duplication? At this
> point I feel like I'm rehasing the opposite of your last point, so let
> me rephrase; how many times do you want to see/type/copy+paste the above
> snippet before you would consider exposing this functionality on a
> higher level?
On a similar note, as Jelle said elsewhere, I think
#:absent-dependencies should be more amenable to programmatic code
generation and transformation than a phase under `modify-phases` would
be. The downside of having lambda, of course, is that some analysis is
intractable or undecidable on Turing-complete (Church-complete?) code:
there is a tradeoff to expressive power.
>
>> It seems like much more discussion would be needed on what the
>> improvements should be, and potentially coordination with other users
>> of (guix build json). Personally, I'd want to represent JSON objects
>> with a real immutable dictionary type that gave us more guarantees
>> about correctness by construction. If we continue with tagged
>> association lists, we should write a little library of purely
>> functional operations on JSON objects. But that all seems very far
>> afield.
> I'll have to say non sequitur to that. The functionality we require to
> efficiently rewrite JSON can perfectly be built on top of (a)list
> primitives and pattern matching, both of which are available to be used
> in build-side code. We could even throw in SXML if we needed, not that
> we do. There is really no need to code up yet another set of JSON
> primitives just to write "hello, world".
The other part of my point is that I think providing a nice set of
utilities for more general JSON transformation is important enough that
it should not be thrown into this patch series as an afterthought. The
design is the hard part, not the code.
If it's useful as an illustration (maybe it's not ...), here's a
non-quirky implementation (not tested) of the interesting parts of
`patch-dependencies` in Racket, with (other than the actual IO)
exclusively pure functions operating on immutable data structures, which
would not eliminate the benefits of `#:absent-dependencies`:
```
(λ (index absent-dependencies in out)
(define (resolve-dependencies orig-deps)
(for/hasheq ([{k v} (in-immutable-hash orig-deps)]
#:unless (memq k absent-dependencies))
(values k (hash-ref index k v))))
(define (resolve-package-meta package-meta)
(hash-update
(hash-update package-meta
'devDependencies
resolve-dependencies
#hasheq())
'dependencies
(λ (orig-deps)
(resolve-dependencies
(hash-union orig-deps (hash-ref package-meta
'peerDependencies
#hasheq()))))
#hasheq()))
(write-json (resolve-package-meta (read-json in))
out))
```
To have a similarly pleasant API---I think we could aspire to an even
better one!---the absolute minimum we'd need is a non-destructive
`assoc-set`, since apparently that doesn't exist: it is, admittedly,
fairly trivial. To be really convenient, though, we'd probably want
`assoc-update`. But should `assoc-update` have an implicit default of
`#f`, like `assoc-ref`, or raising an error, like Racket's
`hash-update`/`hash-ref`/`dict-update`/`dict-ref`? Should we borrow the
Racket convention whereby the "default value" can be a thunk (in which
case it is called, so it could escape or build up some
expensive-to-compute default value)? Or maybe `assoc-update` should take
four mandatory arguments, with the update procedure last, because it
will often be a long lambda expression, and the code might look more
beautiful with that argument last. Maybe the default should be passed as
a keyword argument!
Then there's `assoc-set*`, `assoc-has-key?`, `assoc-delete`,
`assoc-union` ...
But wait! A big source of repetitive boilerplate is wrapping and
unwrapping JSON objects with the '@ tag. If we're implementing all of
these functions anyway, why not effectively compose them with:
>
> If you absolutely require it, though:
> (define json-object->alist cdr)
> (define (alist->json-object alist) (cons '@ alist))
so we can just write `jsobject-ref`, `jsobject-set`, `jsobject-delete`,
`jsobject-update`, etc. directly? Insert bikeshedding about names here.
But wait! Today, (guix build json) is not part of node-build-system's
public API. It is not even part of the default value for #:modules
(though it is in #:imported-modules). If we are ever going to change the
JSON representation we use, surely we should consider it before making
it public. There is a commit [1] in the history changing to use
guile-json: do the reasons it was reverted "for now" [2] in 2019 still
apply? And guile-json is a deprecated alias: would we want guile-json-1,
guile-json-3, or guile-json-4?
[1]:
https://git.savannah.gnu.org/cgit/guix.git/commit/?id=8eb0ba532ebbebef23180e666e0607ea735f9c1a
[2]:
https://git.savannah.gnu.org/cgit/guix.git/commit/?id=a4bb18921099b2ec8c1699e08a73ca0fa78d0486
... and so forth.
These questions do not strike me as trivially self-evident. I don't know
what answers I'd come up with for all of them.
Given that, even if we already had these utility functions, I still
think #:absent-dependencies would be The Right Thing, I'm very reluctant
to add a prerequisite of designing general "package.json" manipulation
tools.
-Philip
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (5 preceding siblings ...)
2021-12-17 2:02 ` [bug#51838] [PATCH v5 06/45] guix: node-build-system: Refactor patch-dependencies phase Philip McGrath
@ 2021-12-17 2:02 ` Philip McGrath
2021-12-17 4:43 ` Liliana Marie Prikler
2021-12-17 2:02 ` [bug#51838] [PATCH v5 08/45] gnu: node-semver-bootstrap: Use #:absent-dependencies Philip McGrath
` (37 subsequent siblings)
44 siblings, 1 reply; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:02 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* 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
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument Philip McGrath
@ 2021-12-17 4:43 ` Liliana Marie Prikler
2021-12-17 15:46 ` Timothy Sample
0 siblings, 1 reply; 458+ messages in thread
From: Liliana Marie Prikler @ 2021-12-17 4:43 UTC (permalink / raw)
To: Philip McGrath, 51838; +Cc: Timothy Sample, Pierre Langlois, Jelle Licht
Hi,
Am Donnerstag, dem 16.12.2021 um 21:02 -0500 schrieb Philip McGrath:
> * 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".
> [...]
> + (absent-dependencies ''())
> [...]
> + (absent-dependencies ''())
> [...]
> -(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))))
I might be sounding like a broken record here, but again for the sake
of being able to add or remove inputs on the user side without
duplicated efforts, I'd use something else in lieu of absent-
dependencies. For the time being, I think a switch between "fail" and
"warn about missing dependencies" ought to be enough. In the future,
we might want to make it so that packages can specify which
dependencies they absolutely require and which they don't (or if
possible infer that from dependencies). WDYT?
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument.
2021-12-17 4:43 ` Liliana Marie Prikler
@ 2021-12-17 15:46 ` Timothy Sample
2021-12-17 19:40 ` Liliana Marie Prikler
0 siblings, 1 reply; 458+ messages in thread
From: Timothy Sample @ 2021-12-17 15:46 UTC (permalink / raw)
To: Liliana Marie Prikler; +Cc: 51838, Pierre Langlois, Jelle Licht, Philip McGrath
Hi Liliana,
Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
> I might be sounding like a broken record here, but again for the sake
> of being able to add or remove inputs on the user side without
> duplicated efforts, I'd use something else in lieu of absent-
> dependencies. For the time being, I think a switch between "fail" and
> "warn about missing dependencies" ought to be enough. In the future,
> we might want to make it so that packages can specify which
> dependencies they absolutely require and which they don't (or if
> possible infer that from dependencies). WDYT?
The way I see it is that we are basically copying the
“--disable-X”/“--without-Y” features of a GNU configure script. With
the GNU build system, if one of our packages specifies “--without-zlib”
for whatever reason, and you as a user want to modify the package to use
zlib, you would have to
1. remove the “--without-zlib” configure flag; and
2. add the zlib package to the package’s inputs.
That’s a “duplicated effort”, right?
Similarly, for a Node package (with a pretend Node zlib package), you
would have to
1. remove “zlib” from absent dependencies; and
2. add the “node-zlib” package to the package’s inputs.
That seems okay to me, but I’m worried I’ve missed what you’re trying to
communicate.
-- Tim
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument.
2021-12-17 15:46 ` Timothy Sample
@ 2021-12-17 19:40 ` Liliana Marie Prikler
2021-12-18 2:48 ` Timothy Sample
0 siblings, 1 reply; 458+ messages in thread
From: Liliana Marie Prikler @ 2021-12-17 19:40 UTC (permalink / raw)
To: Timothy Sample; +Cc: 51838, Pierre Langlois, Jelle Licht, Philip McGrath
Hi Timothy,
Am Freitag, dem 17.12.2021 um 10:46 -0500 schrieb Timothy Sample:
> Hi Liliana,
>
> Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
>
> > I might be sounding like a broken record here, but again for the
> > sake of being able to add or remove inputs on the user side without
> > duplicated efforts, I'd use something else in lieu of absent-
> > dependencies. For the time being, I think a switch between "fail"
> > and "warn about missing dependencies" ought to be enough. In the
> > future, we might want to make it so that packages can specify which
> > dependencies they absolutely require and which they don't (or if
> > possible infer that from dependencies). WDYT?
>
> The way I see it is that we are basically copying the
> “--disable-X”/“--without-Y” features of a GNU configure script. With
> the GNU build system, if one of our packages specifies “--without-
> zlib”
> for whatever reason, and you as a user want to modify the package to
> use zlib, you would have to
>
> 1. remove the “--without-zlib” configure flag; and
> 2. add the zlib package to the package’s inputs.
>
> That’s a “duplicated effort”, right?
>
> Similarly, for a Node package (with a pretend Node zlib package), you
> would have to
>
> 1. remove “zlib” from absent dependencies; and
> 2. add the “node-zlib” package to the package’s inputs.
>
> That seems okay to me, but I’m worried I’ve missed what you’re trying
> to communicate.
For the GNU build system (and likewise meson-build-system), the default
behaviour if you haven't specified anything as per upstream conventions
is typically to error if the package is required and omit it if it's
not. The default behaviour of node-build-system (and likewise cargo
and most other build systems that come with the advertisement of "we
know package managers better than people who actually produce useful
package managers) is "Oh my god, you don't have an exact copy of the
machine that built this stuff locally, I am going to barf huge walls of
noise at you". Therefore, we can't meaningfully compare those build
systems in terms of strategies.
On a slightly related note, I recently had the pleasure of working on a
patch for a package that fails python-build-systems new sanity-check
phase. If we really want some static verification for node-build-
system, I think we should take that as an approach rather than hard-
coding (absent) dependencies literally everywhere. Although in writing
that I must concede that Python is still too sane to be a Web standard.
I'm sorry I can't explain my reasoning in a nicer manner. Your point
would be totally valid if node-build-system did act like the GNU build
system or meson in that dependency resolution is DWIM by default, but
sadly we can't have nice things with "modern" programming languages and
their build systems.
TL;DR: "--without-zlib" is usually implied in packages based on the GNU
build system unless zlib really is a hard requirement of the package.
The same can't be said for node-anything.
Cheers
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument.
2021-12-17 19:40 ` Liliana Marie Prikler
@ 2021-12-18 2:48 ` Timothy Sample
2021-12-18 8:30 ` Liliana Marie Prikler
0 siblings, 1 reply; 458+ messages in thread
From: Timothy Sample @ 2021-12-18 2:48 UTC (permalink / raw)
To: Liliana Marie Prikler; +Cc: 51838, Pierre Langlois, Jelle Licht, Philip McGrath
Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
> For the GNU build system (and likewise meson-build-system), the default
> behaviour if you haven't specified anything as per upstream conventions
> is typically to error if the package is required and omit it if it's
> not. The default behaviour of node-build-system (and likewise cargo
> and most other build systems that come with the advertisement of "we
> know package managers better than people who actually produce useful
> package managers) is "Oh my god, you don't have an exact copy of the
> machine that built this stuff locally, I am going to barf huge walls of
> noise at you". Therefore, we can't meaningfully compare those build
> systems in terms of strategies.
NPM packages tend to wildly over-specify their dependencies. We already
remove dependency version checking, and before this change, many of our
packages skipped any kind of dependency checking by skipping the
configure phase altogether. To me, the ‘#:absent-dependencies’ approach
tries to work around the dependency over-specification by listing
exactly those things that are only there to elicit a useless “Oh my god
[...], I’m going to barf huge walls of noise” message. The rest of the
dependencies are those that the Guix package author deemed required (or
at least important). Basically, ‘#:absent-dependencies’ helps us
translate between the NPM culture of over-specification (which is really
a culture of prioritizing package author over package user) and the GNU
culture of “DWIM” dependencies.
> If we really want some static verification for node-build-system, I
> think we should take that as an approach rather than hard-coding
> (absent) dependencies literally everywhere.
We need some way to know what to statically verify. We can’t magically
know what’s important and what isn’t. The two options in this thread
are ‘#:absent-dependencies’, and only checking what’s already in the
package’s inputs. What worries me about the second approach is that it
offers no help when updating a package. With ‘#:absent-dependencies’,
if the developer adds a new dependency that really is required, we will
get a build-time failure letting us know. Whoever is updating the
package can fix it before even committing anything. If we just check
the inputs, that’s not the case, and we might end up with Philip’s
“mysterious runtime error, potentially many steps down a dependency
chain.” Hopefully tests would catch it, but I like the extra assurance.
Another benefit is that it would help us gain knowledge as to which NPM
packages are often used but not actually required (e.g., NPM publishing
tools). With this knowledge, we could write a clever NPM importer that
ignored obviously inessential dependencies.
I guess I’m starting to sound like a broken record now – this is
basically what we covered before! :) Maybe we’re in need of a fresh
perspective. (If anyone is reading along and has thoughts, feel free to
chime in!)
-- Tim
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument.
2021-12-18 2:48 ` Timothy Sample
@ 2021-12-18 8:30 ` Liliana Marie Prikler
2021-12-18 18:31 ` Philip McGrath
0 siblings, 1 reply; 458+ messages in thread
From: Liliana Marie Prikler @ 2021-12-18 8:30 UTC (permalink / raw)
To: Timothy Sample; +Cc: 51838, Pierre Langlois, Jelle Licht, Philip McGrath
Hi,
Am Freitag, dem 17.12.2021 um 21:48 -0500 schrieb Timothy Sample:
> Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
>
> > For the GNU build system (and likewise meson-build-system), the
> > default behaviour if you haven't specified anything as per upstream
> > conventions is typically to error if the package is required and
> > omit it if it's not. The default behaviour of node-build-system
> > (and likewise cargo and most other build systems that come with the
> > advertisement of "we know package managers better than people who
> > actually produce usefulpackage managers) is "Oh my god, you don't
> > have an exact copy of the machine that built this stuff locally, I
> > am going to barf huge walls of noise at you". Therefore, we can't
> > meaningfully compare those build systems in terms of strategies.
>
> NPM packages tend to wildly over-specify their dependencies. We
> already remove dependency version checking, and before this change,
> many of our packages skipped any kind of dependency checking by
> skipping the configure phase altogether. To me, the ‘#:absent-
> dependencies’ approach tries to work around the dependency over-
> specification by listing exactly those things that are only there to
> elicit a useless “Oh my god [...], I’m going to barf huge walls of
> noise” message. The rest of the dependencies are those that the Guix
> package author deemed required (or at least important). Basically,
> ‘#:absent-dependencies’ helps us translate between the NPM culture of
> over-specification (which is really a culture of prioritizing package
> author over package user) and the GNU culture of “DWIM” dependencies.
Except that it's not. The current workaround is "I know this thing's
going to barf at me, so I prepare an umbrella and hope it has no
holes".
> > If we really want some static verification for node-build-system, I
> > think we should take that as an approach rather than hard-coding
> > (absent) dependencies literally everywhere.
>
> We need some way to know what to statically verify. We can’t
> magically know what’s important and what isn’t. The two options in
> this thread are ‘#:absent-dependencies’, and only checking what’s
> already in the package’s inputs. What worries me about the second
> approach is that it offers no help when updating a package. With
> ‘#:absent-dependencies’, if the developer adds a new dependency that
> really is required, we will get a build-time failure letting us
> know. Whoever is updating the package can fix it before even
> committing anything. If we just check the inputs, that’s not the
> case, and we might end up with Philip’s “mysterious runtime error,
> potentially many steps down a dependency chain.” Hopefully tests
> would catch it, but I like the extra assurance.
That's why I didn't want to default to "do nothing", but to *warn*
about missing dependencies in configure. Then whoever bumps the
package will at least know which warnings are produced if they do so
and they can cross-check by manually building past versions. Including
#:absent-dependencies is no safe-guard against a failure here anyway.
A dependency that was optional in V1 might become required in V2.
> Another benefit is that it would help us gain knowledge as to which
> NPM packages are often used but not actually required (e.g., NPM
> publishing tools). With this knowledge, we could write a clever NPM
> importer that ignored obviously inessential dependencies.
>
> I guess I’m starting to sound like a broken record now – this is
> basically what we covered before! :) Maybe we’re in need of a fresh
> perspective. (If anyone is reading along and has thoughts, feel free
> to chime in!)
I think the NPM convention is to put everything you need "at build
time, but not at runtime" into dev-dependencies, no? In any case, one
approach I could offer is to sanity-check by searching for require()
statements and trying them in a controlled node environment. This
could look something like
eval("try { var dep = require('" + dependency + "'); true }
catch (e) { false; }")
Once we know where require statements are made and whether they
succeed, we can start estimating the impact of a missing dependency.
For this, it'd be nice to have a full function call graph, in which a
node is coloured dirty if it has a failing require statement, lies
within a module that has one or calls into a dirty node. However, as a
primitive approximation we can also count the node modules with failing
requires against those that don't. We set an arbitrary threshold of
allowed failures, e.g. 0.42, and then check that whatever value we
obtain from the above is lower than that.
While that would be nice and all, I think the overall issue with the
current node implementation in Guix is that 'configure' and 'sanity-
check' are the same phase, so you have to disable both or none. I
think we could easily do with a configure phase that does nothing, not
even warn about a missing dependency, and a sanity-check phase that
requires every dependency mentioned in package.json to be met.
Packagers would then outright delete sanity-check as they do for python
and as they did for configure (but not have configure fail due to it!)
or deliberately rewrite the package.json for the sanity check and
dropping absent dependencies, i.e. what you do minus the keyword. If
later needed for the purposes of an importer, we would then still have
that database and could at some point introduce the key #:insane-
requirements. WDYT?
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument.
2021-12-18 8:30 ` Liliana Marie Prikler
@ 2021-12-18 18:31 ` Philip McGrath
2021-12-18 20:49 ` Liliana Marie Prikler
0 siblings, 1 reply; 458+ messages in thread
From: Philip McGrath @ 2021-12-18 18:31 UTC (permalink / raw)
To: Liliana Marie Prikler, Timothy Sample; +Cc: 51838, Pierre Langlois, Jelle Licht
Hi,
On 12/18/21 03:30, Liliana Marie Prikler wrote:
> Hi,
>
> Am Freitag, dem 17.12.2021 um 21:48 -0500 schrieb Timothy Sample:
>> Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
>>
>>> For the GNU build system (and likewise meson-build-system), the
>>> default behaviour if you haven't specified anything as per upstream
>>> conventions is typically to error if the package is required and
>>> omit it if it's not. The default behaviour of node-build-system
>>> (and likewise cargo and most other build systems that come with the
>>> advertisement of "we know package managers better than people who
>>> actually produce usefulpackage managers) is "Oh my god, you don't
>>> have an exact copy of the machine that built this stuff locally, I
>>> am going to barf huge walls of noise at you". Therefore, we can't
>>> meaningfully compare those build systems in terms of strategies.
>>
>> NPM packages tend to wildly over-specify their dependencies. We
>> already remove dependency version checking, and before this change,
>> many of our packages skipped any kind of dependency checking by
>> skipping the configure phase altogether. To me, the ‘#:absent-
>> dependencies’ approach tries to work around the dependency over-
>> specification by listing exactly those things that are only there to
>> elicit a useless “Oh my god [...], I’m going to barf huge walls of
>> noise” message. The rest of the dependencies are those that the Guix
>> package author deemed required (or at least important). Basically,
>> ‘#:absent-dependencies’ helps us translate between the NPM culture of
>> over-specification (which is really a culture of prioritizing package
>> author over package user) and the GNU culture of “DWIM” dependencies.
> Except that it's not. The current workaround is "I know this thing's
> going to barf at me, so I prepare an umbrella and hope it has no
> holes".
>
>>> If we really want some static verification for node-build-system, I
>>> think we should take that as an approach rather than hard-coding
>>> (absent) dependencies literally everywhere.
>>
>> We need some way to know what to statically verify. We can’t
>> magically know what’s important and what isn’t. The two options in
>> this thread are ‘#:absent-dependencies’, and only checking what’s
>> already in the package’s inputs. What worries me about the second
>> approach is that it offers no help when updating a package. With
>> ‘#:absent-dependencies’, if the developer adds a new dependency that
>> really is required, we will get a build-time failure letting us
>> know. Whoever is updating the package can fix it before even
>> committing anything. If we just check the inputs, that’s not the
>> case, and we might end up with Philip’s “mysterious runtime error,
>> potentially many steps down a dependency chain.” Hopefully tests
>> would catch it, but I like the extra assurance.
> That's why I didn't want to default to "do nothing", but to *warn*
> about missing dependencies in configure. Then whoever bumps the
> package will at least know which warnings are produced if they do so
> and they can cross-check by manually building past versions. Including
> #:absent-dependencies is no safe-guard against a failure here anyway.
> A dependency that was optional in V1 might become required in V2.
I also feel like I'm missing something, though maybe I just disagree.
To try to be concrete, here's a real example. Between v3 and v4 of this
patch series, I discovered that leaving out node-debug could actually
cause runtime problems for some of the node-serialport packages. (It
turns out it's really a logging library, which wasn't what I'd thought
at first.) After I added the node-debug, I could easily search
node-xyz.scm for the packages that listed it among their
#:absent-dependencies and add it to them as an input.
It seems like this would be much less convenient if node-build-system
were to silently delete such dependencies and simply print a warning. I
guess I would have to search through the build logs for all Node.js
packages, right?
More generally, I think truly "optional dependencies" (in the Node.js
sense, to the extent I understand it) and dependencies we actively don't
want (e.g. because node-sqlite3 shouldn't transitively depend on
node-aws-sdk) are relatively rare cases.
The most common cases seem to be dependencies we really would like to
have, such as test frameworks or Typescript, but haven't packaged yet,
and thus need to work around. Many packages that have
#:absent-dependencies for such reasons also need to use `#:tests? #f` or
to replace the build phase with some kind of manual alternative.
I guess I don't understand what case the warn-and-drop approach is
optimizing for. For both the case when dependencies aren't packaged for
Guix yet and the case when Guix packagers have actively decided to skip
some upstream dependencies, I think #:absent-dependencies is more
useful. Having to look for that information in warnings in the build log
seems much less ergonomic.
>> Another benefit is that it would help us gain knowledge as to which
>> NPM packages are often used but not actually required (e.g., NPM
>> publishing tools). With this knowledge, we could write a clever NPM
>> importer that ignored obviously inessential dependencies.
I agree with this, too: likewise, we could see packages that are often
wanted but aren't in Guix and prioritize adding them! Part of the
benefit of #:absent-dependencies, IMO, is as a form of communication
with humans.
>> I guess I’m starting to sound like a broken record now – this is
>> basically what we covered before! :) Maybe we’re in need of a fresh
>> perspective. (If anyone is reading along and has thoughts, feel free
>> to chime in!)
> I think the NPM convention is to put everything you need "at build
> time, but not at runtime" into dev-dependencies, no? In any case, one
> approach I could offer is to sanity-check by searching for require()
> statements and trying them in a controlled node environment. This
> could look something like
>
> eval("try { var dep = require('" + dependency + "'); true }
> catch (e) { false; }")
>
> Once we know where require statements are made and whether they
> succeed, we can start estimating the impact of a missing dependency.
> For this, it'd be nice to have a full function call graph, in which a
> node is coloured dirty if it has a failing require statement, lies
> within a module that has one or calls into a dirty node. However, as a
> primitive approximation we can also count the node modules with failing
> requires against those that don't. We set an arbitrary threshold of
> allowed failures, e.g. 0.42, and then check that whatever value we
> obtain from the above is lower than that.
This could be interesting, and I think some of the JavaScript blunders
we don't have packaged for Guix yet try to do something like this, but
such analysis is not tractable in the general case, especially with
CommonJS `require`, which is just a function and can be given arbitrary
arguments computed at runtime. (And some packages really use it that way!)
Also, currently node-build-system doesn't seem to be removing those
files which `npm pack` is supposed to exclude, which would probably be a
prerequisite for addressing this.
> While that would be nice and all, I think the overall issue with the
> current node implementation in Guix is that 'configure' and 'sanity-
> check' are the same phase, so you have to disable both or none. I
> think we could easily do with a configure phase that does nothing, not
> even warn about a missing dependency, and a sanity-check phase that
> requires every dependency mentioned in package.json to be met.
> Packagers would then outright delete sanity-check as they do for python
> and as they did for configure (but not have configure fail due to it!)
> or deliberately rewrite the package.json for the sanity check and
> dropping absent dependencies, i.e. what you do minus the keyword. If
> later needed for the purposes of an importer, we would then still have
> that database and could at some point introduce the key #:insane-
> requirements. WDYT?
I don't understand the benefit of this, and I'm also confused about the
proposed implementation specifics. Why even have "a configure phase that
does nothing"? What phase would run `npm install`? Presumably, we would
have to delete all missing dependencies before that.
I think there is room for improvement in node-build-system. One thing
I've been thinking about is some articles I've seen (but not fully
thought through yet) from the developers of PNPM, an alternative package
manager for Node.js, which seems to have some similarities to Guix in
symlinking things to a "store".[1][2][3] (It could be especially
interesting for bootstrapping npm! And the approach to "monorepos" also
seems relevant.) I also think an importer is very important, even if
it's an imperfect one: `guix import npm-binary` was indispensable in
developing these patches. I have some ideas about improving it, in
particular that we should assume the newer "^" semantics for
dependencies everywhere (i.e. that major versions and only major
versions have incompatible changes: a common case recently seems to be
moving from CommonJS modules to ES6 modules).
As I understand it, node-build-system is undocumented, with no
guarantees of compatibility. If #:absent-dependencies is at least an
improvement over the status quo---which I think it is, since the new
packages wouldn't build with the status quo---could we apply this and
replace it later if someone implements a better strategy? I don't think
I can implement control-flow analysis for JavaScript within the scope of
this patch series.
-Philip
[1]: https://pnpm.io/blog/2020/05/27/flat-node-modules-is-not-the-only-way
[2]: https://pnpm.io/symlinked-node-modules-structure
[3]: https://pnpm.io/how-peers-are-resolved
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument.
2021-12-18 18:31 ` Philip McGrath
@ 2021-12-18 20:49 ` Liliana Marie Prikler
2021-12-18 22:55 ` Philip McGrath
0 siblings, 1 reply; 458+ messages in thread
From: Liliana Marie Prikler @ 2021-12-18 20:49 UTC (permalink / raw)
To: Philip McGrath, Timothy Sample; +Cc: 51838, Pierre Langlois, Jelle Licht
Hi,
Am Samstag, dem 18.12.2021 um 13:31 -0500 schrieb Philip McGrath:
> I also feel like I'm missing something, though maybe I just disagree.
>
> To try to be concrete, here's a real example. Between v3 and v4 of
> this patch series, I discovered that leaving out node-debug could
> actually cause runtime problems for some of the node-serialport
> packages. (It turns out it's really a logging library, which wasn't
> what I'd thought at first.) After I added the node-debug, I could
> easily search node-xyz.scm for the packages that listed it among
> their #:absent-dependencies and add it to them as an input.
Wouldn't we get a huge stack trace of doom with the failed require in
that case if it was truly non-negotiable, though?
> It seems like this would be much less convenient if node-build-system
> were to silently delete such dependencies and simply print a warning.
> I guess I would have to search through the build logs for all Node.js
> packages, right?
Since node packages do have the tendency to pull in the entire
internet, you might not be too far off with that statement, but again
if you have a particular issue in a single package due to an omitted
dependency, the offending package ought to be close to the most recent
call on the stack.
An alternative to searching through the build logs would also be to
build all the sources and grepping their package.jsons ;)
> More generally, I think truly "optional dependencies" (in the Node.js
> sense, to the extent I understand it) and dependencies we actively
> don't want (e.g. because node-sqlite3 shouldn't transitively depend
> on node-aws-sdk) are relatively rare cases.
>
> The most common cases seem to be dependencies we really would like to
> have, such as test frameworks or Typescript, but haven't packaged
> yet, and thus need to work around. Many packages that have
> #:absent-dependencies for such reasons also need to use `#:tests? #f`
> or to replace the build phase with some kind of manual alternative.
>
> I guess I don't understand what case the warn-and-drop approach is
> optimizing for. For both the case when dependencies aren't packaged
> for Guix yet and the case when Guix packagers have actively decided
> to skip some upstream dependencies, I think #:absent-dependencies is
> more useful. Having to look for that information in warnings in the
> build log seems much less ergonomic.
That's why my original suggestion was to have a switch between "strict"
meaning we fail as before and "warn" meaning "we know we have unmet
dependencies". The "warn" case would be annotated similar to #:tests?
#f and the strict case default. So you could still communicate
important missing packages like typescript et al., but people who hack
on their own channels with lower standards can wing it without having
to delete configure.
> > > Another benefit is that it would help us gain knowledge as to
> > > which NPM packages are often used but not actually required
> > > (e.g., NPM publishing tools). With this knowledge, we could
> > > write a clever NPM importer that ignored obviously inessential
> > > dependencies.
>
> I agree with this, too: likewise, we could see packages that are
> often wanted but aren't in Guix and prioritize adding them! Part of
> the benefit of #:absent-dependencies, IMO, is as a form of
> communication with humans.
We do have a wishlist...
> > > I guess I’m starting to sound like a broken record now – this is
> > > basically what we covered before! :) Maybe we’re in need of a
> > > fresh perspective. (If anyone is reading along and has thoughts,
> > > feel free to chime in!)
> > I think the NPM convention is to put everything you need "at build
> > time, but not at runtime" into dev-dependencies, no? In any case,
> > one approach I could offer is to sanity-check by searching for
> > require() statements and trying them in a controlled node
> > environment. Thiscould look something like
> >
> > eval("try { var dep = require('" + dependency + "'); true }
> > catch (e) { false; }")
> >
> > Once we know where require statements are made and whether they
> > succeed, we can start estimating the impact of a missing
> > dependency.
> > For this, it'd be nice to have a full function call graph, in which
> > a node is coloured dirty if it has a failing require statement,
> > lies within a module that has one or calls into a dirty node.
> > However, as a primitive approximation we can also count the node
> > modules with failing requires against those that don't. We set an
> > arbitrary threshold of allowed failures, e.g. 0.42, and then check
> > that whatever value we obtain from the above is lower than that.
>
> This could be interesting, and I think some of the JavaScript
> blunders we don't have packaged for Guix yet try to do something like
> this, but such analysis is not tractable in the general case,
> especially with CommonJS `require`, which is just a function and can
> be given arbitrary arguments computed at runtime. (And some packages
> really use it that way!)
Of course I forgot about computed goto...
> Also, currently node-build-system doesn't seem to be removing those
> files which `npm pack` is supposed to exclude, which would probably
> be a prerequisite for addressing this.
For the record, which files would that be? Could we do emacs-build-
system style #:include and #:exclude lists?
> > While that would be nice and all, I think the overall issue with
> > the current node implementation in Guix is that 'configure' and
> > 'sanity-check' are the same phase, so you have to disable both or
> > none. I think we could easily do with a configure phase that does
> > nothing, not even warn about a missing dependency, and a sanity-
> > check phase that requires every dependency mentioned in
> > package.json to be met. Packagers would then outright delete
> > sanity-check as they do for python and as they did for configure
> > (but not have configure fail due to it!)
> > or deliberately rewrite the package.json for the sanity check and
> > dropping absent dependencies, i.e. what you do minus the keyword.
> > If later needed for the purposes of an importer, we would then
> > still have that database and could at some point introduce the key
> > #:insane-requirements. WDYT?
>
> I don't understand the benefit of this, and I'm also confused about
> the proposed implementation specifics. Why even have "a configure
> phase that does nothing"? What phase would run `npm install`?
> Presumably, we would have to delete all missing dependencies before
> that.
I meant "does nothing" in the sense of "does nothing with missing
dependencies", i.e. does not even warn. It would of course still run
npm whatever.
On that note, I did typo there, so it would be patch-dependencies. So
patch-dependencies would be implemented using and=> or and-let* to
decide whether to patch an entry or not.
Another implementation of the sanity check phase would be to read the
package json once more as we already do for patch-dependencies, but
this time only to check that we have an input that provides it. The
benefit of doing that would the same as the strict/warn switch from
before, but without adding a new keyword at all. The downside would be
that it still invites (delete 'sanity-check) without the comments we'd
tend to write around #:tests? #f.
> I think there is room for improvement in node-build-system. One thing
> I've been thinking about is some articles I've seen (but not fully
> thought through yet) from the developers of PNPM, an alternative
> package manager for Node.js, which seems to have some similarities to
> Guix in symlinking things to a "store".[1][2][3] (It could be
> especially interesting for bootstrapping npm! And the approach to
> "monorepos" also seems relevant.) I also think an importer is very
> important, even if it's an imperfect one: `guix import npm-binary`
> was indispensable in developing these patches. I have some ideas
> about improving it, in particular that we should assume the newer "^"
> semantics for dependencies everywhere (i.e. that major versions and
> only major versions have incompatible changes: a common case recently
> seems to be moving from CommonJS modules to ES6 modules).
>
> As I understand it, node-build-system is undocumented, with no
> guarantees of compatibility. If #:absent-dependencies is at least an
> improvement over the status quo---which I think it is, since the new
> packages wouldn't build with the status quo---could we apply this and
> replace it later if someone implements a better strategy? I don't
> think I can implement control-flow analysis for JavaScript within the
> scope of this patch series.
It's sadly not that easy. See XKCD 1172.
Given the reality of XKCD 1172, I do think that implementing a sanity-
check phase that checks for existence of all packages is the sanest
option here, together with safeguarding against missing dependencies in
patch-dependencies. Does that sound reasonable to everyone else here?
Cheers
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument.
2021-12-18 20:49 ` Liliana Marie Prikler
@ 2021-12-18 22:55 ` Philip McGrath
2021-12-19 1:02 ` Liliana Marie Prikler
0 siblings, 1 reply; 458+ messages in thread
From: Philip McGrath @ 2021-12-18 22:55 UTC (permalink / raw)
To: Liliana Marie Prikler, Timothy Sample; +Cc: 51838, Pierre Langlois, Jelle Licht
Hi,
On 12/18/21 15:49, Liliana Marie Prikler wrote:
> Hi,
>
> Am Samstag, dem 18.12.2021 um 13:31 -0500 schrieb Philip McGrath:
>> I also feel like I'm missing something, though maybe I just disagree.
>>
>> To try to be concrete, here's a real example. Between v3 and v4 of
>> this patch series, I discovered that leaving out node-debug could
>> actually cause runtime problems for some of the node-serialport
>> packages. (It turns out it's really a logging library, which wasn't
>> what I'd thought at first.) After I added the node-debug, I could
>> easily search node-xyz.scm for the packages that listed it among
>> their #:absent-dependencies and add it to them as an input.
> Wouldn't we get a huge stack trace of doom with the failed require in
> that case if it was truly non-negotiable, though?
>
>> It seems like this would be much less convenient if node-build-system
>> were to silently delete such dependencies and simply print a warning.
>> I guess I would have to search through the build logs for all Node.js
>> packages, right?
> Since node packages do have the tendency to pull in the entire
> internet, you might not be too far off with that statement, but again
> if you have a particular issue in a single package due to an omitted
> dependency, the offending package ought to be close to the most recent
> call on the stack.
I think this is part of where our expectations are diverging, because I
think the failure mode for CommonJS require (ES6 import may be at least
somewhat better) is much less clean than this seems to suggest.
Returning to my concrete example, my motivation for this has been trying
to set up a Guix System service to run the Webthings Gateway (formerly
Mozilla IoT).[1] (Currently I have it on a branch of my Guix fork at
[2]; since there are many yacks left to shave before it could be
upstreamed, I plan to turn it into a channel once it can build against
Guix master, i.e. once this patch series is applied.) I discovered the
problem with the missing node-debug only when webthings-service caused
webthings-gateway to load webthings-addon-zwave-adapter at runtime.
(Those are both node-build-system packages, but there are also
webthings-addon-* packages in Python and Rust, and in principle any
language could be used.) The webthings-addon-zwave-adapter has
node-serialport as a package.json dependency. As I remember it, even
then, the lack of node-debug only caused a runtime error on a certain
code path, perhaps triggered by the presence or absence of Z-Wave
adapter hardware: I had used all of the packages without problems before
hitting the issue. There was a stack trace, and it did help somewhat,
but it was immensely helpful to be able to find in node-xyz.scm all of
the packages that wanted, but did not have, node-debug. I imagine it
would be even more useful in a more tangled dependency graph.
In particular, we don't have any JavaScript test frameworks packaged for
Guix yet, so most of the time we aren't actually running the code in our
Node.js packages, just putting the right files in the right places. So
the runtime error may not come until some application/tool has been
created, potentially very far along the dependency graph, and may not be
revealed by tests (that we can actually run) at all.
I think we should optimize for the kind of high-quality packages we
aspire to have in mainline Guix, where eventually we hope to have all
sufficiently useful libre Node.js packages available. In that case,
#:absent-dependencies makes it explicit when Guix packagers are
overriding an upstream decision. While we work to achieve that reality,
I think #:absent-dependencies is a much better place for a to-do list
than having to search build logs or source "package.json"s. However ...
>
> An alternative to searching through the build logs would also be to
> build all the sources and grepping their package.jsons ;)
>
>> More generally, I think truly "optional dependencies" (in the Node.js
>> sense, to the extent I understand it) and dependencies we actively
>> don't want (e.g. because node-sqlite3 shouldn't transitively depend
>> on node-aws-sdk) are relatively rare cases.
>>
>> The most common cases seem to be dependencies we really would like to
>> have, such as test frameworks or Typescript, but haven't packaged
>> yet, and thus need to work around. Many packages that have
>> #:absent-dependencies for such reasons also need to use `#:tests? #f`
>> or to replace the build phase with some kind of manual alternative.
>>
>> I guess I don't understand what case the warn-and-drop approach is
>> optimizing for. For both the case when dependencies aren't packaged
>> for Guix yet and the case when Guix packagers have actively decided
>> to skip some upstream dependencies, I think #:absent-dependencies is
>> more useful. Having to look for that information in warnings in the
>> build log seems much less ergonomic.
> That's why my original suggestion was to have a switch between "strict"
> meaning we fail as before and "warn" meaning "we know we have unmet
> dependencies". The "warn" case would be annotated similar to #:tests?
> #f and the strict case default. So you could still communicate
> important missing packages like typescript et al., but people who hack
> on their own channels with lower standards can wing it without having
> to delete configure.
I can see the use of a "warn" mode for hacking things together quickly
without having to totally delete configure. I think this could coexist
with #:absent-dependencies and could be done in a follow-on to this
patch series.
Right now, the #:absent-dependencies argument must be a list of strings.
To support a "warn" mode, we could loosen that contract a bit: we can
bikeshed about details, but let's say that we're in "warn" mode if the
list contains the symbol 'infer. We change this code:
---
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
to do something like this:
--8<---------------cut here---------------start------------->8---
(if (or (member key absent-dependencies)
(and (memq 'infer absent-dependencies)
(not (hash-ref index key #f))))
acc
(acons key (hash-ref index key value) acc))
--8<---------------cut here---------------end--------------->8---
Would that meet your objective?
>> Also, currently node-build-system doesn't seem to be removing those
>> files which `npm pack` is supposed to exclude, which would probably
>> be a prerequisite for addressing this.
> For the record, which files would that be? Could we do emacs-build-
> system style #:include and #:exclude lists?
It at least includes files listed in ".npmignore", but I think there are
entries in "package.json" that control the behavior, too. We should
adjust our repack phase to ignore those files---but I, at least, would
need to look into it further to know exactly what the correct behavior is.
>> I think there is room for improvement in node-build-system. One thing
>> I've been thinking about is some articles I've seen (but not fully
>> thought through yet) from the developers of PNPM, an alternative
>> package manager for Node.js, which seems to have some similarities to
>> Guix in symlinking things to a "store".[1][2][3] (It could be
>> especially interesting for bootstrapping npm! And the approach to
>> "monorepos" also seems relevant.) I also think an importer is very
>> important, even if it's an imperfect one: `guix import npm-binary`
>> was indispensable in developing these patches. I have some ideas
>> about improving it, in particular that we should assume the newer "^"
>> semantics for dependencies everywhere (i.e. that major versions and
>> only major versions have incompatible changes: a common case recently
>> seems to be moving from CommonJS modules to ES6 modules).
>>
>> As I understand it, node-build-system is undocumented, with no
>> guarantees of compatibility. If #:absent-dependencies is at least an
>> improvement over the status quo---which I think it is, since the new
>> packages wouldn't build with the status quo---could we apply this and
>> replace it later if someone implements a better strategy? I don't
>> think I can implement control-flow analysis for JavaScript within the
>> scope of this patch series.
> It's sadly not that easy. See XKCD 1172.
Certainly that's true in general, but I thought this warning from [3]
would apply here:
When you maintain package definitions outside Guix, we, Guix
developers, consider that *the compatibility burden is on you.*
Remember that package modules and package definitions are just
Scheme code that uses various programming interfaces (APIs). We
want to remain free to change these APIs to keep improving Guix,
possibly in ways that break your channel. We never change APIs
gratuitously, but we will *not* commit to freezing APIs either.
-Philip
[1]: https://webthings.io/
[2]: https://gitlab.com/philip1/guix-patches/-/tree/wip-webthings
[3]: https://guix.gnu.org/manual/devel/en/html_node/Creating-a-Channel.html
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument.
2021-12-18 22:55 ` Philip McGrath
@ 2021-12-19 1:02 ` Liliana Marie Prikler
2021-12-20 19:33 ` Philip McGrath
0 siblings, 1 reply; 458+ messages in thread
From: Liliana Marie Prikler @ 2021-12-19 1:02 UTC (permalink / raw)
To: Philip McGrath, Timothy Sample; +Cc: 51838, Pierre Langlois, Jelle Licht
Am Samstag, dem 18.12.2021 um 17:55 -0500 schrieb Philip McGrath:
> [T]he failure mode for CommonJS require (ES6 import may be at least
> somewhat better) is much less clean than this seems to suggest.
I think the less I know about JavaScript, the better I'll sleep at
night.
> Returning to my concrete example, my motivation for this has been
> trying to set up a Guix System service to run the Webthings Gateway
> (formerly Mozilla IoT).[1] (Currently I have it on a branch of my Guix
> fork at [2]; since there are many yacks left to shave before it could
> be upstreamed, I plan to turn it into a channel once it can build
> against Guix master, i.e. once this patch series is applied.) I
> discovered the problem with the missing node-debug only when webthings-
> service caused webthings-gateway to load webthings-addon-zwave-adapter
> at runtime.
> (Those are both node-build-system packages, but there are also
> webthings-addon-* packages in Python and Rust, and in principle any
> language could be used.) The webthings-addon-zwave-adapter has
> node-serialport as a package.json dependency. As I remember it, even
> then, the lack of node-debug only caused a runtime error on a certain
> code path, perhaps triggered by the presence or absence of Z-Wave
> adapter hardware: I had used all of the packages without problems
> before hitting the issue. There was a stack trace, and it did help
> somewhat, but it was immensely helpful to be able to find in node-
> xyz.scm all of the packages that wanted, but did not have, node-debug.
> I imagine it would be even more useful in a more tangled dependency
> graph.
That might be beneficial in your particular use case here, but you also
have to think about the maintenance burden your mechanism introduces.
What if another leftpad happens and we have to speedrun our core-
updates cycle to add #:absent-dependencies everywhere?
> In particular, we don't have any JavaScript test frameworks packaged
> for Guix yet, so most of the time we aren't actually running the code
> in our Node.js packages, just putting the right files in the right
> places. So the runtime error may not come until some application/tool
> has been created, potentially very far along the dependency graph, and
> may not be revealed by tests (that we can actually run) at all.
The fix to not having test frameworks is adding them, not
> I think we should optimize for the kind of high-quality packages we
> aspire to have in mainline Guix, where eventually we hope to have all
> sufficiently useful libre Node.js packages available. In that case,
> #:absent-dependencies makes it explicit when Guix packagers are
> overriding an upstream decision. While we work to achieve that reality,
> I think #:absent-dependencies is a much better place for a to-do list
> than having to search build logs or source "package.json"s. However...
Compare this to tests. We have a keyword to disable all tests, which
defaults to #f and we have other idioms for disabling particular tests.
Your use case is no different. If at all, we should only have a
keyword to disable the check completely and other idioms to e.g. patch
the package.json file so that sanity-check/patch-dependencies/what-
have-you doesn't error when it relies on its contents.
> I can see the use of a "warn" mode for hacking things together quickly
> without having to totally delete configure. I think this could coexist
> with #:absent-dependencies and could be done in a follow-on to this
> patch series.
>
> Right now, the #:absent-dependencies argument must be a list of
> strings. To support a "warn" mode, we could loosen that contract a bit:
> we can bikeshed about details, but let's say that we're in "warn" mode
> if the list contains the symbol 'infer. We change this code:
>
> ---
>
> 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))))
>
> to do something like this:
>
> --8<---------------cut here---------------start------------->8---
> (if (or (member key absent-dependencies)
> (and (memq 'infer absent-dependencies)
> (not (hash-ref index key #f))))
> acc
> (acons key (hash-ref index key value) acc))
> --8<---------------cut here---------------end--------------->8---
You're actively making the code that resolves dependencies worse to
look at only to keep the keyword. Don't. There are tools besides a
hammer.
> Would that meet your objective?
No. As I repeatedly pointed out, I want either no keyword addition for
this "feature" or a keyword that can be regarded as essentially boolean
if not outright implemented as one.
Reading this again, the existing lines already do what I want (hash-ref
index key value) spits out value as a default if key is not found. So
the solution is to not touch patch-dependencies at all; we don't have
to abuse a function that's not meant for sanity checking to check
sanity.
> It at least includes files listed in ".npmignore", but I think there
> are entries in "package.json" that control the behavior, too. We should
> adjust our repack phase to ignore those files---but I, at least, would
> need to look into it further to know exactly what the correct behavior
> is.
Fair enough, that is probably out of scope for now, but we should
revisit it before importing the node world and changing node-build-
system becomes a core-updates task.
> We never change APIs gratuitously.
In my personal opinion, #:absent-dependencies would be a gratuitous
change in API. There's no need to have this in the build system. We
should rather look into ways that make it possible/easy for users to
patch the package.json file between unpack and configure.
This also calls back to my earlier point of the assoc-set! being out of
place, which itself is also a manifestation of node-build-system not
exposing adequate primitives towards rewriting essential files. For
instance, the procedure
(lambda (file proc)
(with-atomic-file-replacement file
(lambda (in out)
(write-json (proc (read-json in))))))
would probably deserve its own name and export from node-build-system.
Yes, you can export utility procedures from (guix build *-build-
system), look at the Emacs and Python build systems for example.
With this in place, we both get to have our cakes and eat it too.
There would be no keyword added, and package maintainers would drop
"absent" dependencies in a phase like so
(add-after 'unpack 'drop-dependencies
(lambda _
(with-atomic-json-replacement "package.json"
(lambda (json)
(map (match-lambda
(('dependencies '@ . DEPENDENCIES)
(filter away unwanted dependencies))
(('devDependencies '@ . DEPENDENCIES)
(same))
(otherwise otherwise))
json)))))
Of course, if that's too verbose, you can also expose that as a
function from node-build-system. Then all we'd have to bikeshed is the
name, which would be comparatively simple.
Does that sound like a reasonable plan to you?
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument.
2021-12-19 1:02 ` Liliana Marie Prikler
@ 2021-12-20 19:33 ` Philip McGrath
2021-12-20 20:15 ` Timothy Sample
2021-12-20 21:50 ` [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument Liliana Marie Prikler
0 siblings, 2 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-20 19:33 UTC (permalink / raw)
To: Liliana Marie Prikler, Timothy Sample; +Cc: 51838, Pierre Langlois, Jelle Licht
Hi,
On 12/18/21 20:02, Liliana Marie Prikler wrote:
> Am Samstag, dem 18.12.2021 um 17:55 -0500 schrieb Philip McGrath:
>> somewhat, but it was immensely helpful to be able to find in node-
>> xyz.scm all of the packages that wanted, but did not have, node-debug.
>> I imagine it would be even more useful in a more tangled dependency
>> graph.
> That might be beneficial in your particular use case here, but you also
> have to think about the maintenance burden your mechanism introduces.
> What if another leftpad happens and we have to speedrun our core-
> updates cycle to add #:absent-dependencies everywhere?
I don't understand the scenario you have in mind here.
As I remember/understand the left-pad debacle, the package was deleted
from the NPM registry by its author. I don't understand how that would
require changes to Guix package definitions. Hopefully, Software
Heritage would save the day. Perhaps Guix would choose to provide an
alternate, compatible package implementing that single, trivial
function, but we could do that by just changing the definition of the
hypothetical Scheme variable `node-left-pad`. Eventually, downstream
packages would presumably make changes, but we'd have to address those
changes anyway when updating those packages.
Even if I assume a scenario that is going to be fixed by removing a
hypothetical `node-left-pad` packages from all the packages to which it
is an input, that would change O(n) lines of code: having to change
#:absent-dependencies in all cases would just be O(2n) lines, which
doesn't seem prohibitive. Indeed, I think I would be glad to have an
entry in #:absent-dependencies in such a case, communicating explicitly
in the Guix repository that the package was affected and Guix packagers
adopted a workaround. If I'm later updating the package, I can check to
see if the workaround is still needed or if upstream has dropped
node-left-pad. In any case, I much prefer to have this written
explicitly in code in the Guix repository, rather than relying on
external mechanisms like build logs and upstream source files.
Additionally, I think the use case I encountered with node-debug is
likely to come up fairly often. For example, someone might notice that a
lot of packages use `node-tap` for testing, package it for Guix, and
then want to find all of the downstream packages to which to add it and
enable tests.
>> I think we should optimize for the kind of high-quality packages we
>> aspire to have in mainline Guix, where eventually we hope to have all
>> sufficiently useful libre Node.js packages available. In that case,
>> #:absent-dependencies makes it explicit when Guix packagers are
>> overriding an upstream decision. While we work to achieve that reality,
>> I think #:absent-dependencies is a much better place for a to-do list
>> than having to search build logs or source "package.json"s. However...
> Compare this to tests. We have a keyword to disable all tests, which
> defaults to #f and we have other idioms for disabling particular tests.
> Your use case is no different. If at all, we should only have a
> keyword to disable the check completely and other idioms to e.g. patch
> the package.json file so that sanity-check/patch-dependencies/what-
> have-you doesn't error when it relies on its contents.
I don't mean to be dense, but I feel like I'm missing something. I
assume the reason we don't have a declarative, high-level mechanism for
disabling specific tests is that there isn't a general convention for
doing that, AFAIK. We do have `#:configure-flags`, which can be used to
pass things like `--disable-whatever`, even though, in principle, that
could be done by replacing the configure phase. I see
#:absent-dependencies as similar: it provides, IMO, a readable,
declarative mechanism to make a commonly-needed adjustment to the
behavior of the patch-dependencies phase.
>> I can see the use of a "warn" mode for hacking things together quickly
>> without having to totally delete configure. I think this could coexist
>> with #:absent-dependencies and could be done in a follow-on to this
>> patch series.
>> --8<---------------cut here---------------start------------->8---
>> (if (or (member key absent-dependencies)
>> (and (memq 'infer absent-dependencies)
>> (not (hash-ref index key #f))))
>> acc
>> (acons key (hash-ref index key value) acc))
>> --8<---------------cut here---------------end--------------->8---
> You're actively making the code that resolves dependencies worse to
> look at only to keep the keyword. Don't. There are tools besides a
> hammer.
>
>> Would that meet your objective?
> No. As I repeatedly pointed out, I want either no keyword addition for
> this "feature" or a keyword that can be regarded as essentially boolean
> if not outright implemented as one.
>
> Reading this again, the existing lines already do what I want (hash-ref
> index key value) spits out value as a default if key is not found. So
> the solution is to not touch patch-dependencies at all; we don't have
> to abuse a function that's not meant for sanity checking to check
> sanity.
To clarify, I thought you wanted `node-build-system` to issue a warning
and drop dependencies not supplied as package inputs. Is that correct?
In the existing code, if `key` is not found and `value` is returned, the
configure phase (i.e. `npm install`) will always fail. (The name
`patch-dependencies` may be a little vague about the actual purpose of
this phase.)
>> We never change APIs gratuitously.
> In my personal opinion, #:absent-dependencies would be a gratuitous
> change in API. There's no need to have this in the build system. We
> should rather look into ways that make it possible/easy for users to
> patch the package.json file between unpack and configure.
I don't think adding #:absent-dependencies is a breaking change in the
API at all. Any package that builds currently should continue to build
with #:absent-dependencies support added, and indeed with this entire
patch series.
> This also calls back to my earlier point of the assoc-set! being out of
> place, which itself is also a manifestation of node-build-system not
> exposing adequate primitives towards rewriting essential files. For
> instance, the procedure
>
> (lambda (file proc)
> (with-atomic-file-replacement file
> (lambda (in out)
> (write-json (proc (read-json in))))))
>
> would probably deserve its own name and export from node-build-system.
> Yes, you can export utility procedures from (guix build *-build-
> system), look at the Emacs and Python build systems for example.
I do agree that we should provide more utilities for transforming
"package.json" in general ways. It would be nice to make such
transformations at least as convenient as more fragile ones using
`substitute*`. But, as I wrote earlier, that seems out of scope for this
patch series.
>
> With this in place, we both get to have our cakes and eat it too.
> There would be no keyword added, and package maintainers would drop
> "absent" dependencies in a phase like so
>
> (add-after 'unpack 'drop-dependencies
> (lambda _
> (with-atomic-json-replacement "package.json"
> (lambda (json)
> (map (match-lambda
> (('dependencies '@ . DEPENDENCIES)
> (filter away unwanted dependencies))
> (('devDependencies '@ . DEPENDENCIES)
> (same))
> (otherwise otherwise))
> json)))))
>
> Of course, if that's too verbose, you can also expose that as a
> function from node-build-system. Then all we'd have to bikeshed is the
> name, which would be comparatively simple.
>
> Does that sound like a reasonable plan to you?
I'm not sure how to proceed here.
I still think the #:absent-dependencies keyword, with or without a
"warn" mode, is the best approach. It has sounded like others on this
thread also liked the approach, though I don't want to speak for anyone
but myself.
I can understand that you would prefer a different approach. I can see
how a warn-and-ignore could be useful in some cases. My last proposal
was an attempt at a compromise, showing how adding #:absent-dependencies
would not preclude adding support for a warn-and-ignore mode later.
But the impression I'm getting is that you think the
#:absent-dependencies approach would be not merely sub-optimal but
actively harmful, and, if that is indeed your view, I feel like I'm
still failing to understand what the harm is.
If we took your final suggestion above, I think we'd have something like
this:
```
#:phases
(modify-phases %standard-phases
(add-after 'unpack 'delete-dependencies
(make-delete-dependencies-phase '("node-tap"))))
```
That seems pretty similar to, under the current patch series:
```
#:absent-dependencies '("node-tap")
```
I can see pros and cons to both approaches. I still like
`#:absent-dependencies` better, as I find it less verbose, more
declarative, ... trade-offs we probably don't need to rehash further.
But it sounds like you see a huge, prohibitive downside to
`#:absent-dependencies`, and I am just not managing to see what that is.
I don't know what further steps to take to resolve this disagreement or
how some decision ultimately gets made.
More broadly, I agree with you that the current `node-build-system` has
some ugly code and is missing some useful utility functions. But I don't
feel like I can address all of those preexisting issues in the scope of
this patch series, which has already become somewhat unwieldy.
Maybe someone else could weigh in on how to proceed?
-Philip
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument.
2021-12-20 19:33 ` Philip McGrath
@ 2021-12-20 20:15 ` Timothy Sample
2021-12-20 22:00 ` Liliana Marie Prikler
2021-12-20 21:50 ` [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument Liliana Marie Prikler
1 sibling, 1 reply; 458+ messages in thread
From: Timothy Sample @ 2021-12-20 20:15 UTC (permalink / raw)
To: Philip McGrath; +Cc: 51838, Pierre Langlois, Jelle Licht, Liliana Marie Prikler
Hi Philip,
Philip McGrath <philip@philipmcgrath.com> writes:
> If we took your final suggestion above, I think we'd have something
> like this:
>
> ```
> #:phases
> (modify-phases %standard-phases
> (add-after 'unpack 'delete-dependencies
> (make-delete-dependencies-phase '("node-tap"))))
> ```
I’m perfectly happy with this if it’s a compromise we all can agree on.
It is exactly what popped into my imagination when I read Liliana’s
suggestion. I guess the one thing missing is that it would not
necessarily be implemented on top of better “package.json” manipulation
support. That said, it doesn’t preclude providing that support if/when
the need arises.
> I don't know what further steps to take to resolve this disagreement
> or how some decision ultimately gets made.
>
> Maybe someone else could weigh in on how to proceed?
I’m probably not “someone else” enough at this point, but I guess we can
ask the maintainers to weigh in/help facilitate. We try to move forward
by consensus, and maybe replacing the keyword with a phase-making
procedure will get us there. Liliana, what do you say? Have we found
an approach we can agree on? If not, I think that we’re probably stuck
and will need some fresh voices to move forward.
-- Tim
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument.
2021-12-20 20:15 ` Timothy Sample
@ 2021-12-20 22:00 ` Liliana Marie Prikler
2021-12-21 3:59 ` Philip McGrath
0 siblings, 1 reply; 458+ messages in thread
From: Liliana Marie Prikler @ 2021-12-20 22:00 UTC (permalink / raw)
To: Timothy Sample, Philip McGrath; +Cc: 51838, Pierre Langlois, Jelle Licht
Hi Timothy,
Am Montag, dem 20.12.2021 um 15:15 -0500 schrieb Timothy Sample:
> Hi Philip,
>
> Philip McGrath <philip@philipmcgrath.com> writes:
>
> > If we took your final suggestion above, I think we'd have something
> > like this:
> >
> > ```
> > #:phases
> > (modify-phases %standard-phases
> > (add-after 'unpack 'delete-dependencies
> > (make-delete-dependencies-phase '("node-tap"))))
> > ```
>
> I’m perfectly happy with this if it’s a compromise we all can agree on.
> It is exactly what popped into my imagination when I read Liliana’s
> suggestion. I guess the one thing missing is that it would not
> necessarily be implemented on top of better “package.json”
> manipulation support. That said, it doesn’t preclude providing that
> support if/when the need arises.
In my personal opinion, we would write that support first and perhaps
the shorthands later. I.e.
(add-after 'patch-dependencies 'drop-junk
(lambda _
(with-atomic-json-replacement "package.json"
(lambda (json) (delete-dependencies json '("node-tap"))))))
although delete-dependencies could even be some chain of alist
rewriting procedures if we wanted to be super evil.
I don't think we would need to generate phases through FP, we can write
them as code.
> > I don't know what further steps to take to resolve this
> > disagreement or how some decision ultimately gets made.
> >
> > Maybe someone else could weigh in on how to proceed?
>
> I’m probably not “someone else” enough at this point, but I guess we
> can ask the maintainers to weigh in/help facilitate. We try to move
> forward by consensus, and maybe replacing the keyword with a phase-
> making procedure will get us there. Liliana, what do you say? Have
> we found an approach we can agree on? If not, I think that we’re
> probably stuck and will need some fresh voices to move forward.
I personally think phase making is out of scope and we need a solid
foundation first. That said, if Philip does provide both that
foundation and a good reason to have a phase-making procedure, I'm
willing to strike a compromise.
Cheers
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument.
2021-12-20 22:00 ` Liliana Marie Prikler
@ 2021-12-21 3:59 ` Philip McGrath
2021-12-21 5:20 ` Liliana Marie Prikler
0 siblings, 1 reply; 458+ messages in thread
From: Philip McGrath @ 2021-12-21 3:59 UTC (permalink / raw)
To: Liliana Marie Prikler, Timothy Sample; +Cc: 51838, Pierre Langlois, Jelle Licht
Hi all,
On 12/20/21 17:00, Liliana Marie Prikler wrote:
> Hi Timothy,
>
> Am Montag, dem 20.12.2021 um 15:15 -0500 schrieb Timothy Sample:
>> Hi Philip,
>>
>> Philip McGrath <philip@philipmcgrath.com> writes:
>>
>>> If we took your final suggestion above, I think we'd have something
>>> like this:
>>>
>>> ```
>>> #:phases
>>> (modify-phases %standard-phases
>>> (add-after 'unpack 'delete-dependencies
>>> (make-delete-dependencies-phase '("node-tap"))))
>>> ```
>>
>> I’m perfectly happy with this if it’s a compromise we all can agree on.
>> It is exactly what popped into my imagination when I read Liliana’s
>> suggestion. I guess the one thing missing is that it would not
>> necessarily be implemented on top of better “package.json”
>> manipulation support. That said, it doesn’t preclude providing that
>> support if/when the need arises.
> In my personal opinion, we would write that support first and perhaps
> the shorthands later.
I could live with the above as a compromise.
My reservation regarding:
>
> (add-after 'patch-dependencies 'drop-junk
> (lambda _
> (with-atomic-json-replacement "package.json"
> (lambda (json) (delete-dependencies json '("node-tap"))))))
>
is that `with-atomic-json-replacement` would make (guix build json)'s
representation a part of node-build-system's API, which it currently is
not. For the reasons I detailed in my last email, I think that would
open up a larger can of worms than it might seem.
Liliana, I'm not entirely certain, but my impression from:
>> I’m probably not “someone else” enough at this point, but I guess we
>> can ask the maintainers to weigh in/help facilitate. We try to move
>> forward by consensus, and maybe replacing the keyword with a phase-
>> making procedure will get us there. Liliana, what do you say? Have
>> we found an approach we can agree on? If not, I think that we’re
>> probably stuck and will need some fresh voices to move forward.
> I personally think phase making is out of scope and we need a solid
> foundation first. That said, if Philip does provide both that
> foundation and a good reason to have a phase-making procedure, I'm
> willing to strike a compromise.
was that you would still have objections to something like:
>>> ```
>>> #:phases
>>> (modify-phases %standard-phases
>>> (add-after 'unpack 'delete-dependencies
>>> (make-delete-dependencies-phase '("node-tap"))))
>>> ```
unless it came together with code like `with-atomic-json-replacement`
for more general "package.json" transformations.
If that's the case, then I guess we should do as Jelle suggests:
On 12/20/21 18:10, Jelle Licht wrote:
> I believe the best thing to do would be to push the earlier
> uncontroversial node patches.
>
> Perhaps we can get some of the gurus/victims of other build systems
> involved on guix-devel as none of the fundamental issues you've been
> talking about for a while are node-specific. As long as we want to reach
> some kind on consensus, I believe writing/reviewing more code does not
> get us to a desirable outcome at this time.
>
> - Jelle
>
-Philip
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument.
2021-12-21 3:59 ` Philip McGrath
@ 2021-12-21 5:20 ` Liliana Marie Prikler
2021-12-21 18:25 ` Philip McGrath
0 siblings, 1 reply; 458+ messages in thread
From: Liliana Marie Prikler @ 2021-12-21 5:20 UTC (permalink / raw)
To: Philip McGrath, Timothy Sample; +Cc: 51838, Pierre Langlois, Jelle Licht
Hi,
excuse my brevity, but I'll be off to work soon.
Am Montag, dem 20.12.2021 um 22:59 -0500 schrieb Philip McGrath:
> My reservation regarding:
>
> >
> > (add-after 'patch-dependencies 'drop-junk
> > (lambda _
> > (with-atomic-json-replacement "package.json"
> > (lambda (json) (delete-dependencies json '("node-tap"))))))
> >
>
> is that `with-atomic-json-replacement` would make (guix build json)'s
> representation a part of node-build-system's API, which it currently
> is not. For the reasons I detailed in my last email, I think that
> would open up a larger can of worms than it might seem.
That might be a valid concern, but I'd point to the "we don't
gratuitously change API" shield. Plus if we do, we'd replace our
current JSON by Guile-JSON. If that has a different internal
representation that would awfully break things, please do tell.
> I guess we should do as Jelle suggests:
>
> On 12/20/21 18:10, Jelle Licht wrote:
> > I believe the best thing to do would be to push the earlier
> > uncontroversial node patches.
> >
> >[...]
I did suggest that too, but note that it would only upsteam patches 1-4
of 45, as patch 5 already touches node-build-system.
Patch 5 would probably be fine to go as well (can the others confirm
that?), but if the goal is to push today, someone else will have to do
it, as I'll be only back at night.
Cheers
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument.
2021-12-21 5:20 ` Liliana Marie Prikler
@ 2021-12-21 18:25 ` Philip McGrath
2021-12-21 20:44 ` Liliana Marie Prikler
0 siblings, 1 reply; 458+ messages in thread
From: Philip McGrath @ 2021-12-21 18:25 UTC (permalink / raw)
To: Liliana Marie Prikler, Timothy Sample; +Cc: 51838, Pierre Langlois, Jelle Licht
Hi,
On 12/21/21 00:20, Liliana Marie Prikler wrote:
> Hi,
>
> excuse my brevity, but I'll be off to work soon.
>
> Am Montag, dem 20.12.2021 um 22:59 -0500 schrieb Philip McGrath:
>> My reservation regarding:
>>
>>>
>>> (add-after 'patch-dependencies 'drop-junk
>>> (lambda _
>>> (with-atomic-json-replacement "package.json"
>>> (lambda (json) (delete-dependencies json '("node-tap"))))))
>>>
>>
>> is that `with-atomic-json-replacement` would make (guix build json)'s
>> representation a part of node-build-system's API, which it currently
>> is not. For the reasons I detailed in my last email, I think that
>> would open up a larger can of worms than it might seem.
> That might be a valid concern, but I'd point to the "we don't
> gratuitously change API" shield. Plus if we do, we'd replace our
> current JSON by Guile-JSON. If that has a different internal
> representation that would awfully break things, please do tell.
Here are, to the best of my understanding, the differences in
representation among (guix build json) and the three versions of
guile-json packaged in Guix. (For guile-json, this is based on my
relatively-quick reading of the docs, not any direct experience.) An
extra complication is that some part of Guix's code staging seems to
incorrectly turn #nil into '(). I will see if I can narrow that down and
file a bug report.
(guix build json):
• object -> (Pairof '@ (Listof (Pairof String Json)))
• array -> (Listof Json)
• null -> #nil
• string -> String
guile-json-4:
• object -> (Listof (Pairof (U Symbol Number String) Json))
• array -> (Vectorof Json)
• null -> 'null ;; configurable by keyword argument
• string -> (U Symbol String)
guile-json-3:
• object -> (Listof (Pairof (U Symbol Number String) Json))
• array -> (Vectorof Json)
• null -> #nil
• string -> (U Symbol String)
guile-json-1:
• object -> (U (HashTable (U Symbol String) Json)
(Listof (Pairof (U Symbol String) Json)))
• array -> (Listof Json)
• null -> #nil
• string -> (U Symbol String)
-Philip
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument.
2021-12-21 18:25 ` Philip McGrath
@ 2021-12-21 20:44 ` Liliana Marie Prikler
2021-12-23 4:41 ` Philip McGrath
2021-12-23 5:19 ` Philip McGrath
0 siblings, 2 replies; 458+ messages in thread
From: Liliana Marie Prikler @ 2021-12-21 20:44 UTC (permalink / raw)
To: Philip McGrath, Timothy Sample; +Cc: 51838, Pierre Langlois, Jelle Licht
Hi,
Am Dienstag, dem 21.12.2021 um 13:25 -0500 schrieb Philip McGrath:
> Here are, to the best of my understanding, the differences in
> representation among (guix build json) and the three versions of
> guile-json packaged in Guix. (For guile-json, this is based on my
> relatively-quick reading of the docs, not any direct experience.) An
> extra complication is that some part of Guix's code staging seems to
> incorrectly turn #nil into '(). I will see if I can narrow that down
> and file a bug report.
>
> (guix build json):
> • object -> (Pairof '@ (Listof (Pairof String Json)))
> • array -> (Listof Json)
> • null -> #nil
> • string -> String
>
> guile-json-4:
> • object -> (Listof (Pairof (U Symbol Number String) Json))
> • array -> (Vectorof Json)
> • null -> 'null ;; configurable by keyword argument
> • string -> (U Symbol String)
>
> guile-json-3:
> • object -> (Listof (Pairof (U Symbol Number String) Json))
> • array -> (Vectorof Json)
> • null -> #nil
> • string -> (U Symbol String)
#nil to '() conversions are probably the fault of some syntax-case or
match expression. That being said, I hope we don't have to worry about
code staging too much as comparison ought to be done using null? imo.
I think the main difference between (guix build json) and guile-json
here are the extended keys in the latter (guix only has strings) and
the vector/object distinction. I think it'd be rather straight-forward
to write upgrade guidelines in case we ever make the switch.
Similarly, all rules based on pattern-matching *will break*, forcing us
to upgrade all the recipes with it. WDYT? Would that be manageable
(assuming the change to require Guile-JSON would already be core-
updates material)?
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument.
2021-12-21 20:44 ` Liliana Marie Prikler
@ 2021-12-23 4:41 ` Philip McGrath
2021-12-23 5:19 ` Philip McGrath
1 sibling, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-23 4:41 UTC (permalink / raw)
To: Liliana Marie Prikler, Timothy Sample; +Cc: 51838, Pierre Langlois, Jelle Licht
Hi,
On 12/21/21 15:44, Liliana Marie Prikler wrote:
> Am Dienstag, dem 21.12.2021 um 13:25 -0500 schrieb Philip McGrath:
>> An
>> extra complication is that some part of Guix's code staging seems to
>> incorrectly turn #nil into '(). I will see if I can narrow that down
>> and file a bug report.
>>
> #nil to '() conversions are probably the fault of some syntax-case or
> match expression. That being said, I hope we don't have to worry about
> code staging too much as comparison ought to be done using null? imo.
I've reported the problem with g-expressions here:
https://issues.guix.gnu.org/52749
In brief, the problem is that a Scheme value like:
'(@ ("k" . #nil))
ought to produce the JSON:
{"k":null}
but, if it is part of a g-expression, it instead produces:
{"k":[]}
-Philip
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument.
2021-12-21 20:44 ` Liliana Marie Prikler
2021-12-23 4:41 ` Philip McGrath
@ 2021-12-23 5:19 ` Philip McGrath
2021-12-23 18:12 ` Liliana Marie Prikler
1 sibling, 1 reply; 458+ messages in thread
From: Philip McGrath @ 2021-12-23 5:19 UTC (permalink / raw)
To: Liliana Marie Prikler, Timothy Sample; +Cc: 51838, Pierre Langlois, Jelle Licht
On 12/21/21 15:44, Liliana Marie Prikler wrote:
> Am Dienstag, dem 21.12.2021 um 13:25 -0500 schrieb Philip McGrath:
>> Here are, to the best of my understanding, the differences in
>> representation among (guix build json) and the three versions of
>> guile-json packaged in Guix.
> I think the main difference between (guix build json) and guile-json
> here are the extended keys in the latter (guix only has strings) and
> the vector/object distinction.
For guile-json-4, the representation of the JSON value "null" is also
different: #nil vs. the symbol 'null.
> I think it'd be rather straight-forward
> to write upgrade guidelines in case we ever make the switch.
> Similarly, all rules based on pattern-matching *will break*, forcing us
> to upgrade all the recipes with it. WDYT? Would that be manageable
> (assuming the change to require Guile-JSON would already be core-
> updates material)?
>
I actually might like (guix build json) better than guile-json-*! Using
vectors for arrays seems roughly awkward as tagged alists, especially if
Guile really doesn't have purely functional update procedures for
alists---and I sure can't find any---so we'd have to write a little
algebra of operations on JSON objects either way. But I'm not really
familiar with the pros and cons of each, and I don't know the context
behind the previous attempt to switch.
My concern is that someone, or several someones, probably should know
all of that context before exposing one representation or another as
part of node-build-system's API. As I've said, I think that's a
high-priority improvement! But it, and designing nice helper functions,
seem quite far removed from the core purpose of this patch series. Since
IMO #:absent-dependencies would still be The Right Thing even if those
utilities already existed, and since #:absent-dependencies can be
implemented without having to resolve any of the broader questions, I
think it would be better not to entangle them with this patch series.
Would it mitigate your concerns with #:absent-dependencies at all if I
send a separate patch series adding more general utilities based on
(guix build json)?
-Philip
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument.
2021-12-23 5:19 ` Philip McGrath
@ 2021-12-23 18:12 ` Liliana Marie Prikler
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
0 siblings, 1 reply; 458+ messages in thread
From: Liliana Marie Prikler @ 2021-12-23 18:12 UTC (permalink / raw)
To: Philip McGrath, Timothy Sample; +Cc: 51838, Pierre Langlois, Jelle Licht
Am Donnerstag, dem 23.12.2021 um 00:19 -0500 schrieb Philip McGrath:
> On 12/21/21 15:44, Liliana Marie Prikler wrote:
> > Am Dienstag, dem 21.12.2021 um 13:25 -0500 schrieb Philip McGrath:
> > > Here are, to the best of my understanding, the differences in
> > > representation among (guix build json) and the three versions of
> > > guile-json packaged in Guix.
> > I think the main difference between (guix build json) and guile-
> > json here are the extended keys in the latter (guix only has
> > strings) and the vector/object distinction.
>
> For guile-json-4, the representation of the JSON value "null" is also
> different: #nil vs. the symbol 'null.
Different, but configurable, i.e. you can make guile-json-4 return
#nil, which is what would be needed for the sake of compatibility.
>
> > I think it'd be rather straight-forward to write upgrade guidelines
> > in case we ever make the switch. Similarly, all rules based on
> > pattern-matching *will break*, forcing us to upgrade all the
> > recipes with it. WDYT? Would that be manageable (assuming the
> > change to require Guile-JSON would already be core-updates
> > material)?
> >
>
> I actually might like (guix build json) better than guile-json-*!
> Using vectors for arrays seems roughly awkward as tagged alists,
> especially if Guile really doesn't have purely functional update
> procedures for alists---and I sure can't find any---so we'd have to
> write a little algebra of operations on JSON objects either way. But
> I'm not really familiar with the pros and cons of each, and I don't
> know the context behind the previous attempt to switch.
I don't think there's been any. Note that Guix already uses guile-
json, just not at build side. I don't think there's only one reason
for this; of course we have the incompatibility, but guile-json would
probably also pull in much more into the build than would be needed in
most cases, so that's that.
For the medium/long term I do think guile-json will eventually go the
emacs-json route of making everything about its (de)serialization
configurable, which ought to ease the porting of guix build to it.
However, pointing at the API stability shield, I don't think we'll be
too hasty porting things over.
> My concern is that someone, or several someones, probably should know
> all of that context before exposing one representation or another as
> part of node-build-system's API. As I've said, I think that's a
> high-priority improvement! But it, and designing nice helper
> functions, seem quite far removed from the core purpose of this patch
> series.
You would only have to implement helper functions as needed, i.e. for
now just (with-atomic-json-replacement proc) and (delete-dependencies
json). My personal interpretation is that read-json/write-json are
already public Guix API and you can easily use them inside node-build-
system as-is (note: you do need to use-modules them, but it doesn't
require building another module closure), but perhaps someone else has
a different reading.
As for other helper functions, that might become useful over time,
those can be added as-needed.
> Since IMO #:absent-dependencies would still be The Right Thing even
> if those utilities already existed, and since #:absent-dependencies
> can be implemented without having to resolve any of the broader
> questions, I think it would be better not to entangle them with this
> patch series.
I agree, that we can both agree, that whatever we had in mind when
starting this discussion can be implemented without these primitives,
but I disagree on it being The Right Thing. Particularly, in the case
of #:absent-dependencies, simplicity and completeness are lacking,
whereas in my original suggestion correctness and completeness were
lacking.
For the record, I don't think we can get to The Right Thing without
exposing the JSON somehow. However, since you argue we can't, we need
to find a course of action, that will allow us to do The Right Thing
later.
I'm sadly a little out of options as I write this, but open to some
suggestions and perhaps I'll get another idea if I gaze at my navel for
some time.
> Would it mitigate your concerns with #:absent-dependencies at all if
> I send a separate patch series adding more general utilities based on
> (guix build json)?
That series would block this one in my opinion (aside from the node
changes, that could be done without it, but we're talking five patches
at most here and I plan to do them over the holidays). This would
sound like a good idea if you could wait for that discussion to be
resolved, but I fear that's not the case, is it?
Cheers
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp.
2021-12-23 18:12 ` Liliana Marie Prikler
@ 2021-12-30 7:38 ` Philip McGrath
2021-12-30 7:38 ` [bug#51838] [PATCH v6 01/41] guix: node-build-system: Add delete-lockfiles phase Philip McGrath
` (42 more replies)
0 siblings, 43 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:38 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
Hi Liliana (and everyone),
Thanks for taking care of the earlier patches from the series!
It sounds like (guix build json) is going to be around for a reasonably
long time, and I'm ok with that.
In the hope of clearing a path to move forward, I'm sending v6 of this
patch series, immediately followed by a closely-related v7: I strongly
prefer v7, but I would be ok with either version being applied if one of
them can achieve consensus. (If v6 is merged, I'll send a separate patch
series to propose '#:absent-dependencies'.)
I've put the two versions up on GitLab
as <https://gitlab.com/philip1/guix-patches/-/tags/guix-issue-51838-v6>
and <https://gitlab.com/philip1/guix-patches/-/tags/guix-issue-51838-v7>,
respectively.
I've re-organized the patches in the series somewhat to facilitate a
minimal, side-by-side comparison between '#:absent-dependencies' and this
approach:
On 12/20/21 17:00, Liliana Marie Prikler wrote:
> (add-after 'patch-dependencies 'drop-junk
> (lambda _
> (with-atomic-json-replacement "package.json"
> (lambda (json) (delete-dependencies json '("node-tap"))))))
The series is now organized as follows:
- The first 4 patches are identical in v6 and v7:
- Patches 01 & 02/41 are non-controversial build system changes
('delete-lockfiles' and libuv).
- Patch 03/41 adds to (guix build node-build-system) several utility
functions for transforming JSON in the representation used by (guix
build json), especially functional update of tagged JSON
objects. It also adjusts the rest of (guix build node-build-system)
to make use of those functions, eliminating all uses of
'assoc-set!' and other procedures that mutate assosciation lists.
Of the new functions, only 'with-atomic-json-file-replacement' is
exported for now: my hope is that further (valuable and important!)
discussion about the API design of these functions or their
implementations need not block either v6 or v7 of this series.
- Patch 04/41 adds the 'avoid-node-gyp-rebuild' phase. I've re-worked
the implementation to use the new helper functions.
- Patch 05/41 is the truly significant difference between v6 and v7: it
implements the strategy for dealing with missing dependencies.
In v6, it exports a new public function 'delete-dependencies' from
(guix build node-build-system).
In v7, it adds '#:absent-dependencies'. One difference from previous
versions of this series is that it handles '#:absent-dependencies' in a
new 'delete-dependencies' phase, which makes the change even more
self-contained.
- Patches 06 through 17/41 adjust existing packages to make use of the
approach to missing dependencies from patch 05/41 of each series.
- Patches 18 through 41/41 add the new packages excercising native addon
support, again differing based on the approach from patch 05/41. The
other slight difference from previous versions of this series is that,
where applicable, I've adjusted the new package definitions to use
'with-atomic-json-file-replacement' and never to use 'assoc-set!' or
other procedures that mutate assosciation lists.
I continue to think that '#:absent-dependencies' is a good approach, in
brief, as Jelle put it in <https://issues.guix.gnu.org/51838#247>, because:
On 12/20/21 18:10, Jelle Licht wrote:
> Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
>> Am Montag, dem 20.12.2021 um 14:33 -0500 schrieb Philip McGrath:
>>> If we took your final suggestion above, I think we'd have something
>>> like this:
>>>
>>> ```
>>> #:phases
>>> (modify-phases %standard-phases
>>> (add-after 'unpack 'delete-dependencies
>>> (make-delete-dependencies-phase '("node-tap"))))
>>> ```
>>>
>>> That seems pretty similar to, under the current patch series:
>>>
>>> ```
>>> #:absent-dependencies '("node-tap")
>>> ```
>> That is the point, but please don't add a function called "make-delete-
>> dependencies-phase". We have lambda. We can easily add with-atomic-
>> json-replacement. We can also add a "delete-dependencies" function
>> that takes a json and a list of dependencies if you so want.
>>
>> So in short
>>
>> (add-after 'patch-dependencies 'drop-junk
>> (lambda _
>> (with-atomic-json-replacement "package.json"
>> (lambda (json) (delete-dependencies json '("node-tap"))))))
>>
>> would be the "verbose" style of disabling a list of dependencies.
>>
>
> I think you are _really_ underestimating how many packages will need a
> phase like this in the future. I would agree with this approach if it
> were only needed incidentally, similar to the frequency of patching
> version requirements in setup.py or requirements.txt for python
> packages.
>
> Pretty much everything except the '("node-tap") list will be identical
> between packages; how do you propose we reduce this duplication? At this
> point I feel like I'm rehasing the opposite of your last point, so let
> me rephrase; how many times do you want to see/type/copy+paste the above
> snippet before you would consider exposing this functionality on a
> higher level?
>
Additionally, I think having a phase in '%standard-phases' is a good way of
addressing the need to use 'delete-dependencies' after the
'patch-dependencies' phase, which I explain in patch v6 05/41.
But, again, I could live with either v6 or v7 being applied if one of them
can achieve consensus.
So, without further ado, here is v6!
-Philip
Philip McGrath (41):
guix: node-build-system: Add delete-lockfiles phase.
guix: node-build-system: Add implicit libuv input.
guix: node-build-system: Add JSON utilities.
guix: node-build-system: Add avoid-node-gyp-rebuild phase.
guix: node-build-system: Add 'delete-dependencies' helper function.
gnu: node-semver-bootstrap: Use 'delete-dependencies'.
gnu: node-ms-bootstrap: Use 'delete-dependencies'.
gnu: node-binary-search-bootstrap: Use 'delete-dependencies'.
gnu: node-debug-bootstrap: Use 'delete-dependencies'.
gnu: node-llparse-builder-bootstrap: Use 'delete-dependencies'.
gnu: node-llparse-frontend-bootstrap: Use 'delete-dependencies'.
gnu: node-llparse-bootstrap: Use 'delete-dependencies'.
gnu: node-semver: Use 'delete-dependencies'.
gnu: node-wrappy: Use 'delete-dependencies'.
gnu: node-once: Use 'delete-dependencies'.
gnu: node-irc-colors: Use 'delete-dependencies'.
gnu: node-irc: Use 'delete-dependencies'.
gnu: Add node-inherits.
gnu: Add node-safe-buffer.
gnu: Add node-string-decoder.
gnu: Add node-readable-stream.
gnu: Add node-nan.
gnu: Add node-openzwave-shared.
gnu: Add node-addon-api.
gnu: Add node-sqlite3.
gnu: Add node-file-uri-to-path.
gnu: Add node-bindings.
gnu: Add node-segfault-handler.
gnu: Add node-ms.
gnu: Add node-debug.
gnu: Add node-serialport-binding-abstract.
gnu: Add node-serialport-parser-delimiter.
gnu: Add node-serialport-parser-readline.
gnu: Add node-serialport-bindings.
gnu: Add node-serialport-parser-regex.
gnu: Add node-serialport-parser-ready.
gnu: Add node-serialport-parser-inter-byte-timeout.
gnu: Add node-serialport-parser-cctalk.
gnu: Add node-serialport-parser-byte-length.
gnu: Add node-serialport-stream.
gnu: Add node-serialport.
gnu/packages/node-xyz.scm | 1013 +++++++++++++++++++++++++++++-
gnu/packages/node.scm | 78 ++-
gnu/packages/zwave.scm | 64 ++
guix/build-system/node.scm | 9 +-
guix/build/node-build-system.scm | 355 ++++++++++-
5 files changed, 1464 insertions(+), 55 deletions(-)
--
2.32.0
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 01/41] guix: node-build-system: Add delete-lockfiles phase.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
@ 2021-12-30 7:38 ` Philip McGrath
2021-12-30 7:38 ` [bug#51838] [PATCH v6 02/41] guix: node-build-system: Add implicit libuv input Philip McGrath
` (41 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:38 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* guix/build/node-build-system.scm (delete-lockfiles): New function.
Remove 'package-lock.json', 'yarn.lock', and 'npm-shrinkwrap.json',
if they exist. Because these files specify both exact dependency
versions and integrity hashes, they only cause problems for Guix.
(%standard-phases): Add 'delete-lockfiles' after 'patch-dependencies'.
---
guix/build/node-build-system.scm | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index 70a367618e..dcaa719f40 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -96,6 +96,17 @@ (define (resolve-dependencies package-meta meta-key)
(write-json package-meta out))))
#t)
+(define* (delete-lockfiles #:key inputs #:allow-other-keys)
+ "Delete 'package-lock.json', 'yarn.lock', and 'npm-shrinkwrap.json', if they
+exist."
+ (for-each (lambda (pth)
+ (when (file-exists? pth)
+ (delete-file pth)))
+ '("package-lock.json"
+ "yarn.lock"
+ "npm-shrinkwrap.json"))
+ #t)
+
(define* (configure #:key outputs inputs #:allow-other-keys)
(let ((npm (string-append (assoc-ref inputs "node") "/bin/npm")))
(invoke npm "--offline" "--ignore-scripts" "install")
@@ -146,6 +157,7 @@ (define %standard-phases
(modify-phases gnu:%standard-phases
(add-after 'unpack 'set-home set-home)
(add-before 'configure 'patch-dependencies patch-dependencies)
+ (add-after 'patch-dependencies 'delete-lockfiles delete-lockfiles)
(replace 'configure configure)
(replace 'build build)
(replace 'check check)
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 02/41] guix: node-build-system: Add implicit libuv input.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
2021-12-30 7:38 ` [bug#51838] [PATCH v6 01/41] guix: node-build-system: Add delete-lockfiles phase Philip McGrath
@ 2021-12-30 7:38 ` Philip McGrath
2021-12-30 7:38 ` [bug#51838] [PATCH v6 03/41] guix: node-build-system: Add JSON utilities Philip McGrath
` (40 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:38 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* guix/build-system/node.scm (lower): Add the version of libuv
used as an input to the #:node package as an additional implicit
input, so that packages needing libuv always get the correct version.
---
guix/build-system/node.scm | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/guix/build-system/node.scm b/guix/build-system/node.scm
index 735f8dd06e..24bd677bfc 100644
--- a/guix/build-system/node.scm
+++ b/guix/build-system/node.scm
@@ -2,6 +2,8 @@
;;; Copyright © 2016 Jelle Licht <jlicht@fsfe.org>
;;; Copyright © 2019 Timothy Sample <samplet@ngyro.com>
;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2021 Pierre Langlois <pierre.langlois@gmx.com>
+;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -61,10 +63,15 @@ (define private-keywords
`(("source" ,source))
'())
,@inputs
-
;; Keep the standard inputs of 'gnu-build-system'.
,@(standard-packages)))
(build-inputs `(("node" ,node)
+ ;; Many packages with native addons need
+ ;; libuv headers. The libuv version must
+ ;; be exactly the same as for the node
+ ;; package we are adding implicitly,
+ ;; so we take care of adding libuv, too.
+ ("libuv" ,@(assoc-ref (package-inputs node) "libuv"))
,@native-inputs))
(outputs outputs)
(build node-build)
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 03/41] guix: node-build-system: Add JSON utilities.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
2021-12-30 7:38 ` [bug#51838] [PATCH v6 01/41] guix: node-build-system: Add delete-lockfiles phase Philip McGrath
2021-12-30 7:38 ` [bug#51838] [PATCH v6 02/41] guix: node-build-system: Add implicit libuv input Philip McGrath
@ 2021-12-30 7:38 ` Philip McGrath
2021-12-30 16:56 ` Liliana Marie Prikler
2021-12-30 18:18 ` Liliana Marie Prikler
2021-12-30 7:38 ` [bug#51838] [PATCH v6 04/41] guix: node-build-system: Add avoid-node-gyp-rebuild phase Philip McGrath
` (39 subsequent siblings)
42 siblings, 2 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:38 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
This commit adds several utility functions for non-destructive
transformation of the JSON representation used by (guix build json),
particularly for purely functional update of JSON objects. They should
eventually be exported, but most are private for now to allow for more
experience and consideration before commiting to the API. The design
was largely inspired by the 'racket/dict' and 'racket/hash' libraries.
Liliana Marie Prikler proposed 'with-atomic-json-file-replacement'.
* guix/build/node-build-system.scm (jsobject-ref):
(alist-pop):
(alist-delete*):
(jsobject-delete):
(alist-set):
(jsobject-set):
(jsobject-set*):
(alist-update):
(jsobject-update):
(jsobject-update*):
(jsobject-union): New private procedures.
(with-atomic-json-file-replacement): New exported procedure.
(module-name): Use them.
(build): Use them.
(patch-dependencies): Use them. Stop using 'assoc-set!' unsafely.
Co-authored-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
---
guix/build/node-build-system.scm | 275 ++++++++++++++++++++++++++++---
1 file changed, 251 insertions(+), 24 deletions(-)
diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index dcaa719f40..e5c4da5091 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -26,6 +26,7 @@ (define-module (guix build node-build-system)
#:use-module (ice-9 match)
#:use-module (srfi srfi-1)
#:export (%standard-phases
+ with-atomic-json-file-replacement
node-build))
;; Commentary:
@@ -34,6 +35,237 @@ (define-module (guix build node-build-system)
;;
;; Code:
+;;;
+;;; JSON utilities.
+;;;
+;;; The following procedures facilitate transforming JSON values using the
+;;; representation from (guix build json), particularly purely functional
+;;; update of JSON objects. If we decide to make more of them public, we
+;;; might instead put them in their own file or, eventually, add them to
+;;; (guix build json).
+;;;
+;;; JSON objects with duplicate keys are not interoperable: see RFC 8259 § 4.
+;;; These procedures assume, but generally do not check, that JSON objects
+;;; given to them as arguments do not have duplicate keys. As long as that
+;;; precondition is satisfied, they will produce JSON objects without
+;;; duplicate keys. Procedures that operate on unwrapped assosciation lists
+;;; may do likewise, which should be considered before exporting them for
+;;; general use.
+;;;
+
+(define (with-atomic-json-file-replacement file proc)
+ "Like 'with-atomic-file-replacement', but PROC is called with a single
+argument---the result of parsing FILE's contents as json---and should a value
+to be written as json to the replacement FILE."
+ (with-atomic-file-replacement file
+ (lambda (in out)
+ (write-json (proc (read-json in)) out))))
+
+(define (jsobject-ref js key failure-result)
+ "Return the value assosciated with KEY in the json object JS. If KEY is not
+found and FAILURE-RESULT is a procedure, it is called in tail position with
+zero arguments. Otherwise, FAILURE-RESULT is returned."
+ ;; TODO: `failure-result` should be optional, but should the default
+ ;; `failure-result` be #f (like `assoc-ref`), a thunk raising an exception,
+ ;; '(@), or something else? Keep it mandatory until we discuss and decide.
+ (match js
+ (('@ . alist)
+ (match (assoc key alist)
+ (#f
+ (if (procedure? failure-result)
+ (failure-result)
+ failure-result))
+ ((_ . value)
+ value)))))
+
+(define (alist-pop alist key)
+ "Return two values: the first pair in ALIST with the given KEY in its
+'car' (or #f, if no such pair exists) and an assosciation list like (and
+potentially sharing storage with) ALIST, but with no entry for KEY."
+ (match (assoc key alist)
+ ;; If key isn't present, we don't need to do any allocation
+ (#f
+ (values #f alist))
+ (found
+ (values found
+ ;; Because we have `found`, we can find it more
+ ;; efficiently this time with `eq?`. We avoid using
+ ;; `delq` because it would copy pairs in a shared
+ ;; tail. We assume a sufficiently smart compiler to
+ ;; handle "tail recursion modulo cons" (vid. e.g. Indiana
+ ;; University Technical Report No. 19, Friedman & Wise
+ ;; 1975) at least as efficiently as a hand-written
+ ;; tail-recursive implementation with an accumulator.
+ (let loop ((alist alist))
+ (match alist
+ ;; We know that `found` is present,
+ ;; so no need to check for '()
+ ((this . alist)
+ (if (eq? this found)
+ alist
+ (cons this (loop alist))))))))))
+
+;; Sadly, Guile's implementation of (@ (srfi srfi-1) alist-delete)
+;; performs unnecessary allocation, e.g. this currently evaluates to #f:
+;;
+;; (let ((alist `(("a" . 1)("b" . 2)("c" . 3))))
+;; (eq? alist (alist-delete "x" alist)))
+;;
+;; These functions generally choose to allocate a new outer pair (with the '@
+;; tag), even though in unusual cases the resulting object might not have
+;; changed, for the sake of simplicity and to avoid retaining a reference to
+;; the original alist longer than necessary. But that is O(1) allocation that
+;; could only rarely be avoided: `alist-delete` would allocate O(n) pairs,
+;; which would only be necessary in the worst case.
+(define (alist-delete* alist key)
+ "Return an assosciation list like (and potentially sharing storage with)
+ALIST, but with no entry for KEY."
+ (define-values (_popped remaining)
+ (alist-pop alist key))
+ remaining)
+
+(define (jsobject-delete js key)
+ "Return a json object like JS, but with no entry for KEY."
+ (cons '@ (match js
+ (('@ . alist)
+ (alist-delete* alist key)))))
+
+(define (alist-set alist key value)
+ "Return an assosciation list like ALIST, but with KEY mapped to VALUE,
+replacing any existing mapping for KEY."
+ (acons key value (alist-delete* alist key)))
+
+(define (jsobject-set js key value)
+ "Return a json object like JS, but with KEY mapped to VALUE, replacing any
+existing mapping for KEY."
+ (cons '@ (match js
+ (('@ . alist)
+ (alist-set alist key value)))))
+
+(define jsobject-set*
+ (case-lambda
+ "Return a json object like JS, but functionally extended by mapping each
+KEY to each VALUE, replacing any existing mapping for each KEY. The update
+takes place from left to right, so later mappings overwrite earlier mappings
+for the same KEY."
+ ((js)
+ js)
+ ((js key value)
+ (jsobject-set js key value))
+ ((js . args)
+ (cons '@ (match js
+ (('@ . alist)
+ (let loop ((alist alist)
+ (args args))
+ (match args
+ (()
+ alist)
+ ((key value . args)
+ (loop (alist-set alist key value)
+ args))))))))))
+
+(define (alist-update alist key failure-result updater)
+ "Return an assosciation list like ALIST, but with KEY mapped to the result
+of applying UPDATER to the value to which KEY is mapped in ALIST. When ALIST
+does not have an existing mapping for KEY, FAILURE-RESULT is used as with
+'jsobject-ref' to obtain the argument for UPDATER."
+ ;; Often, `updater` will be a lambda expression, so making it the last
+ ;; argument may help to makes the code legible, and the most likely
+ ;; `failure-result` arguments are all shorter than the keyword
+ ;; `#:failure-result`. Plus, making `failure-result` mandatory helps make
+ ;; `alist-update` consistent with `alist-update*`.
+ (define-values (popped tail-alist)
+ (alist-pop alist key))
+ (acons key
+ (updater (match popped
+ (#f
+ (if (procedure? failure-result)
+ (failure-result)
+ failure-result))
+ ((_ . value)
+ value)))
+ tail-alist))
+
+(define (jsobject-update js key failure-result updater)
+ "Return a json object like JS, but with KEY mapped to the result of applying
+UPDATER to the value to which KEY is mapped in JS. When JS does not have an
+existing mapping for KEY, FAILURE-RESULT is used as with 'jsobject-ref' to
+obtain the argument for UPDATER."
+ (cons '@ (match js
+ (('@ . alist)
+ (alist-update alist key failure-result updater)))))
+
+(define jsobject-update*
+ (case-lambda
+ "Return a json object like JS, but functionally extended by replacing the
+mapping for each KEY with the result of applying the corresponding UPDATER to
+the value to which that KEY is mapped in JS---or, if no such mapping exists,
+to a value based on the corresponding FAILURE-RESULT as with 'jsobject-ref'.
+The update takes place from left to right, so later UPDATERs will receive the
+values returned by earlier UPDATERs for the same KEY."
+ ((js)
+ js)
+ ((js key failure-result updater)
+ (jsobject-update js key failure-result updater))
+ ((js . args)
+ (cons '@ (match js
+ (('@ . alist)
+ (let loop ((alist alist)
+ (args args))
+ (match args
+ (()
+ alist)
+ ((key failure-result updater . args)
+ (loop (alist-update alist key failure-result updater)
+ args))))))))))
+
+(define* (jsobject-union #:key
+ (combine (lambda (a b) b))
+ (combine/key (lambda (k a b) (combine a b)))
+ #:rest json-objects)
+ "Combine the given JSON-OBJECTS into a single json object. The JSON-OBJECTS
+are merged from left to right by adding each key/value pair of each object to
+the aggregate object in turn. When one of the JSON-OBJECTS contains a mapping
+from some key KEY to a value VAL such that the aggregate object already
+contains a mapping from KEY to a value VAL0, the aggregate object is
+functionally updated to instead map KEY to the value of (COMBINE/KEY KEY VAL0
+VAL). The default COMBINE/KEY tail-calls (COMBINE VAL0 VAL), and the default
+COMBINE simply returns its second argument, so, by default, mappings in later
+JSON-OBJECTS supersede those in earlier ones."
+ (match (filter (lambda (v)
+ (not (or (keyword? v)
+ (procedure? v))))
+ json-objects)
+ (()
+ '(@))
+ (((and js0 ('@ . _)))
+ js0)
+ ((('@ . alist0) ('@ . alist*) ...)
+ (cons '@ (fold (lambda (alist1 alist0)
+ (if (null? alist0)
+ alist1
+ (fold (lambda (k+v alist0)
+ (match k+v
+ ((k . v)
+ (define-values (popped tail-alist)
+ (alist-pop alist0 k))
+ (match popped
+ (#f
+ (cons k+v tail-alist))
+ ((_ . v0)
+ (acons k
+ (combine/key k v0 v)
+ tail-alist))))))
+ alist0
+ alist1)))
+ alist0
+ alist*)))))
+
+\f
+;;;
+;;; Phases.
+;;;
+
(define (set-home . _)
(with-directory-excursion ".."
(let loop ((i 0))
@@ -49,7 +281,7 @@ (define (set-home . _)
(define (module-name module)
(let* ((package.json (string-append module "/package.json"))
(package-meta (call-with-input-file package.json read-json)))
- (assoc-ref package-meta "name")))
+ (jsobject-ref package-meta "name" #f)))
(define (index-modules input-paths)
(define (list-modules directory)
@@ -73,27 +305,24 @@ (define* (patch-dependencies #:key inputs #:allow-other-keys)
(define index (index-modules (map cdr inputs)))
- (define (resolve-dependencies package-meta meta-key)
- (fold (lambda (key+value acc)
- (match key+value
- ('@ acc)
- ((key . value) (acons key (hash-ref index key value) acc))))
- '()
- (or (assoc-ref package-meta meta-key) '())))
+ (define resolve-dependencies
+ (match-lambda
+ (('@ . alist)
+ (cons '@ (map (match-lambda
+ ((key . value)
+ (cons key (hash-ref index key value))))
+ alist)))))
- (with-atomic-file-replacement "package.json"
- (lambda (in out)
- (let ((package-meta (read-json in)))
- (assoc-set! package-meta "dependencies"
- (append
- '(@)
- (resolve-dependencies package-meta "dependencies")
- (resolve-dependencies package-meta "peerDependencies")))
- (assoc-set! package-meta "devDependencies"
- (append
- '(@)
- (resolve-dependencies package-meta "devDependencies")))
- (write-json package-meta out))))
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (jsobject-update*
+ pkg-meta
+ "devDependencies" '(@) resolve-dependencies
+ "dependencies" '(@) (lambda (deps)
+ (resolve-dependencies
+ (jsobject-union
+ (jsobject-ref pkg-meta "peerDependencies" '(@))
+ deps))))))
#t)
(define* (delete-lockfiles #:key inputs #:allow-other-keys)
@@ -114,9 +343,7 @@ (define* (configure #:key outputs inputs #:allow-other-keys)
(define* (build #:key inputs #:allow-other-keys)
(let ((package-meta (call-with-input-file "package.json" read-json)))
- (if (and=> (assoc-ref package-meta "scripts")
- (lambda (scripts)
- (assoc-ref scripts "build")))
+ (if (jsobject-ref (jsobject-ref package-meta "scripts" '(@)) "build" #f)
(let ((npm (string-append (assoc-ref inputs "node") "/bin/npm")))
(invoke npm "run" "build"))
(format #t "there is no build script to run~%"))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 03/41] guix: node-build-system: Add JSON utilities.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 03/41] guix: node-build-system: Add JSON utilities Philip McGrath
@ 2021-12-30 16:56 ` Liliana Marie Prikler
2021-12-30 18:18 ` Liliana Marie Prikler
1 sibling, 0 replies; 458+ messages in thread
From: Liliana Marie Prikler @ 2021-12-30 16:56 UTC (permalink / raw)
To: Philip McGrath, 51838; +Cc: Timothy Sample, Pierre Langlois, Jelle Licht
Am Donnerstag, dem 30.12.2021 um 02:38 -0500 schrieb Philip McGrath:
> This commit adds several utility functions for non-destructive
> transformation of the JSON representation used by (guix build json),
> particularly for purely functional update of JSON objects. They
> should
> eventually be exported, but most are private for now to allow for
> more
> experience and consideration before commiting to the API. The design
> was largely inspired by the 'racket/dict' and 'racket/hash'
> libraries.
> Liliana Marie Prikler proposed 'with-atomic-json-file-replacement'.
Given that this is a fair amount of procedures that you're proposing, I
think a new file would be appropriate. Perhaps (guix build json-
utils)? Adding that should IIUC not cause a world rebuild, so we could
do that on master.
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 03/41] guix: node-build-system: Add JSON utilities.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 03/41] guix: node-build-system: Add JSON utilities Philip McGrath
2021-12-30 16:56 ` Liliana Marie Prikler
@ 2021-12-30 18:18 ` Liliana Marie Prikler
2021-12-31 5:22 ` Philip McGrath
1 sibling, 1 reply; 458+ messages in thread
From: Liliana Marie Prikler @ 2021-12-30 18:18 UTC (permalink / raw)
To: Philip McGrath, 51838; +Cc: Timothy Sample, Pierre Langlois, Jelle Licht
Having argued for these procedures to be moved into their own file in a
separate mail, now it's time to bikeshed stylistic choices.
Am Donnerstag, dem 30.12.2021 um 02:38 -0500 schrieb Philip McGrath:
> +(define (jsobject-ref js key failure-result)
> + "Return the value assosciated with KEY in the json object JS. If
> KEY is not
> +found and FAILURE-RESULT is a procedure, it is called in tail position
> with
> +zero arguments. Otherwise, FAILURE-RESULT is returned."
> + ;; TODO: `failure-result` should be optional, but should the default
> + ;; `failure-result` be #f (like `assoc-ref`), a thunk raising an
> exception,
> + ;; '(@), or something else? Keep it mandatory until we discuss and
> decide.
> + (match js
> + (('@ . alist)
> + (match (assoc key alist)
> + (#f
> + (if (procedure? failure-result)
> + (failure-result)
> + failure-result))
> + ((_ . value)
> + value)))))
We can safely replace failure-result by Guile's DEFAULT and leave error
handling to the user.
> +(define (alist-pop alist key)
> + "Return two values: the first pair in ALIST with the given KEY in
> its
> +'car' (or #f, if no such pair exists) and an assosciation list like
> (and
> +potentially sharing storage with) ALIST, but with no entry for KEY."
> + (match (assoc key alist)
> + ;; If key isn't present, we don't need to do any allocation
> + (#f
> + (values #f alist))
> + (found
> + (values found
> + ;; Because we have `found`, we can find it more
> + ;; efficiently this time with `eq?`. We avoid using
> + ;; `delq` because it would copy pairs in a shared
> + ;; tail. We assume a sufficiently smart compiler to
> + ;; handle "tail recursion modulo cons" (vid. e.g. Indiana
> + ;; University Technical Report No. 19, Friedman & Wise
> + ;; 1975) at least as efficiently as a hand-written
> + ;; tail-recursive implementation with an accumulator.
> + (let loop ((alist alist))
> + (match alist
> + ;; We know that `found` is present,
> + ;; so no need to check for '()
> + ((this . alist)
> + (if (eq? this found)
> + alist
> + (cons this (loop alist))))))))))
I think this can be more efficiently be done in a "single" loop.
(let loop ((rest alist)
(previous '()))
(match rest
(() (values #f alist))
((first . rest)
(if (eq? (car first) key)
(values first (reverse! previous rest))
(loop rest (cons first previous))))))
Also, I don't think your version is tail-recursive. (loop alist) is
not in tail position from what I can tell.
We should also look into SRFI-1 span.
> +;; Sadly, Guile's implementation of (@ (srfi srfi-1) alist-delete)
> +;; performs unnecessary allocation, e.g. this currently evaluates to
> #f:
> +;;
> +;; (let ((alist `(("a" . 1)("b" . 2)("c" . 3))))
> +;; (eq? alist (alist-delete "x" alist)))
> +;;
> +;; These functions generally choose to allocate a new outer pair
> (with the '@
> +;; tag), even though in unusual cases the resulting object might not
> have
> +;; changed, for the sake of simplicity and to avoid retaining a
> reference to
> +;; the original alist longer than necessary. But that is O(1)
> allocation that
> +;; could only rarely be avoided: `alist-delete` would allocate O(n)
> pairs,
> +;; which would only be necessary in the worst case.
> +(define (alist-delete* alist key)
> + "Return an assosciation list like (and potentially sharing storage
> with)
> +ALIST, but with no entry for KEY."
> + (define-values (_popped remaining)
> + (alist-pop alist key))
> + remaining)
That's a pretty long comment around something that could be done with
call-with-values or SRFI-71 let. I think one of these two should be
preferred.
Note that both our versions of alist-pop only pop the first key (as
they should). This means that alist-delete* should really be called
alist-delete-1 as in "remove the first pair in ALIST belonging to KEY".
For the larger JSON handling below, this makes no difference however.
> +(define (jsobject-delete js key)
> + "Return a json object like JS, but with no entry for KEY."
> + (cons '@ (match js
> + (('@ . alist)
> + (alist-delete* alist key)))))
Fair enough.
> +(define (alist-set alist key value)
> + "Return an assosciation list like ALIST, but with KEY mapped to
> VALUE,
> +replacing any existing mapping for KEY."
> + (acons key value (alist-delete* alist key)))
Is order relevant here? Because we could just as well reimplement our
alist-delete* loop and cons the replacement onto the rest. WDYT?
> +(define (jsobject-set js key value)
> + "Return a json object like JS, but with KEY mapped to VALUE,
> replacing any
> +existing mapping for KEY."
> + (cons '@ (match js
> + (('@ . alist)
> + (alist-set alist key value)))))
I think it'd be wiser to put the cons inside the match.
> +(define jsobject-set*
> + (case-lambda
> + "Return a json object like JS, but functionally extended by
> mapping each
> +KEY to each VALUE, replacing any existing mapping for each KEY. The
> update
> +takes place from left to right, so later mappings overwrite earlier
> mappings
> +for the same KEY."
> + ((js)
> + js)
> + ((js key value)
> + (jsobject-set js key value))
> + ((js . args)
> + (cons '@ (match js
> + (('@ . alist)
> + (let loop ((alist alist)
> + (args args))
> + (match args
> + (()
> + alist)
> + ((key value . args)
> + (loop (alist-set alist key value)
> + args))))))))))
I'm not sure if I like this "syntax". I think I'd prefer
(jsobject-set* obj (FIELD1 VALUE1) (FIELD2 VALUE2) ...)
with FIELD1, FIELD2 being identifiers
WDYT?
> +(define (alist-update alist key failure-result updater)
> + "Return an assosciation list like ALIST, but with KEY mapped to
> the result
> +of applying UPDATER to the value to which KEY is mapped in ALIST.
> When ALIST
> +does not have an existing mapping for KEY, FAILURE-RESULT is used as
> with
> +'jsobject-ref' to obtain the argument for UPDATER."
> + ;; Often, `updater` will be a lambda expression, so making it the
> last
> + ;; argument may help to makes the code legible, and the most
> likely
> + ;; `failure-result` arguments are all shorter than the keyword
> + ;; `#:failure-result`. Plus, making `failure-result` mandatory
> helps make
> + ;; `alist-update` consistent with `alist-update*`.
Which alist-update* are you referring to here? Either way, the
failure-result to default argument from above applies, but we could
keyword it.
> + (define-values (popped tail-alist)
> + (alist-pop alist key))
> + (acons key
> + (updater (match popped
> + (#f
> + (if (procedure? failure-result)
> + (failure-result)
> + failure-result))
> + ((_ . value)
> + value)))
> + tail-alist))
SRFI-71 let says hi. Also the ordering question applies. I'm starting
to think we should implement alist-pop, alist-set and alist-update in
terms of a single more powerful function producing three values (or
SRFI-1 span).
> +(define (jsobject-update js key failure-result updater)
> + "Return a json object like JS, but with KEY mapped to the result
> of applying
> +UPDATER to the value to which KEY is mapped in JS. When JS does not
> have an
> +existing mapping for KEY, FAILURE-RESULT is used as with 'jsobject-
> ref' to
> +obtain the argument for UPDATER."
> + (cons '@ (match js
> + (('@ . alist)
> + (alist-update alist key failure-result updater)))))
Same default argument. Cons inside.
> +(define jsobject-update*
> + (case-lambda
> + "Return a json object like JS, but functionally extended by
> replacing the
> +mapping for each KEY with the result of applying the corresponding
> UPDATER to
> +the value to which that KEY is mapped in JS---or, if no such mapping
> exists,
> +to a value based on the corresponding FAILURE-RESULT as with
> 'jsobject-ref'.
> +The update takes place from left to right, so later UPDATERs will
> receive the
> +values returned by earlier UPDATERs for the same KEY."
> + ((js)
> + js)
> + ((js key failure-result updater)
> + (jsobject-update js key failure-result updater))
> + ((js . args)
> + (cons '@ (match js
> + (('@ . alist)
> + (let loop ((alist alist)
> + (args args))
> + (match args
> + (()
> + alist)
> + ((key failure-result updater . args)
> + (loop (alist-update alist key failure-result
> updater)
> + args))))))))))
Same default argument. Cons inside.
> +(define* (jsobject-union #:key
> + (combine (lambda (a b) b))
> + (combine/key (lambda (k a b) (combine a
> b)))
> + #:rest json-objects)
> + "Combine the given JSON-OBJECTS into a single json object. The
> JSON-OBJECTS
> +are merged from left to right by adding each key/value pair of each
> object to
> +the aggregate object in turn. When one of the JSON-OBJECTS contains
> a mapping
> +from some key KEY to a value VAL such that the aggregate object
> already
> +contains a mapping from KEY to a value VAL0, the aggregate object is
> +functionally updated to instead map KEY to the value of (COMBINE/KEY
> KEY VAL0
> +VAL). The default COMBINE/KEY tail-calls (COMBINE VAL0 VAL), and
> the default
> +COMBINE simply returns its second argument, so, by default, mappings
> in later
> +JSON-OBJECTS supersede those in earlier ones."
> + (match (filter (lambda (v)
> + (not (or (keyword? v)
> + (procedure? v))))
> + json-objects)
> + (()
> + '(@))
> + (((and js0 ('@ . _)))
> + js0)
> + ((('@ . alist0) ('@ . alist*) ...)
> + (cons '@ (fold (lambda (alist1 alist0)
> + (if (null? alist0)
> + alist1
> + (fold (lambda (k+v alist0)
> + (match k+v
> + ((k . v)
> + (define-values (popped tail-
> alist)
> + (alist-pop alist0 k))
> + (match popped
> + (#f
> + (cons k+v tail-alist))
> + ((_ . v0)
> + (acons k
> + (combine/key k v0 v)
> + tail-alist))))))
> + alist0
> + alist1)))
> + alist0
> + alist*)))))
Same default argument. Cons inside.
I think having a single combine function taking (k a b) would be less
confusing than having two. Is there a rationale for the form you
chose?
> +\f
> +;;;
> +;;; Phases.
> +;;;
> +
> (define (set-home . _)
> (with-directory-excursion ".."
> (let loop ((i 0))
> @@ -49,7 +281,7 @@ (define (set-home . _)
> (define (module-name module)
> (let* ((package.json (string-append module "/package.json"))
> (package-meta (call-with-input-file package.json read-
> json)))
> - (assoc-ref package-meta "name")))
> + (jsobject-ref package-meta "name" #f)))
>
> (define (index-modules input-paths)
> (define (list-modules directory)
> @@ -73,27 +305,24 @@ (define* (patch-dependencies #:key inputs
> #:allow-other-keys)
>
> (define index (index-modules (map cdr inputs)))
>
> - (define (resolve-dependencies package-meta meta-key)
> - (fold (lambda (key+value acc)
> - (match key+value
> - ('@ acc)
> - ((key . value) (acons key (hash-ref index key value)
> acc))))
> - '()
> - (or (assoc-ref package-meta meta-key) '())))
> + (define resolve-dependencies
> + (match-lambda
> + (('@ . alist)
> + (cons '@ (map (match-lambda
> + ((key . value)
> + (cons key (hash-ref index key value))))
> + alist)))))
>
> - (with-atomic-file-replacement "package.json"
> - (lambda (in out)
> - (let ((package-meta (read-json in)))
> - (assoc-set! package-meta "dependencies"
> - (append
> - '(@)
> - (resolve-dependencies package-meta
> "dependencies")
> - (resolve-dependencies package-meta
> "peerDependencies")))
> - (assoc-set! package-meta "devDependencies"
> - (append
> - '(@)
> - (resolve-dependencies package-meta
> "devDependencies")))
> - (write-json package-meta out))))
> + (with-atomic-json-file-replacement "package.json"
> + (lambda (pkg-meta)
> + (jsobject-update*
> + pkg-meta
> + "devDependencies" '(@) resolve-dependencies
> + "dependencies" '(@) (lambda (deps)
> + (resolve-dependencies
> + (jsobject-union
> + (jsobject-ref pkg-meta
> "peerDependencies" '(@))
> + deps))))))
> #t)
We should probably add a function to our js utils that "generates an
empty object", because '(@) is quite confusing to see in these
circumstances. Otherwise LGTM with the aforementioned caveats.
Cheers
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 03/41] guix: node-build-system: Add JSON utilities.
2021-12-30 18:18 ` Liliana Marie Prikler
@ 2021-12-31 5:22 ` Philip McGrath
2021-12-31 10:18 ` Liliana Marie Prikler
0 siblings, 1 reply; 458+ messages in thread
From: Philip McGrath @ 2021-12-31 5:22 UTC (permalink / raw)
To: Liliana Marie Prikler, 51838; +Cc: Timothy Sample, Pierre Langlois, Jelle Licht
Hi Liliana,
On 12/30/21 11:56, Liliana Marie Prikler wrote:
> Am Donnerstag, dem 30.12.2021 um 02:38 -0500 schrieb Philip McGrath:
>> This commit adds several utility functions for non-destructive
>> transformation of the JSON representation used by (guix build json),
>> particularly for purely functional update of JSON objects. They
>> should
>> eventually be exported, but most are private for now to allow for
>> more
>> experience and consideration before commiting to the API. The design
>> was largely inspired by the 'racket/dict' and 'racket/hash'
>> libraries.
>> Liliana Marie Prikler proposed 'with-atomic-json-file-replacement'.
> Given that this is a fair amount of procedures that you're proposing, I
> think a new file would be appropriate. Perhaps (guix build json-
> utils)? Adding that should IIUC not cause a world rebuild, so we could
> do that on master.
>
I agree that these functions ultimately belong in their own file, and
I'd even had the name (guix build json-utils) in mind.
I put them in (guix build node-build-system) for now because, if they
were in (guix build json-utils), they would have to be exported, at
which point their API would have to be relatively stable, and I didn't
want designing them to block, or to be rushed by, the rest of this
series. Now, maybe consensus on the json-utils will turn out to be the
easy part! But my high-level question is, in your view, do any of the
points I'm about to respond to block this patch series?
On 12/30/21 13:18, Liliana Marie Prikler wrote:
> Having argued for these procedures to be moved into their own file in a
> separate mail, now it's time to bikeshed stylistic choices.
>
> Am Donnerstag, dem 30.12.2021 um 02:38 -0500 schrieb Philip McGrath:
>> +(define (jsobject-ref js key failure-result)
>> + "Return the value assosciated with KEY in the json object JS. If
>> KEY is not
>> +found and FAILURE-RESULT is a procedure, it is called in tail position
>> with
>> +zero arguments. Otherwise, FAILURE-RESULT is returned."
>> + ;; TODO: `failure-result` should be optional, but should the default
>> + ;; `failure-result` be #f (like `assoc-ref`), a thunk raising an
>> exception,
>> + ;; '(@), or something else? Keep it mandatory until we discuss and
>> decide.
>> + (match js
>> + (('@ . alist)
>> + (match (assoc key alist)
>> + (#f
>> + (if (procedure? failure-result)
>> + (failure-result)
>> + failure-result))
>> + ((_ . value)
>> + value)))))
> We can safely replace failure-result by Guile's DEFAULT and leave error
> handling to the user.
I don't care whether we call it DEFAULT or FAILURE-RESULT.
I agree that it should not raise an exception by default. My current
thinking is that '(@) would be a good default DEFAULT: it is useful for
the common pattern of traversing or transforming nested objects, and, as
you point out at the end of this email, explicitly typing #f (the other
useful possibility) looks much more like normal Scheme than explicitly
typing '(@).
In my experience with [1] and [2] (the purely-functional dictionary
libraries I use most often), the special case for a procedure as DEFAULT
is useful. I feel less strongly about it because it's relatively easy to
work around for JSON, since you can pick some non-JSON signal value, but
it also seems to have especially little downside for JSON, since (guix
build json) will never have a procedure in a valid JSON object. In
addition to raising exceptions and other control flow, it's useful for
default values that are expensive to produce.
[1]: https://docs.racket-lang.org/reference/hashtables.html
[2]: https://docs.racket-lang.org/reference/dicts.html
>
>> +(define (alist-pop alist key)
>> + "Return two values: the first pair in ALIST with the given KEY in
>> its
>> +'car' (or #f, if no such pair exists) and an assosciation list like
>> (and
>> +potentially sharing storage with) ALIST, but with no entry for KEY."
>> + (match (assoc key alist)
>> + ;; If key isn't present, we don't need to do any allocation
>> + (#f
>> + (values #f alist))
>> + (found
>> + (values found
>> + ;; Because we have `found`, we can find it more
>> + ;; efficiently this time with `eq?`. We avoid using
>> + ;; `delq` because it would copy pairs in a shared
>> + ;; tail. We assume a sufficiently smart compiler to
>> + ;; handle "tail recursion modulo cons" (vid. e.g. Indiana
>> + ;; University Technical Report No. 19, Friedman & Wise
>> + ;; 1975) at least as efficiently as a hand-written
>> + ;; tail-recursive implementation with an accumulator.
>> + (let loop ((alist alist))
>> + (match alist
>> + ;; We know that `found` is present,
>> + ;; so no need to check for '()
>> + ((this . alist)
>> + (if (eq? this found)
>> + alist
>> + (cons this (loop alist))))))))))
> I think this can be more efficiently be done in a "single" loop.
>
> (let loop ((rest alist)
> (previous '()))
> (match rest
> (() (values #f alist))
> ((first . rest)
> (if (eq? (car first) key)
> (values first (reverse! previous rest))
> (loop rest (cons first previous))))))
>
I'll admit to a Racket bias, but, having just eliminated the use of
'assoc-set!', I'm loathe to start mutating pairs (even correctly). To
quote a bit from the SRFI-1 spec for 'append-reverse!', "note that this
pattern of iterative computation followed by a reverse can frequently be
rewritten as a recursion, dispensing with the reverse and append-reverse
steps, and shifting temporary, intermediate storage from the heap to the
stack, which is typically a win for reasons of cache locality and eager
storage reclamation." (See how 'set-cdr!' can crash safe Chez Scheme!
<https://github.com/cisco/ChezScheme/issues/599>)
IIUC, using SRFI-1's 'span' would lead to the same situation.
> Also, I don't think your version is tail-recursive. (loop alist) is
> not in tail position from what I can tell.
Yes, "tail recursion modulo cons" refers to a compiler optimization for
functions which are _not_ tail recursive. For full details, see the
Friedman & Wise 1975 tech report I cited at
<https://legacy.cs.indiana.edu/ftp/techreports/TR19.pdf> (or various
other articles), but, as briefly as I can: The optimization rests on the
observation that many recursive functions, like the classic definition
of 'map':
(define (map f lst)
(match lst
(()
'())
((this . lst)
(cons (f this)
(map f lst)))))
are nearly tail-recursive, and the only real work remaining to be done
in the continuation of the recursive call is to fill in the cdr of the
pair. Thus, a compiler can safely transform this code into a truly
tail-recursive implementation:
(define (map f lst)
(match lst
(()
'())
((this . lst)
(define ret (list (f this)))
(let loop ((dest ret)
(lst lst))
(match lst
((this . lst)
(define new (list (f this)))
(set-cdr! dest new)
(loop new lst))
(()
ret))))))
Unlike the Proper Implementation of Tail Calls (so-called "tail-call
optimization"), handling "tail recursion modulo cons" truly is an
optimization: it does not change the space complexity of the function.
But it can allow the compiler to generate whatever code it thinks will
work best with its collector/allocator and continuation/"call stack"
implementation.
(The optimizations applies to constructors in general, not just 'cons',
and a compiler can safely apply it to values that are immutable from the
perspective of the source language.)
>
>> +;; Sadly, Guile's implementation of (@ (srfi srfi-1) alist-delete)
>> +;; performs unnecessary allocation, e.g. this currently evaluates to
>> #f:
>> +;;
>> +;; (let ((alist `(("a" . 1)("b" . 2)("c" . 3))))
>> +;; (eq? alist (alist-delete "x" alist)))
>> +;;
>> +;; These functions generally choose to allocate a new outer pair
>> (with the '@
>> +;; tag), even though in unusual cases the resulting object might not
>> have
>> +;; changed, for the sake of simplicity and to avoid retaining a
>> reference to
>> +;; the original alist longer than necessary. But that is O(1)
>> allocation that
>> +;; could only rarely be avoided: `alist-delete` would allocate O(n)
>> pairs,
>> +;; which would only be necessary in the worst case.
>> +(define (alist-delete* alist key)
>> + "Return an assosciation list like (and potentially sharing storage
>> with)
>> +ALIST, but with no entry for KEY."
>> + (define-values (_popped remaining)
>> + (alist-pop alist key))
>> + remaining)
> That's a pretty long comment around something that could be done with
> call-with-values or SRFI-71 let. I think one of these two should be
> preferred.
>
> Note that both our versions of alist-pop only pop the first key (as
> they should). This means that alist-delete* should really be called
> alist-delete-1 as in "remove the first pair in ALIST belonging to KEY".
> For the larger JSON handling below, this makes no difference however.
Here I was using '*' to mean "a slightly altered version of", as with
'letrec' and 'letrec*', but, yes, since the other functions defined here
use '*' to mean "zero or more times", the name is confusing: I think I'd
just call it 'alist-delete' and not import (srfi srfi-1)'s version.
The comment may be unnecessarily long ... the essence of what I was
trying to explain is that, in all of these implementations, I've tried
to avoid unnecessary allocation. Being able to rely on 'alist-delete',
and more generally 'alist-pop', not to needlessly copy the "spine" of
the list lets later functions use them unconditionally.
Why would you prefer 'call-with-values' or SRFI-71 over 'define-values'?
The style guide against which I'm used to working [3] generally prefers
internal definitions, to avoid rightward drift.
[3]:
https://docs.racket-lang.org/style/Choosing_the_Right_Construct.html#%28part._.Definitions%29
>> +(define (alist-set alist key value)
>> + "Return an assosciation list like ALIST, but with KEY mapped to
>> VALUE,
>> +replacing any existing mapping for KEY."
>> + (acons key value (alist-delete* alist key)))
> Is order relevant here? Because we could just as well reimplement our
> alist-delete* loop and cons the replacement onto the rest. WDYT?
Relying on order for JSON objects is non-interoperable, per RFC 8259 §
4. I'm not intending for these alist procedures to be exported, so I'm
not trying to handle any more general case than that, as I explain in
the comments at the top of the file.
I'm not sure what the advantage would be to reimplementing the
'alist-delete' loop here.
>
>> +(define (jsobject-set js key value)
>> + "Return a json object like JS, but with KEY mapped to VALUE,
>> replacing any
>> +existing mapping for KEY."
>> + (cons '@ (match js
>> + (('@ . alist)
>> + (alist-set alist key value)))))
> I think it'd be wiser to put the cons inside the match.
>
I don't care very much either way.
>> +(define jsobject-set*
>> + (case-lambda
>> + "Return a json object like JS, but functionally extended by
>> mapping each
>> +KEY to each VALUE, replacing any existing mapping for each KEY. The
>> update
>> +takes place from left to right, so later mappings overwrite earlier
>> mappings
>> +for the same KEY."
>> + ((js)
>> + js)
>> + ((js key value)
>> + (jsobject-set js key value))
>> + ((js . args)
>> + (cons '@ (match js
>> + (('@ . alist)
>> + (let loop ((alist alist)
>> + (args args))
>> + (match args
>> + (()
>> + alist)
>> + ((key value . args)
>> + (loop (alist-set alist key value)
>> + args))))))))))
> I'm not sure if I like this "syntax". I think I'd prefer
> (jsobject-set* obj (FIELD1 VALUE1) (FIELD2 VALUE2) ...)
> with FIELD1, FIELD2 being identifiers
> WDYT?
So you would make 'jsobject-set*' a macro? When you say, "with FIELD1,
FIELD2 being identifiers", do you mean that the macro should convert
them to strings at compile-time? While, if I were designing a JSON
representation, I'd much prefer to use symbols for the object keys, I
think it would be confusing to use strings everywhere else but magic
symbols here.
I based this function on 'hash-set*' [4], 'dict-set*' [5], and numerous
similar functions in the Racket world, so I have a high degree of
confidence in the usability of the interface.
[4]:
https://docs.racket-lang.org/reference/hashtables.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._hash-set%2A%29%29
[5]:
https://docs.racket-lang.org/reference/dicts.html#%28def._%28%28lib._racket%2Fdict..rkt%29._dict-set%2A%29%29
>> +(define (alist-update alist key failure-result updater)
>> + "Return an assosciation list like ALIST, but with KEY mapped to
>> the result
>> +of applying UPDATER to the value to which KEY is mapped in ALIST.
>> When ALIST
>> +does not have an existing mapping for KEY, FAILURE-RESULT is used as
>> with
>> +'jsobject-ref' to obtain the argument for UPDATER."
>> + ;; Often, `updater` will be a lambda expression, so making it the
>> last
>> + ;; argument may help to makes the code legible, and the most
>> likely
>> + ;; `failure-result` arguments are all shorter than the keyword
>> + ;; `#:failure-result`. Plus, making `failure-result` mandatory
>> helps make
>> + ;; `alist-update` consistent with `alist-update*`.
> Which alist-update* are you referring to here? Either way, the
> failure-result to default argument from above applies, but we could
> keyword it.
Ah, I guess read that as, "Plus, making 'default' mandatory helps make
'jsobject-update' consistent with 'jsobject-update*'."
>> + (define-values (popped tail-alist)
>> + (alist-pop alist key))
>> + (acons key
>> + (updater (match popped
>> + (#f
>> + (if (procedure? failure-result)
>> + (failure-result)
>> + failure-result))
>> + ((_ . value)
>> + value)))
>> + tail-alist))
> SRFI-71 let says hi. Also the ordering question applies. I'm starting
> to think we should implement alist-pop, alist-set and alist-update in
> terms of a single more powerful function producing three values (or
> SRFI-1 span).
Same question again re 'define-values'.
My intent in creating 'alist-pop' was to have a primitive that would
work for both 'alist-update' and 'alist-delete', and thereby
'alist-set'. Returning the prefix and the tail separately would involve
either extra allocation or mutating pairs. Since order never matters in
this context, why pay that price?
>> +(define* (jsobject-union #:key
>> + (combine (lambda (a b) b))
>> + (combine/key (lambda (k a b) (combine a
>> b)))
>> + #:rest json-objects)
>> + "Combine the given JSON-OBJECTS into a single json object. The
>> JSON-OBJECTS
>> +are merged from left to right by adding each key/value pair of each
>> object to
>> +the aggregate object in turn. When one of the JSON-OBJECTS contains
>> a mapping
>> +from some key KEY to a value VAL such that the aggregate object
>> already
>> +contains a mapping from KEY to a value VAL0, the aggregate object is
>> +functionally updated to instead map KEY to the value of (COMBINE/KEY
>> KEY VAL0
>> +VAL). The default COMBINE/KEY tail-calls (COMBINE VAL0 VAL), and
>> the default
>> +COMBINE simply returns its second argument, so, by default, mappings
>> in later
>> +JSON-OBJECTS supersede those in earlier ones."
>> + (match (filter (lambda (v)
>> + (not (or (keyword? v)
>> + (procedure? v))))
>> + json-objects)
>> + (()
>> + '(@))
>> + (((and js0 ('@ . _)))
>> + js0)
>> + ((('@ . alist0) ('@ . alist*) ...)
>> + (cons '@ (fold (lambda (alist1 alist0)
>> + (if (null? alist0)
>> + alist1
>> + (fold (lambda (k+v alist0)
>> + (match k+v
>> + ((k . v)
>> + (define-values (popped tail-
>> alist)
>> + (alist-pop alist0 k))
>> + (match popped
>> + (#f
>> + (cons k+v tail-alist))
>> + ((_ . v0)
>> + (acons k
>> + (combine/key k v0 v)
>> + tail-alist))))))
>> + alist0
>> + alist1)))
>> + alist0
>> + alist*)))))
> Same default argument. Cons inside.
> I think having a single combine function taking (k a b) would be less
> confusing than having two. Is there a rationale for the form you
> chose?
I based this function in particular on 'hash-union' from 'racket/hash'
[6], which uses these keywords. (But in 'hash-union', collisions trigger
an exception by default, and it requires at least one argument, because
otherwise it would be unclear what key-comparison function the result
should use.)
Having '#:combine' in addition to '#:combine/key' is ultimately just a
convenience, but it is quite a nice convenience in practice. It is quite
rare, in my experience, for a '#:combine' function to actually depend on
the key: it might depend on the type of the value, but, very often, it
unconditionally applies to all keys. Using '#:combine' is particularly
nice when using a combination function that already exists, like
'append' or '+'.
[6]:
https://docs.racket-lang.org/reference/hashtables.html#%28def._%28%28lib._racket%2Fhash..rkt%29._hash-union%29%29
>> + (with-atomic-json-file-replacement "package.json"
>> + (lambda (pkg-meta)
>> + (jsobject-update*
>> + pkg-meta
>> + "devDependencies" '(@) resolve-dependencies
>> + "dependencies" '(@) (lambda (deps)
>> + (resolve-dependencies
>> + (jsobject-union
>> + (jsobject-ref pkg-meta
>> "peerDependencies" '(@))
>> + deps))))))
>> #t)
> We should probably add a function to our js utils that "generates an
> empty object", because '(@) is quite confusing to see in these
> circumstances. Otherwise LGTM with the aforementioned caveats.
I'm not sure what to call it: it would have to be short, or people (me,
at least) might end up writing '(@) anyway. Also, IIUC Guile doesn't
actually prevent you from mutating quoted constant pairs, so I function
would have to allocate a fresh pair to be robust.
It's a somewhat odd idea, but how about this?
(define-syntax |{}| (identifier-syntax '(@)))
It's as short as '(@), it looks like the JSON notation for the empty
object, and IIUC people could only use it to mess up occurrences of '(@)
within the same compilation unit, which we can't stop them from doing
anyway.
Alternatively, if we give up the thunk special case for 'default'
values, we could do:
(define jsobject-update
(case-lambda
((js key updater)
(jsobject-update js key '(@) updater))
((js key default updater)
...)))
(define jsobject-update*
(case-lambda
...
((js . args)
(match js
(('@ . alist)
(cons '@ (let loop ((alist alist)
(args args))
(match args
(()
alist)
((key (? procedure? updater) . args)
(loop (alist-update alist key '(@) updater)
args))
((key default updater . args)
(loop (alist-update alist key '(@) updater)
args))))))))))
-Philip
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 03/41] guix: node-build-system: Add JSON utilities.
2021-12-31 5:22 ` Philip McGrath
@ 2021-12-31 10:18 ` Liliana Marie Prikler
2022-01-08 4:13 ` Philip McGrath
0 siblings, 1 reply; 458+ messages in thread
From: Liliana Marie Prikler @ 2021-12-31 10:18 UTC (permalink / raw)
To: Philip McGrath, 51838; +Cc: Timothy Sample, Pierre Langlois, Jelle Licht
Hi,
Am Freitag, dem 31.12.2021 um 00:22 -0500 schrieb Philip McGrath:
> I agree that these functions ultimately belong in their own file, and
> I'd even had the name (guix build json-utils) in mind.
>
> I put them in (guix build node-build-system) for now because, if they
> were in (guix build json-utils), they would have to be exported, at
> which point their API would have to be relatively stable, and I
> didn't want designing them to block, or to be rushed by, the rest of
> this series. Now, maybe consensus on the json-utils will turn out to
> be the easy part! But my high-level question is, in your view, do any
> of the points I'm about to respond to block this patch series?
We can certainly do them inside node-build-system, but I'd much prefer
if they took up less vertical real-estate. I hope we can agree on
that.
> On 12/30/21 13:18, Liliana Marie Prikler wrote:
> > Having argued for these procedures to be moved into their own file
> > in a separate mail, now it's time to bikeshed stylistic choices.
> >
> > Am Donnerstag, dem 30.12.2021 um 02:38 -0500 schrieb Philip
> > McGrath:
> > > +(define (jsobject-ref js key failure-result)
> > > + "Return the value assosciated with KEY in the json object JS.
> > > If
> > > KEY is not
> > > +found and FAILURE-RESULT is a procedure, it is called in tail
> > > position
> > > with
> > > +zero arguments. Otherwise, FAILURE-RESULT is returned."
> > > + ;; TODO: `failure-result` should be optional, but should the
> > > default
> > > + ;; `failure-result` be #f (like `assoc-ref`), a thunk raising
> > > an
> > > exception,
> > > + ;; '(@), or something else? Keep it mandatory until we
> > > discuss and
> > > decide.
> > > + (match js
> > > + (('@ . alist)
> > > + (match (assoc key alist)
> > > + (#f
> > > + (if (procedure? failure-result)
> > > + (failure-result)
> > > + failure-result))
> > > + ((_ . value)
> > > + value)))))
> > We can safely replace failure-result by Guile's DEFAULT and leave
> > error handling to the user.
>
> I don't care whether we call it DEFAULT or FAILURE-RESULT.
This is not just a question of naming, but also it doesn't really make
sense to call a thunk here. Just take DEFAULT as a value.
> I agree that it should not raise an exception by default. My current
> thinking is that '(@) would be a good default DEFAULT: it is useful
> for the common pattern of traversing or transforming nested objects,
> and, as you point out at the end of this email, explicitly typing #f
> (the other useful possibility) looks much more like normal Scheme
> than explicitly typing '(@).
The question here is whether '(@) is a good meaningful default or
whether we just want a different way of writing it, e.g. empty-object
or (empty-object).
> In my experience with [1] and [2] (the purely-functional dictionary
> libraries I use most often), the special case for a procedure as
> DEFAULT is useful. I feel less strongly about it because it's
> relatively easy to work around for JSON, since you can pick some non-
> JSON signal value, but it also seems to have especially little
> downside for JSON, since (guix build json) will never have a
> procedure in a valid JSON object. In addition to raising exceptions
> and other control flow, it's useful for default values that are
> expensive to produce.
That's all nice and dandy, but given that a valued DEFAULT is simpler
both in terms of interface and implementation, I think it is The Right
Thing here. For error handling purposes, the Guile way of doing things
is to produce a value outside of the expected range (such as #f,
*unspecified* or a locally defined gensym) and check against it.
> [1]: https://docs.racket-lang.org/reference/hashtables.html
> [2]: https://docs.racket-lang.org/reference/dicts.html
>
> >
> > > +(define (alist-pop alist key)
> > > + "Return two values: the first pair in ALIST with the given KEY
> > > in its
> > > +'car' (or #f, if no such pair exists) and an assosciation list
> > > like (and
> > > +potentially sharing storage with) ALIST, but with no entry for
> > > KEY."
> > > + (match (assoc key alist)
> > > + ;; If key isn't present, we don't need to do any allocation
> > > + (#f
> > > + (values #f alist))
> > > + (found
> > > + (values found
> > > + ;; Because we have `found`, we can find it more
> > > + ;; efficiently this time with `eq?`. We avoid using
> > > + ;; `delq` because it would copy pairs in a shared
> > > + ;; tail. We assume a sufficiently smart compiler to
> > > + ;; handle "tail recursion modulo cons" (vid. e.g.
> > > Indiana
> > > + ;; University Technical Report No. 19, Friedman &
> > > Wise
> > > + ;; 1975) at least as efficiently as a hand-written
> > > + ;; tail-recursive implementation with an
> > > accumulator.
> > > + (let loop ((alist alist))
> > > + (match alist
> > > + ;; We know that `found` is present,
> > > + ;; so no need to check for '()
> > > + ((this . alist)
> > > + (if (eq? this found)
> > > + alist
> > > + (cons this (loop alist))))))))))
> > I think this can be more efficiently be done in a "single" loop.
> >
> > (let loop ((rest alist)
> > (previous '()))
> > (match rest
> > (() (values #f alist))
> > ((first . rest)
> > (if (eq? (car first) key)
> > (values first (reverse! previous rest))
> > (loop rest (cons first previous))))))
> >
>
> I'll admit to a Racket bias, but, having just eliminated the use of
> 'assoc-set!', I'm loathe to start mutating pairs (even correctly). To
> quote a bit from the SRFI-1 spec for 'append-reverse!', "note that
> this pattern of iterative computation followed by a reverse can
> frequently be rewritten as a recursion, dispensing with the reverse
> and append-reverse steps, and shifting temporary, intermediate
> storage from the heap to the stack, which is typically a win for
> reasons of cache locality and eager storage reclamation." (See how
> 'set-cdr!' can crash safe Chez Scheme!
> <https://github.com/cisco/ChezScheme/issues/599>)
>
> IIUC, using SRFI-1's 'span' would lead to the same situation.
For the record, we can use the non-destructive append and reverse here
at the expense of more copying. If done in terms of SRFI-1 span, we
would not need reverse as far as I understand.
> > Also, I don't think your version is tail-recursive. (loop alist)
> > is not in tail position from what I can tell.
>
> Yes, "tail recursion modulo cons" refers to a compiler optimization
> for functions which are _not_ tail recursive. For full details, see
> the Friedman & Wise 1975 tech report I cited at
> <https://legacy.cs.indiana.edu/ftp/techreports/TR19.pdf> (or various
> other articles), but, as briefly as I can: The optimization rests on
> the observation that many recursive functions, like the classic
> definition of 'map':
>
> (define (map f lst)
> (match lst
> (()
> '())
> ((this . lst)
> (cons (f this)
> (map f lst)))))
>
> are nearly tail-recursive, and the only real work remaining to be
> done in the continuation of the recursive call is to fill in the cdr
> of the pair. Thus, a compiler can safely transform this code into a
> truly tail-recursive implementation:
>
> (define (map f lst)
> (match lst
> (()
> '())
> ((this . lst)
> (define ret (list (f this)))
> (let loop ((dest ret)
> (lst lst))
> (match lst
> ((this . lst)
> (define new (list (f this)))
> (set-cdr! dest new)
> (loop new lst))
> (()
> ret))))))
>
> Unlike the Proper Implementation of Tail Calls (so-called "tail-call
> optimization"), handling "tail recursion modulo cons" truly is an
> optimization: it does not change the space complexity of the
> function. But it can allow the compiler to generate whatever code it
> thinks will work best with its collector/allocator and
> continuation/"call stack" implementation.
>
> (The optimizations applies to constructors in general, not just
> 'cons', and a compiler can safely apply it to values that are
> immutable from the perspective of the source language.)
I'm not aware to which extent Guile implements tail recursion modulo
cons and I'd argue neither are you until you dig down into disassembly.
I think it's better here to avoid patterns from Racket that would feel
foreign to Guilers, particularly if you have to explain them with
reference to a paper (we already get hate for referring to Wingo's fold
for XML handling).
In principle, what you're supposing is that a sufficiently smart
compiler could rewrite
(let ((before after (span PRED mylist))) (append before after))
to (list-copy mylist), which as far as I'm aware Guile currently
doesn't. It could be argued that it would start doing so once I cast
some magic incantations, but I wouldn't count on it without reading the
disassembly.
> > That's a pretty long comment around something that could be done
> > with call-with-values or SRFI-71 let. I think one of these two
> > should be preferred.
> >
> > Note that both our versions of alist-pop only pop the first key (as
> > they should). This means that alist-delete* should really be
> > called alist-delete-1 as in "remove the first pair in ALIST
> > belonging to KEY".
> > For the larger JSON handling below, this makes no difference
> > however.
>
> Here I was using '*' to mean "a slightly altered version of", as with
> 'letrec' and 'letrec*', but, yes, since the other functions defined
> here use '*' to mean "zero or more times", the name is confusing: I
> think I'd just call it 'alist-delete' and not import (srfi srfi-1)'s
> version.
That's not the issue here, the issue is that the behaviour also differs
from alist-delete!
> The comment may be unnecessarily long ... the essence of what I was
> trying to explain is that, in all of these implementations, I've
> tried to avoid unnecessary allocation. Being able to rely on
> 'alist-delete', and more generally 'alist-pop', not to needlessly
> copy the "spine" of the list lets later functions use them
> unconditionally.
Which again would be simpler if we used SRFI-1 span or another
primitive that produced (head item spine) as three outputs. WDYT?
> Why would you prefer 'call-with-values' or SRFI-71 over 'define-
> values'? The style guide against which I'm used to working [3]
> generally prefers internal definitions, to avoid rightward drift.
>
> [3]:
> https://docs.racket-lang.org/style/Choosing_the_Right_Construct.html#%28part._.Definitions%29
Again, that's a racketism. To avoid rightward drift, we either
carefully choose where to indent or simplify our definitions to no
longer drift. A single let in a function spanning three lines is
hardly an issue w.r.t. rightward drift.
+(define (alist-set alist key value)
> > Is order relevant here? Because we could just as well reimplement
> > our alist-delete* loop and cons the replacement onto the rest.
> > WDYT?
>
> Relying on order for JSON objects is non-interoperable, per RFC 8259
> §4. I'm not intending for these alist procedures to be exported, so
> I'm not trying to handle any more general case than that, as I
> explain in the comments at the top of the file.
>
> I'm not sure what the advantage would be to reimplementing the
> 'alist-delete' loop here.
Fair enough, the question was however not so much what is required per
RFC, but rather if there is a natural feel of order to package.json
that we ought not disturb. Particularly, putting dependencies before
name and version could be confusing to whoever needs to debug a delete-
dependencies phase gone wrong.
> So you would make 'jsobject-set*' a macro? When you say, "with
> FIELD1, FIELD2 being identifiers", do you mean that the macro should
> convert them to strings at compile-time?
Yes to both.
> While, if I were designing a JSON representation, I'd much prefer to
> use symbols for the object keys, I think it would be confusing to use
> strings everywhere else but magic symbols here.
I don't think I agree here. Assuming that jsobject-set* is a primitive
we need at the moment to be defined (rather than the more generic
jsobject-update*), I think using identifiers for JSON keys in our
rewriters would be a good abstraction. That being said, this is not
necessarily a blocker, just a weird interface imo.
>
> > Which alist-update* are you referring to here? Either way, the
> > failure-result to default argument from above applies, but we could
> > keyword it.
>
> Ah, I guess read that as, "Plus, making 'default' mandatory helps
> make 'jsobject-update' consistent with 'jsobject-update*'."
Fair enough, it's okay to admit one's typos :)
> >
> > SRFI-71 let says hi. Also the ordering question applies. I'm
> > starting to think we should implement alist-pop, alist-set and
> > alist-update in terms of a single more powerful function producing
> > three values (or SRFI-1 span).
>
> Same question again re 'define-values'.
Same answer.
> My intent in creating 'alist-pop' was to have a primitive that would
> work for both 'alist-update' and 'alist-delete', and thereby
> 'alist-set'. Returning the prefix and the tail separately would
> involve either extra allocation or mutating pairs. Since order never
> matters in this context, why pay that price?
Again, our consumers are not just machines, but also human readers who
might value that order. It is nice that you're paying attention to
allocated objects, but I think you are blind to some allocations that
you are accustomed to being reasoned away by Racket.
>
> > Same default argument. Cons inside.
> > I think having a single combine function taking (k a b) would be
> > less confusing than having two. Is there a rationale for the form
> > you chose?
>
> I based this function in particular on 'hash-union' from
> 'racket/hash' [6], which uses these keywords. (But in 'hash-union',
> collisions trigger an exception by default, and it requires at least
> one argument, because otherwise it would be unclear what key-
> comparison function the result should use.)
>
> Having '#:combine' in addition to '#:combine/key' is ultimately just
> a convenience, but it is quite a nice convenience in practice. It is
> quite rare, in my experience, for a '#:combine' function to actually
> depend on the key: it might depend on the type of the value, but,
> very often, it unconditionally applies to all keys. Using
> '#:combine' is particularly nice when using a combination function
> that already exists, like 'append' or '+'.
Fair enough, but what about having #:combine be your #:combine/key and
#:default-combine be your #:combine in that keyword soup? It takes up
more horizontal real-estate (not that we wouldn't write those
vertically anyway).
Alternatively, this would be a good place to use procedure generators
for once. (ignore-key combinator) takes a procedure that takes two
arguments (such as 'append' or '+') and produces one that takes three
and ignores the initial key. This would also help making the interface
and implementation simpler: (json-union combinator obj ...)
> >
> > > + (with-atomic-json-file-replacement "package.json"
> > > + (lambda (pkg-meta)
> > > + (jsobject-update*
> > > + pkg-meta
> > > + "devDependencies" '(@) resolve-dependencies
> > > + "dependencies" '(@) (lambda (deps)
> > > + (resolve-dependencies
> > > + (jsobject-union
> > > + (jsobject-ref pkg-meta
> > > "peerDependencies" '(@))
> > > + deps))))))
> > > #t)
> > We should probably add a function to our js utils that "generates
> > anempty object", because '(@) is quite confusing to see in these
> > circumstances. Otherwise LGTM with the aforementioned caveats.
>
> I'm not sure what to call it: it would have to be short, or people
> (me, at least) might end up writing '(@) anyway.
'none', 'epsilon', '@psilon' would be nice "short" ways of writing
"empty object".
> Also, IIUC Guile doesn't actually prevent you from mutating quoted
> constant pairs, so a function would have to allocate a fresh pair to
> be robust.
That is correct, so we do have to be careful with our other primitives
here.
> It's a somewhat odd idea, but how about this?
>
> (define-syntax |{}| (identifier-syntax '(@)))
We can currently do without the bar escapes, but I'd prefer not to do
either, since it'd appear as similar line noise to '(@). Having a
readable name is in my opinion to be preferred. That being said,
identifier-syntax is the right direction in general imo.
> Alternatively, if we give up the thunk special case for 'default'
> values, we could do:
>
> (define jsobject-update
> (case-lambda
> ((js key updater)
> (jsobject-update js key '(@) updater))
> ((js key default updater)
> ...)))
> [...]
For the record, I think the only JSON primitive we need here is
(rewrite-json-file "package.json"
((dependencies) [do stuff with dependencies bound])
((devDependencies) [do stuff with devDependencies bound])
[...])
wherein we can convert dependencies and devDependencies to and from
alists using alist->json-object and json-object->alist. The rest can
be done using [a]list stuff from Guile core and SRFI-1 with one or two
amendments of our own. WDYT?
The delete-dependencies phase would then be defined as
(define (delete-dependencies . etc)
(define (%delete-dependencies (obj)
(let ((alist (json-object->alist obj)))
(alist->json [actually delete the dependencies]))))
(rewrite-json-file "package.json"
((dependencies) (%delete-dependencies dependencies))
((devDependencies) (%delete-dependencies devDependencies))))
Pardon me not writing out etc, but I think you get the idea.
As for what happens if a value is unbound, we could make it
((key [default]) code)
so imagine writing (dependencies none) instead of (dependencies) for
safety.
Cheers
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 03/41] guix: node-build-system: Add JSON utilities.
2021-12-31 10:18 ` Liliana Marie Prikler
@ 2022-01-08 4:13 ` Philip McGrath
0 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2022-01-08 4:13 UTC (permalink / raw)
To: Liliana Marie Prikler, 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Leo Famulari
Hi,
On 12/31/21 05:18, Liliana Marie Prikler wrote:
> Am Freitag, dem 31.12.2021 um 00:22 -0500 schrieb Philip McGrath:
>>>> +(define (alist-pop alist key)
>>>> + "Return two values: the first pair in ALIST with the given KEY
>>>> in its
>>>> +'car' (or #f, if no such pair exists) and an assosciation list
>>>> like (and
>>>> +potentially sharing storage with) ALIST, but with no entry for
>>>> KEY."
>>>> + (match (assoc key alist)
>>>> + ;; If key isn't present, we don't need to do any allocation
>>>> + (#f
>>>> + (values #f alist))
>>>> + (found
>>>> + (values found
>>>> + ;; Because we have `found`, we can find it more
>>>> + ;; efficiently this time with `eq?`. We avoid using
>>>> + ;; `delq` because it would copy pairs in a shared
>>>> + ;; tail. We assume a sufficiently smart compiler to
>>>> + ;; handle "tail recursion modulo cons" (vid. e.g.
>>>> Indiana
>>>> + ;; University Technical Report No. 19, Friedman &
>>>> Wise
>>>> + ;; 1975) at least as efficiently as a hand-written
>>>> + ;; tail-recursive implementation with an
>>>> accumulator.
>>>> + (let loop ((alist alist))
>>>> + (match alist
>>>> + ;; We know that `found` is present,
>>>> + ;; so no need to check for '()
>>>> + ((this . alist)
>>>> + (if (eq? this found)
>>>> + alist
>>>> + (cons this (loop alist))))))))))
>>> I think this can be more efficiently be done in a "single" loop.
>>>
>>> (let loop ((rest alist)
>>> (previous '()))
>>> (match rest
>>> (() (values #f alist))
>>> ((first . rest)
>>> (if (eq? (car first) key)
>>> (values first (reverse! previous rest))
>>> (loop rest (cons first previous))))))
>>>
>>
>> I'll admit to a Racket bias, but, having just eliminated the use of
>> 'assoc-set!', I'm loathe to start mutating pairs (even correctly). To
>> quote a bit from the SRFI-1 spec for 'append-reverse!', "note that
>> this pattern of iterative computation followed by a reverse can
>> frequently be rewritten as a recursion, dispensing with the reverse
>> and append-reverse steps, and shifting temporary, intermediate
>> storage from the heap to the stack, which is typically a win for
>> reasons of cache locality and eager storage reclamation." (See how
>> 'set-cdr!' can crash safe Chez Scheme!
>> <https://github.com/cisco/ChezScheme/issues/599>)
>>
>> IIUC, using SRFI-1's 'span' would lead to the same situation.
> For the record, we can use the non-destructive append and reverse here
> at the expense of more copying. If done in terms of SRFI-1 span, we
> would not need reverse as far as I understand.
>
>>> Also, I don't think your version is tail-recursive. (loop alist)
>>> is not in tail position from what I can tell.
>>
>> Yes, "tail recursion modulo cons" refers to a compiler optimization
>> for functions which are _not_ tail recursive. For full details, see
>> the Friedman & Wise 1975 tech report I cited at
>> <https://legacy.cs.indiana.edu/ftp/techreports/TR19.pdf> (or various
>> other articles), but, as briefly as I can: The optimization rests on
>> the observation that many recursive functions, like the classic
>> definition of 'map':
>>
>> (define (map f lst)
>> (match lst
>> (()
>> '())
>> ((this . lst)
>> (cons (f this)
>> (map f lst)))))
>>
>> are nearly tail-recursive, and the only real work remaining to be
>> done in the continuation of the recursive call is to fill in the cdr
>> of the pair. Thus, a compiler can safely transform this code into a
>> truly tail-recursive implementation:
>>
>> (define (map f lst)
>> (match lst
>> (()
>> '())
>> ((this . lst)
>> (define ret (list (f this)))
>> (let loop ((dest ret)
>> (lst lst))
>> (match lst
>> ((this . lst)
>> (define new (list (f this)))
>> (set-cdr! dest new)
>> (loop new lst))
>> (()
>> ret))))))
>>
>> Unlike the Proper Implementation of Tail Calls (so-called "tail-call
>> optimization"), handling "tail recursion modulo cons" truly is an
>> optimization: it does not change the space complexity of the
>> function. But it can allow the compiler to generate whatever code it
>> thinks will work best with its collector/allocator and
>> continuation/"call stack" implementation.
>>
>> (The optimizations applies to constructors in general, not just
>> 'cons', and a compiler can safely apply it to values that are
>> immutable from the perspective of the source language.)
> I'm not aware to which extent Guile implements tail recursion modulo
> cons and I'd argue neither are you until you dig down into disassembly.
> I think it's better here to avoid patterns from Racket that would feel
> foreign to Guilers, particularly if you have to explain them with
> reference to a paper (we already get hate for referring to Wingo's fold
> for XML handling).
In a sense, "tail recursion modulo cons" was a red herring here. The
essential requirement for implementing 'alist-pop' or 'map' as I did is
that the language implementation be "safe for space", i.e. not have
"stack overflow"s: Guile meets that requirement. [1]
In a safe-for-space language, the naturally recursive implementations
and the implementations with explicit, non-destructive accumulators both
allocate O(n) temporary storage. The difference is that the explicit
accumulator versions allocate temporary pairs on the heap, while the
naturally recursive version allocates its temporary space on the "stack"
(i.e. additional frames of the (non-reified) continuation), which is
generally, and specifically for Guile per [1], much better (though a
sufficiently smart generational garbage collector with bump-pointer
allocation in the nursery could mitigate the difference somewhat).
All of that relies just on the guarantees of Guile as a safe-for-space
language. The optimization in "tail recursion modulo cons" is that a
compiler could, if it chose to expend its effort this way, make the
naturally recursive implementations work without the O(n) temporary
"stack" storage by transforming transforming the non-tail recursion into
tail recursion. In essence, it could achieve a similar effect to an
explicit accumulator plus 'reverse!' without the many downsides (some of
which [1] discusses).
But the naturally recursive implementation is preferable even if the
optimization does not apply.
>
> In principle, what you're supposing is that a sufficiently smart
> compiler could rewrite
>
> (let ((before after (span PRED mylist))) (append before after))
>
> to (list-copy mylist), which as far as I'm aware Guile currently
> doesn't. It could be argued that it would start doing so once I cast
> some magic incantations, but I wouldn't count on it without reading the
> disassembly.
In some sense that's true, but your example would require a lot of
interprocedural analysis, not just a directly visible pattern with
well-known primitives using analysis that has been well known since the
'70s. But, again, the optimization isn't really relevant.
>>> Is order relevant here? Because we could just as well reimplement
>>> our alist-delete* loop and cons the replacement onto the rest.
>>> WDYT?
>>
>> Relying on order for JSON objects is non-interoperable, per RFC 8259
>> §4. I'm not intending for these alist procedures to be exported, so
>> I'm not trying to handle any more general case than that, as I
>> explain in the comments at the top of the file.
>>
>> I'm not sure what the advantage would be to reimplementing the
>> 'alist-delete' loop here.
> Fair enough, the question was however not so much what is required per
> RFC, but rather if there is a natural feel of order to package.json
> that we ought not disturb. Particularly, putting dependencies before
> name and version could be confusing to whoever needs to debug a delete-
> dependencies phase gone wrong.
I haven't noticed a consistent convention in "package.json" files (which
IIUC may not be entirely hand-written).
For debugging, the biggest problem is that (guix build json) doesn't add
any linebreaks or indentation.
If I were changing it, I'd want it to write object keys in 'string<?'
order and to raise an exception if given duplicate keys.
-Philip
[1]:
https://www.gnu.org/software/guile/docs/docs-2.2/guile-ref/Stack-Overflow.html
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 04/41] guix: node-build-system: Add avoid-node-gyp-rebuild phase.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (2 preceding siblings ...)
2021-12-30 7:38 ` [bug#51838] [PATCH v6 03/41] guix: node-build-system: Add JSON utilities Philip McGrath
@ 2021-12-30 7:38 ` Philip McGrath
2021-12-30 7:38 ` [bug#51838] [PATCH v6 05/41] guix: node-build-system: Add 'delete-dependencies' helper function Philip McGrath
` (38 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:38 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* guix/build/node-build-system.scm (avoid-node-gyp-rebuild): New
function. Override the default install script for packages with
native addons to prevent it from attempting to write to the store
when such packages are used.
(%standard-phases): Add 'avoid-node-gyp-rebuild' after 'install'.
---
guix/build/node-build-system.scm | 50 +++++++++++++++++++++++++++++++-
1 file changed, 49 insertions(+), 1 deletion(-)
diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index e5c4da5091..dc8b6a41c2 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -380,6 +380,53 @@ (define* (install #:key outputs inputs #:allow-other-keys)
"install" "../package.tgz")
#t))
+(define* (avoid-node-gyp-rebuild #:key outputs #:allow-other-keys)
+ "Adjust the installed 'package.json' to remove an 'install' script that
+would try to run 'node-gyp rebuild'."
+ ;; We want to take advantage of `npm install`'s automatic support for
+ ;; building native addons with node-gyp: in particular, it helps us avoid
+ ;; hard-coding the specifics of how npm's internal copy of node-gyp is
+ ;; currently packaged. However, the mechanism by which the automatic support
+ ;; is implemented causes problems for us.
+ ;;
+ ;; If a package contains a 'binding.gyp' file and does not define an
+ ;; 'install' or 'preinstall' script, 'npm install' runs a default install
+ ;; script consisting of 'node-gyp rebuild'. In our 'install' phase, this
+ ;; implicit 'install' script, if it is applicable, is explicitly added to
+ ;; the "package.json" file. However, if another Guix package were to use a
+ ;; Node.js package with such an 'install' script, the dependent package's
+ ;; build process would fail, because 'node-gyp rebuild' would try to write
+ ;; to the store.
+ ;;
+ ;; Here, if the installed "package.json" defines scripts.install as
+ ;; "node-gyp rebuild", we replace it with a no-op. Importantly, deleting the
+ ;; install script definition would not be enough, because the default
+ ;; install script would cause the same problem.
+ ;;
+ ;; For further details, see:
+ ;; - https://docs.npmjs.com/cli/v8/configuring-npm/package-json#default-values
+ ;; - https://docs.npmjs.com/cli/v8/using-npm/scripts#best-practices
+ (define installed-package.json
+ (search-input-file outputs (string-append "/lib/node_modules/"
+ (module-name ".")
+ "/package.json")))
+ ;; not with-atomic-json-file-replacement, because we usually don't
+ ;; want or need to overwrite it
+ (define pkg-meta
+ (call-with-input-file installed-package.json read-json))
+ (define scripts
+ (jsobject-ref pkg-meta "scripts" '(@)))
+ (when (equal? "node-gyp rebuild" (jsobject-ref scripts "install" #f))
+ (call-with-output-file installed-package.json
+ (lambda (out)
+ (write-json
+ (jsobject-set pkg-meta
+ "scripts"
+ (jsobject-set scripts
+ "install"
+ "echo Guix: avoiding node-gyp rebuild"))
+ out)))))
+
(define %standard-phases
(modify-phases gnu:%standard-phases
(add-after 'unpack 'set-home set-home)
@@ -389,7 +436,8 @@ (define %standard-phases
(replace 'build build)
(replace 'check check)
(add-before 'install 'repack repack)
- (replace 'install install)))
+ (replace 'install install)
+ (add-after 'install 'avoid-node-gyp-rebuild avoid-node-gyp-rebuild)))
(define* (node-build #:key inputs (phases %standard-phases)
#:allow-other-keys #:rest args)
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 05/41] guix: node-build-system: Add 'delete-dependencies' helper function.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (3 preceding siblings ...)
2021-12-30 7:38 ` [bug#51838] [PATCH v6 04/41] guix: node-build-system: Add avoid-node-gyp-rebuild phase Philip McGrath
@ 2021-12-30 7:38 ` Philip McGrath
2021-12-30 17:29 ` Liliana Marie Prikler
2021-12-30 7:38 ` [bug#51838] [PATCH v6 06/41] gnu: node-semver-bootstrap: Use 'delete-dependencies' Philip McGrath
` (37 subsequent siblings)
42 siblings, 1 reply; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:38 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* guix/build/node-build-system.scm (delete-dependencies): New exported
procedure. Functionally updates a "package.json"-like value by removing
specified npm packages from the "dependencies" and "devDependencies"
objects.
---
guix/build/node-build-system.scm | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index dc8b6a41c2..9967223b86 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -27,6 +27,7 @@ (define-module (guix build node-build-system)
#:use-module (srfi srfi-1)
#:export (%standard-phases
with-atomic-json-file-replacement
+ delete-dependencies
node-build))
;; Commentary:
@@ -325,6 +326,23 @@ (define resolve-dependencies
deps))))))
#t)
+(define (delete-dependencies pkg-meta absent-dependencies)
+ "Functionally update PKG-META, a json object corresponding to a
+'package.json' file, to allow building without the ABSENT-DEPENDENCIES. To
+avoid reintroducing the ABSENT-DEPENDENCIES, only use this procedure after the
+'patch-dependencies' phase."
+ (define delete-fom-jsobject
+ (match-lambda
+ (('@ . alist)
+ (cons '@ (filter (match-lambda
+ ((k . v)
+ (not (member k absent-dependencies))))
+ alist)))))
+ (jsobject-update*
+ pkg-meta
+ "devDependencies" '(@) delete-fom-jsobject
+ "dependencies" '(@) delete-fom-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
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 05/41] guix: node-build-system: Add 'delete-dependencies' helper function.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 05/41] guix: node-build-system: Add 'delete-dependencies' helper function Philip McGrath
@ 2021-12-30 17:29 ` Liliana Marie Prikler
2021-12-31 1:09 ` Philip McGrath
0 siblings, 1 reply; 458+ messages in thread
From: Liliana Marie Prikler @ 2021-12-30 17:29 UTC (permalink / raw)
To: Philip McGrath, 51838; +Cc: Timothy Sample, Pierre Langlois, Jelle Licht
Am Donnerstag, dem 30.12.2021 um 02:38 -0500 schrieb Philip McGrath:
> * guix/build/node-build-system.scm (delete-dependencies): New
> exported procedure. Functionally updates a "package.json"-like value
> by removing specified npm packages from the "dependencies" and
> "devDependencies" objects.
> ---
> guix/build/node-build-system.scm | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/guix/build/node-build-system.scm b/guix/build/node-
> build-system.scm
> index dc8b6a41c2..9967223b86 100644
> --- a/guix/build/node-build-system.scm
> +++ b/guix/build/node-build-system.scm
> @@ -27,6 +27,7 @@ (define-module (guix build node-build-system)
> #:use-module (srfi srfi-1)
> #:export (%standard-phases
> with-atomic-json-file-replacement
> + delete-dependencies
> node-build))
>
> ;; Commentary:
> @@ -325,6 +326,23 @@ (define resolve-dependencies
> deps))))))
> #t)
>
> +(define (delete-dependencies pkg-meta absent-dependencies)
> + "Functionally update PKG-META, a json object corresponding to a
> +'package.json' file, to allow building without the ABSENT-
> DEPENDENCIES. To
> +avoid reintroducing the ABSENT-DEPENDENCIES, only use this procedure
> after the
> +'patch-dependencies' phase."
> + (define delete-fom-jsobject
> + (match-lambda
> + (('@ . alist)
> + (cons '@ (filter (match-lambda
> + ((k . v)
> + (not (member k absent-dependencies))))
> + alist)))))
> + (jsobject-update*
> + pkg-meta
> + "devDependencies" '(@) delete-fom-jsobject
> + "dependencies" '(@) delete-fom-jsobject))
Given this rather easy definition in terms of our helper functions, I
think this procedure can do more. Particularly, I'd argue that we can
define it as such:
(define* (delete-dependencies dependencies #:key (file "package.json")
(json-keys
'("dependencies" "devDependencies"))
"Remove DEPENDENCIES from JSON_KEYS in FILE."
(with-atomic-json-file-replacement ...))
This would in turn make it easier to delete dependencies from #:phases,
eliminating the need to shorten it to #:absent-dependencies. WDYT?
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 05/41] guix: node-build-system: Add 'delete-dependencies' helper function.
2021-12-30 17:29 ` Liliana Marie Prikler
@ 2021-12-31 1:09 ` Philip McGrath
2021-12-31 2:46 ` Liliana Marie Prikler
0 siblings, 1 reply; 458+ messages in thread
From: Philip McGrath @ 2021-12-31 1:09 UTC (permalink / raw)
To: Liliana Marie Prikler, 51838; +Cc: Timothy Sample, Pierre Langlois, Jelle Licht
Hi,
On 12/30/21 12:29, Liliana Marie Prikler wrote:
> Am Donnerstag, dem 30.12.2021 um 02:38 -0500 schrieb Philip McGrath:
>> +(define (delete-dependencies pkg-meta absent-dependencies)
>> + "Functionally update PKG-META, a json object corresponding to a
>> +'package.json' file, to allow building without the ABSENT-
>> DEPENDENCIES. To
>> +avoid reintroducing the ABSENT-DEPENDENCIES, only use this procedure
>> after the
>> +'patch-dependencies' phase."
>> + (define delete-fom-jsobject
>> + (match-lambda
>> + (('@ . alist)
>> + (cons '@ (filter (match-lambda
>> + ((k . v)
>> + (not (member k absent-dependencies))))
>> + alist)))))
>> + (jsobject-update*
>> + pkg-meta
>> + "devDependencies" '(@) delete-fom-jsobject
>> + "dependencies" '(@) delete-fom-jsobject))
> Given this rather easy definition in terms of our helper functions, I
> think this procedure can do more. Particularly, I'd argue that we can
> define it as such:
>
> (define* (delete-dependencies dependencies #:key (file "package.json")
> (json-keys
> '("dependencies" "devDependencies"))
> "Remove DEPENDENCIES from JSON_KEYS in FILE."
> (with-atomic-json-file-replacement ...))
>
> This would in turn make it easier to delete dependencies from #:phases,
> eliminating the need to shorten it to #:absent-dependencies. WDYT?
>
I don't think '#:json-keys' would be helpful.
In my view, the high-level purpose of 'delete-dependencies',
'#:absent-dependencies', or whatever is to gather our collective
procedural knowledge about how to modify a "package.json" file to build
a package without some of the dependencies its developers have declared
and to encode that knowledge in a single, abstracted point of control in
'node-build-system', so that authors of Node.js package definitions can
simply specify which declared dependencies are absent and leave it to
'node-build-system' to act accordingly. (I don't think it matters _why_
the dependencies are absent, i.e. whether we don't want the them or
merely don't have them.)
In our experience so far, the necessary modification does concretely
amount to "Remove DEPENDENCIES from JSON_KEYS in FILE.", but that is not
the ultimate purpose of this code, and I think that description, along
with '#:json-keys', ends up being simultaneously too flexible and too
restrictive. It is unnecessarily flexible because, if a package author
ever passes some other value for '#:json-keys', that would seem to
indicate that there's some procedural knowledge missing from
'node-build-system', and it should be added there. More significantly,
it unnecessarily seems to restrict 'delete-dependencies' from taking
other kinds of actions to handle the absent dependencies, if in the
future we should discover that there's something we need to do that
wouldn't amount to just adding another JSON key. It's a little odd to
give an example of something we might not know, but, for example, I
could imagine learning that correct handling of absent
"peerDependencies" could require more involved transformation of the
structures under "peerDependenciesMeta".
As far as the rest of your suggestion, on the one hand, this:
(define* (delete-dependencies deps #:key (file "package.json"))
(with-atomic-json-file-replacement ...))
seems like a fine enhancement, and I could live with it---I'd even
prefer it, if v6 but not v7 of this patch series can achieve consensus.
On the other hand, at the risk of beating a dead horse, it seems like a
tiny step from the above to:
(define* ((delete-dependencies deps #:key (file "package.json")) . _)
(with-atomic-json-file-replacement ...))
which is just another name for 'make-delete-dependencies-phase', which
AIUI you had found objectionable. (Apparently that shorthand would need
(ice-9 curried-definitions).)
Indeed, if we observe that '#:file', similarly to '#:json-keys', will
never be anything _other_ than "package.json", we could further simplify to:
(define* ((delete-dependencies deps) . _)
(with-atomic-json-file-replacement ...))
at which point we've basically re-invented the implementation of patch
v7 05/41, which basically amounts to:
(define* (delete-dependencies #:key absent-dependencies)
(with-atomic-json-file-replacement ...))
In other words, I don't agree that any of these possible changes would
"eliminat[e] the need to shorten it to #:absent-dependencies",
I still feel that there's something I'm fundamentally not understanding
about your objections to '#:make-absent-dependencies', which is why, in
v6, I tried to do exactly as you had proposed:
On 12/20/21 17:00, Liliana Marie Prikler wrote:
> Hi Timothy,
>
> Am Montag, dem 20.12.2021 um 15:15 -0500 schrieb Timothy Sample:
>> Hi Philip,
>>
>> Philip McGrath <philip@philipmcgrath.com> writes:
>>
>>> If we took your final suggestion above, I think we'd have something
>>> like this:
>>>
>>> ```
>>> #:phases
>>> (modify-phases %standard-phases
>>> (add-after 'unpack 'delete-dependencies
>>> (make-delete-dependencies-phase '("node-tap"))))
>>> ```
>>
>> I’m perfectly happy with this if it’s a compromise we all can agree on.
>> It is exactly what popped into my imagination when I read Liliana’s
>> suggestion. I guess the one thing missing is that it would not
>> necessarily be implemented on top of better “package.json”
>> manipulation support. That said, it doesn’t preclude providing that
>> support if/when the need arises.
> In my personal opinion, we would write that support first and perhaps
> the shorthands later. I.e.
>
> (add-after 'patch-dependencies 'drop-junk
> (lambda _
> (with-atomic-json-replacement "package.json"
> (lambda (json) (delete-dependencies json '("node-tap"))))))
Certainly I do agree that it would be better to support code more
concise than that! But I think all of these variations are strictly
worse than '#:absent-dependencies'. It isn't just that they are more
typing: the require authors of package definitions to have some (not
very much, but some) procedural knowledge about _how_
'node-build-system' deals with the absence of dependencies, rather than
with '#:absent-dependencies', declaratively specifying _what_ is to be
done. For example, as I mentioned in my cover letter at
<https://issues.guix.gnu.org/51838#257>, even my own code from the
exchange I just quoted:
>>> (add-after 'unpack 'delete-dependencies
>>> (make-delete-dependencies-phase '("node-tap"))))
would be broken in v6, because the implementation of
'delete-dependencies' assumes that the 'patch-dependencies' phase has
already been run. I think this is an implementation detail that users of
'node-build-system' should not be required to know! Indeed, I think that
would be a good reason to have 'patch-dependencies' handle the absent
dependencies itself, as previous versions of this series have done, but
at least making 'delete-dependencies' a phase in 'standard-phases', as
v7 does, relieves the user of burden of managing the ordering
requirement manually.
I expect the majority of Guix's Node.js packages will continue for the
foreseeable future to need the functionality for absent dependencies I
described at the beginning of this email, so I think we should provide
it through a mechanism that is as high-level, concise, declarative as
possible, and ideally one that will facilitate automated code generation
and static analysis. On each of these criteria, I think
'#:absent-dependencies' is better than any of the other proposals I've
heard.
But, as I said, in the interest of compromise and moving forward, I'm
willing to live with something based on v6 for now if that's what can
achieve consensus, and then propose '#:absent-dependencies' separately.
So, if you want me to send a new version with one of these other
variations, tell me which one, and I'll do it.
I hope my tone isn't coming across the wrong way---I really don't mean
to be snarky! But I am genuinely struggling to understand the
significance of the difference between:
>>> (add-after 'unpack 'delete-dependencies
>>> (make-delete-dependencies-phase '("node-tap"))))
which I thought you objected to, and the result of what I think you've
most recently proposed:
(add-after 'patch-dependencies 'delete-dependencies
(lambda () (delete-dependencies '("node-tap"))))
which would have avoided my earlier reservations about making the JSON
representation part of the build system's public API for the first time.
So I'm not feeling very confident in my ability to predict what changes
would or would not block consensus.
-Philip
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 05/41] guix: node-build-system: Add 'delete-dependencies' helper function.
2021-12-31 1:09 ` Philip McGrath
@ 2021-12-31 2:46 ` Liliana Marie Prikler
2022-01-05 19:08 ` Philip McGrath
0 siblings, 1 reply; 458+ messages in thread
From: Liliana Marie Prikler @ 2021-12-31 2:46 UTC (permalink / raw)
To: Philip McGrath, 51838; +Cc: Timothy Sample, Pierre Langlois, Jelle Licht
Hi,
Am Donnerstag, dem 30.12.2021 um 20:09 -0500 schrieb Philip McGrath:
> Hi,
>
> On 12/30/21 12:29, Liliana Marie Prikler wrote:
> > Am Donnerstag, dem 30.12.2021 um 02:38 -0500 schrieb Philip
> > McGrath:
> > > + (define delete-fom-jsobject
For the record, I forgot to mention the typo here. It obviously ought
to be delete-from-jsobject.
> [...]
> I don't think '#:json-keys' would be helpful.
>
> In my view, the high-level purpose of 'delete-dependencies',
> '#:absent-dependencies', or whatever is to gather our collective
> procedural knowledge about how to modify a "package.json" file to
> build a package without some of the dependencies its developers have
> declared and to encode that knowledge in a single, abstracted point
> of control in 'node-build-system', so that authors of Node.js package
> definitions can simply specify which declared dependencies are absent
> and leave it to 'node-build-system' to act accordingly. (I don't
> think it matters _why_ the dependencies are absent, i.e. whether we
> don't want the them or merely don't have them.)
For the record, you can delete present dependencies as well, which is
one shortcoming in the "absent dependencies" metaphor. As for deleting
absent packages automatically without specifying them, one could argue
that a shortcoming of this set is that it doesn't provide a way of
doing that. I'll take a closer look at the ease-of-use as I walk down
your reply.
> In our experience so far, the necessary modification does concretely
> amount to "Remove DEPENDENCIES from JSON_KEYS in FILE.", but that is
> not the ultimate purpose of this code, and I think that description,
> along with '#:json-keys', ends up being simultaneously too flexible
> and too restrictive.
Admittedly, if you read DEPENDENCIES, JSON_KEYS and FILE as mere
variables with no meaning that's bad, but the key here is that
DEPENDENCIES is a list of dependencies and JSON_KEYS is a list of json
keys that refer to dependency lists. Anything else would be unlawful
use.
> It is unnecessarily flexible because, if a package author ever passes
> some other value for '#:json-keys', that would seem to indicate that
> there's some procedural knowledge missing from 'node-build-system',
> and it should be added there.
The reason I have it as such is that a packager might decide in the
future to e.g. only drop a peer dependency, that might share a name
with a dev dependency or something along those lines. Along with
#:file, it's also supposed to guard against files other than
package.json containing a list of dependencies that blows up in our
faces, which we could edit with the same primitive. That being said, I
do get your point in that it's overly flexible for now in which the
point is just to rewrite package.json.
> More significantly, it unnecessarily seems to restrict 'delete-
> dependencies' from taking other kinds of actions to handle the absent
> dependencies, if in the future we should discover that there's
> something we need to do that wouldn't amount to just adding another
> JSON key. It's a little odd to give an example of something we might
> not know, but, for example, I could imagine learning that correct
> handling of absent "peerDependencies" could require more involved
> transformation of the structures under "peerDependenciesMeta".
Do you mean that as in "if a dependency is found under this key, then
foo, bar and baz also need to happen"? If so, that would be
concerning, but also a good reason to have that abstraction.
> As far as the rest of your suggestion, on the one hand, this:
>
> (define* (delete-dependencies deps #:key (file "package.json"))
> (with-atomic-json-file-replacement ...))
>
> seems like a fine enhancement, and I could live with it---I'd even
> prefer it, if v6 but not v7 of this patch series can achieve
> consensus.
Given that you deleted keys, I don't think there's a good reason to
keep around file... or can it be located in a subdirectory?
> On the other hand, at the risk of beating a dead horse, it seems like
> a tiny step from the above to:
>
> (define* ((delete-dependencies deps #:key (file "package.json")) .
> _)
> (with-atomic-json-file-replacement ...))
>
> which is just another name for 'make-delete-dependencies-phase',
> which AIUI you had found objectionable. (Apparently that shorthand
> would need (ice-9 curried-definitions).)
The reason to not use a phase writer here, is that you could combine it
with other stuff in a single phase. E.g.
(add-after 'unpack 'remove-foo
(lambda _
(delete-dependencies '("foo" "bar" "baz"))
(delete-file "baz-loader.js")))
> Indeed, if we observe that '#:file', similarly to '#:json-keys', will
> never be anything _other_ than "package.json", we could further
> simplify to:
>
> (define* ((delete-dependencies deps) . _)
> (with-atomic-json-file-replacement ...))
>
> at which point we've basically re-invented the implementation of
> patch v7 05/41, which basically amounts to:
>
> (define* (delete-dependencies #:key absent-dependencies)
> (with-atomic-json-file-replacement ...))
>
> In other words, I don't agree that any of these possible changes
> would "eliminat[e] the need to shorten it to #:absent-dependencies",
Sorry for the typo.
> I still feel that there's something I'm fundamentally not
> understanding about your objections to '#:make-absent-dependencies',
> which is why, in v6, I tried to do exactly as you had proposed:
>
> On 12/20/21 17:00, Liliana Marie Prikler wrote:
> > Hi Timothy,
> >
> > Am Montag, dem 20.12.2021 um 15:15 -0500 schrieb Timothy Sample:
> >> Hi Philip,
> >>
> >> Philip McGrath <philip@philipmcgrath.com> writes:
> >>
> >>> If we took your final suggestion above, I think we'd have
> something
> >>> like this:
> >>>
> >>> ```
> >>> #:phases
> >>> (modify-phases %standard-phases
> >>> (add-after 'unpack 'delete-dependencies
> >>> (make-delete-dependencies-phase '("node-tap"))))
> >>> ```
> >>
> >> I’m perfectly happy with this if it’s a compromise we all can
> agree on.
> >> It is exactly what popped into my imagination when I read
> Liliana’s
> >> suggestion. I guess the one thing missing is that it would not
> >> necessarily be implemented on top of better “package.json”
> >> manipulation support. That said, it doesn’t preclude providing
> that
> >> support if/when the need arises.
> > In my personal opinion, we would write that support first and
> perhaps
> > the shorthands later. I.e.
> >
> > (add-after 'patch-dependencies 'drop-junk
> > (lambda _
> > (with-atomic-json-replacement "package.json"
> > (lambda (json) (delete-dependencies json '("node-tap"))))))
To be fair, finding the right sweet spot between being overly verbose
and code golfing is difficult.
> Certainly I do agree that it would be better to support code more
> concise than that! But I think all of these variations are strictly
> worse than '#:absent-dependencies'. It isn't just that they are more
> typing: the require authors of package definitions to have some (not
> very much, but some) procedural knowledge about _how_ 'node-build-
> system' deals with the absence of dependencies, rather
> than with '#:absent-dependencies', declaratively specifying _what_ is
> to be done.
Understanding build systems is for nerds. We here at leftpad.org care
about the things that are really important.
> For example, as I mentioned in my cover letter at
> <https://issues.guix.gnu.org/51838#257>, even my own code from the
> exchange I just quoted:
>
> >>> (add-after 'unpack 'delete-dependencies
> >>> (make-delete-dependencies-phase '("node-tap"))))
>
> would be broken in v6, because the implementation of
> 'delete-dependencies' assumes that the 'patch-dependencies' phase has
> already been run.
I think that is an issue with your patch, however. With mine, you
could at least add "peerDependencies" on your own.
> I think this is an implementation detail that users of
> 'node-build-system' should not be required to know! Indeed, I think
> that would be a good reason to have 'patch-dependencies' handle the
> absent dependencies itself [...]
I think something like that can be arranged. We could make patch-
dependencies drop all the dependencies it doesn't know about if we add
a "verify-dependencies" phase before it. (Note that I already
suggested that once). verify-dependencies would raise an error if a
dependency is missing and the user could then decide to drop it or
(add-before 'verify-dependencies 'drop-dependencies ...).
> I expect the majority of Guix's Node.js packages will continue for
> the foreseeable future to need the functionality for absent
> dependencies I described at the beginning of this email, so I think
> we should provide it through a mechanism that is as high-level,
> concise, declarative as possible, and ideally one that will
> facilitate automated code generation and static analysis. On each of
> these criteria, I think '#:absent-dependencies' is better than any of
> the other proposals I've heard.
>
> But, as I said, in the interest of compromise and moving forward, I'm
> willing to live with something based on v6 for now if that's what can
> achieve consensus, and then propose '#:absent-dependencies'
> separately. So, if you want me to send a new version with one of
> these other variations, tell me which one, and I'll do it.
I think amending v6 with what we learn from this discussion and the
discussion on patch 3 of this series is the way to go.
Another thing I forget to mention all the time are regexps. I think
it'd be beneficial if delete-dependencies could delete dependencies
based on their name matching a regexp rather than a string exactly.
This would make some of your lists shorter (e.g. "karma.*"), but there
might be a debate on whether to use "^karma.*$" or whether to only
consider regexps that match the dependency fully.
> I hope my tone isn't coming across the wrong way---I really don't
> mean to be snarky! But I am genuinely struggling to understand the
> significance of the difference between:
>
> >>> (add-after 'unpack 'delete-dependencies
> >>> (make-delete-dependencies-phase '("node-tap"))))
>
> which I thought you objected to, and the result of what I think
> you've most recently proposed:
>
> (add-after 'patch-dependencies 'delete-dependencies
> (lambda () (delete-dependencies '("node-tap"))))
To be clear, there are two things in here which I objected.
1. make-delete-dependencies-phase as a procedure which returns the
actual phase instead of writing the lambda out. BTW if I ever wrote
(lambda () (delete-dependencies ...)), that was a mistake on my part.
As for the reason, scroll up.
2. implementing delete-dependencies in terms of messy ad-hoc json
primitives using inner defines rather than reusable ones.
The goal was not to create the most unwieldy incantation even though it
certainly appears as though it was looking back. Sorry for the
misunderstanding.
> which would have avoided my earlier reservations about making the
> JSON representation part of the build system's public API for the
> first time.
>
> So I'm not feeling very confident in my ability to predict what
> changes would or would not block consensus.
Adding a gratuitous keyword is an immediate blocker as we've discussed
at length ;)
Using curried functions is also unlikely going to meaningfully advance
the discussion, but there could be a niche application in which they're
actually useful that I had not thought about.
Apart from that, there is a large room simply for discussions, where it
is unclear what form consensus will take before it is shaped. For
instance, for patch 3, you had to write a lot of functionality from
scratch, which prompted me to suggest that you put them in their own
file (which would then be public API, though), but with a little bit of
refactoring in terms of SRFI-1 we might make it small enough to keep to
npm-build-system until Rust folks demand the same goodies. Phase
ordering as you mentioned is also still up to debate. So there's a lot
in which you can can add your opinion.
If you are doubtful about whether or not a particular change would be
good, you could probe different versions you have in your head and ask
for opinions on them. E.g. provide two or three implementations of
assoc-set and let the "best" be selected. If you only have a single
one, you can still ask if something like that would be okay and if you
receive a "No" that you don't understand it's okay to ask "what would
be the problem, what solution do you propose?" etc. XKCD's "inventing
a new standard to cover both use-cases" applies as always too :)
Cheers
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 05/41] guix: node-build-system: Add 'delete-dependencies' helper function.
2021-12-31 2:46 ` Liliana Marie Prikler
@ 2022-01-05 19:08 ` Philip McGrath
2022-01-05 20:02 ` Leo Famulari
2022-01-05 21:04 ` Liliana Marie Prikler
0 siblings, 2 replies; 458+ messages in thread
From: Philip McGrath @ 2022-01-05 19:08 UTC (permalink / raw)
To: Liliana Marie Prikler, 51838; +Cc: Timothy Sample, Pierre Langlois, Jelle Licht
Hi,
On 12/30/21 21:46, Liliana Marie Prikler wrote:
> Am Donnerstag, dem 30.12.2021 um 20:09 -0500 schrieb Philip McGrath:
>> I still feel that there's something I'm fundamentally not
>> understanding about your objections to '#:make-absent-dependencies',
>> which is why, in v6, I tried to do exactly as you had proposed:
>>
>> On 12/20/21 17:00, Liliana Marie Prikler wrote:
>> > Hi Timothy,
>> >
>> > Am Montag, dem 20.12.2021 um 15:15 -0500 schrieb Timothy Sample:
>> >> Hi Philip,
>> >>
>> >> Philip McGrath <philip@philipmcgrath.com> writes:
>> >>
>> >>> If we took your final suggestion above, I think we'd have
>> something
>> >>> like this:
>> >>>
>> >>> ```
>> >>> #:phases
>> >>> (modify-phases %standard-phases
>> >>> (add-after 'unpack 'delete-dependencies
>> >>> (make-delete-dependencies-phase '("node-tap"))))
>> >>> ```
>> >>
>> >> I’m perfectly happy with this if it’s a compromise we all can
>> agree on.
>> >> It is exactly what popped into my imagination when I read
>> Liliana’s
>> >> suggestion. I guess the one thing missing is that it would not
>> >> necessarily be implemented on top of better “package.json”
>> >> manipulation support. That said, it doesn’t preclude providing
>> that
>> >> support if/when the need arises.
>> > In my personal opinion, we would write that support first and
>> perhaps
>> > the shorthands later. I.e.
>> >
>> > (add-after 'patch-dependencies 'drop-junk
>> > (lambda _
>> > (with-atomic-json-replacement "package.json"
>> > (lambda (json) (delete-dependencies json '("node-tap"))))))
> To be fair, finding the right sweet spot between being overly verbose
> and code golfing is difficult.
I will admit that I am more than a little frustrated that, having put
aside my own reservations and implemented the compromise proposal it
seemed everyone could live with, it now seems that the consensus was in
fact illusory. Moreover, I still do not understand what specific changes
I could send in a v8 that would get this patch series to a state where
everyone would agree it could be applied.
>
>> Certainly I do agree that it would be better to support code more
>> concise than that! But I think all of these variations are strictly
>> worse than '#:absent-dependencies'. It isn't just that they are more
>> typing: the require authors of package definitions to have some (not
>> very much, but some) procedural knowledge about _how_ 'node-build-
>> system' deals with the absence of dependencies, rather
>> than with '#:absent-dependencies', declaratively specifying _what_ is
>> to be done.
> Understanding build systems is for nerds. We here at leftpad.org care
> about the things that are really important.
>
I don't know what to make of this comment, and I especially don't
understand what the notorious left-pad incident has to do with my views.
Aside from its inflammatory nature, I think left-pad is a confusing way
to make a point because many people have tried to make it "stand for"
many different, perhaps even mutually contradictory, conclusions.
In case it helps at all to state my position more fully: with or without
Guix, I think a major purpose, perhaps even the primary purpose, of
_any_ build system is to relieve users (including ourselves) of the
cognitive burden of lower-level details. Build systems are a means of
abstraction and encapsulation.
We use './configure && make && make install' to avoid having to know
about the intricacies of flags for gcc, ordering requirements for
building sub-projects, and innumerable quirks of strange and venerable
systems that Autotools supports so that most of us can ignore them. We
use 'gnu-build-system' to avoid having to know, and constantly repeat,
the details of invoking 'configure' and 'make' to find Guix inputs and
build to Guix outputs, along with further details of what files need to
be patched when. Sometimes we nonetheless need to drop down to a lower
level of abstraction, and Guix makes it convenient to do so, but the
goal is to provide useful abstractions.
For a personal example, I've never written so much as "Hello, world" in
Go, but I've been able to contribute packages to Guix for software I use
that happens to be written in Go, which was much easier to do because
'go-build-system' offers useful high-level abstractions like
'#:unpack-path' and '#:import-path'. I didn't need to know _how_
'go-build-system' arranges the build environment based on those values,
or even anything beyond the most superficial understanding of _what_
those values are, in order to build a Go package.
>> which would have avoided my earlier reservations about making the
>> JSON representation part of the build system's public API for the
>> first time.
>>
>> So I'm not feeling very confident in my ability to predict what
>> changes would or would not block consensus.
> Adding a gratuitous keyword is an immediate blocker as we've discussed
> at length ;)
Even when I have disagreed with your point of view, I have been trying
my best to understand it, and I don't doubt that it is offered in good
faith. I hope this is just a matter of some nuance in the connotation of
the word "gratuitous" not coming across properly, but I would appreciate
the same consideration being extended to my perspective.
Almost tautologically, I don't think adding '#:absent-dependencies'
would be gratuitous, or I wouldn't have proposed it.
I don't want to speak for anyone but myself, but I haven't heard anyone
else share these objections. And again, I also agreed to v6 of this
series, in which I removed the keyword.
I don't have time right now to go through the latest comments point by
point: I will try to do so later. From my perspective, though, the
substance of these patches has been ready to go for something like six
weeks now, and the few enhancements since then could easily have been
small follow-on patches. I would consider it very regrettable if this
patch series were to continue to be blocked by stylistic considerations
in the implementation of unexported helper functions.
-Philip
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 05/41] guix: node-build-system: Add 'delete-dependencies' helper function.
2022-01-05 19:08 ` Philip McGrath
@ 2022-01-05 20:02 ` Leo Famulari
2022-01-06 16:50 ` Liliana Marie Prikler
2022-01-05 21:04 ` Liliana Marie Prikler
1 sibling, 1 reply; 458+ messages in thread
From: Leo Famulari @ 2022-01-05 20:02 UTC (permalink / raw)
To: Philip McGrath
Cc: 51838, Timothy Sample, Pierre Langlois, Jelle Licht,
Liliana Marie Prikler
On Wed, Jan 05, 2022 at 02:08:30PM -0500, Philip McGrath wrote:
> I would consider it very regrettable if this patch series were to
> continue to be blocked by stylistic considerations in the implementation of
> unexported helper functions.
Agreed.
Is there a concrete problem with these patches? Or will they work as
specified for Guix packagers?
Let's remember that the primary goal of code review is to bring a
contribution into the codebase.
We have added suboptimal code to Guix many times, because it worked well
enough. Later we can refine things.
You mention go-build-system as being useful for you. That's very
gratifying, because it was a lot of hard work for me to help finalize
those patches, and they were quite far from ideal even when they were
committed. But the build system allowed Guix users to add Go packages,
which later attracted more contributions, and the go-build-system keeps
improving as a result.
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 05/41] guix: node-build-system: Add 'delete-dependencies' helper function.
2022-01-05 20:02 ` Leo Famulari
@ 2022-01-06 16:50 ` Liliana Marie Prikler
2022-01-06 17:28 ` Leo Famulari
0 siblings, 1 reply; 458+ messages in thread
From: Liliana Marie Prikler @ 2022-01-06 16:50 UTC (permalink / raw)
To: Leo Famulari, Philip McGrath
Cc: 51838, Timothy Sample, Pierre Langlois, Jelle Licht
[-- Attachment #1: Type: text/plain, Size: 1279 bytes --]
Hi Leo,
Am Mittwoch, dem 05.01.2022 um 15:02 -0500 schrieb Leo Famulari:
> On Wed, Jan 05, 2022 at 02:08:30PM -0500, Philip McGrath wrote:
> > I would consider it very regrettable if this patch series were to
> > continue to be blocked by stylistic considerations in the
> > implementation of
> > unexported helper functions.
>
> Agreed.
>
> Is there a concrete problem with these patches? Or will they work as
> specified for Guix packagers?
>
> Let's remember that the primary goal of code review is to bring a
> contribution into the codebase.
I'm currently in the process of applying my own checklist, see
<https://issues.guix.gnu.org/issue/51838/raw/352>
Each of my fixup commits is a change on top of Philip's corresponding
commit (or at least I hope so, I haven't squashed them yet) and delete-
dependencies.patch shows the savings in the rest of the series. I so
far successfully built node-irc and node-serialport with these changes
applied on top.
It'll take some time to check the rest of the toplevel packages and
thereafter I'll squash and cleanup commit messages.
So from my position, everything is about to be done. Should I resend
this as v8 for a complete check that I'm not doing anything harmful or
should I go ahead and commit once I'm done?
Cheers
[-- Attachment #2: 0001-Fixup-03-41.patch --]
[-- Type: text/x-patch, Size: 15899 bytes --]
From 280dd782003075444037297a4a5dd5723ff1f459 Mon Sep 17 00:00:00 2001
From: Liliana Marie Prikler <liliana.prikler@gmail.com>
Date: Thu, 6 Jan 2022 15:08:24 +0100
Subject: [PATCH 1/3] Fixup 03/41.
This commit adds several utility functions for non-destructive
transformation of the JSON representation used by (guix build json),
particularly for purely functional update of JSON objects. They ought
to eventually be exported from their own module, but for now are kept
private to allow experimentation.
* guix/build/node-build-system.scm (assoc-ref*, jsobject-ref, alist-pop)
(alist-update, jsobject-update*, jsobject-union): New variables.
(with-atomic-json-file-replacement): New public variable.
(module-name, build, patch-dependencies): Use them. Do not resort to
unsafe alist primitives from Guile core.
---
guix/build/node-build-system.scm | 313 +++++++++----------------------
1 file changed, 85 insertions(+), 228 deletions(-)
diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index 9967223b86..d695424e50 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -25,35 +25,12 @@ (define-module (guix build node-build-system)
#:use-module (ice-9 ftw)
#: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))
-;; Commentary:
-;;
-;; Builder-side code of the standard Node/NPM package install procedure.
-;;
-;; Code:
-
-;;;
-;;; JSON utilities.
-;;;
-;;; The following procedures facilitate transforming JSON values using the
-;;; representation from (guix build json), particularly purely functional
-;;; update of JSON objects. If we decide to make more of them public, we
-;;; might instead put them in their own file or, eventually, add them to
-;;; (guix build json).
-;;;
-;;; JSON objects with duplicate keys are not interoperable: see RFC 8259 § 4.
-;;; These procedures assume, but generally do not check, that JSON objects
-;;; given to them as arguments do not have duplicate keys. As long as that
-;;; precondition is satisfied, they will produce JSON objects without
-;;; duplicate keys. Procedures that operate on unwrapped assosciation lists
-;;; may do likewise, which should be considered before exporting them for
-;;; general use.
-;;;
-
(define (with-atomic-json-file-replacement file proc)
"Like 'with-atomic-file-replacement', but PROC is called with a single
argument---the result of parsing FILE's contents as json---and should a value
@@ -62,205 +39,83 @@ (define (with-atomic-json-file-replacement file proc)
(lambda (in out)
(write-json (proc (read-json in)) out))))
-(define (jsobject-ref js key failure-result)
- "Return the value assosciated with KEY in the json object JS. If KEY is not
-found and FAILURE-RESULT is a procedure, it is called in tail position with
-zero arguments. Otherwise, FAILURE-RESULT is returned."
- ;; TODO: `failure-result` should be optional, but should the default
- ;; `failure-result` be #f (like `assoc-ref`), a thunk raising an exception,
- ;; '(@), or something else? Keep it mandatory until we discuss and decide.
+(define* (assoc-ref* alist key #:optional default)
+ "Like assoc-ref, but return DEFAULT instead of #f if no value exists."
+ (match (assoc key alist)
+ (#f default)
+ ((_ . value) value)))
+
+(define* (jsobject-ref obj key #:optional default)
+ (match obj
+ (('@ . alist) (assoc-ref* alist key default))))
+
+(define* (alist-pop alist key #:optional (= equal?))
+ "Return two values, the first pair in ALIST with key KEY, and the other
+elements. Equality calls are made as (= KEY ALISTCAR)."
+ (define (found? pair)
+ (= key (car pair)))
+
+ (let ((before after (break found? alist)))
+ (if (pair? after)
+ (values (car after) (append before (cdr after)))
+ (values #f before))))
+
+(define* (alist-update alist key proc #:optional default (= equal?))
+ "Return an association list like ALIST, but with KEY mapped to the result of
+PROC applied to the first value found under the comparison (= KEY ALISTCAR).
+If no such value exists, use DEFAULT instead.
+Unlike acons, this removes the previous association of KEY (assuming it is
+unique), but the result may still share storage with ALIST."
+ (let ((pair rest (alist-pop alist key =)))
+ (acons key
+ (proc (if (pair? pair)
+ (cdr pair)
+ default))
+ rest)))
+
+(define (jsobject-update* js . updates)
+ "Return a json object like JS, but with all UPDATES applied. Each update
+is a list (KEY PROC [DEFAULT]), so that KEY is mapped to the result of
+PROC applied to the value found for it, or DEFAULT otherwise."
(match js
(('@ . alist)
- (match (assoc key alist)
- (#f
- (if (procedure? failure-result)
- (failure-result)
- failure-result))
- ((_ . value)
- value)))))
-
-(define (alist-pop alist key)
- "Return two values: the first pair in ALIST with the given KEY in its
-'car' (or #f, if no such pair exists) and an assosciation list like (and
-potentially sharing storage with) ALIST, but with no entry for KEY."
- (match (assoc key alist)
- ;; If key isn't present, we don't need to do any allocation
- (#f
- (values #f alist))
- (found
- (values found
- ;; Because we have `found`, we can find it more
- ;; efficiently this time with `eq?`. We avoid using
- ;; `delq` because it would copy pairs in a shared
- ;; tail. We assume a sufficiently smart compiler to
- ;; handle "tail recursion modulo cons" (vid. e.g. Indiana
- ;; University Technical Report No. 19, Friedman & Wise
- ;; 1975) at least as efficiently as a hand-written
- ;; tail-recursive implementation with an accumulator.
- (let loop ((alist alist))
- (match alist
- ;; We know that `found` is present,
- ;; so no need to check for '()
- ((this . alist)
- (if (eq? this found)
- alist
- (cons this (loop alist))))))))))
-
-;; Sadly, Guile's implementation of (@ (srfi srfi-1) alist-delete)
-;; performs unnecessary allocation, e.g. this currently evaluates to #f:
-;;
-;; (let ((alist `(("a" . 1)("b" . 2)("c" . 3))))
-;; (eq? alist (alist-delete "x" alist)))
-;;
-;; These functions generally choose to allocate a new outer pair (with the '@
-;; tag), even though in unusual cases the resulting object might not have
-;; changed, for the sake of simplicity and to avoid retaining a reference to
-;; the original alist longer than necessary. But that is O(1) allocation that
-;; could only rarely be avoided: `alist-delete` would allocate O(n) pairs,
-;; which would only be necessary in the worst case.
-(define (alist-delete* alist key)
- "Return an assosciation list like (and potentially sharing storage with)
-ALIST, but with no entry for KEY."
- (define-values (_popped remaining)
- (alist-pop alist key))
- remaining)
-
-(define (jsobject-delete js key)
- "Return a json object like JS, but with no entry for KEY."
- (cons '@ (match js
- (('@ . alist)
- (alist-delete* alist key)))))
-
-(define (alist-set alist key value)
- "Return an assosciation list like ALIST, but with KEY mapped to VALUE,
-replacing any existing mapping for KEY."
- (acons key value (alist-delete* alist key)))
-
-(define (jsobject-set js key value)
- "Return a json object like JS, but with KEY mapped to VALUE, replacing any
-existing mapping for KEY."
- (cons '@ (match js
- (('@ . alist)
- (alist-set alist key value)))))
-
-(define jsobject-set*
- (case-lambda
- "Return a json object like JS, but functionally extended by mapping each
-KEY to each VALUE, replacing any existing mapping for each KEY. The update
-takes place from left to right, so later mappings overwrite earlier mappings
-for the same KEY."
- ((js)
- js)
- ((js key value)
- (jsobject-set js key value))
- ((js . args)
- (cons '@ (match js
- (('@ . alist)
- (let loop ((alist alist)
- (args args))
- (match args
- (()
- alist)
- ((key value . args)
- (loop (alist-set alist key value)
- args))))))))))
-
-(define (alist-update alist key failure-result updater)
- "Return an assosciation list like ALIST, but with KEY mapped to the result
-of applying UPDATER to the value to which KEY is mapped in ALIST. When ALIST
-does not have an existing mapping for KEY, FAILURE-RESULT is used as with
-'jsobject-ref' to obtain the argument for UPDATER."
- ;; Often, `updater` will be a lambda expression, so making it the last
- ;; argument may help to makes the code legible, and the most likely
- ;; `failure-result` arguments are all shorter than the keyword
- ;; `#:failure-result`. Plus, making `failure-result` mandatory helps make
- ;; `alist-update` consistent with `alist-update*`.
- (define-values (popped tail-alist)
- (alist-pop alist key))
- (acons key
- (updater (match popped
- (#f
- (if (procedure? failure-result)
- (failure-result)
- failure-result))
- ((_ . value)
- value)))
- tail-alist))
-
-(define (jsobject-update js key failure-result updater)
- "Return a json object like JS, but with KEY mapped to the result of applying
-UPDATER to the value to which KEY is mapped in JS. When JS does not have an
-existing mapping for KEY, FAILURE-RESULT is used as with 'jsobject-ref' to
-obtain the argument for UPDATER."
- (cons '@ (match js
- (('@ . alist)
- (alist-update alist key failure-result updater)))))
-
-(define jsobject-update*
- (case-lambda
- "Return a json object like JS, but functionally extended by replacing the
-mapping for each KEY with the result of applying the corresponding UPDATER to
-the value to which that KEY is mapped in JS---or, if no such mapping exists,
-to a value based on the corresponding FAILURE-RESULT as with 'jsobject-ref'.
-The update takes place from left to right, so later UPDATERs will receive the
-values returned by earlier UPDATERs for the same KEY."
- ((js)
- js)
- ((js key failure-result updater)
- (jsobject-update js key failure-result updater))
- ((js . args)
- (cons '@ (match js
- (('@ . alist)
- (let loop ((alist alist)
- (args args))
- (match args
- (()
- alist)
- ((key failure-result updater . args)
- (loop (alist-update alist key failure-result updater)
- args))))))))))
-
-(define* (jsobject-union #:key
- (combine (lambda (a b) b))
- (combine/key (lambda (k a b) (combine a b)))
- #:rest json-objects)
- "Combine the given JSON-OBJECTS into a single json object. The JSON-OBJECTS
-are merged from left to right by adding each key/value pair of each object to
-the aggregate object in turn. When one of the JSON-OBJECTS contains a mapping
-from some key KEY to a value VAL such that the aggregate object already
-contains a mapping from KEY to a value VAL0, the aggregate object is
-functionally updated to instead map KEY to the value of (COMBINE/KEY KEY VAL0
-VAL). The default COMBINE/KEY tail-calls (COMBINE VAL0 VAL), and the default
-COMBINE simply returns its second argument, so, by default, mappings in later
-JSON-OBJECTS supersede those in earlier ones."
- (match (filter (lambda (v)
- (not (or (keyword? v)
- (procedure? v))))
- json-objects)
- (()
- '(@))
- (((and js0 ('@ . _)))
- js0)
- ((('@ . alist0) ('@ . alist*) ...)
- (cons '@ (fold (lambda (alist1 alist0)
- (if (null? alist0)
- alist1
- (fold (lambda (k+v alist0)
- (match k+v
- ((k . v)
- (define-values (popped tail-alist)
- (alist-pop alist0 k))
- (match popped
- (#f
- (cons k+v tail-alist))
- ((_ . v0)
- (acons k
- (combine/key k v0 v)
- tail-alist))))))
- alist0
- alist1)))
- alist0
- alist*)))))
+ (let loop ((alist alist)
+ (updates updates))
+ (match updates
+ (() (cons '@ alist))
+ (((key proc) . updates)
+ (loop (alist-update alist key proc #f equal?) updates))
+ (((key proc default) . updates)
+ (loop (alist-update alist key proc default equal?) updates)))))))
+
+(define (jsobject-union combine seed . objects)
+ "Merge OBJECTS into SEED by applying (COMBINE KEY VAL0 VAL), where VAL0
+is the value found in the (possibly updated) SEED and VAL is the new value
+found in one of the OBJECTS."
+ (match seed
+ (('@ . aseed)
+ (match objects
+ (() seed)
+ ((('@ . alists) ...)
+ (cons
+ '@
+ (fold (lambda (alist aseed)
+ (if (null? aseed) alist
+ (fold
+ (match-lambda*
+ (((k . v) aseed)
+ (let ((pair tail (alist-pop alist k)))
+ (match pair
+ (#f (acons k v aseed))
+ ((_ . v0) (acons k (combine k v0 v) aseed))))))
+ aseed
+ alist)))
+ aseed
+ alists)))))))
+
+;; Possibly useful helper functions:
+;; (define (newest key val0 val) val)
+;; (define (unkeyed->keyed proc) (lambda (_key val0 val) (proc val0 val)))
\f
;;;
@@ -282,7 +137,7 @@ (define (set-home . _)
(define (module-name module)
(let* ((package.json (string-append module "/package.json"))
(package-meta (call-with-input-file package.json read-json)))
- (jsobject-ref package-meta "name" #f)))
+ (jsobject-ref package-meta "name")))
(define (index-modules input-paths)
(define (list-modules directory)
@@ -318,12 +173,14 @@ (define resolve-dependencies
(lambda (pkg-meta)
(jsobject-update*
pkg-meta
- "devDependencies" '(@) resolve-dependencies
- "dependencies" '(@) (lambda (deps)
- (resolve-dependencies
- (jsobject-union
- (jsobject-ref pkg-meta "peerDependencies" '(@))
- deps))))))
+ `("devDependencies" ,resolve-dependencies (@))
+ `("dependencies" ,(lambda (deps)
+ (resolve-dependencies
+ (jsobject-union
+ (lambda (k a b) b)
+ (jsobject-ref pkg-meta "peerDependencies" '(@))
+ deps)))
+ (@)))))
#t)
(define (delete-dependencies pkg-meta absent-dependencies)
--
2.34.0
[-- Attachment #3: 0002-Fixup-04-41.patch --]
[-- Type: text/x-patch, Size: 1799 bytes --]
From 41819ee4536ca36bfcb8e87b29503cf1791b056f Mon Sep 17 00:00:00 2001
From: Liliana Marie Prikler <liliana.prikler@gmail.com>
Date: Thu, 6 Jan 2022 15:31:48 +0100
Subject: [PATCH 2/3] Fixup 04/41.
Packages with native addons currently try to write to store paths
when used as dependecies. This patch adds a phase to replace that
behaviour with a no-op.
* guix/build/node-build-system.scm (avoid-node-gyp-rebuild): New
variable.
(%standard-phases): Add 'avoid-node-gyp-rebuild' after 'install'.
Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
---
guix/build/node-build-system.scm | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index d695424e50..1a0e187028 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -285,12 +285,16 @@ (define installed-package.json
(search-input-file outputs (string-append "/lib/node_modules/"
(module-name ".")
"/package.json")))
- ;; not with-atomic-json-file-replacement, because we usually don't
- ;; want or need to overwrite it
+ ;; We don't want to use an atomic replacement here, because we often don't
+ ;; even need to overwrite this file. Therefore, let's use some helpers
+ ;; that we'd otherwise not need.
(define pkg-meta
(call-with-input-file installed-package.json read-json))
(define scripts
(jsobject-ref pkg-meta "scripts" '(@)))
+ (define (jsobject-set js key val)
+ (jsobject-update* js (list key (const val))))
+
(when (equal? "node-gyp rebuild" (jsobject-ref scripts "install" #f))
(call-with-output-file installed-package.json
(lambda (out)
--
2.34.0
[-- Attachment #4: 0003-Fixup-05-41.patch --]
[-- Type: text/x-patch, Size: 2943 bytes --]
From 0b839bf89df5188447275f960e9bbff3935afea4 Mon Sep 17 00:00:00 2001
From: Liliana Marie Prikler <liliana.prikler@gmail.com>
Date: Thu, 6 Jan 2022 15:35:35 +0100
Subject: [PATCH 3/3] Fixup 05/41.
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.
Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
---
guix/build/node-build-system.scm | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index 1a0e187028..76aa51c52f 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -23,6 +23,7 @@ (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)
@@ -183,22 +184,29 @@ (define resolve-dependencies
(@)))))
#t)
-(define (delete-dependencies pkg-meta absent-dependencies)
- "Functionally update PKG-META, a json object corresponding to a
-'package.json' file, to allow building without the ABSENT-DEPENDENCIES. To
-avoid reintroducing the ABSENT-DEPENDENCIES, only use this procedure after the
-'patch-dependencies' phase."
- (define delete-fom-jsobject
+(define (delete-dependencies unwanted)
+ "Rewrite package.json to remove UNWANTED dependencies. Unwanted dependencies
+can be specified as regular expressions to exclude a range of related
+dependencies, e.g. \"tap\" excludes all dependencies including \"tap\" in their
+name, but \"^tap$\" explicitly excludes \"tap\"."
+ (define delete-from-jsobject
(match-lambda
(('@ . alist)
(cons '@ (filter (match-lambda
((k . v)
- (not (member k absent-dependencies))))
+ (not (any
+ (lambda (pattern)
+ (string-match pattern k))
+ unwanted))))
alist)))))
- (jsobject-update*
- pkg-meta
- "devDependencies" '(@) delete-fom-jsobject
- "dependencies" '(@) delete-fom-jsobject))
+
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (jsobject-update*
+ pkg-meta
+ `("peerDependencies" ,delete-from-jsobject (@))
+ `("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
--
2.34.0
[-- Attachment #5: delete-dependencies.patch --]
[-- Type: text/x-patch, Size: 25985 bytes --]
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 1f51c0d636..990b26a689 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -297,9 +297,7 @@ (define-public node-semver
(modify-phases %standard-phases
(add-after 'patch-dependencies 'delete-dependencies
(lambda args
- (with-atomic-json-file-replacement "package.json"
- (lambda (pkg-meta)
- (delete-dependencies pkg-meta '("tap")))))))
+ (delete-dependencies '("^tap$")))))
;; FIXME: Tests depend on node-tap
#:tests? #f))
(home-page "https://github.com/npm/node-semver")
@@ -329,9 +327,7 @@ (define-public node-wrappy
(modify-phases %standard-phases
(add-after 'patch-dependencies 'delete-dependencies
(lambda args
- (with-atomic-json-file-replacement "package.json"
- (lambda (pkg-meta)
- (delete-dependencies pkg-meta '("tap")))))))))
+ (delete-dependencies '("^tap$")))))))
(home-page "https://github.com/npm/wrappy")
(synopsis "Callback wrapping utility")
(description "@code{wrappy} is a utility for Node.js to wrap callbacks.")
@@ -356,9 +352,7 @@ (define-public node-once
(modify-phases %standard-phases
(add-after 'patch-dependencies 'delete-dependencies
(lambda args
- (with-atomic-json-file-replacement "package.json"
- (lambda (pkg-meta)
- (delete-dependencies pkg-meta '("tap")))))))
+ (delete-dependencies '("^tap$")))))
;; FIXME: Tests depend on node-tap
#:tests? #f))
(inputs
@@ -391,9 +385,7 @@ (define-public node-inherits
(modify-phases %standard-phases
(add-after 'patch-dependencies 'delete-dependencies
(lambda args
- (with-atomic-json-file-replacement "package.json"
- (lambda (pkg-meta)
- (delete-dependencies pkg-meta '("tap")))))))
+ (delete-dependencies '("^tap$")))))
;; FIXME: Tests depend on node-tap
#:tests? #f))
(home-page
@@ -425,10 +417,7 @@ (define-public node-safe-buffer
(modify-phases %standard-phases
(add-after 'patch-dependencies 'delete-dependencies
(lambda args
- (with-atomic-json-file-replacement "package.json"
- (lambda (pkg-meta)
- (delete-dependencies pkg-meta '("tape"
- "standard")))))))
+ (delete-dependencies '("^tape$" "^standard$")))))
#:tests? #f))
(home-page
"https://github.com/feross/safe-buffer")
@@ -458,12 +447,8 @@ (define-public node-string-decoder
(modify-phases %standard-phases
(add-after 'patch-dependencies 'delete-dependencies
(lambda args
- (with-atomic-json-file-replacement "package.json"
- (lambda (pkg-meta)
- (delete-dependencies pkg-meta
- '("tap"
- "core-util-is"
- "babel-polyfill")))))))
+ (delete-dependencies
+ '("^tap$" "^core-util-is$" "^babel-polyfill$")))))
;; FIXME: Tests depend on node-tap
#:tests? #f))
(inputs
@@ -497,29 +482,22 @@ (define-public node-readable-stream
(modify-phases %standard-phases
(add-after 'patch-dependencies 'delete-dependencies
(lambda args
- (with-atomic-json-file-replacement "package.json"
- (lambda (pkg-meta)
- (delete-dependencies pkg-meta
- `("@babel/cli"
- "@babel/core"
- "@babel/polyfill"
- "@babel/preset-env"
- "airtap"
- "assert"
- "bl"
- "deep-strict-equal"
- "events.once"
- "glob"
- "gunzip-maybe"
- "hyperquest"
- "lolex"
- "nyc"
- "pump"
- "rimraf"
- "tap"
- "tape"
- "tar-fs"
- "util-promisify")))))))
+ (delete-dependencies `("^@babel/"
+ "^airtap$"
+ "^assert$"
+ "^bl$"
+ "^deep-strict-equal$"
+ "^events\\.once$"
+ "^glob$"
+ "^gunzip-maybe$"
+ "^hyperquest$"
+ "^lolex$"
+ "^nyc$"
+ "^pump$"
+ "^rimraf$"
+ "^tape?$"
+ "^tar-fs$"
+ "^util-promisify$")))))
#:tests? #f))
(inputs
(list node-util-deprecate node-string-decoder node-inherits))
@@ -554,10 +532,7 @@ (define-public node-irc-colors
(modify-phases %standard-phases
(add-after 'patch-dependencies 'delete-dependencies
(lambda args
- (with-atomic-json-file-replacement "package.json"
- (lambda (pkg-meta)
- (delete-dependencies pkg-meta `("istanbul"
- "vows")))))))
+ (delete-dependencies `("^istanbul$" "^vows$")))))
#:tests? #f))
(home-page "https://github.com/fent/irc-colors.js")
(synopsis "Node.js module providing color and formatting for IRC")
@@ -586,12 +561,8 @@ (define-public node-irc
(modify-phases %standard-phases
(add-after 'patch-dependencies 'delete-dependencies
(lambda args
- (with-atomic-json-file-replacement "package.json"
- (lambda (pkg-meta)
- (delete-dependencies pkg-meta `("ansi-color"
- "faucet"
- "jscs"
- "tape")))))))
+ (delete-dependencies
+ `("^ansi-color$" "^faucet$" "^jscs$" "^tape$")))))
#:tests? #f))
(inputs
(list node-irc-colors))
@@ -620,17 +591,14 @@ (define-public node-nan
(modify-phases %standard-phases
(add-after 'patch-dependencies 'delete-dependencies
(lambda args
- (with-atomic-json-file-replacement "package.json"
- (lambda (pkg-meta)
- (delete-dependencies
- pkg-meta
- '("bindings"
- "commander"
- "glob"
- "request"
- "node-gyp" ;; would be needed for tests
- "tap"
- "xtend")))))))
+ (delete-dependencies
+ '("^bindings$"
+ "^commander$"
+ "^glob$"
+ "^request$"
+ "^node-gyp$" ;; would be needed for tests
+ "^tap$"
+ "^xtend$")))))
;; tests need tap and other dependencies
#:tests? #f))
(inputs
@@ -673,21 +641,11 @@ (define-public node-addon-api
(modify-phases %standard-phases
(add-after 'patch-dependencies 'delete-dependencies
(lambda args
- (with-atomic-json-file-replacement "package.json"
- (lambda (pkg-meta)
- (delete-dependencies pkg-meta
- `("benchmark"
- "bindings"
- "clang-format"
- "eslint"
- "eslint-config-semistandard"
- "eslint-config-standard"
- "eslint-plugin-import"
- "eslint-plugin-node"
- "eslint-plugin-promise"
- "fs-extra"
- "path"
- "pre-commit"))))))
+ (delete-dependencies
+ `("^benchmark$" "^bindings$" "^clang-format$"
+ "^eslint"
+ "^fs-extra$" "^path$" "^pre-commit$"))
+ ))
(add-after 'unpack 'skip-js-tests
;; We can't run the js-based tests,
;; but we can still do the C++ parts
@@ -767,29 +725,26 @@ (define-public node-sqlite3
(modify-phases %standard-phases
(add-after 'patch-dependencies 'delete-dependencies
(lambda args
- (with-atomic-json-file-replacement "package.json"
- (lambda (pkg-meta)
- (delete-dependencies
- pkg-meta
- `(;; Normally, this is "built" using @mapbox/node-pre-gyp,
- ;; which publishes or downloads pre-built binaries or
- ;; falls back to building from source. Here, we patch out
- ;; all of that and just build directly. It might be
- ;; better to patch a version of @mapbox/node-pre-gyp that
- ;; always builds from source, as Debian does, but there
- ;; are a number of dependencies that need to be packaged
- ;; or removed.
- "@mapbox/node-pre-gyp"
- "node-pre-gyp" ;; deprecated name still used in some places
- "aws-sdk"
- "@mapbox/cloudfriend"
- ;; Confusingly, this is only a dependency because of
- ;; @mapbox/node-pre-gyp: with that removed,
- ;; npm will use its own copy:
- "node-gyp"
- ;; These we'd like, we just don't have them yet:
- "eslint"
- "mocha"))))))
+ (delete-dependencies
+ `(;; Normally, this is "built" using @mapbox/node-pre-gyp,
+ ;; which publishes or downloads pre-built binaries or
+ ;; falls back to building from source. Here, we patch out
+ ;; all of that and just build directly. It might be
+ ;; better to patch a version of @mapbox/node-pre-gyp that
+ ;; always builds from source, as Debian does, but there
+ ;; are a number of dependencies that need to be packaged
+ ;; or removed.
+ "^@mapbox/node-pre-gyp$"
+ "^node-pre-gyp$" ;; deprecated name still used in some places
+ "^aws-sdk$"
+ "^@mapbox/cloudfriend$"
+ ;; Confusingly, this is only a dependency because of
+ ;; @mapbox/node-pre-gyp: with that removed,
+ ;; npm will use its own copy:
+ "^node-gyp$"
+ ;; These we'd like, we just don't have them yet:
+ "^eslint$"
+ "^mocha$"))))
(add-before 'configure 'npm-config-sqlite
;; We need this step even if we do replace @mapbox/node-pre-gyp
;; because the package expects to build its bundled sqlite
@@ -885,24 +840,12 @@ (define-public node-file-uri-to-path
(modify-phases %standard-phases
(add-after 'patch-dependencies 'delete-dependencies
(lambda args
- (with-atomic-json-file-replacement "package.json"
- (lambda (pkg-meta)
- (delete-dependencies pkg-meta
- `("@types/mocha"
- "@types/node"
- "@typescript-eslint/eslint-plugin"
- "@typescript-eslint/parser"
- "cpy-cli"
- "eslint"
- "eslint-config-airbnb"
- "eslint-config-prettier"
- "eslint-import-resolver-typescript"
- "eslint-plugin-import"
- "eslint-plugin-jsx-a11y"
- "eslint-plugin-react"
- "mocha"
- "rimraf"
- "typescript"))))))
+ (delete-dependencies
+ `("^@types/mocha$" "^@types/node$"
+ "typescript"
+ "eslint"
+ "^cpy-cli$"
+ "^mocha$" "^rimraf$"))))
(replace 'build
(lambda* (#:key inputs native-inputs #:allow-other-keys)
(copy-recursively "src" "dist")
@@ -995,14 +938,12 @@ (define-public node-ms
(modify-phases %standard-phases
(add-after 'patch-dependencies 'delete-dependencies
(lambda args
- (with-atomic-json-file-replacement "package.json"
- (lambda (pkg-meta)
- (delete-dependencies pkg-meta `("eslint"
- "expect.js"
- "husky"
- "lint-staged"
- "mocha"
- "prettier")))))))
+ (delete-dependencies `("^eslint$"
+ "^expect\\.js$"
+ "^husky$"
+ "^lint-staged$"
+ "^mocha$"
+ "^prettier$")))))
#:tests? #f))
(home-page "https://github.com/vercel/ms")
(synopsis "Tiny millisecond conversion utility")
@@ -1045,20 +986,15 @@ (define-public node-debug
(modify-phases %standard-phases
(add-after 'patch-dependencies 'delete-dependencies
(lambda args
- (with-atomic-json-file-replacement "package.json"
- (lambda (pkg-meta)
- (delete-dependencies pkg-meta `("brfs"
- "browserify"
- "coveralls"
- "istanbul"
- "karma"
- "karma-browserify"
- "karma-chrome-launcher"
- "karma-mocha"
- "mocha"
- "mocha-lcov-reporter"
- "xo"
- "supports-color")))))))
+ (delete-dependencies
+ `("^brfs$"
+ "^browserify$"
+ "^coveralls$"
+ "^istanbul$"
+ "^karma"
+ "^mocha"
+ "^xo$"
+ "^supports-color$")))))
#:tests? #f))
(home-page "https://github.com/debug-js/debug")
(synopsis "Lightweight debugging utility for Node.js and the browser")
@@ -1173,12 +1109,10 @@ (define-public node-serialport-bindings
(chdir "packages/bindings")))
(add-after 'patch-dependencies 'delete-dependencies
(lambda args
- (with-atomic-json-file-replacement "package.json"
- (lambda (pkg-meta)
- (delete-dependencies pkg-meta `("prebuild-install"
- ;; devDependencies
- "@serialport/binding-mock"
- "node-abi"))))))
+ (delete-dependencies `("^prebuild-install$"
+ ;; devDependencies
+ "^@serialport/binding-mock$"
+ "^node-abi$"))))
(add-after 'chdir 'avoid-prebuild-install
(lambda args
(with-atomic-json-file-replacement "package.json"
@@ -1330,11 +1264,8 @@ (define-public node-serialport-stream
(modify-phases %standard-phases
(add-after 'patch-dependencies 'delete-dependencies
(lambda args
- (with-atomic-json-file-replacement "package.json"
- (lambda (pkg-meta)
- (delete-dependencies pkg-meta
- `(;; devDependencies
- "@serialport/binding-mock"))))))
+ (delete-dependencies `(;; devDependencies
+ "^@serialport/binding-mock$"))))
(add-after 'unpack 'chdir
(lambda args
(chdir "packages/stream"))))
@@ -1370,10 +1301,8 @@ (define-public node-serialport
(modify-phases %standard-phases
(add-after 'patch-dependencies 'delete-dependencies
(lambda args
- (with-atomic-json-file-replacement "package.json"
- (lambda (pkg-meta)
- (delete-dependencies pkg-meta
- `("@serialport/binding-mock"))))))
+ (delete-dependencies `("^@serialport/binding-mock$"))
+ ))
(add-after 'unpack 'chdir
(lambda args
(chdir "packages/serialport"))))
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 5a4401e779..49e6323a9d 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -348,9 +348,7 @@ (define-public node-semver-bootstrap
(modify-phases %standard-phases
(add-after 'patch-dependencies 'delete-dependencies
(lambda args
- (with-atomic-json-file-replacement "package.json"
- (lambda (pkg-meta)
- (delete-dependencies pkg-meta '("tap")))))))))
+ (delete-dependencies '("^tap$")))))))
(home-page "https://github.com/npm/node-semver")
(properties '((hidden? . #t)))
(synopsis "Parses semantic versions strings")
@@ -381,13 +379,11 @@ (define-public node-ms-bootstrap
(modify-phases %standard-phases
(add-after 'patch-dependencies 'delete-dependencies
(lambda args
- (with-atomic-json-file-replacement "package.json"
- (lambda (pkg-meta)
- (delete-dependencies pkg-meta '("eslint"
- "expect.js"
- "husky"
- "lint-staged"
- "mocha")))))))))
+ (delete-dependencies '("^eslint$"
+ "^expect\\.js$"
+ "^husky$"
+ "^lint-staged$"
+ "^mocha$")))))))
(home-page "https://github.com/zeit/ms#readme")
(properties '((hidden? . #t)))
(synopsis "Tiny millisecond conversion utility")
@@ -417,10 +413,7 @@ (define-public node-binary-search-bootstrap
(modify-phases %standard-phases
(add-after 'patch-dependencies 'delete-dependencies
(lambda args
- (with-atomic-json-file-replacement "package.json"
- (lambda (pkg-meta)
- (delete-dependencies pkg-meta `("chai"
- "mocha")))))))))
+ (delete-dependencies `("^(chai\|mocha)$")))))))
(home-page "https://github.com/darkskyapp/binary-search#readme")
(properties '((hidden? . #t)))
(synopsis "Tiny binary search function with comparators")
@@ -449,20 +442,13 @@ (define-public node-debug-bootstrap
(modify-phases %standard-phases
(add-after 'patch-dependencies 'delete-dependencies
(lambda args
- (with-atomic-json-file-replacement "package.json"
- (lambda (pkg-meta)
- (delete-dependencies pkg-meta
- `("brfs"
- "browserify"
- "coveralls"
- "istanbul"
- "karma"
- "karma-browserify"
- "karma-chrome-launcher"
- "karma-mocha"
- "mocha"
- "mocha-lcov-reporter"
- "xo")))))))))
+ (delete-dependencies `("^brfs$"
+ "^browserify$"
+ "^coveralls$"
+ "^istanbul$"
+ "^karma"
+ "^mocha"
+ "^xo$")))))))
(inputs (list node-ms-bootstrap))
(home-page "https://github.com/visionmedia/debug#readme")
(properties '((hidden? . #t)))
@@ -517,15 +503,12 @@ (define-public node-llparse-builder-bootstrap
#:phases
(modify-phases %standard-phases
(add-after 'patch-dependencies 'delete-dependencies
- (lambda args
- (with-atomic-json-file-replacement "package.json"
- (lambda (pkg-meta)
- (delete-dependencies pkg-meta `("@types/mocha"
- "@types/node"
- "mocha"
- "ts-node"
- "tslint"
- "typescript"))))))
+ (lambda _
+ (delete-dependencies `("^@types/node$"
+ "mocha$"
+ "^ts-node$"
+ "^tslint$"
+ "^typescript$"))))
(replace 'build
(lambda* (#:key inputs #:allow-other-keys)
(let ((esbuild (search-input-file inputs "/bin/esbuild")))
@@ -581,15 +564,13 @@ (define-public node-llparse-frontend-bootstrap
(modify-phases %standard-phases
(add-after 'patch-dependencies 'delete-dependencies
(lambda args
- (with-atomic-json-file-replacement "package.json"
- (lambda (pkg-meta)
- (delete-dependencies pkg-meta `("@types/debug"
- "@types/mocha"
- "@types/node"
- "mocha"
- "ts-node"
- "tslint"
- "typescript"))))))
+ (delete-dependencies `("^@types/debug$"
+ "^@types/mocha$"
+ "^@types/node$"
+ "^mocha$"
+ "^ts-node$"
+ "^tslint$"
+ "^typescript$"))))
(replace 'build
(lambda* (#:key inputs #:allow-other-keys)
(let ((esbuild (search-input-file inputs "/bin/esbuild")))
@@ -644,18 +625,15 @@ (define-public node-llparse-bootstrap
(modify-phases %standard-phases
(add-after 'patch-dependencies 'delete-dependencies
(lambda args
- (with-atomic-json-file-replacement "package.json"
- (lambda (pkg-meta)
- (delete-dependencies pkg-meta
- `("@types/debug"
- "@types/mocha"
- "@types/node"
- "esm"
- "llparse-test-fixture"
- "mocha"
- "ts-node"
- "tslint"
- "typescript"))))))
+ (delete-dependencies `("^@types/debug$"
+ "^@types/mocha$"
+ "^@types/node$"
+ "^esm$"
+ "^llparse-test-fixture$"
+ "^mocha$"
+ "^ts-node$"
+ "^tslint$"
+ "^typescript$"))))
(replace 'build
(lambda* (#:key inputs #:allow-other-keys)
(let ((esbuild (search-input-file inputs "/bin/esbuild")))
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 05/41] guix: node-build-system: Add 'delete-dependencies' helper function.
2022-01-06 16:50 ` Liliana Marie Prikler
@ 2022-01-06 17:28 ` Leo Famulari
0 siblings, 0 replies; 458+ messages in thread
From: Leo Famulari @ 2022-01-06 17:28 UTC (permalink / raw)
To: Liliana Marie Prikler
Cc: 51838, Timothy Sample, Pierre Langlois, Jelle Licht,
Philip McGrath
On Thu, Jan 06, 2022 at 05:50:08PM +0100, Liliana Marie Prikler wrote:
> So from my position, everything is about to be done. Should I resend
> this as v8 for a complete check that I'm not doing anything harmful or
> should I go ahead and commit once I'm done?
I think we should wait to see what Philip thinks about the revisions.
I don't have specific feedback about the patches. Instead, I wanted to
give a nudge towards resolution of the "ticket", which I think is
important in terms of how contributors feel about their work with Guix.
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 05/41] guix: node-build-system: Add 'delete-dependencies' helper function.
2022-01-05 19:08 ` Philip McGrath
2022-01-05 20:02 ` Leo Famulari
@ 2022-01-05 21:04 ` Liliana Marie Prikler
2022-01-05 22:58 ` Liliana Marie Prikler
2022-01-08 4:14 ` Philip McGrath
1 sibling, 2 replies; 458+ messages in thread
From: Liliana Marie Prikler @ 2022-01-05 21:04 UTC (permalink / raw)
To: Philip McGrath, 51838; +Cc: Timothy Sample, Pierre Langlois, Jelle Licht
Hi,
Am Mittwoch, dem 05.01.2022 um 14:08 -0500 schrieb Philip McGrath:
> I will admit that I am more than a little frustrated that, having put
> aside my own reservations and implemented the compromise proposal it
> seemed everyone could live with, it now seems that the consensus was
> in fact illusory. Moreover, I still do not understand what specific
> changes I could send in a v8 that would get this patch series to a
> state where everyone would agree it could be applied.
To be honest, I should do part of my job as well here and apply some of
my own suggestions as I push if you deem them reasonable. I think
that'd get us to consensus in one iteration.
>
> I don't know what to make of this comment, and I especially don't
> understand what the notorious left-pad incident has to do with my
> views. Aside from its inflammatory nature, I think left-pad is a
> confusing way to make a point because many people have tried to make
> it "stand for" many different, perhaps even mutually contradictory,
> conclusions.
Point taken, I'll try to dedent my Javascript jokes.
> In case it helps at all to state my position more fully: with or
> without Guix, I think a major purpose, perhaps even the primary
> purpose, of _any_ build system is to relieve users (including
> ourselves) of the cognitive burden of lower-level details. Build
> systems are a means of abstraction and encapsulation.
>
> [...]
I agree with you that abstractions ought to help, but we do have some
disagreements about the amount by which certain abstractions help.
Those are gut feeling value judgements, they're not all entirely
rational.
> I hope this is just a matter of some nuance in the connotation of
> the word "gratuitous" not coming across properly, but I would
> appreciate the same consideration being extended to my perspective.
>
> Almost tautologically, I don't think adding '#:absent-dependencies'
> would be gratuitous, or I wouldn't have proposed it.
Generally, keywords are reserved for a few special operations. I don't
currently have the time to write them all up, but suffice it to say I
don't believe the way #:absent-dependencies would be used fits into any
of those. I can write that up in a later message if you feel it's
imporant enough.
> From my perspective, though, the substance of these patches has been
> ready to go for something like six weeks now, and the few
> enhancements since then could easily have been small follow-on
> patches. I would consider it very regrettable if this patch series
> were to continue to be blocked by stylistic considerations
> in the implementation of unexported helper functions.
That's not at all my intention. I'll write up a checklist as a follow-
up. We can go over these shortly and I'll have v6 with minor
adjustments land hopefully soon (if it can't be done tomorrow I'll
shoot for Sunday). Would that be acceptable?
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 05/41] guix: node-build-system: Add 'delete-dependencies' helper function.
2022-01-05 21:04 ` Liliana Marie Prikler
@ 2022-01-05 22:58 ` Liliana Marie Prikler
2022-01-08 4:14 ` Philip McGrath
1 sibling, 0 replies; 458+ messages in thread
From: Liliana Marie Prikler @ 2022-01-05 22:58 UTC (permalink / raw)
To: Philip McGrath, 51838; +Cc: Timothy Sample, Pierre Langlois, Jelle Licht
Am Mittwoch, dem 05.01.2022 um 22:04 +0100 schrieb Liliana Marie
Prikler:
> That's not at all my intention. I'll write up a checklist as a
> follow-up. We can go over these shortly and I'll have v6 with minor
> adjustments land hopefully soon (if it can't be done tomorrow I'll
> shoot for Sunday). Would that be acceptable?
Okay, here's my checklist. I'll denote discussion points with numbers
and actionable tasks with square brackets. Send me a reply in which
you mark either the ones you want to have or the ones you don't (give a
short reason for each) and I'll make it work. The entries marked with
a forward slash would require an additional round of review to ensure I
don't fuck any of this up (pardon my lack of a better term), so it's
probably better to open up separate bugs for those if we want to be
quick. I feel rather confident about the rest, however.
1. Move alist/json primitives to new file or shrink them in vertical
size. Since you raised valid points against moving them, that'd be
shrinking them in vertical size. To this end:
[ ] Use SRFI-71 wherever applicable.
[ ] Implement them in terms of SRFI-1 span.
[ ] For the json-side only define json-update* as it appears to be the
only one used later on (need confirmation on that one)
2. Reduce Racketisms
[ ] Use DEFAULT instead of FAILURE_RESULT.
[/] Define json-update* as syntax.
3. Generic style stuff
[ ] Move conses inside match.
[/] Merge with-atomic-json-file-replacement and json-update into a
single syntax (rewrite-json-file).
[ ] Simplify delete-dependencies so that we can directly write
(lambda args (delete-dependencies DEPS).
[ ] Use identifier-syntax for the empty JSON object (how do we name
it?)
If I omitted anything and it's simple enough to fit this mold, do add
it and I'll see if I can tack it on or we would need to go through
another round for that. Sorry this all took so long.
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 05/41] guix: node-build-system: Add 'delete-dependencies' helper function.
2022-01-05 21:04 ` Liliana Marie Prikler
2022-01-05 22:58 ` Liliana Marie Prikler
@ 2022-01-08 4:14 ` Philip McGrath
2022-01-08 7:59 ` Liliana Marie Prikler
1 sibling, 1 reply; 458+ messages in thread
From: Philip McGrath @ 2022-01-08 4:14 UTC (permalink / raw)
To: Liliana Marie Prikler, 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Leo Famulari
Hi,
On 1/5/22 16:04, Liliana Marie Prikler wrote:
> Am Mittwoch, dem 05.01.2022 um 14:08 -0500 schrieb Philip McGrath:
>> In case it helps at all to state my position more fully: with or
>> without Guix, I think a major purpose, perhaps even the primary
>> purpose, of _any_ build system is to relieve users (including
>> ourselves) of the cognitive burden of lower-level details. Build
>> systems are a means of abstraction and encapsulation.
>>
>> [...]
> I agree with you that abstractions ought to help, but we do have some
> disagreements about the amount by which certain abstractions help.
> Those are gut feeling value judgements, they're not all entirely
> rational.
>
>> I hope this is just a matter of some nuance in the connotation of
>> the word "gratuitous" not coming across properly, but I would
>> appreciate the same consideration being extended to my perspective.
>>
>> Almost tautologically, I don't think adding '#:absent-dependencies'
>> would be gratuitous, or I wouldn't have proposed it.
> Generally, keywords are reserved for a few special operations. I don't
> currently have the time to write them all up, but suffice it to say I
> don't believe the way #:absent-dependencies would be used fits into any
> of those. I can write that up in a later message if you feel it's
> imporant enough.
It isn't needed right now, since we've agreed to go ahead without
'#:absent-dependencies', but, since I do intend to propose
'#:absent-dependencies' immediately thereafter, I think it would be
useful: this seems to get close to the core of the disagreement we've
been having for the last ... couple months?
I don't see a reason why we should hesitate to use keywords when they
enable especially nice code. Actually, I've sometimes wished build
systems would '#:allow-other-keys'.
I'd expect '#:absent-dependencies' to be more common for
'node-build-system' packages than '#:tests?', since I'd expect almost
every package that would use '#:tests? #f', plus a significant number
that wouldn't, to use '#:absent-dependencies'.
Jumping back to an earlier email:
On 12/30/21 21:46, Liliana Marie Prikler wrote:
> Am Donnerstag, dem 30.12.2021 um 20:09 -0500 schrieb Philip McGrath:
>> In my view, the high-level purpose of 'delete-dependencies',
>> '#:absent-dependencies', or whatever is to gather our collective
>> procedural knowledge about how to modify a "package.json" file to
>> build a package without some of the dependencies its developers have
>> declared and to encode that knowledge in a single, abstracted point
>> of control in 'node-build-system', so that authors of Node.js package
>> definitions can simply specify which declared dependencies are absent
>> and leave it to 'node-build-system' to act accordingly. (I don't
>> think it matters _why_ the dependencies are absent, i.e. whether we
>> don't want the them or merely don't have them.)
> For the record, you can delete present dependencies as well, which is
> one shortcoming in the "absent dependencies" metaphor.
[...]
>> It is unnecessarily flexible because, if a package author ever passes
>> some other value for '#:json-keys', that would seem to indicate that
>> there's some procedural knowledge missing from 'node-build-system',
>> and it should be added there.
> The reason I have it as such is that a packager might decide in the
> future to e.g. only drop a peer dependency, that might share a name
> with a dev dependency or something along those lines.
Since I don't think I've written it down before, my hope in describing
them as "absent" dependencies was to state that they are absent from the
build environment, while being as neutral as I could about _why_ they
might be absent. In particular, I wanted to avoid the implications of
"missing", which can have implications of "we don't know where X is" and
"it would be better if we found X". One day, it would probably be nice
to have 'node-aws-sdk' packaged for Guix, but, even if we knew the
precise line number in "node-xyz.scm" where it we could find its
definition, we would not want to use it while building 'node-sqlite3'.
So, having established that the adjectives are a little fuzzy, I don't
understand what it would mean to "delete present dependencies". If they
are present in the build environment, why delete them? If the issue is
that they only are needed at build time, the 'install' phase of
'node-build-system' should already handle this by passing '--production'
to 'npm install'.
If a "peerDependency" and a "devDependency" share a name, then they
refer to the same package. I believe it would be an error (logically,
that is: I do know npm would not raise an exception) to have a
"peerDependency" that is also a "devDependency" or a "dependency": as I
understand it (poorly!), peer dependencies are meant to be some weaker
kind of relationship.
But again, none of this needs to stand in the way of merging this patch
series.
-Philip
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 05/41] guix: node-build-system: Add 'delete-dependencies' helper function.
2022-01-08 4:14 ` Philip McGrath
@ 2022-01-08 7:59 ` Liliana Marie Prikler
0 siblings, 0 replies; 458+ messages in thread
From: Liliana Marie Prikler @ 2022-01-08 7:59 UTC (permalink / raw)
To: Philip McGrath, 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Leo Famulari
Hi,
Am Freitag, dem 07.01.2022 um 23:14 -0500 schrieb Philip McGrath:
> I do intend to propose '#:absent-dependencies' immediately
> thereafter.
And I do intend to reject that proposal immediately thereafter.
Nothing personal, but I think I've made a clear enough case against it,
although I could go into even more detail if you want me to.
> I don't see a reason why we should hesitate to use keywords when they
> enable especially nice code. Actually, I've sometimes wished build
> systems would '#:allow-other-keys'.
The reason to e.g. use #:tests? over (delete 'check) is not because the
code looks nicer (although it does). As Jelle pointed out, code that
does ugly things should be allowed to look ugly, and in terms of node-
build-system needing to delete dependencies *at all* is already an ugly
thing. There's no need for a convenience keyword, much less a reason
to implement one for the sake of nicer-looking code.
> Since I don't think I've written it down before, my hope in
> describing them as "absent" dependencies was to state that they are
> absent from the build environment, while being as neutral as I could
> about _why_ they might be absent.
The word absent is not neutral. It implies it's not there when it
should be. My use of unwanted does the opposite. It implies it should
not be there when upstream claims it should. The obvious middle ground
is good old "exclude", but I think it'd be hard to make an argument
even for #:excluded-dependencies.
> In particular, I wanted to avoid the implications of
> "missing", which can have implications of "we don't know where X is"
> and "it would be better if we found X".
You just substituted missing for another spelling of it. That doesn't
really help here.
> So, having established that the adjectives are a little fuzzy, I
> don't understand what it would mean to "delete present dependencies".
> If they are present in the build environment, why delete them?
It would mean committing the error of specifying a dependency both as
input and as absent. This is for the lack of a better word UB.
> If a "peerDependency" and a "devDependency" share a name, then they
> refer to the same package. I believe it would be an error (logically,
> that is: I do know npm would not raise an exception) to have a
> "peerDependency" that is also a "devDependency" or a "dependency": as
> I understand it (poorly!), peer dependencies are meant to be some
> weaker kind of relationship.
Even then, much of our other discussion revolves around the question of
what the implications of those are. If we, the experts, can't be
trusted to have a clear enough understanding, how should we trust non-
expert users on the matter? That's why I wanted to encode the
dependency key in delete-dependencies. That way, one could specify
"delete X from dependencies after it was introduced by Guix" or "no, I
really don't want it to be a peer dependency either". And until we
have a clearer image, we could accept both forms and see what problems
they'd cause later on, then reject one in favour of the other by
patching them out over time.
None of that would be possible with a keyword, at least one with a nice
value encoding. You either change all node packages at a time,
potentially causing a c-u-worthy rebuild, or you don't and you're
stuck.
Cheers
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 06/41] gnu: node-semver-bootstrap: Use 'delete-dependencies'.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (4 preceding siblings ...)
2021-12-30 7:38 ` [bug#51838] [PATCH v6 05/41] guix: node-build-system: Add 'delete-dependencies' helper function Philip McGrath
@ 2021-12-30 7:38 ` Philip McGrath
2021-12-30 7:38 ` [bug#51838] [PATCH v6 07/41] gnu: node-ms-bootstrap: " Philip McGrath
` (36 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:38 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node.scm (node-semver-bootstrap)[arguments]: Use
'delete-dependencies'. Stop deleting the 'configure' phase.
---
gnu/packages/node.scm | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 51a393caab..255a92964d 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -346,7 +346,11 @@ (define-public node-semver-bootstrap
#:tests? #f
#:phases
(modify-phases %standard-phases
- (delete 'configure))))
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (delete-dependencies pkg-meta '("tap")))))))))
(home-page "https://github.com/npm/node-semver")
(properties '((hidden? . #t)))
(synopsis "Parses semantic versions strings")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 07/41] gnu: node-ms-bootstrap: Use 'delete-dependencies'.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (5 preceding siblings ...)
2021-12-30 7:38 ` [bug#51838] [PATCH v6 06/41] gnu: node-semver-bootstrap: Use 'delete-dependencies' Philip McGrath
@ 2021-12-30 7:38 ` Philip McGrath
2021-12-30 7:38 ` [bug#51838] [PATCH v6 08/41] gnu: node-binary-search-bootstrap: " Philip McGrath
` (35 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:38 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node.scm (node-ms-bootstrap)[arguments]: Use
'delete-dependencies'. Stop deleting the 'configure' phase.
---
gnu/packages/node.scm | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 255a92964d..e5a1c58140 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -379,7 +379,15 @@ (define-public node-ms-bootstrap
#:tests? #f
#:phases
(modify-phases %standard-phases
- (delete 'configure))))
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (delete-dependencies pkg-meta '("eslint"
+ "expect.js"
+ "husky"
+ "lint-staged"
+ "mocha")))))))))
(home-page "https://github.com/zeit/ms#readme")
(properties '((hidden? . #t)))
(synopsis "Tiny millisecond conversion utility")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 08/41] gnu: node-binary-search-bootstrap: Use 'delete-dependencies'.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (6 preceding siblings ...)
2021-12-30 7:38 ` [bug#51838] [PATCH v6 07/41] gnu: node-ms-bootstrap: " Philip McGrath
@ 2021-12-30 7:38 ` Philip McGrath
2021-12-30 7:38 ` [bug#51838] [PATCH v6 09/41] gnu: node-debug-bootstrap: " Philip McGrath
` (34 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:38 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node.scm (node-binary-search-bootstrap)[arguments]: Use
'delete-dependencies'. Stop deleting the 'configure' phase.
---
gnu/packages/node.scm | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index e5a1c58140..32f7c8f980 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -415,7 +415,12 @@ (define-public node-binary-search-bootstrap
#:tests? #f
#:phases
(modify-phases %standard-phases
- (delete 'configure))))
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (delete-dependencies pkg-meta `("chai"
+ "mocha")))))))))
(home-page "https://github.com/darkskyapp/binary-search#readme")
(properties '((hidden? . #t)))
(synopsis "Tiny binary search function with comparators")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 09/41] gnu: node-debug-bootstrap: Use 'delete-dependencies'.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (7 preceding siblings ...)
2021-12-30 7:38 ` [bug#51838] [PATCH v6 08/41] gnu: node-binary-search-bootstrap: " Philip McGrath
@ 2021-12-30 7:38 ` Philip McGrath
2021-12-30 7:38 ` [bug#51838] [PATCH v6 10/41] gnu: node-llparse-builder-bootstrap: " Philip McGrath
` (33 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:38 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node.scm (node-debug-bootstrap)[arguments]: Use
'delete-dependencies'. Stop deleting the 'configure' phase.
---
gnu/packages/node.scm | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 32f7c8f980..6e37097f5e 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -447,7 +447,22 @@ (define-public node-debug-bootstrap
#:tests? #f
#:phases
(modify-phases %standard-phases
- (delete 'configure))))
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (delete-dependencies pkg-meta
+ `("brfs"
+ "browserify"
+ "coveralls"
+ "istanbul"
+ "karma"
+ "karma-browserify"
+ "karma-chrome-launcher"
+ "karma-mocha"
+ "mocha"
+ "mocha-lcov-reporter"
+ "xo")))))))))
(inputs (list node-ms-bootstrap))
(home-page "https://github.com/visionmedia/debug#readme")
(properties '((hidden? . #t)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 10/41] gnu: node-llparse-builder-bootstrap: Use 'delete-dependencies'.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (8 preceding siblings ...)
2021-12-30 7:38 ` [bug#51838] [PATCH v6 09/41] gnu: node-debug-bootstrap: " Philip McGrath
@ 2021-12-30 7:38 ` Philip McGrath
2021-12-30 7:38 ` [bug#51838] [PATCH v6 11/41] gnu: node-llparse-frontend-bootstrap: " Philip McGrath
` (32 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:38 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node.scm (node-llparse-builder-bootstrap)[arguments]: Use
'delete-dependencies'. Stop deleting the 'configure' phase.
---
gnu/packages/node.scm | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 6e37097f5e..0563d9c290 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -516,7 +516,16 @@ (define-public node-llparse-builder-bootstrap
#:tests? #f
#:phases
(modify-phases %standard-phases
- (delete 'configure)
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (delete-dependencies pkg-meta `("@types/mocha"
+ "@types/node"
+ "mocha"
+ "ts-node"
+ "tslint"
+ "typescript"))))))
(replace 'build
(lambda* (#:key inputs #:allow-other-keys)
(let ((esbuild (search-input-file inputs "/bin/esbuild")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 11/41] gnu: node-llparse-frontend-bootstrap: Use 'delete-dependencies'.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (9 preceding siblings ...)
2021-12-30 7:38 ` [bug#51838] [PATCH v6 10/41] gnu: node-llparse-builder-bootstrap: " Philip McGrath
@ 2021-12-30 7:38 ` Philip McGrath
2021-12-30 7:38 ` [bug#51838] [PATCH v6 12/41] gnu: node-llparse-bootstrap: " Philip McGrath
` (31 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:38 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node.scm (node-llparse-frontend-bootstrap)[arguments]: Use
'delete-dependencies'. Stop deleting the 'configure' phase.
---
gnu/packages/node.scm | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 0563d9c290..b132ce730b 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -579,7 +579,17 @@ (define-public node-llparse-frontend-bootstrap
#:tests? #f
#:phases
(modify-phases %standard-phases
- (delete 'configure)
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (delete-dependencies pkg-meta `("@types/debug"
+ "@types/mocha"
+ "@types/node"
+ "mocha"
+ "ts-node"
+ "tslint"
+ "typescript"))))))
(replace 'build
(lambda* (#:key inputs #:allow-other-keys)
(let ((esbuild (search-input-file inputs "/bin/esbuild")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 12/41] gnu: node-llparse-bootstrap: Use 'delete-dependencies'.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (10 preceding siblings ...)
2021-12-30 7:38 ` [bug#51838] [PATCH v6 11/41] gnu: node-llparse-frontend-bootstrap: " Philip McGrath
@ 2021-12-30 7:38 ` Philip McGrath
2021-12-30 7:38 ` [bug#51838] [PATCH v6 13/41] gnu: node-semver: " Philip McGrath
` (30 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:38 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node.scm (node-llparse-bootstrap)[arguments]: Use
'delete-dependencies'. Stop deleting the 'configure' phase.
---
gnu/packages/node.scm | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index b132ce730b..5a4401e779 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -642,7 +642,20 @@ (define-public node-llparse-bootstrap
#:tests? #f
#:phases
(modify-phases %standard-phases
- (delete 'configure)
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (delete-dependencies pkg-meta
+ `("@types/debug"
+ "@types/mocha"
+ "@types/node"
+ "esm"
+ "llparse-test-fixture"
+ "mocha"
+ "ts-node"
+ "tslint"
+ "typescript"))))))
(replace 'build
(lambda* (#:key inputs #:allow-other-keys)
(let ((esbuild (search-input-file inputs "/bin/esbuild")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 13/41] gnu: node-semver: Use 'delete-dependencies'.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (11 preceding siblings ...)
2021-12-30 7:38 ` [bug#51838] [PATCH v6 12/41] gnu: node-llparse-bootstrap: " Philip McGrath
@ 2021-12-30 7:38 ` Philip McGrath
2021-12-30 7:38 ` [bug#51838] [PATCH v6 14/41] gnu: node-wrappy: " Philip McGrath
` (29 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:38 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node-xyz.scm (node-semver)[arguments]: Use
'delete-dependencies'. Stop deleting the 'configure' phase.
---
gnu/packages/node-xyz.scm | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 9a0be96852..08a22f4aff 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -288,11 +288,15 @@ (define-public node-semver
"06biknqb05r9xsmcflm3ygh50pjvdk84x6r79w43kmck4fn3qn5p"))))
(build-system node-build-system)
(arguments
- '(#:tests? #f ; FIXME: Tests depend on node-tap
- #:phases
+ '(#:phases
(modify-phases %standard-phases
- ;; The only dependency to check for is tap, which we don't have.
- (delete 'configure))))
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (delete-dependencies pkg-meta '("tap")))))))
+ ;; FIXME: Tests depend on node-tap
+ #:tests? #f))
(home-page "https://github.com/npm/node-semver")
(synopsis "Parses semantic versions strings")
(description
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 14/41] gnu: node-wrappy: Use 'delete-dependencies'.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (12 preceding siblings ...)
2021-12-30 7:38 ` [bug#51838] [PATCH v6 13/41] gnu: node-semver: " Philip McGrath
@ 2021-12-30 7:38 ` Philip McGrath
2021-12-30 7:38 ` [bug#51838] [PATCH v6 15/41] gnu: node-once: " Philip McGrath
` (28 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:38 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node-xyz.scm (node-wrappy)[arguments]: Use
'delete-dependencies'. Stop deleting the 'configure' phase.
---
gnu/packages/node-xyz.scm | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 08a22f4aff..da855cb16e 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -322,8 +322,11 @@ (define-public node-wrappy
'(#:tests? #f ; FIXME: Tests depend on node-tap
#:phases
(modify-phases %standard-phases
- ;; The only dependency to check for is tap, which we don't have.
- (delete 'configure))))
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (delete-dependencies pkg-meta '("tap")))))))))
(home-page "https://github.com/npm/wrappy")
(synopsis "Callback wrapping utility")
(description "@code{wrappy} is a utility for Node.js to wrap callbacks.")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 15/41] gnu: node-once: Use 'delete-dependencies'.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (13 preceding siblings ...)
2021-12-30 7:38 ` [bug#51838] [PATCH v6 14/41] gnu: node-wrappy: " Philip McGrath
@ 2021-12-30 7:38 ` Philip McGrath
2021-12-30 7:38 ` [bug#51838] [PATCH v6 16/41] gnu: node-irc-colors: " Philip McGrath
` (27 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:38 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node-xyz.scm (node-once)[arguments]: Use
'delete-dependencies'. Stop deleting the 'configure' phase.
---
gnu/packages/node-xyz.scm | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index da855cb16e..ef251c07bf 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -347,13 +347,15 @@ (define-public node-once
"1z8dcbf28dqdcp4wb0c53wrs90a07nkrax2c9kk26dsk1dhrnxav"))))
(build-system node-build-system)
(arguments
- '(#:tests? #f ; FIXME: tests depend on node-tap
- #:phases
+ '(#:phases
(modify-phases %standard-phases
- ;; The default configure phase fails due to tap being missing, as we do
- ;; not have tap packaged yet. It is used only for tests. This package
- ;; still works as a dependency of node-glob and node-inflight.
- (delete 'configure))))
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (delete-dependencies pkg-meta '("tap")))))))
+ ;; FIXME: Tests depend on node-tap
+ #:tests? #f))
(inputs
(list node-wrappy))
(home-page "https://github.com/isaacs/once")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 16/41] gnu: node-irc-colors: Use 'delete-dependencies'.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (14 preceding siblings ...)
2021-12-30 7:38 ` [bug#51838] [PATCH v6 15/41] gnu: node-once: " Philip McGrath
@ 2021-12-30 7:38 ` Philip McGrath
2021-12-30 7:38 ` [bug#51838] [PATCH v6 17/41] gnu: node-irc: " Philip McGrath
` (26 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:38 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node-xyz.scm (node-irc-colors)[arguments]: Use
'delete-dependencies'. Stop deleting the 'configure' phase.
---
gnu/packages/node-xyz.scm | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index ef251c07bf..f9c7f7ac2a 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -381,12 +381,15 @@ (define-public node-irc-colors
"0q3y34rbnlc55jcakmdxkicwazyvyph9r6gaf6hi8k7wj2nfwfli"))))
(build-system node-build-system)
(arguments
- '(#:tests? #f ; FIXME: tests depend on node-istanbul
- #:phases
+ '(#:phases
(modify-phases %standard-phases
- ;; The default configure phase fails due to various packages
- ;; being missing, as we don't have them packaged yet.
- (delete 'configure))))
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (delete-dependencies pkg-meta `("istanbul"
+ "vows")))))))
+ #:tests? #f))
(home-page "https://github.com/fent/irc-colors.js")
(synopsis "Node.js module providing color and formatting for IRC")
(description "@code{node-irc-colors} is a Node.js module that
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 17/41] gnu: node-irc: Use 'delete-dependencies'.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (15 preceding siblings ...)
2021-12-30 7:38 ` [bug#51838] [PATCH v6 16/41] gnu: node-irc-colors: " Philip McGrath
@ 2021-12-30 7:38 ` Philip McGrath
2021-12-30 7:38 ` [bug#51838] [PATCH v6 18/41] gnu: Add node-inherits Philip McGrath
` (25 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:38 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node-xyz.scm (node-irc)[arguments]: Use
'delete-dependencies'. Stop deleting the 'configure' phase.
---
gnu/packages/node-xyz.scm | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index f9c7f7ac2a..feea4ca614 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -413,12 +413,17 @@ (define-public node-irc
"1ln4qfx20jbwg4cp8lp0vf27m5281z2sz16d15xd6150n26cbi4x"))))
(build-system node-build-system)
(arguments
- '(#:tests? #f ; FIXME: tests depend on node-faucet
- #:phases
+ '(#:phases
(modify-phases %standard-phases
- ;; The default configure phase fails due to various packages
- ;; being missing, as we don't have them packaged yet.
- (delete 'configure))))
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (delete-dependencies pkg-meta `("ansi-color"
+ "faucet"
+ "jscs"
+ "tape")))))))
+ #:tests? #f))
(inputs
(list node-irc-colors))
(home-page "https://github.com/martynsmith/node-irc")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 18/41] gnu: Add node-inherits.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (16 preceding siblings ...)
2021-12-30 7:38 ` [bug#51838] [PATCH v6 17/41] gnu: node-irc: " Philip McGrath
@ 2021-12-30 7:38 ` Philip McGrath
2021-12-30 7:38 ` [bug#51838] [PATCH v6 19/41] gnu: Add node-safe-buffer Philip McGrath
` (24 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:38 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-inherits): New variable.
---
gnu/packages/node-xyz.scm | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index feea4ca614..49d99534fb 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -3,6 +3,7 @@
;;; Copyright © 2020 Giacomo Leidi <goodoldpaul@autistici.org>
;;; Copyright © 2021 Noisytoot <noisytoot@disroot.org>
;;; Copyright © 2021 Charles <charles.b.jackson@protonmail.com>
+;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -366,6 +367,40 @@ (define-public node-once
if desired.")
(license license:isc)))
+(define-public node-inherits
+ (package
+ (name "node-inherits")
+ (version "2.0.4")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/isaacs/inherits")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0cpsr5yqwkxpbbbbl0rwk4mcby6zbx841k2zb4c3gb1579i5wq9p"))))
+ (build-system node-build-system)
+ (arguments
+ '(#:phases
+ (modify-phases %standard-phases
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (delete-dependencies pkg-meta '("tap")))))))
+ ;; FIXME: Tests depend on node-tap
+ #:tests? #f))
+ (home-page
+ "https://github.com/isaacs/inherits")
+ (synopsis
+ "Browser-friendly inheritance Node.js")
+ (description
+ "Browser-friendly inheritance fully compatible with standard Node.js
+@code{inherits()}.")
+ (license license:isc)))
+
(define-public node-irc-colors
(package
(name "node-irc-colors")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 19/41] gnu: Add node-safe-buffer.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (17 preceding siblings ...)
2021-12-30 7:38 ` [bug#51838] [PATCH v6 18/41] gnu: Add node-inherits Philip McGrath
@ 2021-12-30 7:38 ` Philip McGrath
2021-12-30 7:38 ` [bug#51838] [PATCH v6 20/41] gnu: Add node-string-decoder Philip McGrath
` (23 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:38 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-safe-buffer): New variable.
---
gnu/packages/node-xyz.scm | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 49d99534fb..6b4b7efd7e 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -401,6 +401,39 @@ (define-public node-inherits
@code{inherits()}.")
(license license:isc)))
+(define-public node-safe-buffer
+ (package
+ (name "node-safe-buffer")
+ (version "5.2.1")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/feross/safe-buffer")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0r26m0nl41h90ihnl2xf0cqs6z9z7jb87dl5j8yqb7887r9jlbpi"))))
+ (build-system node-build-system)
+ (arguments
+ '(#:phases
+ (modify-phases %standard-phases
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (delete-dependencies pkg-meta '("tape"
+ "standard")))))))
+ #:tests? #f))
+ (home-page
+ "https://github.com/feross/safe-buffer")
+ (synopsis "Safer Node.js Buffer API")
+ (description "A safe drop-in replacement the Node.js @code{Buffer} API
+that works in all versions of Node.js, using the built-in implementation when
+available.")
+ (license license:expat)))
+
(define-public node-irc-colors
(package
(name "node-irc-colors")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 20/41] gnu: Add node-string-decoder.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (18 preceding siblings ...)
2021-12-30 7:38 ` [bug#51838] [PATCH v6 19/41] gnu: Add node-safe-buffer Philip McGrath
@ 2021-12-30 7:38 ` Philip McGrath
2021-12-30 7:38 ` [bug#51838] [PATCH v6 21/41] gnu: Add node-readable-stream Philip McGrath
` (22 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:38 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-string-decoder): New variable.
---
gnu/packages/node-xyz.scm | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 6b4b7efd7e..c8a0f79eba 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -434,6 +434,45 @@ (define-public node-safe-buffer
available.")
(license license:expat)))
+(define-public node-string-decoder
+ (package
+ (name "node-string-decoder")
+ (version "1.3.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/nodejs/string_decoder")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0xxvyya9fl9rlkqwmxzqzbz4rdr3jgw4vf37hff7cgscxkhg266k"))))
+ (build-system node-build-system)
+ (arguments
+ '(#:phases
+ (modify-phases %standard-phases
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (delete-dependencies pkg-meta
+ '("tap"
+ "core-util-is"
+ "babel-polyfill")))))))
+ ;; FIXME: Tests depend on node-tap
+ #:tests? #f))
+ (inputs
+ (list node-safe-buffer node-inherits))
+ (home-page
+ "https://github.com/nodejs/string_decoder")
+ (synopsis
+ "Node.js core @code{string_decoder} for userland")
+ (description
+ "This package is a mirror of the @code{string_decoder} implementation in
+Node-core.")
+ (license license:expat)))
+
(define-public node-irc-colors
(package
(name "node-irc-colors")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 21/41] gnu: Add node-readable-stream.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (19 preceding siblings ...)
2021-12-30 7:38 ` [bug#51838] [PATCH v6 20/41] gnu: Add node-string-decoder Philip McGrath
@ 2021-12-30 7:38 ` Philip McGrath
2021-12-30 7:39 ` [bug#51838] [PATCH v6 22/41] gnu: Add node-nan Philip McGrath
` (21 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:38 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-readable-stream): New variable.
---
gnu/packages/node-xyz.scm | 58 +++++++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index c8a0f79eba..3f0ec35547 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -473,6 +473,64 @@ (define-public node-string-decoder
Node-core.")
(license license:expat)))
+(define-public node-readable-stream
+ (package
+ (name "node-readable-stream")
+ (version "3.6.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/nodejs/readable-stream")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0ybl4cdgsm9c5jq3xq8s01201jk8w0yakh63hlclsfbcdfqhd9ri"))))
+ (build-system node-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (delete-dependencies pkg-meta
+ `("@babel/cli"
+ "@babel/core"
+ "@babel/polyfill"
+ "@babel/preset-env"
+ "airtap"
+ "assert"
+ "bl"
+ "deep-strict-equal"
+ "events.once"
+ "glob"
+ "gunzip-maybe"
+ "hyperquest"
+ "lolex"
+ "nyc"
+ "pump"
+ "rimraf"
+ "tap"
+ "tape"
+ "tar-fs"
+ "util-promisify")))))))
+ #:tests? #f))
+ (inputs
+ (list node-util-deprecate node-string-decoder node-inherits))
+ (home-page
+ "https://github.com/nodejs/readable-stream")
+ (synopsis
+ "Node.js core streams for userland")
+ (description
+ "This package is a mirror of the streams implementations in Node.js.
+
+If you want to guarantee a stable streams base, regardless of what version of
+Node you (or the users of your libraries) are using, use
+@code{readable-stream} only and avoid the @code{stream} module in Node-core.")
+ (license license:expat)))
+
(define-public node-irc-colors
(package
(name "node-irc-colors")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 22/41] gnu: Add node-nan.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (20 preceding siblings ...)
2021-12-30 7:38 ` [bug#51838] [PATCH v6 21/41] gnu: Add node-readable-stream Philip McGrath
@ 2021-12-30 7:39 ` Philip McGrath
2021-12-30 7:39 ` [bug#51838] [PATCH v6 23/41] gnu: Add node-openzwave-shared Philip McGrath
` (20 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:39 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-nan): New variable.
---
gnu/packages/node-xyz.scm | 46 +++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 3f0ec35547..4eda001dc4 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -596,3 +596,49 @@ (define-public node-irc
(description "@code{node-irc} is an IRC client library for Node.js.
It has functions for joining, parting, talking, and many other IRC commands.")
(license license:gpl3+)))
+
+(define-public node-nan
+ (package
+ (name "node-nan")
+ (version "2.15.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/nodejs/nan")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "18xslh9va5ld872scrp5y4251ax9s3c6qh0lnl1200lpzbsxy7yd"))))
+ (build-system node-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (delete-dependencies
+ pkg-meta
+ '("bindings"
+ "commander"
+ "glob"
+ "request"
+ "node-gyp" ;; would be needed for tests
+ "tap"
+ "xtend")))))))
+ ;; tests need tap and other dependencies
+ #:tests? #f))
+ (inputs
+ (list node-readable-stream))
+ (home-page "https://github.com/nodejs/nan")
+ (synopsis "Native Abstractions for Node.js")
+ (description "Native Abstractions for Node.js (``NaN'') provides a header
+file filled with macro and utility goodness for making add-on development for
+Node.js easier across versions. The goal of this project is to store all logic
+necessary to develop native Node.js addons without having to inspect
+@code{NODE_MODULE_VERSION} and get yourself into a macro-tangle.
+
+This project also contains some helper utilities that make addon development a
+bit more pleasant.")
+ (license license:expat)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 23/41] gnu: Add node-openzwave-shared.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (21 preceding siblings ...)
2021-12-30 7:39 ` [bug#51838] [PATCH v6 22/41] gnu: Add node-nan Philip McGrath
@ 2021-12-30 7:39 ` Philip McGrath
2021-12-30 7:39 ` [bug#51838] [PATCH v6 24/41] gnu: Add node-addon-api Philip McGrath
` (19 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:39 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/zwave.scm (node-openzwave-shared): New variable.
---
gnu/packages/zwave.scm | 64 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 64 insertions(+)
diff --git a/gnu/packages/zwave.scm b/gnu/packages/zwave.scm
index 4d8286e334..3e99bd7687 100644
--- a/gnu/packages/zwave.scm
+++ b/gnu/packages/zwave.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -21,11 +22,14 @@ (define-module (gnu packages zwave)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix git-download)
#:use-module (guix build-system gnu)
+ #:use-module (guix build-system node)
#:use-module (gnu packages)
#:use-module (gnu packages base)
+ #:use-module (gnu packages node-xyz)
#:use-module (gnu packages libusb)
#:use-module (gnu packages linux)
#:use-module (gnu packages perl)
+ #:use-module (gnu packages python)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages xml))
@@ -85,3 +89,63 @@ (define-public open-zwave
and respond to devices on a Z-Wave network, without requiring in-depth
knowledge of the Z-Wave protocol.")
(license license:lgpl3+)))
+
+(define-public node-openzwave-shared
+ (package
+ (name "node-openzwave-shared")
+ (version "1.7.2")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/OpenZWave/node-openzwave-shared")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1bqqy12dzqj05j9wsh50dmn84dddmhz0gjzvd3y20z4hpy1v8rsc"))))
+ (inputs
+ (list open-zwave node-nan))
+ (native-inputs
+ (list which python pkg-config))
+ (build-system node-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (replace 'build
+ ;; For some reason, `npm install` doesn't build
+ ;; the addon automatically, so we do it explicitly here.
+ ;; We go through `npx` so the npmrc file sets the
+ ;; configuration up properly.
+ (lambda* (#:key native-inputs inputs #:allow-other-keys)
+ (invoke (search-input-file (or native-inputs inputs) "/bin/npx")
+ "--call"
+ (string-append
+ (search-input-file
+ (or native-inputs inputs)
+ "/lib/node_modules/npm/bin/node-gyp-bin/node-gyp")
+ " rebuild")))))))
+ (home-page "https://github.com/OpenZWave/node-openzwave-shared")
+ (synopsis "Node.js bindings for OpenZWave")
+ (description
+ "With the @code{node-openzwave-shared} package, you can easily control
+and manage your Z-Wave devices (lights, dimmers, blinds, you name it) from
+within Node.js applications. This library also supports secure
+devices (e.g. door locks) that require encryption. All widely used Node.js
+versions are supported with the help of @code{node-nan}.
+
+This library is currently able to:
+@itemize @bullet
+@item
+scan a Z-Wave network and report on connected devices;
+@item
+write values to Z-Wave nodes;
+@item
+monitor the network for changes;
+@item
+heal nodes and/or the network; and
+@item
+perform management tasks: add or remove nodes, replace failed nodes,
+manage their group associations, etc.
+@end itemize")
+ (license license:isc)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 24/41] gnu: Add node-addon-api.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (22 preceding siblings ...)
2021-12-30 7:39 ` [bug#51838] [PATCH v6 23/41] gnu: Add node-openzwave-shared Philip McGrath
@ 2021-12-30 7:39 ` Philip McGrath
2021-12-30 7:39 ` [bug#51838] [PATCH v6 25/41] gnu: Add node-sqlite3 Philip McGrath
` (18 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:39 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-addon-api): New variable.
---
gnu/packages/node-xyz.scm | 87 +++++++++++++++++++++++++++++++++++++++
1 file changed, 87 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 4eda001dc4..656642eb43 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -22,6 +22,9 @@
(define-module (gnu packages node-xyz)
#:use-module ((guix licenses) #:prefix license:)
+ #:use-module (gnu packages sqlite)
+ #:use-module (gnu packages python)
+ #:use-module (guix gexp)
#:use-module (guix packages)
#:use-module (guix git-download)
#:use-module (guix build-system node))
@@ -642,3 +645,87 @@ (define-public node-nan
This project also contains some helper utilities that make addon development a
bit more pleasant.")
(license license:expat)))
+
+(define-public node-addon-api
+ (package
+ (name "node-addon-api")
+ (version "4.2.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/nodejs/node-addon-api")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "1bhvfi2m9nxfz418s619914vmidcnrzbjv6l9nid476c3zlpazch"))))
+ (inputs
+ (list python node-safe-buffer))
+ (build-system node-build-system)
+ (arguments
+ `(#:modules
+ ((guix build node-build-system)
+ (srfi srfi-1)
+ (ice-9 match)
+ (guix build utils))
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (delete-dependencies pkg-meta
+ `("benchmark"
+ "bindings"
+ "clang-format"
+ "eslint"
+ "eslint-config-semistandard"
+ "eslint-config-standard"
+ "eslint-plugin-import"
+ "eslint-plugin-node"
+ "eslint-plugin-promise"
+ "fs-extra"
+ "path"
+ "pre-commit"))))))
+ (add-after 'unpack 'skip-js-tests
+ ;; We can't run the js-based tests,
+ ;; but we can still do the C++ parts
+ (lambda args
+ (define new-test-script
+ "echo stopping after pretest on Guix")
+ (with-atomic-json-file-replacement "package.json"
+ (match-lambda
+ (('@ . pkg-meta-alist)
+ (cons
+ '@
+ (map (match-lambda
+ (("scripts" '@ . scripts-alist)
+ `("scripts" @ ,@(map (match-lambda
+ (("test" . _)
+ (cons "test"
+ new-test-script))
+ (other
+ other))
+ scripts-alist)))
+ (other
+ other))
+ pkg-meta-alist))))))))))
+ (home-page "https://github.com/nodejs/node-addon-api")
+ (synopsis "Node.js API (Node-API) header-only C++ wrappers")
+ (description "This module contains header-only C++ wrapper classes which
+simplify the use of the C based Node-API provided by Node.js when using C++.
+It provides a C++ object model and exception handling semantics with low
+overhead.
+
+Node-API is an ABI stable C interface provided by Node.js for building native
+addons. It is intended to insulate native addons from changes in the
+underlying JavaScript engine and allow modules compiled for one version to run
+on later versions of Node.js without recompilation. The @code{node-addon-api}
+module, which is not part of Node.js, preserves the benefits of the Node-API
+as it consists only of inline code that depends only on the stable API
+provided by Node-API.
+
+It is important to remember that @emph{other} Node.js interfaces such as
+@code{libuv} (included in a project via @code{#include <uv.h>}) are not
+ABI-stable across Node.js major versions.")
+ (license license:expat)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 25/41] gnu: Add node-sqlite3.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (23 preceding siblings ...)
2021-12-30 7:39 ` [bug#51838] [PATCH v6 24/41] gnu: Add node-addon-api Philip McGrath
@ 2021-12-30 7:39 ` Philip McGrath
2021-12-30 7:39 ` [bug#51838] [PATCH v6 26/41] gnu: Add node-file-uri-to-path Philip McGrath
` (17 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:39 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-sqlite3): New variable.
---
gnu/packages/node-xyz.scm | 133 ++++++++++++++++++++++++++++++++++++++
1 file changed, 133 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 656642eb43..23ed209fd1 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -729,3 +729,136 @@ (define new-test-script
@code{libuv} (included in a project via @code{#include <uv.h>}) are not
ABI-stable across Node.js major versions.")
(license license:expat)))
+
+(define-public node-sqlite3
+ (package
+ (name "node-sqlite3")
+ (version "5.0.2")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/mapbox/node-sqlite3")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "0sbbzzli282nxyfha10zx0k5m8hdp0sf3ipl59khjb7wm449j86h"))
+ (snippet
+ (with-imported-modules '((guix build utils))
+ #~(begin
+ (use-modules (guix build utils))
+ ;; unbundle sqlite
+ (for-each delete-file-recursively
+ (find-files "deps"
+ (lambda (pth stat)
+ (gzip-file? pth)))))))))
+ (inputs
+ (list node-addon-api python sqlite))
+ (build-system node-build-system)
+ (arguments
+ `(#:modules
+ ((guix build node-build-system)
+ (srfi srfi-1)
+ (ice-9 match)
+ (guix build utils))
+ #:tests? #f ; FIXME: tests depend on node-mocha
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (delete-dependencies
+ pkg-meta
+ `(;; Normally, this is "built" using @mapbox/node-pre-gyp,
+ ;; which publishes or downloads pre-built binaries or
+ ;; falls back to building from source. Here, we patch out
+ ;; all of that and just build directly. It might be
+ ;; better to patch a version of @mapbox/node-pre-gyp that
+ ;; always builds from source, as Debian does, but there
+ ;; are a number of dependencies that need to be packaged
+ ;; or removed.
+ "@mapbox/node-pre-gyp"
+ "node-pre-gyp" ;; deprecated name still used in some places
+ "aws-sdk"
+ "@mapbox/cloudfriend"
+ ;; Confusingly, this is only a dependency because of
+ ;; @mapbox/node-pre-gyp: with that removed,
+ ;; npm will use its own copy:
+ "node-gyp"
+ ;; These we'd like, we just don't have them yet:
+ "eslint"
+ "mocha"))))))
+ (add-before 'configure 'npm-config-sqlite
+ ;; We need this step even if we do replace @mapbox/node-pre-gyp
+ ;; because the package expects to build its bundled sqlite
+ (lambda* (#:key inputs #:allow-other-keys)
+ (setenv "npm_config_sqlite" (assoc-ref inputs "sqlite"))))
+ (add-after 'install 'patch-binding-path
+ ;; We replace a file that dynamic searches for the addon using
+ ;; node-pre-gyp (which we don't have) with a version that
+ ;; simply uses the path to the addon we built directly.
+ ;; The exact path is supposed to depend on things like the
+ ;; architecture and napi_build_version, so, to avoid having
+ ;; hard-code the details accurately, we do this after the addon
+ ;; has been built so we can just find where it ended up.
+ (lambda* (#:key outputs #:allow-other-keys)
+ (with-directory-excursion
+ (search-input-directory outputs
+ "lib/node_modules/sqlite3/lib")
+ (match (find-files "binding" "\\.node$")
+ ((rel-path)
+ (with-atomic-file-replacement "sqlite3-binding.js"
+ (lambda (in out)
+ (format out "var binding = require('./~a');\n" rel-path)
+ (display "module.exports = exports = binding;\n"
+ out))))))))
+ (add-after 'patch-dependencies 'avoid-node-pre-gyp
+ (lambda args
+ ;; We need to patch .npmignore before the 'repack phase
+ ;; so that the built addon is installed with in the package.
+ ;; (Upstream assumes node-pre-gyp will download a pre-built
+ ;; version when this package is installed.)
+ (substitute* ".npmignore"
+ (("lib/binding")
+ "#lib/binding # <- patched for Guix"))
+ (with-atomic-json-file-replacement "package.json"
+ (match-lambda
+ (('@ . pkg-meta-alist)
+ (match (assoc-ref pkg-meta-alist "binary")
+ (('@ . binary-alist)
+ ;; When it builds from source, node-pre-gyp supplies
+ ;; module_name and module_path based on the entries under
+ ;; "binary" from "package.json", so this package's
+ ;; "binding.gyp" doesn't define them. Thus, we also need
+ ;; to supply them. The GYP_DEFINES environment variable
+ ;; turns out to be the easiest way to make sure they are
+ ;; propagated from npm to node-gyp to gyp.
+ (setenv "GYP_DEFINES"
+ (string-append
+ "module_name="
+ (assoc-ref binary-alist "module_name")
+ " "
+ "module_path="
+ (assoc-ref binary-alist "module_path")))))
+ ;; We need to remove the install script from "package.json",
+ ;; as it would try to use node-pre-gyp and would block the
+ ;; automatic building performed by `npm install`.
+ (cons '@ (map (match-lambda
+ (("scripts" @ . scripts-alist)
+ `("scripts" @ ,@(filter (match-lambda
+ (("install" . _)
+ #f)
+ (_
+ #t))
+ scripts-alist)))
+ (other
+ other))
+ pkg-meta-alist))))))))))
+ (home-page "https://github.com/mapbox/node-sqlite3")
+ (synopsis "Asynchronous, non-blocking SQLite3 bindings for Node.js")
+ (description
+ "The Node.js add-on @code{node-sqlite3} provides a set of a asynchronous,
+non-blocking bindings for SQLite3, written in modern C++ and tested for memory
+leaks.")
+ (license license:bsd-3)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 26/41] gnu: Add node-file-uri-to-path.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (24 preceding siblings ...)
2021-12-30 7:39 ` [bug#51838] [PATCH v6 25/41] gnu: Add node-sqlite3 Philip McGrath
@ 2021-12-30 7:39 ` Philip McGrath
2021-12-30 7:39 ` [bug#51838] [PATCH v6 27/41] gnu: Add node-bindings Philip McGrath
` (16 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:39 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-file-uri-to-path): New variable.
---
gnu/packages/node-xyz.scm | 58 +++++++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 23ed209fd1..ef190e56c1 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -24,6 +24,7 @@ (define-module (gnu packages node-xyz)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (gnu packages sqlite)
#:use-module (gnu packages python)
+ #:use-module (gnu packages web)
#:use-module (guix gexp)
#:use-module (guix packages)
#:use-module (guix git-download)
@@ -862,3 +863,60 @@ (define-public node-sqlite3
non-blocking bindings for SQLite3, written in modern C++ and tested for memory
leaks.")
(license license:bsd-3)))
+
+(define-public node-file-uri-to-path
+ (package
+ (name "node-file-uri-to-path")
+ (version "2.0.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/TooTallNate/file-uri-to-path")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "08l779az44czm12xdhgcrnzpqw34s59hbrlfphs7g9y2k26drqav"))))
+ (native-inputs
+ (list esbuild))
+ (build-system node-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (delete-dependencies pkg-meta
+ `("@types/mocha"
+ "@types/node"
+ "@typescript-eslint/eslint-plugin"
+ "@typescript-eslint/parser"
+ "cpy-cli"
+ "eslint"
+ "eslint-config-airbnb"
+ "eslint-config-prettier"
+ "eslint-import-resolver-typescript"
+ "eslint-plugin-import"
+ "eslint-plugin-jsx-a11y"
+ "eslint-plugin-react"
+ "mocha"
+ "rimraf"
+ "typescript"))))))
+ (replace 'build
+ (lambda* (#:key inputs native-inputs #:allow-other-keys)
+ (copy-recursively "src" "dist")
+ (invoke (search-input-file (or native-inputs inputs)
+ "/bin/esbuild")
+ "dist/index.ts"
+ "--outfile=dist/src/index.js"
+ "--format=cjs"
+ "--sourcemap"
+ "--platform=node"))))
+ #:tests? #f))
+ (home-page "https://github.com/TooTallNate/file-uri-to-path")
+ (synopsis "Convert a @code{file:} URI to a file path")
+ (description "This package provides a function to convert a @code{file:}
+URI to a file path. It accepts a @code{file:} URI and returns a file path
+suitable for use with the @code{fs} module functions.")
+ (license license:expat)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 27/41] gnu: Add node-bindings.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (25 preceding siblings ...)
2021-12-30 7:39 ` [bug#51838] [PATCH v6 26/41] gnu: Add node-file-uri-to-path Philip McGrath
@ 2021-12-30 7:39 ` Philip McGrath
2021-12-30 7:39 ` [bug#51838] [PATCH v6 28/41] gnu: Add node-segfault-handler Philip McGrath
` (15 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:39 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-bindings): New variable.
---
gnu/packages/node-xyz.scm | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index ef190e56c1..8d183cbe97 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -920,3 +920,29 @@ (define-public node-file-uri-to-path
URI to a file path. It accepts a @code{file:} URI and returns a file path
suitable for use with the @code{fs} module functions.")
(license license:expat)))
+
+(define-public node-bindings
+ (package
+ (name "node-bindings")
+ (version "1.5.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/TooTallNate/node-bindings")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "100gp6kpjvd4j1dqnp0sbjr1hqx5mz7r61q9qy527jyhk9mj47wk"))))
+ (inputs
+ (list node-file-uri-to-path))
+ (build-system node-build-system)
+ (arguments
+ ;; there are no tests
+ `(#:tests? #f))
+ (home-page "https://github.com/TooTallNate/node-bindings")
+ (synopsis "Help for loading your native module's @code{.node} file")
+ (description "This is a helper module for authors of Node.js native addon
+modules. It is basically the ``swiss army knife'' of @code{require()}ing your
+native module's @code{.node} file.")
+ (license license:expat)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 28/41] gnu: Add node-segfault-handler.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (26 preceding siblings ...)
2021-12-30 7:39 ` [bug#51838] [PATCH v6 27/41] gnu: Add node-bindings Philip McGrath
@ 2021-12-30 7:39 ` Philip McGrath
2021-12-30 7:39 ` [bug#51838] [PATCH v6 29/41] gnu: Add node-ms Philip McGrath
` (14 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:39 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-segfault-handler): New variable.
---
gnu/packages/node-xyz.scm | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 8d183cbe97..e2eb17b23c 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -946,3 +946,32 @@ (define-public node-bindings
modules. It is basically the ``swiss army knife'' of @code{require()}ing your
native module's @code{.node} file.")
(license license:expat)))
+
+(define-public node-segfault-handler
+ (package
+ (name "node-segfault-handler")
+ (version "1.3.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/ddopson/node-segfault-handler")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "07nbw35wvrr18kmh8f388v4k5mpjgyy0260bx0xzjdv795i3xvfv"))))
+ (native-inputs
+ (list python))
+ (inputs
+ (list node-bindings node-nan))
+ (build-system node-build-system)
+ (arguments
+ ;; there are no tests
+ `(#:tests? #f))
+ (home-page "https://github.com/ddopson/node-segfault-handler")
+ (synopsis "Catches @code{SIGSEGV} and prints diagnostic information")
+ (description "This package is a tool for debugging Node.js C/C++ native
+code modules and getting stack traces when things go wrong. If a
+@code{SIGSEGV} signal is raised, the module will print a native stack trace to
+both @code{STDERR} and to a timestamped file.")
+ (license license:bsd-3)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 29/41] gnu: Add node-ms.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (27 preceding siblings ...)
2021-12-30 7:39 ` [bug#51838] [PATCH v6 28/41] gnu: Add node-segfault-handler Philip McGrath
@ 2021-12-30 7:39 ` Philip McGrath
2021-12-30 7:39 ` [bug#51838] [PATCH v6 30/41] gnu: Add node-debug Philip McGrath
` (13 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:39 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-ms): New variable.
---
gnu/packages/node-xyz.scm | 48 +++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index e2eb17b23c..23c45d971e 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -975,3 +975,51 @@ (define-public node-segfault-handler
@code{SIGSEGV} signal is raised, the module will print a native stack trace to
both @code{STDERR} and to a timestamped file.")
(license license:bsd-3)))
+
+(define-public node-ms
+ (package
+ (name "node-ms")
+ (version "2.1.3")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/vercel/ms")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "1l74kmmwffmzdz38lli0v5mdb9p9jmsjxpb48ncknqw2n74cgf08"))))
+ (build-system node-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (delete-dependencies pkg-meta `("eslint"
+ "expect.js"
+ "husky"
+ "lint-staged"
+ "mocha"
+ "prettier")))))))
+ #:tests? #f))
+ (home-page "https://github.com/vercel/ms")
+ (synopsis "Tiny millisecond conversion utility")
+ (description "Use this package to easily convert various time formats to
+milliseconds.
+
+Features:
+@itemize @bullet
+@item
+Works both in Node.js and in the browser.
+@item
+If a number is supplied to @code{ms}, a string with a unit is returned.
+@item
+If a string that contains the number is supplied, it returns it as a
+number (e.g. it returns @code{100} for @code{'100'}).
+@item
+If you pass a string with a number and a valid unit, the number of
+equivalent milliseconds is returned.
+@end itemize")
+ (license license:expat)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 30/41] gnu: Add node-debug.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (28 preceding siblings ...)
2021-12-30 7:39 ` [bug#51838] [PATCH v6 29/41] gnu: Add node-ms Philip McGrath
@ 2021-12-30 7:39 ` Philip McGrath
2021-12-30 7:39 ` [bug#51838] [PATCH v6 31/41] gnu: Add node-serialport-binding-abstract Philip McGrath
` (12 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:39 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-debug): New variable.
---
gnu/packages/node-xyz.scm | 47 +++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 23c45d971e..f1cbb184bd 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1023,3 +1023,50 @@ (define-public node-ms
equivalent milliseconds is returned.
@end itemize")
(license license:expat)))
+
+(define-public node-debug
+ (package
+ (name "node-debug")
+ (version "4.3.3")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/debug-js/debug")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "0ji0dmdl2xkgxqxvd6xjy7k3mmknmhvqjgc40vyly9ka1mpf20vb"))))
+ (inputs
+ (list node-ms))
+ (build-system node-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (delete-dependencies pkg-meta `("brfs"
+ "browserify"
+ "coveralls"
+ "istanbul"
+ "karma"
+ "karma-browserify"
+ "karma-chrome-launcher"
+ "karma-mocha"
+ "mocha"
+ "mocha-lcov-reporter"
+ "xo"
+ "supports-color")))))))
+ #:tests? #f))
+ (home-page "https://github.com/debug-js/debug")
+ (synopsis "Lightweight debugging utility for Node.js and the browser")
+ (description "A tiny JavaScript debugging utility modelled after Node.js
+core's debugging technique. orks in Node.js and web browsers.
+
+The @code{debug} module exposes a function; simply pass this function the name
+of your module, and it will return a decorated version of @code{console.error}
+for you to pass debug statements to. This will allow you to toggle the debug
+output for different parts of your module as well as the module as a whole.")
+ (license license:expat)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 31/41] gnu: Add node-serialport-binding-abstract.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (29 preceding siblings ...)
2021-12-30 7:39 ` [bug#51838] [PATCH v6 30/41] gnu: Add node-debug Philip McGrath
@ 2021-12-30 7:39 ` Philip McGrath
2021-12-30 7:39 ` [bug#51838] [PATCH v6 32/41] gnu: Add node-serialport-parser-delimiter Philip McGrath
` (11 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:39 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-binding-abstract): New
variable.
---
gnu/packages/node-xyz.scm | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index f1cbb184bd..462d5d844a 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1070,3 +1070,37 @@ (define-public node-debug
for you to pass debug statements to. This will allow you to toggle the debug
output for different parts of your module as well as the module as a whole.")
(license license:expat)))
+
+(define-public node-serialport-binding-abstract
+ (package
+ (name "node-serialport-binding-abstract")
+ (version "9.2.3")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/serialport/node-serialport")
+ (commit "v9.2.7")))
+ (file-name (git-file-name "serialport-monorepo" version))
+ (sha256
+ (base32 "0x7zm59a5ff5yygjyw15xs3r5m3rb8av1yfrh4snn44mrwq87yg8"))))
+ (inputs
+ (list node-debug))
+ (build-system node-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/binding-abstract"))))
+ #:tests? #f))
+ (home-page "https://serialport.io")
+ (synopsis "Abstract base class for Node SerialPort bindings")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+This package provides the @code{AbstractBinding} class, the base for all Node
+SerialPort bindings. You wouldn't use this class directly, but instead extend
+it to make a new binding for a different platform or underling technology.")
+ (license license:expat)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 32/41] gnu: Add node-serialport-parser-delimiter.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (30 preceding siblings ...)
2021-12-30 7:39 ` [bug#51838] [PATCH v6 31/41] gnu: Add node-serialport-binding-abstract Philip McGrath
@ 2021-12-30 7:39 ` Philip McGrath
2021-12-30 7:39 ` [bug#51838] [PATCH v6 33/41] gnu: Add node-serialport-parser-readline Philip McGrath
` (10 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:39 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-parser-delimiter): New
variable.
---
gnu/packages/node-xyz.scm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 462d5d844a..34de7e0819 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1104,3 +1104,25 @@ (define-public node-serialport-binding-abstract
SerialPort bindings. You wouldn't use this class directly, but instead extend
it to make a new binding for a different platform or underling technology.")
(license license:expat)))
+
+(define-public node-serialport-parser-delimiter
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-parser-delimiter")
+ (version "9.2.4")
+ (inputs `())
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/parser-delimiter"))))
+ #:tests? #f))
+ (synopsis "Node SerialPort parser to split data on a delimiter")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+Parsers are used to take raw binary data and transform them into usable
+messages. This package provides @code{Delimiter}, a parser that emits data
+each time a specified byte sequence is received.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 33/41] gnu: Add node-serialport-parser-readline.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (31 preceding siblings ...)
2021-12-30 7:39 ` [bug#51838] [PATCH v6 32/41] gnu: Add node-serialport-parser-delimiter Philip McGrath
@ 2021-12-30 7:39 ` Philip McGrath
2021-12-30 7:39 ` [bug#51838] [PATCH v6 34/41] gnu: Add node-serialport-bindings Philip McGrath
` (9 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:39 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-parser-readline): New
variable.
---
gnu/packages/node-xyz.scm | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 34de7e0819..e33a35a0a0 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1126,3 +1126,26 @@ (define-public node-serialport-parser-delimiter
Parsers are used to take raw binary data and transform them into usable
messages. This package provides @code{Delimiter}, a parser that emits data
each time a specified byte sequence is received.")))
+
+(define-public node-serialport-parser-readline
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-parser-readline")
+ (version "9.2.4")
+ (inputs
+ (list node-serialport-parser-delimiter))
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/parser-readline"))))
+ #:tests? #f))
+ (synopsis "Node SerialPort parser to split data on newlines")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+Parsers are used to take raw binary data and transform them into usable
+messages. This package provides @code{Readline}, a parser that emits data
+after a (configurable) newline delimiter is received.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 34/41] gnu: Add node-serialport-bindings.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (32 preceding siblings ...)
2021-12-30 7:39 ` [bug#51838] [PATCH v6 33/41] gnu: Add node-serialport-parser-readline Philip McGrath
@ 2021-12-30 7:39 ` Philip McGrath
2021-12-30 7:39 ` [bug#51838] [PATCH v6 35/41] gnu: Add node-serialport-parser-regex Philip McGrath
` (8 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:39 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-bindings): New variable.
---
gnu/packages/node-xyz.scm | 56 +++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index e33a35a0a0..fe1a2d4e5f 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1149,3 +1149,59 @@ (define-public node-serialport-parser-readline
Parsers are used to take raw binary data and transform them into usable
messages. This package provides @code{Readline}, a parser that emits data
after a (configurable) newline delimiter is received.")))
+
+(define-public node-serialport-bindings
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-bindings")
+ (version "9.2.7")
+ (native-inputs
+ (list python))
+ (inputs
+ (list node-nan node-bindings node-serialport-binding-abstract
+ node-serialport-parser-readline node-debug))
+ (arguments
+ `(#:modules
+ ((guix build node-build-system)
+ (srfi srfi-1)
+ (ice-9 match)
+ (guix build utils))
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/bindings")))
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (delete-dependencies pkg-meta `("prebuild-install"
+ ;; devDependencies
+ "@serialport/binding-mock"
+ "node-abi"))))))
+ (add-after 'chdir 'avoid-prebuild-install
+ (lambda args
+ (with-atomic-json-file-replacement "package.json"
+ (match-lambda
+ (('@ . pkg-meta-alist)
+ (cons '@ (map (match-lambda
+ (("scripts" @ . scripts-alist)
+ `("scripts" @ ,@(filter (match-lambda
+ (("install" . _)
+ #f)
+ (_
+ #t))
+ scripts-alist)))
+ (other
+ other))
+ pkg-meta-alist))))))))
+ #:tests? #f))
+ (synopsis "Abstract base class for Node SerialPort bindings")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+This package provides the @code{Binding} class, which uses a native addon to
+talk to the underlying system. You never have to use @code{Binding} objects
+directly. There is also a @code{MockBinding} available (but not yet packaged
+for Guix) to assist with testing.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 35/41] gnu: Add node-serialport-parser-regex.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (33 preceding siblings ...)
2021-12-30 7:39 ` [bug#51838] [PATCH v6 34/41] gnu: Add node-serialport-bindings Philip McGrath
@ 2021-12-30 7:39 ` Philip McGrath
2021-12-30 7:39 ` [bug#51838] [PATCH v6 36/41] gnu: Add node-serialport-parser-ready Philip McGrath
` (7 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:39 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-parser-regex): New variable.
---
gnu/packages/node-xyz.scm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index fe1a2d4e5f..2fada26799 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1205,3 +1205,25 @@ (define-public node-serialport-bindings
talk to the underlying system. You never have to use @code{Binding} objects
directly. There is also a @code{MockBinding} available (but not yet packaged
for Guix) to assist with testing.")))
+
+(define-public node-serialport-parser-regex
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-parser-regex")
+ (version "9.2.4")
+ (inputs `())
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/parser-regex"))))
+ #:tests? #f))
+ (synopsis "Node SerialPort parser to split data on a regular expression")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+Parsers are used to take raw binary data and transform them into usable
+messages. This package provides @code{Regex}, a parser that uses a regular
+expression to split the incoming text.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 36/41] gnu: Add node-serialport-parser-ready.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (34 preceding siblings ...)
2021-12-30 7:39 ` [bug#51838] [PATCH v6 35/41] gnu: Add node-serialport-parser-regex Philip McGrath
@ 2021-12-30 7:39 ` Philip McGrath
2021-12-30 7:39 ` [bug#51838] [PATCH v6 37/41] gnu: Add node-serialport-parser-inter-byte-timeout Philip McGrath
` (6 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:39 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-parser-ready): New variable.
---
gnu/packages/node-xyz.scm | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 2fada26799..55b60fa773 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1227,3 +1227,26 @@ (define-public node-serialport-parser-regex
Parsers are used to take raw binary data and transform them into usable
messages. This package provides @code{Regex}, a parser that uses a regular
expression to split the incoming text.")))
+
+(define-public node-serialport-parser-ready
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-parser-ready")
+ (version "9.2.4")
+ (inputs `())
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/parser-ready"))))
+ #:tests? #f))
+ (synopsis "Node SerialPort parser to wait for specified byte sequence")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+Parsers are used to take raw binary data and transform them into usable
+messages. This package provides @code{Ready}, a parser that waits for a
+specified sequence of ``ready'' bytes before emitting a ready event and
+emitting data events.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 37/41] gnu: Add node-serialport-parser-inter-byte-timeout.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (35 preceding siblings ...)
2021-12-30 7:39 ` [bug#51838] [PATCH v6 36/41] gnu: Add node-serialport-parser-ready Philip McGrath
@ 2021-12-30 7:39 ` Philip McGrath
2021-12-30 7:39 ` [bug#51838] [PATCH v6 38/41] gnu: Add node-serialport-parser-cctalk Philip McGrath
` (5 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:39 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm
(node-serialport-parser-inter-byte-timeout): New variable.
---
gnu/packages/node-xyz.scm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 55b60fa773..6337554830 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1250,3 +1250,25 @@ (define-public node-serialport-parser-ready
messages. This package provides @code{Ready}, a parser that waits for a
specified sequence of ``ready'' bytes before emitting a ready event and
emitting data events.")))
+
+(define-public node-serialport-parser-inter-byte-timeout
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-parser-inter-byte-timeout")
+ (version "9.2.4")
+ (inputs `())
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/parser-inter-byte-timeout"))))
+ #:tests? #f))
+ (synopsis "Node SerialPort parser to detect pauses in data")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+Parsers are used to take raw binary data and transform them into usable
+messages. This package provides @code{InterByteTimeout}, a parser that emits
+data if there is a pause between packets for the specified amount of time.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 38/41] gnu: Add node-serialport-parser-cctalk.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (36 preceding siblings ...)
2021-12-30 7:39 ` [bug#51838] [PATCH v6 37/41] gnu: Add node-serialport-parser-inter-byte-timeout Philip McGrath
@ 2021-12-30 7:39 ` Philip McGrath
2021-12-30 7:39 ` [bug#51838] [PATCH v6 39/41] gnu: Add node-serialport-parser-byte-length Philip McGrath
` (4 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:39 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-parser-cctalk): New variable.
---
gnu/packages/node-xyz.scm | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 6337554830..758d72a52a 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1272,3 +1272,26 @@ (define-public node-serialport-parser-inter-byte-timeout
Parsers are used to take raw binary data and transform them into usable
messages. This package provides @code{InterByteTimeout}, a parser that emits
data if there is a pause between packets for the specified amount of time.")))
+
+(define-public node-serialport-parser-cctalk
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-parser-cctalk")
+ (version "9.2.4")
+ (inputs `())
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/parser-cctalk"))))
+ #:tests? #f))
+ (synopsis "Node SerialPort parser for the ccTalk protocol")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+Parsers are used to take raw binary data and transform them into usable
+messages. This package provides @code{CCTalk}, which emits packets for the
+ccTalk protocol (an open standard for currency detectors) as they are
+received.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 39/41] gnu: Add node-serialport-parser-byte-length.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (37 preceding siblings ...)
2021-12-30 7:39 ` [bug#51838] [PATCH v6 38/41] gnu: Add node-serialport-parser-cctalk Philip McGrath
@ 2021-12-30 7:39 ` Philip McGrath
2021-12-30 7:39 ` [bug#51838] [PATCH v6 40/41] gnu: Add node-serialport-stream Philip McGrath
` (3 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:39 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-parser-byte-length): New
variable.
---
gnu/packages/node-xyz.scm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 758d72a52a..e427f31b1a 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1295,3 +1295,25 @@ (define-public node-serialport-parser-cctalk
messages. This package provides @code{CCTalk}, which emits packets for the
ccTalk protocol (an open standard for currency detectors) as they are
received.")))
+
+(define-public node-serialport-parser-byte-length
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-parser-byte-length")
+ (version "9.2.4")
+ (inputs `())
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/parser-byte-length"))))
+ #:tests? #f))
+ (synopsis "Node SerialPort parser for fixed-length buffers")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+Parsers are used to take raw binary data and transform them into usable
+messages. This package provides @code{ByteLength}, a parser that emits data
+as a buffer every time a specified number of bytes are received.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 40/41] gnu: Add node-serialport-stream.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (38 preceding siblings ...)
2021-12-30 7:39 ` [bug#51838] [PATCH v6 39/41] gnu: Add node-serialport-parser-byte-length Philip McGrath
@ 2021-12-30 7:39 ` Philip McGrath
2021-12-30 7:39 ` [bug#51838] [PATCH v6 41/41] gnu: Add node-serialport Philip McGrath
` (2 subsequent siblings)
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:39 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-stream): New variable.
---
gnu/packages/node-xyz.scm | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index e427f31b1a..a95749f737 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1317,3 +1317,34 @@ (define-public node-serialport-parser-byte-length
Parsers are used to take raw binary data and transform them into usable
messages. This package provides @code{ByteLength}, a parser that emits data
as a buffer every time a specified number of bytes are received.")))
+
+(define-public node-serialport-stream
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-stream")
+ (version "9.2.4")
+ (inputs
+ (list node-debug))
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (delete-dependencies pkg-meta
+ `(;; devDependencies
+ "@serialport/binding-mock"))))))
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/stream"))))
+ #:tests? #f))
+ (synopsis "Node.js stream interface for Node SerialPort")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+This package provides an interface for using Node SerialPort bindings via the
+Node.js Stream API. The stream is a duplex stream, allowing for reading and
+writing. It has additional methods for managing the SerialPort
+connection.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 41/41] gnu: Add node-serialport.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (39 preceding siblings ...)
2021-12-30 7:39 ` [bug#51838] [PATCH v6 40/41] gnu: Add node-serialport-stream Philip McGrath
@ 2021-12-30 7:39 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
2021-12-30 20:03 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Ryan Sundberg via Guix-patches via
42 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:39 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport): New variable.
---
gnu/packages/node-xyz.scm | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index a95749f737..1f51c0d636 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1348,3 +1348,38 @@ (define-public node-serialport-stream
Node.js Stream API. The stream is a duplex stream, allowing for reading and
writing. It has additional methods for managing the SerialPort
connection.")))
+
+(define-public node-serialport
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport")
+ (version "9.2.7")
+ (inputs
+ (list node-serialport-bindings
+ node-serialport-parser-delimiter
+ node-serialport-parser-readline
+ node-serialport-parser-regex
+ node-serialport-parser-ready
+ node-serialport-parser-inter-byte-timeout
+ node-serialport-parser-cctalk
+ node-serialport-parser-byte-length
+ node-serialport-stream
+ node-debug))
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (delete-dependencies pkg-meta
+ `("@serialport/binding-mock"))))))
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/serialport"))))
+ #:tests? #f))
+ (synopsis "Node.js package to access serial ports")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. This package is the recommended entry point for most
+projects. It combines a high-level Node.js stream interface with a useful
+default set of parsers and bindings.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (40 preceding siblings ...)
2021-12-30 7:39 ` [bug#51838] [PATCH v6 41/41] gnu: Add node-serialport Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 01/41] guix: node-build-system: Add delete-lockfiles phase Philip McGrath
` (40 more replies)
2021-12-30 20:03 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Ryan Sundberg via Guix-patches via
42 siblings, 41 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
Hi again,
Here, as promised, is v7!
As I said above, this is my preferred version of this patch series, but I
could also live with v6 if it could achieve consensus.
-Philip
Philip McGrath (41):
guix: node-build-system: Add delete-lockfiles phase.
guix: node-build-system: Add implicit libuv input.
guix: node-build-system: Add JSON utilities.
guix: node-build-system: Add avoid-node-gyp-rebuild phase.
guix: node-build-system: Add #:absent-dependencies argument.
gnu: node-semver-bootstrap: Use #:absent-dependencies.
gnu: node-ms-bootstrap: Use #:absent-dependencies.
gnu: node-binary-search-bootstrap: Use #:absent-dependencies.
gnu: node-debug-bootstrap: Use #:absent-dependencies.
gnu: node-llparse-builder-bootstrap: Use #:absent-dependencies.
gnu: node-llparse-frontend-bootstrap: Use #:absent-dependencies.
gnu: node-llparse-bootstrap: Use #:absent-dependencies.
gnu: node-semver: Use #:absent-dependencies.
gnu: node-wrappy: Use #:absent-dependencies.
gnu: node-once: Use #:absent-dependencies.
gnu: node-irc-colors: Use #:absent-dependencies.
gnu: node-irc: Use #:absent-dependencies.
gnu: Add node-inherits.
gnu: Add node-safe-buffer.
gnu: Add node-string-decoder.
gnu: Add node-readable-stream.
gnu: Add node-nan.
gnu: Add node-openzwave-shared.
gnu: Add node-addon-api.
gnu: Add node-sqlite3.
gnu: Add node-file-uri-to-path.
gnu: Add node-bindings.
gnu: Add node-segfault-handler.
gnu: Add node-ms.
gnu: Add node-debug.
gnu: Add node-serialport-binding-abstract.
gnu: Add node-serialport-parser-delimiter.
gnu: Add node-serialport-parser-readline.
gnu: Add node-serialport-bindings.
gnu: Add node-serialport-parser-regex.
gnu: Add node-serialport-parser-ready.
gnu: Add node-serialport-parser-inter-byte-timeout.
gnu: Add node-serialport-parser-cctalk.
gnu: Add node-serialport-parser-byte-length.
gnu: Add node-serialport-stream.
gnu: Add node-serialport.
gnu/packages/node-xyz.scm | 937 ++++++++++++++++++++++++++++++-
gnu/packages/node.scm | 63 ++-
gnu/packages/zwave.scm | 64 +++
guix/build-system/node.scm | 28 +-
guix/build/node-build-system.scm | 354 +++++++++++-
5 files changed, 1376 insertions(+), 70 deletions(-)
--
2.32.0
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 01/41] guix: node-build-system: Add delete-lockfiles phase.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 02/41] guix: node-build-system: Add implicit libuv input Philip McGrath
` (39 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* guix/build/node-build-system.scm (delete-lockfiles): New function.
Remove 'package-lock.json', 'yarn.lock', and 'npm-shrinkwrap.json',
if they exist. Because these files specify both exact dependency
versions and integrity hashes, they only cause problems for Guix.
(%standard-phases): Add 'delete-lockfiles' after 'patch-dependencies'.
---
guix/build/node-build-system.scm | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index 70a367618e..dcaa719f40 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -96,6 +96,17 @@ (define (resolve-dependencies package-meta meta-key)
(write-json package-meta out))))
#t)
+(define* (delete-lockfiles #:key inputs #:allow-other-keys)
+ "Delete 'package-lock.json', 'yarn.lock', and 'npm-shrinkwrap.json', if they
+exist."
+ (for-each (lambda (pth)
+ (when (file-exists? pth)
+ (delete-file pth)))
+ '("package-lock.json"
+ "yarn.lock"
+ "npm-shrinkwrap.json"))
+ #t)
+
(define* (configure #:key outputs inputs #:allow-other-keys)
(let ((npm (string-append (assoc-ref inputs "node") "/bin/npm")))
(invoke npm "--offline" "--ignore-scripts" "install")
@@ -146,6 +157,7 @@ (define %standard-phases
(modify-phases gnu:%standard-phases
(add-after 'unpack 'set-home set-home)
(add-before 'configure 'patch-dependencies patch-dependencies)
+ (add-after 'patch-dependencies 'delete-lockfiles delete-lockfiles)
(replace 'configure configure)
(replace 'build build)
(replace 'check check)
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 02/41] guix: node-build-system: Add implicit libuv input.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 01/41] guix: node-build-system: Add delete-lockfiles phase Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 03/41] guix: node-build-system: Add JSON utilities Philip McGrath
` (38 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* guix/build-system/node.scm (lower): Add the version of libuv
used as an input to the #:node package as an additional implicit
input, so that packages needing libuv always get the correct version.
---
guix/build-system/node.scm | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/guix/build-system/node.scm b/guix/build-system/node.scm
index 735f8dd06e..24bd677bfc 100644
--- a/guix/build-system/node.scm
+++ b/guix/build-system/node.scm
@@ -2,6 +2,8 @@
;;; Copyright © 2016 Jelle Licht <jlicht@fsfe.org>
;;; Copyright © 2019 Timothy Sample <samplet@ngyro.com>
;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2021 Pierre Langlois <pierre.langlois@gmx.com>
+;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -61,10 +63,15 @@ (define private-keywords
`(("source" ,source))
'())
,@inputs
-
;; Keep the standard inputs of 'gnu-build-system'.
,@(standard-packages)))
(build-inputs `(("node" ,node)
+ ;; Many packages with native addons need
+ ;; libuv headers. The libuv version must
+ ;; be exactly the same as for the node
+ ;; package we are adding implicitly,
+ ;; so we take care of adding libuv, too.
+ ("libuv" ,@(assoc-ref (package-inputs node) "libuv"))
,@native-inputs))
(outputs outputs)
(build node-build)
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 03/41] guix: node-build-system: Add JSON utilities.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 01/41] guix: node-build-system: Add delete-lockfiles phase Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 02/41] guix: node-build-system: Add implicit libuv input Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 04/41] guix: node-build-system: Add avoid-node-gyp-rebuild phase Philip McGrath
` (37 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
This commit adds several utility functions for non-destructive
transformation of the JSON representation used by (guix build json),
particularly for purely functional update of JSON objects. They should
eventually be exported, but most are private for now to allow for more
experience and consideration before commiting to the API. The design
was largely inspired by the 'racket/dict' and 'racket/hash' libraries.
Liliana Marie Prikler proposed 'with-atomic-json-file-replacement'.
* guix/build/node-build-system.scm (jsobject-ref):
(alist-pop):
(alist-delete*):
(jsobject-delete):
(alist-set):
(jsobject-set):
(jsobject-set*):
(alist-update):
(jsobject-update):
(jsobject-update*):
(jsobject-union): New private procedures.
(with-atomic-json-file-replacement): New exported procedure.
(module-name): Use them.
(build): Use them.
(patch-dependencies): Use them. Stop using 'assoc-set!' unsafely.
Co-authored-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
---
guix/build/node-build-system.scm | 275 ++++++++++++++++++++++++++++---
1 file changed, 251 insertions(+), 24 deletions(-)
diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index dcaa719f40..e5c4da5091 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -26,6 +26,7 @@ (define-module (guix build node-build-system)
#:use-module (ice-9 match)
#:use-module (srfi srfi-1)
#:export (%standard-phases
+ with-atomic-json-file-replacement
node-build))
;; Commentary:
@@ -34,6 +35,237 @@ (define-module (guix build node-build-system)
;;
;; Code:
+;;;
+;;; JSON utilities.
+;;;
+;;; The following procedures facilitate transforming JSON values using the
+;;; representation from (guix build json), particularly purely functional
+;;; update of JSON objects. If we decide to make more of them public, we
+;;; might instead put them in their own file or, eventually, add them to
+;;; (guix build json).
+;;;
+;;; JSON objects with duplicate keys are not interoperable: see RFC 8259 § 4.
+;;; These procedures assume, but generally do not check, that JSON objects
+;;; given to them as arguments do not have duplicate keys. As long as that
+;;; precondition is satisfied, they will produce JSON objects without
+;;; duplicate keys. Procedures that operate on unwrapped assosciation lists
+;;; may do likewise, which should be considered before exporting them for
+;;; general use.
+;;;
+
+(define (with-atomic-json-file-replacement file proc)
+ "Like 'with-atomic-file-replacement', but PROC is called with a single
+argument---the result of parsing FILE's contents as json---and should a value
+to be written as json to the replacement FILE."
+ (with-atomic-file-replacement file
+ (lambda (in out)
+ (write-json (proc (read-json in)) out))))
+
+(define (jsobject-ref js key failure-result)
+ "Return the value assosciated with KEY in the json object JS. If KEY is not
+found and FAILURE-RESULT is a procedure, it is called in tail position with
+zero arguments. Otherwise, FAILURE-RESULT is returned."
+ ;; TODO: `failure-result` should be optional, but should the default
+ ;; `failure-result` be #f (like `assoc-ref`), a thunk raising an exception,
+ ;; '(@), or something else? Keep it mandatory until we discuss and decide.
+ (match js
+ (('@ . alist)
+ (match (assoc key alist)
+ (#f
+ (if (procedure? failure-result)
+ (failure-result)
+ failure-result))
+ ((_ . value)
+ value)))))
+
+(define (alist-pop alist key)
+ "Return two values: the first pair in ALIST with the given KEY in its
+'car' (or #f, if no such pair exists) and an assosciation list like (and
+potentially sharing storage with) ALIST, but with no entry for KEY."
+ (match (assoc key alist)
+ ;; If key isn't present, we don't need to do any allocation
+ (#f
+ (values #f alist))
+ (found
+ (values found
+ ;; Because we have `found`, we can find it more
+ ;; efficiently this time with `eq?`. We avoid using
+ ;; `delq` because it would copy pairs in a shared
+ ;; tail. We assume a sufficiently smart compiler to
+ ;; handle "tail recursion modulo cons" (vid. e.g. Indiana
+ ;; University Technical Report No. 19, Friedman & Wise
+ ;; 1975) at least as efficiently as a hand-written
+ ;; tail-recursive implementation with an accumulator.
+ (let loop ((alist alist))
+ (match alist
+ ;; We know that `found` is present,
+ ;; so no need to check for '()
+ ((this . alist)
+ (if (eq? this found)
+ alist
+ (cons this (loop alist))))))))))
+
+;; Sadly, Guile's implementation of (@ (srfi srfi-1) alist-delete)
+;; performs unnecessary allocation, e.g. this currently evaluates to #f:
+;;
+;; (let ((alist `(("a" . 1)("b" . 2)("c" . 3))))
+;; (eq? alist (alist-delete "x" alist)))
+;;
+;; These functions generally choose to allocate a new outer pair (with the '@
+;; tag), even though in unusual cases the resulting object might not have
+;; changed, for the sake of simplicity and to avoid retaining a reference to
+;; the original alist longer than necessary. But that is O(1) allocation that
+;; could only rarely be avoided: `alist-delete` would allocate O(n) pairs,
+;; which would only be necessary in the worst case.
+(define (alist-delete* alist key)
+ "Return an assosciation list like (and potentially sharing storage with)
+ALIST, but with no entry for KEY."
+ (define-values (_popped remaining)
+ (alist-pop alist key))
+ remaining)
+
+(define (jsobject-delete js key)
+ "Return a json object like JS, but with no entry for KEY."
+ (cons '@ (match js
+ (('@ . alist)
+ (alist-delete* alist key)))))
+
+(define (alist-set alist key value)
+ "Return an assosciation list like ALIST, but with KEY mapped to VALUE,
+replacing any existing mapping for KEY."
+ (acons key value (alist-delete* alist key)))
+
+(define (jsobject-set js key value)
+ "Return a json object like JS, but with KEY mapped to VALUE, replacing any
+existing mapping for KEY."
+ (cons '@ (match js
+ (('@ . alist)
+ (alist-set alist key value)))))
+
+(define jsobject-set*
+ (case-lambda
+ "Return a json object like JS, but functionally extended by mapping each
+KEY to each VALUE, replacing any existing mapping for each KEY. The update
+takes place from left to right, so later mappings overwrite earlier mappings
+for the same KEY."
+ ((js)
+ js)
+ ((js key value)
+ (jsobject-set js key value))
+ ((js . args)
+ (cons '@ (match js
+ (('@ . alist)
+ (let loop ((alist alist)
+ (args args))
+ (match args
+ (()
+ alist)
+ ((key value . args)
+ (loop (alist-set alist key value)
+ args))))))))))
+
+(define (alist-update alist key failure-result updater)
+ "Return an assosciation list like ALIST, but with KEY mapped to the result
+of applying UPDATER to the value to which KEY is mapped in ALIST. When ALIST
+does not have an existing mapping for KEY, FAILURE-RESULT is used as with
+'jsobject-ref' to obtain the argument for UPDATER."
+ ;; Often, `updater` will be a lambda expression, so making it the last
+ ;; argument may help to makes the code legible, and the most likely
+ ;; `failure-result` arguments are all shorter than the keyword
+ ;; `#:failure-result`. Plus, making `failure-result` mandatory helps make
+ ;; `alist-update` consistent with `alist-update*`.
+ (define-values (popped tail-alist)
+ (alist-pop alist key))
+ (acons key
+ (updater (match popped
+ (#f
+ (if (procedure? failure-result)
+ (failure-result)
+ failure-result))
+ ((_ . value)
+ value)))
+ tail-alist))
+
+(define (jsobject-update js key failure-result updater)
+ "Return a json object like JS, but with KEY mapped to the result of applying
+UPDATER to the value to which KEY is mapped in JS. When JS does not have an
+existing mapping for KEY, FAILURE-RESULT is used as with 'jsobject-ref' to
+obtain the argument for UPDATER."
+ (cons '@ (match js
+ (('@ . alist)
+ (alist-update alist key failure-result updater)))))
+
+(define jsobject-update*
+ (case-lambda
+ "Return a json object like JS, but functionally extended by replacing the
+mapping for each KEY with the result of applying the corresponding UPDATER to
+the value to which that KEY is mapped in JS---or, if no such mapping exists,
+to a value based on the corresponding FAILURE-RESULT as with 'jsobject-ref'.
+The update takes place from left to right, so later UPDATERs will receive the
+values returned by earlier UPDATERs for the same KEY."
+ ((js)
+ js)
+ ((js key failure-result updater)
+ (jsobject-update js key failure-result updater))
+ ((js . args)
+ (cons '@ (match js
+ (('@ . alist)
+ (let loop ((alist alist)
+ (args args))
+ (match args
+ (()
+ alist)
+ ((key failure-result updater . args)
+ (loop (alist-update alist key failure-result updater)
+ args))))))))))
+
+(define* (jsobject-union #:key
+ (combine (lambda (a b) b))
+ (combine/key (lambda (k a b) (combine a b)))
+ #:rest json-objects)
+ "Combine the given JSON-OBJECTS into a single json object. The JSON-OBJECTS
+are merged from left to right by adding each key/value pair of each object to
+the aggregate object in turn. When one of the JSON-OBJECTS contains a mapping
+from some key KEY to a value VAL such that the aggregate object already
+contains a mapping from KEY to a value VAL0, the aggregate object is
+functionally updated to instead map KEY to the value of (COMBINE/KEY KEY VAL0
+VAL). The default COMBINE/KEY tail-calls (COMBINE VAL0 VAL), and the default
+COMBINE simply returns its second argument, so, by default, mappings in later
+JSON-OBJECTS supersede those in earlier ones."
+ (match (filter (lambda (v)
+ (not (or (keyword? v)
+ (procedure? v))))
+ json-objects)
+ (()
+ '(@))
+ (((and js0 ('@ . _)))
+ js0)
+ ((('@ . alist0) ('@ . alist*) ...)
+ (cons '@ (fold (lambda (alist1 alist0)
+ (if (null? alist0)
+ alist1
+ (fold (lambda (k+v alist0)
+ (match k+v
+ ((k . v)
+ (define-values (popped tail-alist)
+ (alist-pop alist0 k))
+ (match popped
+ (#f
+ (cons k+v tail-alist))
+ ((_ . v0)
+ (acons k
+ (combine/key k v0 v)
+ tail-alist))))))
+ alist0
+ alist1)))
+ alist0
+ alist*)))))
+
+\f
+;;;
+;;; Phases.
+;;;
+
(define (set-home . _)
(with-directory-excursion ".."
(let loop ((i 0))
@@ -49,7 +281,7 @@ (define (set-home . _)
(define (module-name module)
(let* ((package.json (string-append module "/package.json"))
(package-meta (call-with-input-file package.json read-json)))
- (assoc-ref package-meta "name")))
+ (jsobject-ref package-meta "name" #f)))
(define (index-modules input-paths)
(define (list-modules directory)
@@ -73,27 +305,24 @@ (define* (patch-dependencies #:key inputs #:allow-other-keys)
(define index (index-modules (map cdr inputs)))
- (define (resolve-dependencies package-meta meta-key)
- (fold (lambda (key+value acc)
- (match key+value
- ('@ acc)
- ((key . value) (acons key (hash-ref index key value) acc))))
- '()
- (or (assoc-ref package-meta meta-key) '())))
+ (define resolve-dependencies
+ (match-lambda
+ (('@ . alist)
+ (cons '@ (map (match-lambda
+ ((key . value)
+ (cons key (hash-ref index key value))))
+ alist)))))
- (with-atomic-file-replacement "package.json"
- (lambda (in out)
- (let ((package-meta (read-json in)))
- (assoc-set! package-meta "dependencies"
- (append
- '(@)
- (resolve-dependencies package-meta "dependencies")
- (resolve-dependencies package-meta "peerDependencies")))
- (assoc-set! package-meta "devDependencies"
- (append
- '(@)
- (resolve-dependencies package-meta "devDependencies")))
- (write-json package-meta out))))
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (jsobject-update*
+ pkg-meta
+ "devDependencies" '(@) resolve-dependencies
+ "dependencies" '(@) (lambda (deps)
+ (resolve-dependencies
+ (jsobject-union
+ (jsobject-ref pkg-meta "peerDependencies" '(@))
+ deps))))))
#t)
(define* (delete-lockfiles #:key inputs #:allow-other-keys)
@@ -114,9 +343,7 @@ (define* (configure #:key outputs inputs #:allow-other-keys)
(define* (build #:key inputs #:allow-other-keys)
(let ((package-meta (call-with-input-file "package.json" read-json)))
- (if (and=> (assoc-ref package-meta "scripts")
- (lambda (scripts)
- (assoc-ref scripts "build")))
+ (if (jsobject-ref (jsobject-ref package-meta "scripts" '(@)) "build" #f)
(let ((npm (string-append (assoc-ref inputs "node") "/bin/npm")))
(invoke npm "run" "build"))
(format #t "there is no build script to run~%"))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 04/41] guix: node-build-system: Add avoid-node-gyp-rebuild phase.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (2 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 03/41] guix: node-build-system: Add JSON utilities Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 05/41] guix: node-build-system: Add #:absent-dependencies argument Philip McGrath
` (36 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* guix/build/node-build-system.scm (avoid-node-gyp-rebuild): New
function. Override the default install script for packages with
native addons to prevent it from attempting to write to the store
when such packages are used.
(%standard-phases): Add 'avoid-node-gyp-rebuild' after 'install'.
---
guix/build/node-build-system.scm | 50 +++++++++++++++++++++++++++++++-
1 file changed, 49 insertions(+), 1 deletion(-)
diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index e5c4da5091..dc8b6a41c2 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -380,6 +380,53 @@ (define* (install #:key outputs inputs #:allow-other-keys)
"install" "../package.tgz")
#t))
+(define* (avoid-node-gyp-rebuild #:key outputs #:allow-other-keys)
+ "Adjust the installed 'package.json' to remove an 'install' script that
+would try to run 'node-gyp rebuild'."
+ ;; We want to take advantage of `npm install`'s automatic support for
+ ;; building native addons with node-gyp: in particular, it helps us avoid
+ ;; hard-coding the specifics of how npm's internal copy of node-gyp is
+ ;; currently packaged. However, the mechanism by which the automatic support
+ ;; is implemented causes problems for us.
+ ;;
+ ;; If a package contains a 'binding.gyp' file and does not define an
+ ;; 'install' or 'preinstall' script, 'npm install' runs a default install
+ ;; script consisting of 'node-gyp rebuild'. In our 'install' phase, this
+ ;; implicit 'install' script, if it is applicable, is explicitly added to
+ ;; the "package.json" file. However, if another Guix package were to use a
+ ;; Node.js package with such an 'install' script, the dependent package's
+ ;; build process would fail, because 'node-gyp rebuild' would try to write
+ ;; to the store.
+ ;;
+ ;; Here, if the installed "package.json" defines scripts.install as
+ ;; "node-gyp rebuild", we replace it with a no-op. Importantly, deleting the
+ ;; install script definition would not be enough, because the default
+ ;; install script would cause the same problem.
+ ;;
+ ;; For further details, see:
+ ;; - https://docs.npmjs.com/cli/v8/configuring-npm/package-json#default-values
+ ;; - https://docs.npmjs.com/cli/v8/using-npm/scripts#best-practices
+ (define installed-package.json
+ (search-input-file outputs (string-append "/lib/node_modules/"
+ (module-name ".")
+ "/package.json")))
+ ;; not with-atomic-json-file-replacement, because we usually don't
+ ;; want or need to overwrite it
+ (define pkg-meta
+ (call-with-input-file installed-package.json read-json))
+ (define scripts
+ (jsobject-ref pkg-meta "scripts" '(@)))
+ (when (equal? "node-gyp rebuild" (jsobject-ref scripts "install" #f))
+ (call-with-output-file installed-package.json
+ (lambda (out)
+ (write-json
+ (jsobject-set pkg-meta
+ "scripts"
+ (jsobject-set scripts
+ "install"
+ "echo Guix: avoiding node-gyp rebuild"))
+ out)))))
+
(define %standard-phases
(modify-phases gnu:%standard-phases
(add-after 'unpack 'set-home set-home)
@@ -389,7 +436,8 @@ (define %standard-phases
(replace 'build build)
(replace 'check check)
(add-before 'install 'repack repack)
- (replace 'install install)))
+ (replace 'install install)
+ (add-after 'install 'avoid-node-gyp-rebuild avoid-node-gyp-rebuild)))
(define* (node-build #:key inputs (phases %standard-phases)
#:allow-other-keys #:rest args)
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 05/41] guix: node-build-system: Add #:absent-dependencies argument.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (3 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 04/41] guix: node-build-system: Add avoid-node-gyp-rebuild phase Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 06/41] gnu: node-semver-bootstrap: Use #:absent-dependencies Philip McGrath
` (35 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* 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 (delete-dependencies): New
procedure. Respect the #:absent-dependencies argument, removing
specified npm packages from the "dependencies" or "devDependencies"
tables in "package.json".
(%standard-phases): Add 'delete-dependencies after
'patch-dependencies.
---
guix/build-system/node.scm | 19 ++++++++++++++++++-
guix/build/node-build-system.scm | 19 ++++++++++++++++++-
2 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/guix/build-system/node.scm b/guix/build-system/node.scm
index 24bd677bfc..47af4bb9e2 100644
--- a/guix/build-system/node.scm
+++ b/guix/build-system/node.scm
@@ -49,6 +49,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."
@@ -84,6 +85,7 @@ (define* (node-build name inputs
(test-target "test")
(tests? #t)
(phases '%standard-phases)
+ (absent-dependencies ''())
(outputs '("out"))
(search-paths '())
(system (%current-system))
@@ -91,7 +93,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
@@ -103,6 +119,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 dc8b6a41c2..e6b0811ca1 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -325,6 +325,22 @@ (define resolve-dependencies
deps))))))
#t)
+(define* (delete-dependencies #:key absent-dependencies #:allow-other-keys)
+ "Modify 'package.json' to allow building without the ABSENT-DEPENDENCIES."
+ (define delete-fom-jsobject
+ (match-lambda
+ (('@ . alist)
+ (cons '@ (filter (match-lambda
+ ((k . v)
+ (not (member k absent-dependencies))))
+ alist)))))
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (jsobject-update*
+ pkg-meta
+ "devDependencies" '(@) delete-fom-jsobject
+ "dependencies" '(@) delete-fom-jsobject))))
+
(define* (delete-lockfiles #:key inputs #:allow-other-keys)
"Delete 'package-lock.json', 'yarn.lock', and 'npm-shrinkwrap.json', if they
exist."
@@ -431,7 +447,8 @@ (define %standard-phases
(modify-phases gnu:%standard-phases
(add-after 'unpack 'set-home set-home)
(add-before 'configure 'patch-dependencies patch-dependencies)
- (add-after 'patch-dependencies 'delete-lockfiles delete-lockfiles)
+ (add-after 'patch-dependencies 'delete-dependencies delete-dependencies)
+ (add-after 'delete-dependencies 'delete-lockfiles delete-lockfiles)
(replace 'configure configure)
(replace 'build build)
(replace 'check check)
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 06/41] gnu: node-semver-bootstrap: Use #:absent-dependencies.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (4 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 05/41] guix: node-build-system: Add #:absent-dependencies argument Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 07/41] gnu: node-ms-bootstrap: " Philip McGrath
` (34 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node.scm (node-semver-bootstrap)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node.scm | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 51a393caab..95f5f28b3d 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -344,9 +344,8 @@ (define-public node-semver-bootstrap
(arguments
`(#:node ,node-bootstrap
#:tests? #f
- #:phases
- (modify-phases %standard-phases
- (delete 'configure))))
+ #:absent-dependencies
+ '("tap")))
(home-page "https://github.com/npm/node-semver")
(properties '((hidden? . #t)))
(synopsis "Parses semantic versions strings")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 07/41] gnu: node-ms-bootstrap: Use #:absent-dependencies.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (5 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 06/41] gnu: node-semver-bootstrap: Use #:absent-dependencies Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 08/41] gnu: node-binary-search-bootstrap: " Philip McGrath
` (33 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node.scm (node-ms-bootstrap)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node.scm | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 95f5f28b3d..bec3f4620a 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -372,9 +372,12 @@ (define-public node-ms-bootstrap
(arguments
`(#:node ,node-bootstrap
#:tests? #f
- #:phases
- (modify-phases %standard-phases
- (delete 'configure))))
+ #:absent-dependencies
+ `("eslint"
+ "expect.js"
+ "husky"
+ "lint-staged"
+ "mocha")))
(home-page "https://github.com/zeit/ms#readme")
(properties '((hidden? . #t)))
(synopsis "Tiny millisecond conversion utility")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 08/41] gnu: node-binary-search-bootstrap: Use #:absent-dependencies.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (6 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 07/41] gnu: node-ms-bootstrap: " Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 09/41] gnu: node-debug-bootstrap: " Philip McGrath
` (32 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node.scm (node-binary-search-bootstrap)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node.scm | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index bec3f4620a..0a66b032bb 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -403,9 +403,9 @@ (define-public node-binary-search-bootstrap
(arguments
`(#:node ,node-bootstrap
#:tests? #f
- #:phases
- (modify-phases %standard-phases
- (delete 'configure))))
+ #:absent-dependencies
+ `("chai"
+ "mocha")))
(home-page "https://github.com/darkskyapp/binary-search#readme")
(properties '((hidden? . #t)))
(synopsis "Tiny binary search function with comparators")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 09/41] gnu: node-debug-bootstrap: Use #:absent-dependencies.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (7 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 08/41] gnu: node-binary-search-bootstrap: " Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 10/41] gnu: node-llparse-builder-bootstrap: " Philip McGrath
` (31 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node.scm (node-debug-bootstrap)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node.scm | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 0a66b032bb..985a2fdb20 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -430,9 +430,18 @@ (define-public node-debug-bootstrap
(arguments
`(#:node ,node-bootstrap
#:tests? #f
- #:phases
- (modify-phases %standard-phases
- (delete 'configure))))
+ #:absent-dependencies
+ `("brfs"
+ "browserify"
+ "coveralls"
+ "istanbul"
+ "karma"
+ "karma-browserify"
+ "karma-chrome-launcher"
+ "karma-mocha"
+ "mocha"
+ "mocha-lcov-reporter"
+ "xo")))
(inputs (list node-ms-bootstrap))
(home-page "https://github.com/visionmedia/debug#readme")
(properties '((hidden? . #t)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 10/41] gnu: node-llparse-builder-bootstrap: Use #:absent-dependencies.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (8 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 09/41] gnu: node-debug-bootstrap: " Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 11/41] gnu: node-llparse-frontend-bootstrap: " Philip McGrath
` (30 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node.scm (node-llparse-builder-bootstrap)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node.scm | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 985a2fdb20..31df15ffc3 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -493,9 +493,15 @@ (define-public node-llparse-builder-bootstrap
(arguments
`(#:node ,node-bootstrap
#:tests? #f
+ #:absent-dependencies
+ `("@types/mocha"
+ "@types/node"
+ "mocha"
+ "ts-node"
+ "tslint"
+ "typescript")
#:phases
(modify-phases %standard-phases
- (delete 'configure)
(replace 'build
(lambda* (#:key inputs #:allow-other-keys)
(let ((esbuild (search-input-file inputs "/bin/esbuild")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 11/41] gnu: node-llparse-frontend-bootstrap: Use #:absent-dependencies.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (9 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 10/41] gnu: node-llparse-builder-bootstrap: " Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 12/41] gnu: node-llparse-bootstrap: " Philip McGrath
` (29 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node.scm (node-llparse-frontend-bootstrap)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node.scm | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 31df15ffc3..4d3db6a8ea 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -553,9 +553,16 @@ (define-public node-llparse-frontend-bootstrap
(arguments
`(#:node ,node-bootstrap
#:tests? #f
+ #:absent-dependencies
+ `("@types/debug"
+ "@types/mocha"
+ "@types/node"
+ "mocha"
+ "ts-node"
+ "tslint"
+ "typescript")
#:phases
(modify-phases %standard-phases
- (delete 'configure)
(replace 'build
(lambda* (#:key inputs #:allow-other-keys)
(let ((esbuild (search-input-file inputs "/bin/esbuild")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 12/41] gnu: node-llparse-bootstrap: Use #:absent-dependencies.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (10 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 11/41] gnu: node-llparse-frontend-bootstrap: " Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 13/41] gnu: node-semver: " Philip McGrath
` (28 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node.scm (node-llparse-bootstrap)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node.scm | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 4d3db6a8ea..f952119a9f 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -613,9 +613,18 @@ (define-public node-llparse-bootstrap
(arguments
`(#:node ,node-bootstrap
#:tests? #f
+ #:absent-dependencies
+ `("@types/debug"
+ "@types/mocha"
+ "@types/node"
+ "esm"
+ "llparse-test-fixture"
+ "mocha"
+ "ts-node"
+ "tslint"
+ "typescript")
#:phases
(modify-phases %standard-phases
- (delete 'configure)
(replace 'build
(lambda* (#:key inputs #:allow-other-keys)
(let ((esbuild (search-input-file inputs "/bin/esbuild")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 13/41] gnu: node-semver: Use #:absent-dependencies.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (11 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 12/41] gnu: node-llparse-bootstrap: " Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 14/41] gnu: node-wrappy: " Philip McGrath
` (27 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node-xyz.scm (node-semver)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node-xyz.scm | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 9a0be96852..bd72eea807 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -288,11 +288,10 @@ (define-public node-semver
"06biknqb05r9xsmcflm3ygh50pjvdk84x6r79w43kmck4fn3qn5p"))))
(build-system node-build-system)
(arguments
- '(#:tests? #f ; FIXME: Tests depend on node-tap
- #:phases
- (modify-phases %standard-phases
- ;; The only dependency to check for is tap, which we don't have.
- (delete 'configure))))
+ '(#:absent-dependencies
+ '("tap")
+ ;; FIXME: Tests depend on node-tap
+ #:tests? #f))
(home-page "https://github.com/npm/node-semver")
(synopsis "Parses semantic versions strings")
(description
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 14/41] gnu: node-wrappy: Use #:absent-dependencies.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (12 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 13/41] gnu: node-semver: " Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 15/41] gnu: node-once: " Philip McGrath
` (26 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node-xyz.scm (node-wrappy)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node-xyz.scm | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index bd72eea807..ceef48887e 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -315,10 +315,8 @@ (define-public node-wrappy
(build-system node-build-system)
(arguments
'(#:tests? #f ; FIXME: Tests depend on node-tap
- #:phases
- (modify-phases %standard-phases
- ;; The only dependency to check for is tap, which we don't have.
- (delete 'configure))))
+ #:absent-dependencies
+ '("tap")))
(home-page "https://github.com/npm/wrappy")
(synopsis "Callback wrapping utility")
(description "@code{wrappy} is a utility for Node.js to wrap callbacks.")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 15/41] gnu: node-once: Use #:absent-dependencies.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (13 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 14/41] gnu: node-wrappy: " Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 16/41] gnu: node-irc-colors: " Philip McGrath
` (25 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node-xyz.scm (node-once)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node-xyz.scm | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index ceef48887e..9e602fd0e8 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -337,13 +337,10 @@ (define-public node-once
"1z8dcbf28dqdcp4wb0c53wrs90a07nkrax2c9kk26dsk1dhrnxav"))))
(build-system node-build-system)
(arguments
- '(#:tests? #f ; FIXME: tests depend on node-tap
- #:phases
- (modify-phases %standard-phases
- ;; The default configure phase fails due to tap being missing, as we do
- ;; not have tap packaged yet. It is used only for tests. This package
- ;; still works as a dependency of node-glob and node-inflight.
- (delete 'configure))))
+ '(#:absent-dependencies
+ '("tap")
+ ;; FIXME: Tests depend on node-tap
+ #:tests? #f))
(inputs
(list node-wrappy))
(home-page "https://github.com/isaacs/once")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 16/41] gnu: node-irc-colors: Use #:absent-dependencies.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (14 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 15/41] gnu: node-once: " Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 17/41] gnu: node-irc: " Philip McGrath
` (24 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node-xyz.scm (node-irc-colors)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node-xyz.scm | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 9e602fd0e8..6c3811528a 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -366,12 +366,10 @@ (define-public node-irc-colors
"0q3y34rbnlc55jcakmdxkicwazyvyph9r6gaf6hi8k7wj2nfwfli"))))
(build-system node-build-system)
(arguments
- '(#:tests? #f ; FIXME: tests depend on node-istanbul
- #:phases
- (modify-phases %standard-phases
- ;; The default configure phase fails due to various packages
- ;; being missing, as we don't have them packaged yet.
- (delete 'configure))))
+ '(#:absent-dependencies
+ `("istanbul"
+ "vows")
+ #:tests? #f))
(home-page "https://github.com/fent/irc-colors.js")
(synopsis "Node.js module providing color and formatting for IRC")
(description "@code{node-irc-colors} is a Node.js module that
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 17/41] gnu: node-irc: Use #:absent-dependencies.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (15 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 16/41] gnu: node-irc-colors: " Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 18/41] gnu: Add node-inherits Philip McGrath
` (23 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node-xyz.scm (node-irc)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node-xyz.scm | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 6c3811528a..93bd067311 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -393,12 +393,12 @@ (define-public node-irc
"1ln4qfx20jbwg4cp8lp0vf27m5281z2sz16d15xd6150n26cbi4x"))))
(build-system node-build-system)
(arguments
- '(#:tests? #f ; FIXME: tests depend on node-faucet
- #:phases
- (modify-phases %standard-phases
- ;; The default configure phase fails due to various packages
- ;; being missing, as we don't have them packaged yet.
- (delete 'configure))))
+ '(#:absent-dependencies
+ `("ansi-color"
+ "faucet"
+ "jscs"
+ "tape")
+ #:tests? #f))
(inputs
(list node-irc-colors))
(home-page "https://github.com/martynsmith/node-irc")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 18/41] gnu: Add node-inherits.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (16 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 17/41] gnu: node-irc: " Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 19/41] gnu: Add node-safe-buffer Philip McGrath
` (22 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-inherits): New variable.
---
gnu/packages/node-xyz.scm | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 93bd067311..ce098e6e8c 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -3,6 +3,7 @@
;;; Copyright © 2020 Giacomo Leidi <goodoldpaul@autistici.org>
;;; Copyright © 2021 Noisytoot <noisytoot@disroot.org>
;;; Copyright © 2021 Charles <charles.b.jackson@protonmail.com>
+;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -351,6 +352,35 @@ (define-public node-once
if desired.")
(license license:isc)))
+(define-public node-inherits
+ (package
+ (name "node-inherits")
+ (version "2.0.4")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/isaacs/inherits")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0cpsr5yqwkxpbbbbl0rwk4mcby6zbx841k2zb4c3gb1579i5wq9p"))))
+ (build-system node-build-system)
+ (arguments
+ '(#:absent-dependencies
+ '("tap")
+ ;; FIXME: Tests depend on node-tap
+ #:tests? #f))
+ (home-page
+ "https://github.com/isaacs/inherits")
+ (synopsis
+ "Browser-friendly inheritance Node.js")
+ (description
+ "Browser-friendly inheritance fully compatible with standard Node.js
+@code{inherits()}.")
+ (license license:isc)))
+
(define-public node-irc-colors
(package
(name "node-irc-colors")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 19/41] gnu: Add node-safe-buffer.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (17 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 18/41] gnu: Add node-inherits Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 20/41] gnu: Add node-string-decoder Philip McGrath
` (21 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-safe-buffer): New variable.
---
gnu/packages/node-xyz.scm | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index ce098e6e8c..410dfd6a62 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -381,6 +381,34 @@ (define-public node-inherits
@code{inherits()}.")
(license license:isc)))
+(define-public node-safe-buffer
+ (package
+ (name "node-safe-buffer")
+ (version "5.2.1")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/feross/safe-buffer")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0r26m0nl41h90ihnl2xf0cqs6z9z7jb87dl5j8yqb7887r9jlbpi"))))
+ (build-system node-build-system)
+ (arguments
+ '(#:absent-dependencies
+ '("tape"
+ "standard")
+ #:tests? #f))
+ (home-page
+ "https://github.com/feross/safe-buffer")
+ (synopsis "Safer Node.js Buffer API")
+ (description "A safe drop-in replacement the Node.js @code{Buffer} API
+that works in all versions of Node.js, using the built-in implementation when
+available.")
+ (license license:expat)))
+
(define-public node-irc-colors
(package
(name "node-irc-colors")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 20/41] gnu: Add node-string-decoder.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (18 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 19/41] gnu: Add node-safe-buffer Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 21/41] gnu: Add node-readable-stream Philip McGrath
` (20 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-string-decoder): New variable.
---
gnu/packages/node-xyz.scm | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 410dfd6a62..5dbe2cf244 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -409,6 +409,39 @@ (define-public node-safe-buffer
available.")
(license license:expat)))
+(define-public node-string-decoder
+ (package
+ (name "node-string-decoder")
+ (version "1.3.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/nodejs/string_decoder")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0xxvyya9fl9rlkqwmxzqzbz4rdr3jgw4vf37hff7cgscxkhg266k"))))
+ (build-system node-build-system)
+ (arguments
+ '(#:absent-dependencies
+ '("tap"
+ "core-util-is"
+ "babel-polyfill")
+ ;; FIXME: Tests depend on node-tap
+ #:tests? #f))
+ (inputs
+ (list node-safe-buffer node-inherits))
+ (home-page
+ "https://github.com/nodejs/string_decoder")
+ (synopsis
+ "Node.js core @code{string_decoder} for userland")
+ (description
+ "This package is a mirror of the @code{string_decoder} implementation in
+Node-core.")
+ (license license:expat)))
+
(define-public node-irc-colors
(package
(name "node-irc-colors")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 21/41] gnu: Add node-readable-stream.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (19 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 20/41] gnu: Add node-string-decoder Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 22/41] gnu: Add node-nan Philip McGrath
` (19 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-readable-stream): New variable.
---
gnu/packages/node-xyz.scm | 52 +++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 5dbe2cf244..87694c7d00 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -442,6 +442,58 @@ (define-public node-string-decoder
Node-core.")
(license license:expat)))
+(define-public node-readable-stream
+ (package
+ (name "node-readable-stream")
+ (version "3.6.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/nodejs/readable-stream")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0ybl4cdgsm9c5jq3xq8s01201jk8w0yakh63hlclsfbcdfqhd9ri"))))
+ (build-system node-build-system)
+ (arguments
+ `(#:absent-dependencies
+ `("@babel/cli"
+ "@babel/core"
+ "@babel/polyfill"
+ "@babel/preset-env"
+ "airtap"
+ "assert"
+ "bl"
+ "deep-strict-equal"
+ "events.once"
+ "glob"
+ "gunzip-maybe"
+ "hyperquest"
+ "lolex"
+ "nyc"
+ "pump"
+ "rimraf"
+ "tap"
+ "tape"
+ "tar-fs"
+ "util-promisify")
+ #:tests? #f))
+ (inputs
+ (list node-util-deprecate node-string-decoder node-inherits))
+ (home-page
+ "https://github.com/nodejs/readable-stream")
+ (synopsis
+ "Node.js core streams for userland")
+ (description
+ "This package is a mirror of the streams implementations in Node.js.
+
+If you want to guarantee a stable streams base, regardless of what version of
+Node you (or the users of your libraries) are using, use
+@code{readable-stream} only and avoid the @code{stream} module in Node-core.")
+ (license license:expat)))
+
(define-public node-irc-colors
(package
(name "node-irc-colors")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 22/41] gnu: Add node-nan.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (20 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 21/41] gnu: Add node-readable-stream Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 23/41] gnu: Add node-openzwave-shared Philip McGrath
` (18 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-nan): New variable.
---
gnu/packages/node-xyz.scm | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 87694c7d00..d8ce7248f8 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -549,3 +549,42 @@ (define-public node-irc
(description "@code{node-irc} is an IRC client library for Node.js.
It has functions for joining, parting, talking, and many other IRC commands.")
(license license:gpl3+)))
+
+(define-public node-nan
+ (package
+ (name "node-nan")
+ (version "2.15.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/nodejs/nan")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "18xslh9va5ld872scrp5y4251ax9s3c6qh0lnl1200lpzbsxy7yd"))))
+ (build-system node-build-system)
+ (arguments
+ `(#:absent-dependencies
+ '("bindings"
+ "commander"
+ "glob"
+ "request"
+ "node-gyp" ;; would be needed for tests
+ "tap"
+ "xtend")
+ ;; tests need tap and other dependencies
+ #:tests? #f))
+ (inputs
+ (list node-readable-stream))
+ (home-page "https://github.com/nodejs/nan")
+ (synopsis "Native Abstractions for Node.js")
+ (description "Native Abstractions for Node.js (``NaN'') provides a header
+file filled with macro and utility goodness for making add-on development for
+Node.js easier across versions. The goal of this project is to store all logic
+necessary to develop native Node.js addons without having to inspect
+@code{NODE_MODULE_VERSION} and get yourself into a macro-tangle.
+
+This project also contains some helper utilities that make addon development a
+bit more pleasant.")
+ (license license:expat)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 23/41] gnu: Add node-openzwave-shared.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (21 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 22/41] gnu: Add node-nan Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 24/41] gnu: Add node-addon-api Philip McGrath
` (17 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/zwave.scm (node-openzwave-shared): New variable.
---
gnu/packages/zwave.scm | 64 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 64 insertions(+)
diff --git a/gnu/packages/zwave.scm b/gnu/packages/zwave.scm
index 4d8286e334..3e99bd7687 100644
--- a/gnu/packages/zwave.scm
+++ b/gnu/packages/zwave.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -21,11 +22,14 @@ (define-module (gnu packages zwave)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix git-download)
#:use-module (guix build-system gnu)
+ #:use-module (guix build-system node)
#:use-module (gnu packages)
#:use-module (gnu packages base)
+ #:use-module (gnu packages node-xyz)
#:use-module (gnu packages libusb)
#:use-module (gnu packages linux)
#:use-module (gnu packages perl)
+ #:use-module (gnu packages python)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages xml))
@@ -85,3 +89,63 @@ (define-public open-zwave
and respond to devices on a Z-Wave network, without requiring in-depth
knowledge of the Z-Wave protocol.")
(license license:lgpl3+)))
+
+(define-public node-openzwave-shared
+ (package
+ (name "node-openzwave-shared")
+ (version "1.7.2")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/OpenZWave/node-openzwave-shared")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1bqqy12dzqj05j9wsh50dmn84dddmhz0gjzvd3y20z4hpy1v8rsc"))))
+ (inputs
+ (list open-zwave node-nan))
+ (native-inputs
+ (list which python pkg-config))
+ (build-system node-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (replace 'build
+ ;; For some reason, `npm install` doesn't build
+ ;; the addon automatically, so we do it explicitly here.
+ ;; We go through `npx` so the npmrc file sets the
+ ;; configuration up properly.
+ (lambda* (#:key native-inputs inputs #:allow-other-keys)
+ (invoke (search-input-file (or native-inputs inputs) "/bin/npx")
+ "--call"
+ (string-append
+ (search-input-file
+ (or native-inputs inputs)
+ "/lib/node_modules/npm/bin/node-gyp-bin/node-gyp")
+ " rebuild")))))))
+ (home-page "https://github.com/OpenZWave/node-openzwave-shared")
+ (synopsis "Node.js bindings for OpenZWave")
+ (description
+ "With the @code{node-openzwave-shared} package, you can easily control
+and manage your Z-Wave devices (lights, dimmers, blinds, you name it) from
+within Node.js applications. This library also supports secure
+devices (e.g. door locks) that require encryption. All widely used Node.js
+versions are supported with the help of @code{node-nan}.
+
+This library is currently able to:
+@itemize @bullet
+@item
+scan a Z-Wave network and report on connected devices;
+@item
+write values to Z-Wave nodes;
+@item
+monitor the network for changes;
+@item
+heal nodes and/or the network; and
+@item
+perform management tasks: add or remove nodes, replace failed nodes,
+manage their group associations, etc.
+@end itemize")
+ (license license:isc)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 24/41] gnu: Add node-addon-api.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (22 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 23/41] gnu: Add node-openzwave-shared Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 25/41] gnu: Add node-sqlite3 Philip McGrath
` (16 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-addon-api): New variable.
---
gnu/packages/node-xyz.scm | 83 +++++++++++++++++++++++++++++++++++++++
1 file changed, 83 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index d8ce7248f8..91a007b55c 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -22,6 +22,9 @@
(define-module (gnu packages node-xyz)
#:use-module ((guix licenses) #:prefix license:)
+ #:use-module (gnu packages sqlite)
+ #:use-module (gnu packages python)
+ #:use-module (guix gexp)
#:use-module (guix packages)
#:use-module (guix git-download)
#:use-module (guix build-system node))
@@ -588,3 +591,83 @@ (define-public node-nan
This project also contains some helper utilities that make addon development a
bit more pleasant.")
(license license:expat)))
+
+(define-public node-addon-api
+ (package
+ (name "node-addon-api")
+ (version "4.2.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/nodejs/node-addon-api")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "1bhvfi2m9nxfz418s619914vmidcnrzbjv6l9nid476c3zlpazch"))))
+ (inputs
+ (list python node-safe-buffer))
+ (build-system node-build-system)
+ (arguments
+ `(#:absent-dependencies
+ `("benchmark"
+ "bindings"
+ "clang-format"
+ "eslint"
+ "eslint-config-semistandard"
+ "eslint-config-standard"
+ "eslint-plugin-import"
+ "eslint-plugin-node"
+ "eslint-plugin-promise"
+ "fs-extra"
+ "path"
+ "pre-commit")
+ #:modules
+ ((guix build node-build-system)
+ (srfi srfi-1)
+ (ice-9 match)
+ (guix build utils))
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'skip-js-tests
+ ;; We can't run the js-based tests,
+ ;; but we can still do the C++ parts
+ (lambda args
+ (define new-test-script
+ "echo stopping after pretest on Guix")
+ (with-atomic-json-file-replacement "package.json"
+ (match-lambda
+ (('@ . pkg-meta-alist)
+ (cons
+ '@
+ (map (match-lambda
+ (("scripts" '@ . scripts-alist)
+ `("scripts" @ ,@(map (match-lambda
+ (("test" . _)
+ (cons "test"
+ new-test-script))
+ (other
+ other))
+ scripts-alist)))
+ (other
+ other))
+ pkg-meta-alist))))))))))
+ (home-page "https://github.com/nodejs/node-addon-api")
+ (synopsis "Node.js API (Node-API) header-only C++ wrappers")
+ (description "This module contains header-only C++ wrapper classes which
+simplify the use of the C based Node-API provided by Node.js when using C++.
+It provides a C++ object model and exception handling semantics with low
+overhead.
+
+Node-API is an ABI stable C interface provided by Node.js for building native
+addons. It is intended to insulate native addons from changes in the
+underlying JavaScript engine and allow modules compiled for one version to run
+on later versions of Node.js without recompilation. The @code{node-addon-api}
+module, which is not part of Node.js, preserves the benefits of the Node-API
+as it consists only of inline code that depends only on the stable API
+provided by Node-API.
+
+It is important to remember that @emph{other} Node.js interfaces such as
+@code{libuv} (included in a project via @code{#include <uv.h>}) are not
+ABI-stable across Node.js major versions.")
+ (license license:expat)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 25/41] gnu: Add node-sqlite3.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (23 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 24/41] gnu: Add node-addon-api Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 26/41] gnu: Add node-file-uri-to-path Philip McGrath
` (15 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-sqlite3): New variable.
---
gnu/packages/node-xyz.scm | 128 ++++++++++++++++++++++++++++++++++++++
1 file changed, 128 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 91a007b55c..d525da8dc3 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -671,3 +671,131 @@ (define new-test-script
@code{libuv} (included in a project via @code{#include <uv.h>}) are not
ABI-stable across Node.js major versions.")
(license license:expat)))
+
+(define-public node-sqlite3
+ (package
+ (name "node-sqlite3")
+ (version "5.0.2")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/mapbox/node-sqlite3")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "0sbbzzli282nxyfha10zx0k5m8hdp0sf3ipl59khjb7wm449j86h"))
+ (snippet
+ (with-imported-modules '((guix build utils))
+ #~(begin
+ (use-modules (guix build utils))
+ ;; unbundle sqlite
+ (for-each delete-file-recursively
+ (find-files "deps"
+ (lambda (pth stat)
+ (gzip-file? pth)))))))))
+ (inputs
+ (list node-addon-api python sqlite))
+ (build-system node-build-system)
+ (arguments
+ `(#:modules
+ ((guix build node-build-system)
+ (srfi srfi-1)
+ (ice-9 match)
+ (guix build utils))
+ #:tests? #f ; FIXME: tests depend on node-mocha
+ #:absent-dependencies
+ `(;; Normally, this is "built" using @mapbox/node-pre-gyp,
+ ;; which publishes or downloads pre-built binaries
+ ;; or falls back to building from source.
+ ;; Here, we patch out all of that and just build directly.
+ ;; It would be better to patch a version of @mapbox/node-pre-gyp
+ ;; that always builds from source, as Debian does,
+ ;; but there are a number of dependencies that need
+ ;; to be packaged or removed.
+ "@mapbox/node-pre-gyp"
+ "node-pre-gyp" ;; deprecated name still used in some places
+ "aws-sdk"
+ "@mapbox/cloudfriend"
+ ;; Confusingly, this is only a dependency because of
+ ;; @mapbox/node-pre-gyp: with that removed,
+ ;; npm will use its own copy:
+ "node-gyp"
+ ;; These we'd like, we just don't have them yet:
+ "eslint"
+ "mocha")
+ #:phases
+ (modify-phases %standard-phases
+ (add-before 'configure 'npm-config-sqlite
+ ;; We need this step even if we do replace @mapbox/node-pre-gyp
+ ;; because the package expects to build its bundled sqlite
+ (lambda* (#:key inputs #:allow-other-keys)
+ (setenv "npm_config_sqlite" (assoc-ref inputs "sqlite"))))
+ (add-after 'install 'patch-binding-path
+ ;; We replace a file that dynamic searches for the addon using
+ ;; node-pre-gyp (which we don't have) with a version that
+ ;; simply uses the path to the addon we built directly.
+ ;; The exact path is supposed to depend on things like the
+ ;; architecture and napi_build_version, so, to avoid having
+ ;; hard-code the details accurately, we do this after the addon
+ ;; has been built so we can just find where it ended up.
+ (lambda* (#:key outputs #:allow-other-keys)
+ (with-directory-excursion
+ (search-input-directory outputs
+ "lib/node_modules/sqlite3/lib")
+ (match (find-files "binding" "\\.node$")
+ ((rel-path)
+ (with-atomic-file-replacement "sqlite3-binding.js"
+ (lambda (in out)
+ (format out "var binding = require('./~a');\n" rel-path)
+ (display "module.exports = exports = binding;\n"
+ out))))))))
+ (add-after 'patch-dependencies 'avoid-node-pre-gyp
+ (lambda args
+ ;; We need to patch .npmignore before the 'repack phase
+ ;; so that the built addon is installed with in the package.
+ ;; (Upstream assumes node-pre-gyp will download a pre-built
+ ;; version when this package is installed.)
+ (substitute* ".npmignore"
+ (("lib/binding")
+ "#lib/binding # <- patched for Guix"))
+ (with-atomic-json-file-replacement "package.json"
+ (match-lambda
+ (('@ . pkg-meta-alist)
+ (match (assoc-ref pkg-meta-alist "binary")
+ (('@ . binary-alist)
+ ;; When it builds from source, node-pre-gyp supplies
+ ;; module_name and module_path based on the entries under
+ ;; "binary" from "package.json", so this package's
+ ;; "binding.gyp" doesn't define them. Thus, we also need
+ ;; to supply them. The GYP_DEFINES environment variable
+ ;; turns out to be the easiest way to make sure they are
+ ;; propagated from npm to node-gyp to gyp.
+ (setenv "GYP_DEFINES"
+ (string-append
+ "module_name="
+ (assoc-ref binary-alist "module_name")
+ " "
+ "module_path="
+ (assoc-ref binary-alist "module_path")))))
+ ;; We need to remove the install script from "package.json",
+ ;; as it would try to use node-pre-gyp and would block the
+ ;; automatic building performed by `npm install`.
+ (cons '@ (map (match-lambda
+ (("scripts" @ . scripts-alist)
+ `("scripts" @ ,@(filter (match-lambda
+ (("install" . _)
+ #f)
+ (_
+ #t))
+ scripts-alist)))
+ (other
+ other))
+ pkg-meta-alist))))))))))
+ (home-page "https://github.com/mapbox/node-sqlite3")
+ (synopsis "Asynchronous, non-blocking SQLite3 bindings for Node.js")
+ (description
+ "The Node.js add-on @code{node-sqlite3} provides a set of a asynchronous,
+non-blocking bindings for SQLite3, written in modern C++ and tested for memory
+leaks.")
+ (license license:bsd-3)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 26/41] gnu: Add node-file-uri-to-path.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (24 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 25/41] gnu: Add node-sqlite3 Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 27/41] gnu: Add node-bindings Philip McGrath
` (14 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-file-uri-to-path): New variable.
---
gnu/packages/node-xyz.scm | 54 +++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index d525da8dc3..6aeb651c4e 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -24,6 +24,7 @@ (define-module (gnu packages node-xyz)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (gnu packages sqlite)
#:use-module (gnu packages python)
+ #:use-module (gnu packages web)
#:use-module (guix gexp)
#:use-module (guix packages)
#:use-module (guix git-download)
@@ -799,3 +800,56 @@ (define-public node-sqlite3
non-blocking bindings for SQLite3, written in modern C++ and tested for memory
leaks.")
(license license:bsd-3)))
+
+(define-public node-file-uri-to-path
+ (package
+ (name "node-file-uri-to-path")
+ (version "2.0.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/TooTallNate/file-uri-to-path")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "08l779az44czm12xdhgcrnzpqw34s59hbrlfphs7g9y2k26drqav"))))
+ (native-inputs
+ (list esbuild))
+ (build-system node-build-system)
+ (arguments
+ `(#:absent-dependencies
+ `("@types/mocha"
+ "@types/node"
+ "@typescript-eslint/eslint-plugin"
+ "@typescript-eslint/parser"
+ "cpy-cli"
+ "eslint"
+ "eslint-config-airbnb"
+ "eslint-config-prettier"
+ "eslint-import-resolver-typescript"
+ "eslint-plugin-import"
+ "eslint-plugin-jsx-a11y"
+ "eslint-plugin-react"
+ "mocha"
+ "rimraf"
+ "typescript")
+ #:phases
+ (modify-phases %standard-phases
+ (replace 'build
+ (lambda* (#:key inputs native-inputs #:allow-other-keys)
+ (copy-recursively "src" "dist")
+ (invoke (search-input-file (or native-inputs inputs)
+ "/bin/esbuild")
+ "dist/index.ts"
+ "--outfile=dist/src/index.js"
+ "--format=cjs"
+ "--sourcemap"
+ "--platform=node"))))
+ #:tests? #f))
+ (home-page "https://github.com/TooTallNate/file-uri-to-path")
+ (synopsis "Convert a @code{file:} URI to a file path")
+ (description "This package provides a function to convert a @code{file:}
+URI to a file path. It accepts a @code{file:} URI and returns a file path
+suitable for use with the @code{fs} module functions.")
+ (license license:expat)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 27/41] gnu: Add node-bindings.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (25 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 26/41] gnu: Add node-file-uri-to-path Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 28/41] gnu: Add node-segfault-handler Philip McGrath
` (13 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-bindings): New variable.
---
gnu/packages/node-xyz.scm | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 6aeb651c4e..ff59028e69 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -853,3 +853,29 @@ (define-public node-file-uri-to-path
URI to a file path. It accepts a @code{file:} URI and returns a file path
suitable for use with the @code{fs} module functions.")
(license license:expat)))
+
+(define-public node-bindings
+ (package
+ (name "node-bindings")
+ (version "1.5.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/TooTallNate/node-bindings")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "100gp6kpjvd4j1dqnp0sbjr1hqx5mz7r61q9qy527jyhk9mj47wk"))))
+ (inputs
+ (list node-file-uri-to-path))
+ (build-system node-build-system)
+ (arguments
+ ;; there are no tests
+ `(#:tests? #f))
+ (home-page "https://github.com/TooTallNate/node-bindings")
+ (synopsis "Help for loading your native module's @code{.node} file")
+ (description "This is a helper module for authors of Node.js native addon
+modules. It is basically the ``swiss army knife'' of @code{require()}ing your
+native module's @code{.node} file.")
+ (license license:expat)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 28/41] gnu: Add node-segfault-handler.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (26 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 27/41] gnu: Add node-bindings Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 29/41] gnu: Add node-ms Philip McGrath
` (12 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-segfault-handler): New variable.
---
gnu/packages/node-xyz.scm | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index ff59028e69..595885b191 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -879,3 +879,32 @@ (define-public node-bindings
modules. It is basically the ``swiss army knife'' of @code{require()}ing your
native module's @code{.node} file.")
(license license:expat)))
+
+(define-public node-segfault-handler
+ (package
+ (name "node-segfault-handler")
+ (version "1.3.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/ddopson/node-segfault-handler")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "07nbw35wvrr18kmh8f388v4k5mpjgyy0260bx0xzjdv795i3xvfv"))))
+ (native-inputs
+ (list python))
+ (inputs
+ (list node-bindings node-nan))
+ (build-system node-build-system)
+ (arguments
+ ;; there are no tests
+ `(#:tests? #f))
+ (home-page "https://github.com/ddopson/node-segfault-handler")
+ (synopsis "Catches @code{SIGSEGV} and prints diagnostic information")
+ (description "This package is a tool for debugging Node.js C/C++ native
+code modules and getting stack traces when things go wrong. If a
+@code{SIGSEGV} signal is raised, the module will print a native stack trace to
+both @code{STDERR} and to a timestamped file.")
+ (license license:bsd-3)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 29/41] gnu: Add node-ms.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (27 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 28/41] gnu: Add node-segfault-handler Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 30/41] gnu: Add node-debug Philip McGrath
` (11 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-ms): New variable.
---
gnu/packages/node-xyz.scm | 43 +++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 595885b191..6415fb92f5 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -908,3 +908,46 @@ (define-public node-segfault-handler
@code{SIGSEGV} signal is raised, the module will print a native stack trace to
both @code{STDERR} and to a timestamped file.")
(license license:bsd-3)))
+
+(define-public node-ms
+ (package
+ (name "node-ms")
+ (version "2.1.3")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/vercel/ms")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "1l74kmmwffmzdz38lli0v5mdb9p9jmsjxpb48ncknqw2n74cgf08"))))
+ (build-system node-build-system)
+ (arguments
+ `(#:absent-dependencies
+ `("eslint"
+ "expect.js"
+ "husky"
+ "lint-staged"
+ "mocha"
+ "prettier")
+ #:tests? #f))
+ (home-page "https://github.com/vercel/ms")
+ (synopsis "Tiny millisecond conversion utility")
+ (description "Use this package to easily convert various time formats to
+milliseconds.
+
+Features:
+@itemize @bullet
+@item
+Works both in Node.js and in the browser.
+@item
+If a number is supplied to @code{ms}, a string with a unit is returned.
+@item
+If a string that contains the number is supplied, it returns it as a
+number (e.g. it returns @code{100} for @code{'100'}).
+@item
+If you pass a string with a number and a valid unit, the number of
+equivalent milliseconds is returned.
+@end itemize")
+ (license license:expat)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 30/41] gnu: Add node-debug.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (28 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 29/41] gnu: Add node-ms Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 31/41] gnu: Add node-serialport-binding-abstract Philip McGrath
` (10 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-debug): New variable.
---
gnu/packages/node-xyz.scm | 42 +++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 6415fb92f5..c07822f65b 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -951,3 +951,45 @@ (define-public node-ms
equivalent milliseconds is returned.
@end itemize")
(license license:expat)))
+
+(define-public node-debug
+ (package
+ (name "node-debug")
+ (version "4.3.3")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/debug-js/debug")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "0ji0dmdl2xkgxqxvd6xjy7k3mmknmhvqjgc40vyly9ka1mpf20vb"))))
+ (inputs
+ (list node-ms))
+ (build-system node-build-system)
+ (arguments
+ `(#:absent-dependencies
+ `("brfs"
+ "browserify"
+ "coveralls"
+ "istanbul"
+ "karma"
+ "karma-browserify"
+ "karma-chrome-launcher"
+ "karma-mocha"
+ "mocha"
+ "mocha-lcov-reporter"
+ "xo"
+ "supports-color")
+ #:tests? #f))
+ (home-page "https://github.com/debug-js/debug")
+ (synopsis "Lightweight debugging utility for Node.js and the browser")
+ (description "A tiny JavaScript debugging utility modelled after Node.js
+core's debugging technique. orks in Node.js and web browsers.
+
+The @code{debug} module exposes a function; simply pass this function the name
+of your module, and it will return a decorated version of @code{console.error}
+for you to pass debug statements to. This will allow you to toggle the debug
+output for different parts of your module as well as the module as a whole.")
+ (license license:expat)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 31/41] gnu: Add node-serialport-binding-abstract.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (29 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 30/41] gnu: Add node-debug Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 32/41] gnu: Add node-serialport-parser-delimiter Philip McGrath
` (9 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-binding-abstract): New
variable.
---
gnu/packages/node-xyz.scm | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index c07822f65b..e459f9fa40 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -993,3 +993,37 @@ (define-public node-debug
for you to pass debug statements to. This will allow you to toggle the debug
output for different parts of your module as well as the module as a whole.")
(license license:expat)))
+
+(define-public node-serialport-binding-abstract
+ (package
+ (name "node-serialport-binding-abstract")
+ (version "9.2.3")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/serialport/node-serialport")
+ (commit "v9.2.7")))
+ (file-name (git-file-name "serialport-monorepo" version))
+ (sha256
+ (base32 "0x7zm59a5ff5yygjyw15xs3r5m3rb8av1yfrh4snn44mrwq87yg8"))))
+ (inputs
+ (list node-debug))
+ (build-system node-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/binding-abstract"))))
+ #:tests? #f))
+ (home-page "https://serialport.io")
+ (synopsis "Abstract base class for Node SerialPort bindings")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+This package provides the @code{AbstractBinding} class, the base for all Node
+SerialPort bindings. You wouldn't use this class directly, but instead extend
+it to make a new binding for a different platform or underling technology.")
+ (license license:expat)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 32/41] gnu: Add node-serialport-parser-delimiter.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (30 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 31/41] gnu: Add node-serialport-binding-abstract Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 33/41] gnu: Add node-serialport-parser-readline Philip McGrath
` (8 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-parser-delimiter): New
variable.
---
gnu/packages/node-xyz.scm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index e459f9fa40..7a04e66efa 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1027,3 +1027,25 @@ (define-public node-serialport-binding-abstract
SerialPort bindings. You wouldn't use this class directly, but instead extend
it to make a new binding for a different platform or underling technology.")
(license license:expat)))
+
+(define-public node-serialport-parser-delimiter
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-parser-delimiter")
+ (version "9.2.4")
+ (inputs `())
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/parser-delimiter"))))
+ #:tests? #f))
+ (synopsis "Node SerialPort parser to split data on a delimiter")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+Parsers are used to take raw binary data and transform them into usable
+messages. This package provides @code{Delimiter}, a parser that emits data
+each time a specified byte sequence is received.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 33/41] gnu: Add node-serialport-parser-readline.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (31 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 32/41] gnu: Add node-serialport-parser-delimiter Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 34/41] gnu: Add node-serialport-bindings Philip McGrath
` (7 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-parser-readline): New
variable.
---
gnu/packages/node-xyz.scm | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 7a04e66efa..ca18e5055e 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1049,3 +1049,26 @@ (define-public node-serialport-parser-delimiter
Parsers are used to take raw binary data and transform them into usable
messages. This package provides @code{Delimiter}, a parser that emits data
each time a specified byte sequence is received.")))
+
+(define-public node-serialport-parser-readline
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-parser-readline")
+ (version "9.2.4")
+ (inputs
+ (list node-serialport-parser-delimiter))
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/parser-readline"))))
+ #:tests? #f))
+ (synopsis "Node SerialPort parser to split data on newlines")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+Parsers are used to take raw binary data and transform them into usable
+messages. This package provides @code{Readline}, a parser that emits data
+after a (configurable) newline delimiter is received.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 34/41] gnu: Add node-serialport-bindings.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (32 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 33/41] gnu: Add node-serialport-parser-readline Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 35/41] gnu: Add node-serialport-parser-regex Philip McGrath
` (6 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-bindings): New variable.
---
gnu/packages/node-xyz.scm | 53 +++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index ca18e5055e..4495ea9b68 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1072,3 +1072,56 @@ (define-public node-serialport-parser-readline
Parsers are used to take raw binary data and transform them into usable
messages. This package provides @code{Readline}, a parser that emits data
after a (configurable) newline delimiter is received.")))
+
+(define-public node-serialport-bindings
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-bindings")
+ (version "9.2.7")
+ (native-inputs
+ (list python))
+ (inputs
+ (list node-nan node-bindings node-serialport-binding-abstract
+ node-serialport-parser-readline node-debug))
+ (arguments
+ `(#:absent-dependencies
+ `("prebuild-install"
+ ;; devDependencies
+ "@serialport/binding-mock"
+ "node-abi")
+ #:modules
+ ((guix build node-build-system)
+ (srfi srfi-1)
+ (ice-9 match)
+ (guix build utils))
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/bindings")))
+ (add-after 'chdir 'avoid-prebuild-install
+ (lambda args
+ (with-atomic-json-file-replacement "package.json"
+ (match-lambda
+ (('@ . pkg-meta-alist)
+ (cons '@ (map (match-lambda
+ (("scripts" @ . scripts-alist)
+ `("scripts" @ ,@(filter (match-lambda
+ (("install" . _)
+ #f)
+ (_
+ #t))
+ scripts-alist)))
+ (other
+ other))
+ pkg-meta-alist))))))))
+ #:tests? #f))
+ (synopsis "Abstract base class for Node SerialPort bindings")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+This package provides the @code{Binding} class, which uses a native addon to
+talk to the underlying system. You never have to use @code{Binding} objects
+directly. There is also a @code{MockBinding} available (but not yet packaged
+for Guix) to assist with testing.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 35/41] gnu: Add node-serialport-parser-regex.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (33 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 34/41] gnu: Add node-serialport-bindings Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 36/41] gnu: Add node-serialport-parser-ready Philip McGrath
` (5 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-parser-regex): New variable.
---
gnu/packages/node-xyz.scm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 4495ea9b68..d26c4b8ba1 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1125,3 +1125,25 @@ (define-public node-serialport-bindings
talk to the underlying system. You never have to use @code{Binding} objects
directly. There is also a @code{MockBinding} available (but not yet packaged
for Guix) to assist with testing.")))
+
+(define-public node-serialport-parser-regex
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-parser-regex")
+ (version "9.2.4")
+ (inputs `())
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/parser-regex"))))
+ #:tests? #f))
+ (synopsis "Node SerialPort parser to split data on a regular expression")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+Parsers are used to take raw binary data and transform them into usable
+messages. This package provides @code{Regex}, a parser that uses a regular
+expression to split the incoming text.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 36/41] gnu: Add node-serialport-parser-ready.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (34 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 35/41] gnu: Add node-serialport-parser-regex Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 37/41] gnu: Add node-serialport-parser-inter-byte-timeout Philip McGrath
` (4 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-parser-ready): New variable.
---
gnu/packages/node-xyz.scm | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index d26c4b8ba1..125b32ea74 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1147,3 +1147,26 @@ (define-public node-serialport-parser-regex
Parsers are used to take raw binary data and transform them into usable
messages. This package provides @code{Regex}, a parser that uses a regular
expression to split the incoming text.")))
+
+(define-public node-serialport-parser-ready
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-parser-ready")
+ (version "9.2.4")
+ (inputs `())
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/parser-ready"))))
+ #:tests? #f))
+ (synopsis "Node SerialPort parser to wait for specified byte sequence")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+Parsers are used to take raw binary data and transform them into usable
+messages. This package provides @code{Ready}, a parser that waits for a
+specified sequence of ``ready'' bytes before emitting a ready event and
+emitting data events.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 37/41] gnu: Add node-serialport-parser-inter-byte-timeout.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (35 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 36/41] gnu: Add node-serialport-parser-ready Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 38/41] gnu: Add node-serialport-parser-cctalk Philip McGrath
` (3 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm
(node-serialport-parser-inter-byte-timeout): New variable.
---
gnu/packages/node-xyz.scm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 125b32ea74..b240890c5b 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1170,3 +1170,25 @@ (define-public node-serialport-parser-ready
messages. This package provides @code{Ready}, a parser that waits for a
specified sequence of ``ready'' bytes before emitting a ready event and
emitting data events.")))
+
+(define-public node-serialport-parser-inter-byte-timeout
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-parser-inter-byte-timeout")
+ (version "9.2.4")
+ (inputs `())
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/parser-inter-byte-timeout"))))
+ #:tests? #f))
+ (synopsis "Node SerialPort parser to detect pauses in data")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+Parsers are used to take raw binary data and transform them into usable
+messages. This package provides @code{InterByteTimeout}, a parser that emits
+data if there is a pause between packets for the specified amount of time.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 38/41] gnu: Add node-serialport-parser-cctalk.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (36 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 37/41] gnu: Add node-serialport-parser-inter-byte-timeout Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 39/41] gnu: Add node-serialport-parser-byte-length Philip McGrath
` (2 subsequent siblings)
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-parser-cctalk): New variable.
---
gnu/packages/node-xyz.scm | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index b240890c5b..e6e25f036a 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1192,3 +1192,26 @@ (define-public node-serialport-parser-inter-byte-timeout
Parsers are used to take raw binary data and transform them into usable
messages. This package provides @code{InterByteTimeout}, a parser that emits
data if there is a pause between packets for the specified amount of time.")))
+
+(define-public node-serialport-parser-cctalk
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-parser-cctalk")
+ (version "9.2.4")
+ (inputs `())
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/parser-cctalk"))))
+ #:tests? #f))
+ (synopsis "Node SerialPort parser for the ccTalk protocol")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+Parsers are used to take raw binary data and transform them into usable
+messages. This package provides @code{CCTalk}, which emits packets for the
+ccTalk protocol (an open standard for currency detectors) as they are
+received.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 39/41] gnu: Add node-serialport-parser-byte-length.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (37 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 38/41] gnu: Add node-serialport-parser-cctalk Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 40/41] gnu: Add node-serialport-stream Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 41/41] gnu: Add node-serialport Philip McGrath
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-parser-byte-length): New
variable.
---
gnu/packages/node-xyz.scm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index e6e25f036a..fa9498e31e 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1215,3 +1215,25 @@ (define-public node-serialport-parser-cctalk
messages. This package provides @code{CCTalk}, which emits packets for the
ccTalk protocol (an open standard for currency detectors) as they are
received.")))
+
+(define-public node-serialport-parser-byte-length
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-parser-byte-length")
+ (version "9.2.4")
+ (inputs `())
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/parser-byte-length"))))
+ #:tests? #f))
+ (synopsis "Node SerialPort parser for fixed-length buffers")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+Parsers are used to take raw binary data and transform them into usable
+messages. This package provides @code{ByteLength}, a parser that emits data
+as a buffer every time a specified number of bytes are received.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 40/41] gnu: Add node-serialport-stream.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (38 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 39/41] gnu: Add node-serialport-parser-byte-length Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
2021-12-30 7:44 ` [bug#51838] [PATCH v7 41/41] gnu: Add node-serialport Philip McGrath
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-stream): New variable.
---
gnu/packages/node-xyz.scm | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index fa9498e31e..e3fc8c23b7 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1237,3 +1237,30 @@ (define-public node-serialport-parser-byte-length
Parsers are used to take raw binary data and transform them into usable
messages. This package provides @code{ByteLength}, a parser that emits data
as a buffer every time a specified number of bytes are received.")))
+
+(define-public node-serialport-stream
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-stream")
+ (version "9.2.4")
+ (inputs
+ (list node-debug))
+ (arguments
+ `(#:absent-dependencies
+ `(;; devDependencies
+ "@serialport/binding-mock")
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/stream"))))
+ #:tests? #f))
+ (synopsis "Node.js stream interface for Node SerialPort")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+This package provides an interface for using Node SerialPort bindings via the
+Node.js Stream API. The stream is a duplex stream, allowing for reading and
+writing. It has additional methods for managing the SerialPort
+connection.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v7 41/41] gnu: Add node-serialport.
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (39 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 40/41] gnu: Add node-serialport-stream Philip McGrath
@ 2021-12-30 7:44 ` Philip McGrath
40 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-30 7:44 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport): New variable.
---
gnu/packages/node-xyz.scm | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index e3fc8c23b7..449b2a04fd 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1264,3 +1264,34 @@ (define-public node-serialport-stream
Node.js Stream API. The stream is a duplex stream, allowing for reading and
writing. It has additional methods for managing the SerialPort
connection.")))
+
+(define-public node-serialport
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport")
+ (version "9.2.7")
+ (inputs
+ (list node-serialport-bindings
+ node-serialport-parser-delimiter
+ node-serialport-parser-readline
+ node-serialport-parser-regex
+ node-serialport-parser-ready
+ node-serialport-parser-inter-byte-timeout
+ node-serialport-parser-cctalk
+ node-serialport-parser-byte-length
+ node-serialport-stream
+ node-debug))
+ (arguments
+ `(#:absent-dependencies
+ `("@serialport/binding-mock")
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/serialport"))))
+ #:tests? #f))
+ (synopsis "Node.js package to access serial ports")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. This package is the recommended entry point for most
+projects. It combines a high-level Node.js stream interface with a useful
+default set of parsers and bindings.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp.
2021-12-30 7:38 ` [bug#51838] [PATCH v6 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (41 preceding siblings ...)
2021-12-30 7:44 ` [bug#51838] [PATCH v7 00/41] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
@ 2021-12-30 20:03 ` Ryan Sundberg via Guix-patches via
42 siblings, 0 replies; 458+ messages in thread
From: Ryan Sundberg via Guix-patches via @ 2021-12-30 20:03 UTC (permalink / raw)
To: 51838
[-- Attachment #1.1: Type: text/plain, Size: 8525 bytes --]
I think the #:absent-dependencies pattern is very straightforward
argument and is clearly a common enough occurrence to merit a shorthand
expression. I have not been following the developments in the
node-build-system here recently but it looks like lots of progress is
being made. Thanks all for contributing!
--
Sincerely,
Ryan Sundberg
On 12/29/21 11:38 PM, Philip McGrath wrote:
> Hi Liliana (and everyone),
>
> Thanks for taking care of the earlier patches from the series!
>
> It sounds like (guix build json) is going to be around for a reasonably
> long time, and I'm ok with that.
>
> In the hope of clearing a path to move forward, I'm sending v6 of this
> patch series, immediately followed by a closely-related v7: I strongly
> prefer v7, but I would be ok with either version being applied if one of
> them can achieve consensus. (If v6 is merged, I'll send a separate patch
> series to propose '#:absent-dependencies'.)
>
> I've put the two versions up on GitLab
> as <https://gitlab.com/philip1/guix-patches/-/tags/guix-issue-51838-v6>
> and <https://gitlab.com/philip1/guix-patches/-/tags/guix-issue-51838-v7>,
> respectively.
>
> I've re-organized the patches in the series somewhat to facilitate a
> minimal, side-by-side comparison between '#:absent-dependencies' and this
> approach:
>
> On 12/20/21 17:00, Liliana Marie Prikler wrote:
>> (add-after 'patch-dependencies 'drop-junk
>> (lambda _
>> (with-atomic-json-replacement "package.json"
>> (lambda (json) (delete-dependencies json '("node-tap"))))))
>
> The series is now organized as follows:
>
> - The first 4 patches are identical in v6 and v7:
>
> - Patches 01 & 02/41 are non-controversial build system changes
> ('delete-lockfiles' and libuv).
>
> - Patch 03/41 adds to (guix build node-build-system) several utility
> functions for transforming JSON in the representation used by (guix
> build json), especially functional update of tagged JSON
> objects. It also adjusts the rest of (guix build node-build-system)
> to make use of those functions, eliminating all uses of
> 'assoc-set!' and other procedures that mutate assosciation lists.
>
> Of the new functions, only 'with-atomic-json-file-replacement' is
> exported for now: my hope is that further (valuable and important!)
> discussion about the API design of these functions or their
> implementations need not block either v6 or v7 of this series.
>
> - Patch 04/41 adds the 'avoid-node-gyp-rebuild' phase. I've re-worked
> the implementation to use the new helper functions.
>
> - Patch 05/41 is the truly significant difference between v6 and v7: it
> implements the strategy for dealing with missing dependencies.
>
> In v6, it exports a new public function 'delete-dependencies' from
> (guix build node-build-system).
>
> In v7, it adds '#:absent-dependencies'. One difference from previous
> versions of this series is that it handles '#:absent-dependencies' in a
> new 'delete-dependencies' phase, which makes the change even more
> self-contained.
>
> - Patches 06 through 17/41 adjust existing packages to make use of the
> approach to missing dependencies from patch 05/41 of each series.
>
> - Patches 18 through 41/41 add the new packages excercising native addon
> support, again differing based on the approach from patch 05/41. The
> other slight difference from previous versions of this series is that,
> where applicable, I've adjusted the new package definitions to use
> 'with-atomic-json-file-replacement' and never to use 'assoc-set!' or
> other procedures that mutate assosciation lists.
>
> I continue to think that '#:absent-dependencies' is a good approach, in
> brief, as Jelle put it in <https://issues.guix.gnu.org/51838#247>, because:
>
> On 12/20/21 18:10, Jelle Licht wrote:
>> Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
>>> Am Montag, dem 20.12.2021 um 14:33 -0500 schrieb Philip McGrath:
>>>> If we took your final suggestion above, I think we'd have something
>>>> like this:
>>>>
>>>> ```
>>>> #:phases
>>>> (modify-phases %standard-phases
>>>> (add-after 'unpack 'delete-dependencies
>>>> (make-delete-dependencies-phase '("node-tap"))))
>>>> ```
>>>>
>>>> That seems pretty similar to, under the current patch series:
>>>>
>>>> ```
>>>> #:absent-dependencies '("node-tap")
>>>> ```
>>> That is the point, but please don't add a function called "make-delete-
>>> dependencies-phase". We have lambda. We can easily add with-atomic-
>>> json-replacement. We can also add a "delete-dependencies" function
>>> that takes a json and a list of dependencies if you so want.
>>>
>>> So in short
>>>
>>> (add-after 'patch-dependencies 'drop-junk
>>> (lambda _
>>> (with-atomic-json-replacement "package.json"
>>> (lambda (json) (delete-dependencies json '("node-tap"))))))
>>>
>>> would be the "verbose" style of disabling a list of dependencies.
>>>
>>
>> I think you are _really_ underestimating how many packages will need a
>> phase like this in the future. I would agree with this approach if it
>> were only needed incidentally, similar to the frequency of patching
>> version requirements in setup.py or requirements.txt for python
>> packages.
>>
>> Pretty much everything except the '("node-tap") list will be identical
>> between packages; how do you propose we reduce this duplication? At this
>> point I feel like I'm rehasing the opposite of your last point, so let
>> me rephrase; how many times do you want to see/type/copy+paste the above
>> snippet before you would consider exposing this functionality on a
>> higher level?
>>
>
> Additionally, I think having a phase in '%standard-phases' is a good way of
> addressing the need to use 'delete-dependencies' after the
> 'patch-dependencies' phase, which I explain in patch v6 05/41.
>
> But, again, I could live with either v6 or v7 being applied if one of them
> can achieve consensus.
>
> So, without further ado, here is v6!
>
> -Philip
>
> Philip McGrath (41):
> guix: node-build-system: Add delete-lockfiles phase.
> guix: node-build-system: Add implicit libuv input.
> guix: node-build-system: Add JSON utilities.
> guix: node-build-system: Add avoid-node-gyp-rebuild phase.
> guix: node-build-system: Add 'delete-dependencies' helper function.
> gnu: node-semver-bootstrap: Use 'delete-dependencies'.
> gnu: node-ms-bootstrap: Use 'delete-dependencies'.
> gnu: node-binary-search-bootstrap: Use 'delete-dependencies'.
> gnu: node-debug-bootstrap: Use 'delete-dependencies'.
> gnu: node-llparse-builder-bootstrap: Use 'delete-dependencies'.
> gnu: node-llparse-frontend-bootstrap: Use 'delete-dependencies'.
> gnu: node-llparse-bootstrap: Use 'delete-dependencies'.
> gnu: node-semver: Use 'delete-dependencies'.
> gnu: node-wrappy: Use 'delete-dependencies'.
> gnu: node-once: Use 'delete-dependencies'.
> gnu: node-irc-colors: Use 'delete-dependencies'.
> gnu: node-irc: Use 'delete-dependencies'.
> gnu: Add node-inherits.
> gnu: Add node-safe-buffer.
> gnu: Add node-string-decoder.
> gnu: Add node-readable-stream.
> gnu: Add node-nan.
> gnu: Add node-openzwave-shared.
> gnu: Add node-addon-api.
> gnu: Add node-sqlite3.
> gnu: Add node-file-uri-to-path.
> gnu: Add node-bindings.
> gnu: Add node-segfault-handler.
> gnu: Add node-ms.
> gnu: Add node-debug.
> gnu: Add node-serialport-binding-abstract.
> gnu: Add node-serialport-parser-delimiter.
> gnu: Add node-serialport-parser-readline.
> gnu: Add node-serialport-bindings.
> gnu: Add node-serialport-parser-regex.
> gnu: Add node-serialport-parser-ready.
> gnu: Add node-serialport-parser-inter-byte-timeout.
> gnu: Add node-serialport-parser-cctalk.
> gnu: Add node-serialport-parser-byte-length.
> gnu: Add node-serialport-stream.
> gnu: Add node-serialport.
>
> gnu/packages/node-xyz.scm | 1013 +++++++++++++++++++++++++++++-
> gnu/packages/node.scm | 78 ++-
> gnu/packages/zwave.scm | 64 ++
> guix/build-system/node.scm | 9 +-
> guix/build/node-build-system.scm | 355 ++++++++++-
> 5 files changed, 1464 insertions(+), 55 deletions(-)
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument.
2021-12-20 19:33 ` Philip McGrath
2021-12-20 20:15 ` Timothy Sample
@ 2021-12-20 21:50 ` Liliana Marie Prikler
2021-12-20 23:10 ` Jelle Licht
1 sibling, 1 reply; 458+ messages in thread
From: Liliana Marie Prikler @ 2021-12-20 21:50 UTC (permalink / raw)
To: Philip McGrath, Timothy Sample; +Cc: 51838, Pierre Langlois, Jelle Licht
Hi,
Am Montag, dem 20.12.2021 um 14:33 -0500 schrieb Philip McGrath:
> Hi,
>
> On 12/18/21 20:02, Liliana Marie Prikler wrote:
> > Am Samstag, dem 18.12.2021 um 17:55 -0500 schrieb Philip McGrath:
> > > somewhat, but it was immensely helpful to be able to find in
> > > node-xyz.scm all of the packages that wanted, but did not have,
> > > node-debug. I imagine it would be even more useful in a more
> > > tangled dependency graph.
> > That might be beneficial in your particular use case here, but you
> > also have to think about the maintenance burden your mechanism
> > introduces. What if another leftpad happens and we have to speedrun
> > our core-updates cycle to add #:absent-dependencies everywhere?
>
> [...]
>
> Even if I assume a scenario that is going to be fixed by removing a
> hypothetical `node-left-pad` packages from all the packages to which
> it is an input, that would change O(n) lines of code: having to
> change #:absent-dependencies in all cases would just be O(2n) lines,
> which doesn't seem prohibitive.
Sure. While we're at it, let's add k #:absent-dependencies-esque
fields, because surely the big O notation is an accurate measurement of
painful monkey work.
We are talking about human labour and Kolmogorov complexity here, both
of which I'd like to keep low, kthxbye.
> Indeed, I think I would be glad to have an entry in #:absent-
> dependencies in such a case, communicating explicitly
> in the Guix repository that the package was affected and Guix
> packagers adopted a workaround.
This might be fine and dandy if you only have one or two packages which
actually need this crutch, but when you start summoning a demon from
the seventh layer of hell to make your particular pattern-obsessed
hello world program work, you will curse your past self for being so
stubborn and not implementing something that could leverage the
expressiveness of a programming language.
> If I'm later updating the package, I can check to see if the
> workaround is still needed or if upstream has dropped node-left-pad.
> In any case, I much prefer to have this written explicitly in code in
> the Guix repository, rather than relying on external mechanisms like
> build logs and upstream source files.
How are upstream sources not a source of truth here? If anything, you
would have to always check that whatever hack you employed back then
still produces a functional package and #:absent-dependencies is not
helping in that.
> Additionally, I think the use case I encountered with node-debug is
> likely to come up fairly often. For example, someone might notice
> that a lot of packages use `node-tap` for testing, package it for
> Guix, and then want to find all of the downstream packages to which
> to add it and enable tests.
Whoever contributes node-tap will not be responsible to update any
package that might want to take advantage of it. They can go out of
their way to add it, but the idea, that "I have to update 300 packages
in each and every patch set" is flawed from the get-go. We can rely on
the community's collective brain to either remember in the future that
node-tap was optional for some package and add it or to not care.
Whether they are aided by comments or glorified comments (or not) makes
little difference at that point.
> > Compare this to tests. We have a keyword to disable all tests,
> > which defaults to #f and we have other idioms for disabling
> > particular tests. Your use case is no different. If at all, we
> > should only have a keyword to disable the check completely and
> > other idioms to e.g. patch the package.json file so that sanity-
> > check/patch-dependencies/what-have-you doesn't error when it relies
> > on its contents.
>
> I don't mean to be dense, but I feel like I'm missing something. I
> assume the reason we don't have a declarative, high-level mechanism
> for disabling specific tests is that there isn't a general convention
> for doing that, AFAIK.
At least within GNU build system there's the convention of passing
TESTS="subset of tests you want" to your invocation of make check. The
meson code could also be adapted to such a use-case. It still doesn't
make sense to do so.
> We do have `#:configure-flags`, which can be used to pass things like
> `--disable-whatever`, even though, in principle, that could be done
> by replacing the configure phase.
Guess what, even with #:configure-flags, we have to replace the
configure phase to *only* use #:configure-flags in certain packages.
Then again, if node supported --without-left-pad, we wouldn't be here
discussing #:absent-dependencies, would we?
> I see #:absent-dependencies as similar: it provides, IMO, a readable,
> declarative mechanism to make a commonly-needed adjustment to the
> behavior of the patch-dependencies phase.
"Readable" is quite a stretch here. I prefer "parseable boilerplate".
What's more readable?
(#:strict? #f) ; node-tap...
(#:absent-dependencies '("node-tap" "node-tap-the-cloud" "node-tap-
more" "node-tap-pat" "node-tap-atapter" "node-tap-left-pad" [...]))
> To clarify, I thought you wanted `node-build-system` to issue a
> warning and drop dependencies not supplied as package inputs. Is that
> correct?
> In the existing code, if `key` is not found and `value` is returned,
> the configure phase (i.e. `npm install`) will always fail. (The name
> `patch-dependencies` may be a little vague about the actual purpose
> of this phase.)
Both statements are correct. My first suggestion was indeed to just
issue a warning, but after thinking about it harder, I feel as though
it shouldn't even be the responsibility of the patch-dependencies phase
to act as a generic json rewriting tool. The `patch-dependencies'
phase is simply named that because we're not Java and thereby have no
moral obligation to name it
patchDependenciesAndWhileYoureAtItAlsoInlineDevDependenciesIntoTheMainT
hingKThxBye.
Back then, I thought that rewriting the package.json to reflect the
inputs during build ought to be the simple and correct choice, but I do
agree that at certain times you might also be right and deleting a
single dependency from the tree is the correct option. So I think we
have a problem for which there cannot be a high-level solution in the
build system and we need to write #:phases into the packages, not the
build system. The build system does need to provide some primitives to
make that simple, though, e.g. with-atomic-json-replacement.
> > > We never change APIs gratuitously.
> > In my personal opinion, #:absent-dependencies would be a gratuitous
> > change in API. There's no need to have this in the build system.
> > We should rather look into ways that make it possible/easy for
> > users to patch the package.json file between unpack and configure.
>
> I don't think adding #:absent-dependencies is a breaking change in
> the API at all. Any package that builds currently should continue to
> build with #:absent-dependencies support added, and indeed with this
> entire patch series.
Merriam-Webster defines gratuitous as "don't fucking quote Merriam-
Webster during code review".
Your patch might itself not break anything, but the patch to remove it
and update it with something better will. And as an armchair software
architect, I sit firmly in the "do it right the first time" camp.
> > This also calls back to my earlier point of the assoc-set! being
> > out of place, which itself is also a manifestation of node-build-
> > system not exposing adequate primitives towards rewriting essential
> > files. For instance, the procedure
> >
> > (lambda (file proc)
> > (with-atomic-file-replacement file
> > (lambda (in out)
> > (write-json (proc (read-json in))))))
> >
> > would probably deserve its own name and export from node-build-
> > system.
> > Yes, you can export utility procedures from (guix build *-build-
> > system), look at the Emacs and Python build systems for example.
>
> I do agree that we should provide more utilities for transforming
> "package.json" in general ways. It would be nice to make such
> transformations at least as convenient as more fragile ones using
> `substitute*`. But, as I wrote earlier, that seems out of scope for
> this patch series.
If this is out-of-scope for the series, then so is #:absent-
dependencies. Please rewrite your series to not require a keyword
addition then and have fun building your new packages with substitute*.
I'm really not trying to be mean here in holding back your patch
without good reason, but I do think that there's enough things to fix
to require a v6 (perhaps even a v7, but let's stay optimistic) before
we can upstream this in good conscience. There's also the fact, that
(as Jelle pointed out) we've discussed more than we've written patches.
If I wanted to dictate a solution here, I could easily have submitted a
v6 on my own at some time during review, but in my personal opinion
that doesn't help much in reaching a consensus.
> > With this in place, we both get to have our cakes and eat it too.
> > There would be no keyword added, and package maintainers would drop
> > "absent" dependencies in a phase like so
> >
> > (add-after 'unpack 'drop-dependencies
> > (lambda _
> > (with-atomic-json-replacement "package.json"
> > (lambda (json)
> > (map (match-lambda
> > (('dependencies '@ . DEPENDENCIES)
> > (filter away unwanted dependencies))
> > (('devDependencies '@ . DEPENDENCIES)
> > (same))
> > (otherwise otherwise))
> > json)))))
> >
> > Of course, if that's too verbose, you can also expose that as a
> > function from node-build-system. Then all we'd have to bikeshed is
> > the name, which would be comparatively simple.
> >
> > Does that sound like a reasonable plan to you?
>
> I'm not sure how to proceed here.
>
> I still think the #:absent-dependencies keyword, with or without a
> "warn" mode, is the best approach. It has sounded like others on this
> thread also liked the approach, though I don't want to speak for
> anyone but myself.
>
> I can understand that you would prefer a different approach. I can
> see how a warn-and-ignore could be useful in some cases. My last
> proposal was an attempt at a compromise, showing how adding
> #:absent-dependencies would not preclude adding support for a warn-
> and-ignore mode later.
>
> But the impression I'm getting is that you think the
> #:absent-dependencies approach would be not merely sub-optimal but
> actively harmful, and, if that is indeed your view, I feel like I'm
> still failing to understand what the harm is.
#:absent-dependencies is brittle boilerplate and at the same time
extremely limited.
My initially suggested "warn, not fail" is somewhat less limited and
not boilerplate, but still brittle in another way (giving gratuitous
runtime errors).
Adding a phase opens up all the power of Guile Scheme, making the
package exactly as sensitive to errors as you want it to be, plus it
requires only minimal change in the API in the form of more exported
functions, but no changed calling conventions.
There ought to be no question as to which option is the superior one
here :)
> If we took your final suggestion above, I think we'd have something
> like this:
>
> ```
> #:phases
> (modify-phases %standard-phases
> (add-after 'unpack 'delete-dependencies
> (make-delete-dependencies-phase '("node-tap"))))
> ```
>
> That seems pretty similar to, under the current patch series:
>
> ```
> #:absent-dependencies '("node-tap")
> ```
That is the point, but please don't add a function called "make-delete-
dependencies-phase". We have lambda. We can easily add with-atomic-
json-replacement. We can also add a "delete-dependencies" function
that takes a json and a list of dependencies if you so want.
So in short
(add-after 'patch-dependencies 'drop-junk
(lambda _
(with-atomic-json-replacement "package.json"
(lambda (json) (delete-dependencies json '("node-tap"))))))
would be the "verbose" style of disabling a list of dependencies.
> I can see pros and cons to both approaches. I still like
> `#:absent-dependencies` better, as I find it less verbose, more
> declarative, ... trade-offs we probably don't need to rehash further.
> But it sounds like you see a huge, prohibitive downside to
> `#:absent-dependencies`, and I am just not managing to see what that
> is.
If you want something that's not verbose and declarative, implement
#:strict? #f. #:absent-dependencies is extremely verbose for what it
achieves, particularly when we think about the implementation as well.
> I don't know what further steps to take to resolve this disagreement
> or how some decision ultimately gets made.
>
> More broadly, I agree with you that the current `node-build-system`
> has some ugly code and is missing some useful utility functions. But
> I don't feel like I can address all of those preexisting issues in
> the scope of this patch series, which has already become somewhat
> unwieldy.
>
> Maybe someone else could weigh in on how to proceed?
To be clear, I never demanded you fix all the bad code in node-build-
system or something like that. I only pointed out issues, which are
adjacent to the patch set at hand and more importantly those that we
could "easily" fix with tools that we already have at our disposal.
Perhaps I am misjudging the difficulty of some tasks involved here, but
I haven't really seen a call for help in your replies. If you do think
I'm pushing unfair amounts of work onto you, please say so. If not,
then happy hacking :)
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument.
2021-12-20 21:50 ` [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument Liliana Marie Prikler
@ 2021-12-20 23:10 ` Jelle Licht
2021-12-20 23:33 ` Philip McGrath
0 siblings, 1 reply; 458+ messages in thread
From: Jelle Licht @ 2021-12-20 23:10 UTC (permalink / raw)
To: Liliana Marie Prikler, Philip McGrath, Timothy Sample
Cc: 51838, Pierre Langlois
Hey folks,
Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
> Hi,
>
> Am Montag, dem 20.12.2021 um 14:33 -0500 schrieb Philip McGrath:
>> Hi,
>>
>> On 12/18/21 20:02, Liliana Marie Prikler wrote:
>> > Am Samstag, dem 18.12.2021 um 17:55 -0500 schrieb Philip McGrath:
>> > > somewhat, but it was immensely helpful to be able to find in
>> > > node-xyz.scm all of the packages that wanted, but did not have,
>> > > node-debug. I imagine it would be even more useful in a more
>> > > tangled dependency graph.
>> > That might be beneficial in your particular use case here, but you
>> > also have to think about the maintenance burden your mechanism
>> > introduces. What if another leftpad happens and we have to speedrun
>> > our core-updates cycle to add #:absent-dependencies everywhere?
>>
>> [...]
>>
>> Even if I assume a scenario that is going to be fixed by removing a
>> hypothetical `node-left-pad` packages from all the packages to which
>> it is an input, that would change O(n) lines of code: having to
>> change #:absent-dependencies in all cases would just be O(2n) lines,
>> which doesn't seem prohibitive.
> Sure. While we're at it, let's add k #:absent-dependencies-esque
> fields, because surely the big O notation is an accurate measurement of
> painful monkey work.
>
> We are talking about human labour and Kolmogorov complexity here, both
> of which I'd like to keep low, kthxbye.
I think we are drifting a bit off-topic here.
>> Indeed, I think I would be glad to have an entry in #:absent-
>> dependencies in such a case, communicating explicitly
>> in the Guix repository that the package was affected and Guix
>> packagers adopted a workaround.
> This might be fine and dandy if you only have one or two packages which
> actually need this crutch, but when you start summoning a demon from
> the seventh layer of hell to make your particular pattern-obsessed
> hello world program work, you will curse your past self for being so
> stubborn and not implementing something that could leverage the
> expressiveness of a programming language.
>
>> If I'm later updating the package, I can check to see if the
>> workaround is still needed or if upstream has dropped node-left-pad.
>> In any case, I much prefer to have this written explicitly in code in
>> the Guix repository, rather than relying on external mechanisms like
>> build logs and upstream source files.
> How are upstream sources not a source of truth here? If anything, you
> would have to always check that whatever hack you employed back then
> still produces a functional package and #:absent-dependencies is not
> helping in that.
>> Additionally, I think the use case I encountered with node-debug is
>> likely to come up fairly often. For example, someone might notice
>> that a lot of packages use `node-tap` for testing, package it for
>> Guix, and then want to find all of the downstream packages to which
>> to add it and enable tests.
> Whoever contributes node-tap will not be responsible to update any
> package that might want to take advantage of it. They can go out of
> their way to add it, but the idea, that "I have to update 300 packages
> in each and every patch set" is flawed from the get-go. We can rely on
> the community's collective brain to either remember in the future that
> node-tap was optional for some package and add it or to not care.
> Whether they are aided by comments or glorified comments (or not) makes
> little difference at that point.
>> > Compare this to tests. We have a keyword to disable all tests,
>> > which defaults to #f and we have other idioms for disabling
>> > particular tests. Your use case is no different. If at all, we
>> > should only have a keyword to disable the check completely and
>> > other idioms to e.g. patch the package.json file so that sanity-
>> > check/patch-dependencies/what-have-you doesn't error when it relies
>> > on its contents.
>>
>> I don't mean to be dense, but I feel like I'm missing something. I
>> assume the reason we don't have a declarative, high-level mechanism
>> for disabling specific tests is that there isn't a general convention
>> for doing that, AFAIK.
> At least within GNU build system there's the convention of passing
> TESTS="subset of tests you want" to your invocation of make check. The
> meson code could also be adapted to such a use-case. It still doesn't
> make sense to do so.
>
What are you arguing against/for?
>> We do have `#:configure-flags`, which can be used to pass things like
>> `--disable-whatever`, even though, in principle, that could be done
>> by replacing the configure phase.
> Guess what, even with #:configure-flags, we have to replace the
> configure phase to *only* use #:configure-flags in certain packages.
> Then again, if node supported --without-left-pad, we wouldn't be here
> discussing #:absent-dependencies, would we?
>
>> I see #:absent-dependencies as similar: it provides, IMO, a readable,
>> declarative mechanism to make a commonly-needed adjustment to the
>> behavior of the patch-dependencies phase.
> "Readable" is quite a stretch here. I prefer "parseable boilerplate".
> What's more readable?
>
> (#:strict? #f) ; node-tap...
> (#:absent-dependencies '("node-tap" "node-tap-the-cloud" "node-tap-
> more" "node-tap-pat" "node-tap-atapter" "node-tap-left-pad" [...]))
>
I'm guessing that's a retorical question, but I vastly prefer the second
over the first because it is parseable boilerplate:
- This means we could add a transformation to define package variants
- This also means we could programmatically rewrite some of this code
later, `guix style'-style.
With the first approach you are 'stuck' with something that no sane
person will ever manually refactor for any significant number of
packages.
>> To clarify, I thought you wanted `node-build-system` to issue a
>> warning and drop dependencies not supplied as package inputs. Is that
>> correct?
>> In the existing code, if `key` is not found and `value` is returned,
>> the configure phase (i.e. `npm install`) will always fail. (The name
>> `patch-dependencies` may be a little vague about the actual purpose
>> of this phase.)
> Both statements are correct. My first suggestion was indeed to just
> issue a warning, but after thinking about it harder, I feel as though
> it shouldn't even be the responsibility of the patch-dependencies phase
> to act as a generic json rewriting tool. The `patch-dependencies'
> phase is simply named that because we're not Java and thereby have no
> moral obligation to name it
> patchDependenciesAndWhileYoureAtItAlsoInlineDevDependenciesIntoTheMainT
> hingKThxBye.
>
> Back then, I thought that rewriting the package.json to reflect the
> inputs during build ought to be the simple and correct choice, but I do
> agree that at certain times you might also be right and deleting a
> single dependency from the tree is the correct option. So I think we
> have a problem for which there cannot be a high-level solution in the
> build system and we need to write #:phases into the packages, not the
> build system. The build system does need to provide some primitives to
> make that simple, though, e.g. with-atomic-json-replacement.
>
>> > > We never change APIs gratuitously.
>> > In my personal opinion, #:absent-dependencies would be a gratuitous
>> > change in API. There's no need to have this in the build system.
>> > We should rather look into ways that make it possible/easy for
>> > users to patch the package.json file between unpack and configure.
>>
>> I don't think adding #:absent-dependencies is a breaking change in
>> the API at all. Any package that builds currently should continue to
>> build with #:absent-dependencies support added, and indeed with this
>> entire patch series.
> Merriam-Webster defines gratuitous as "don't fucking quote Merriam-
> Webster during code review".
> Your patch might itself not break anything, but the patch to remove it
> and update it with something better will. And as an armchair software
> architect, I sit firmly in the "do it right the first time" camp.
>
Too late for that I'm afraid :).
>> > This also calls back to my earlier point of the assoc-set! being
>> > out of place, which itself is also a manifestation of node-build-
>> > system not exposing adequate primitives towards rewriting essential
>> > files. For instance, the procedure
>> >
>> > (lambda (file proc)
>> > (with-atomic-file-replacement file
>> > (lambda (in out)
>> > (write-json (proc (read-json in))))))
>> >
>> > would probably deserve its own name and export from node-build-
>> > system.
>> > Yes, you can export utility procedures from (guix build *-build-
>> > system), look at the Emacs and Python build systems for example.
>>
>> I do agree that we should provide more utilities for transforming
>> "package.json" in general ways. It would be nice to make such
>> transformations at least as convenient as more fragile ones using
>> `substitute*`. But, as I wrote earlier, that seems out of scope for
>> this patch series.
> If this is out-of-scope for the series, then so is #:absent-
> dependencies. Please rewrite your series to not require a keyword
> addition then and have fun building your new packages with substitute*.
I think this is an unfair assesment.
>
> I'm really not trying to be mean here in holding back your patch
> without good reason, but I do think that there's enough things to fix
> to require a v6 (perhaps even a v7, but let's stay optimistic) before
> we can upstream this in good conscience. There's also the fact, that
> (as Jelle pointed out) we've discussed more than we've written patches.
> If I wanted to dictate a solution here, I could easily have submitted a
> v6 on my own at some time during review, but in my personal opinion
> that doesn't help much in reaching a consensus.
>
My poor T400 takes about 10 seconds to render the entire conversation,
indeed.
>> > With this in place, we both get to have our cakes and eat it too.
>> > There would be no keyword added, and package maintainers would drop
>> > "absent" dependencies in a phase like so
>> >
>> > (add-after 'unpack 'drop-dependencies
>> > (lambda _
>> > (with-atomic-json-replacement "package.json"
>> > (lambda (json)
>> > (map (match-lambda
>> > (('dependencies '@ . DEPENDENCIES)
>> > (filter away unwanted dependencies))
>> > (('devDependencies '@ . DEPENDENCIES)
>> > (same))
>> > (otherwise otherwise))
>> > json)))))
>> >
>> > Of course, if that's too verbose, you can also expose that as a
>> > function from node-build-system. Then all we'd have to bikeshed is
>> > the name, which would be comparatively simple.
>> >
>> > Does that sound like a reasonable plan to you?
>>
>> I'm not sure how to proceed here.
>>
>> I still think the #:absent-dependencies keyword, with or without a
>> "warn" mode, is the best approach. It has sounded like others on this
>> thread also liked the approach, though I don't want to speak for
>> anyone but myself.
>>
>> I can understand that you would prefer a different approach. I can
>> see how a warn-and-ignore could be useful in some cases. My last
>> proposal was an attempt at a compromise, showing how adding
>> #:absent-dependencies would not preclude adding support for a warn-
>> and-ignore mode later.
>>
>> But the impression I'm getting is that you think the
>> #:absent-dependencies approach would be not merely sub-optimal but
>> actively harmful, and, if that is indeed your view, I feel like I'm
>> still failing to understand what the harm is.
> #:absent-dependencies is brittle boilerplate and at the same time
> extremely limited.
> My initially suggested "warn, not fail" is somewhat less limited and
> not boilerplate, but still brittle in another way (giving gratuitous
> runtime errors).
> Adding a phase opens up all the power of Guile Scheme, making the
> package exactly as sensitive to errors as you want it to be, plus it
> requires only minimal change in the API in the form of more exported
> functions, but no changed calling conventions.
>
> There ought to be no question as to which option is the superior one
> here :)
>
To be fair, you can always add a phase (and remove existing phases), so
this is a bit of a silly argument. Power of Guile Scheme and all that ;)
>> If we took your final suggestion above, I think we'd have something
>> like this:
>>
>> ```
>> #:phases
>> (modify-phases %standard-phases
>> (add-after 'unpack 'delete-dependencies
>> (make-delete-dependencies-phase '("node-tap"))))
>> ```
>>
>> That seems pretty similar to, under the current patch series:
>>
>> ```
>> #:absent-dependencies '("node-tap")
>> ```
> That is the point, but please don't add a function called "make-delete-
> dependencies-phase". We have lambda. We can easily add with-atomic-
> json-replacement. We can also add a "delete-dependencies" function
> that takes a json and a list of dependencies if you so want.
>
> So in short
>
> (add-after 'patch-dependencies 'drop-junk
> (lambda _
> (with-atomic-json-replacement "package.json"
> (lambda (json) (delete-dependencies json '("node-tap"))))))
>
> would be the "verbose" style of disabling a list of dependencies.
>
I think you are _really_ underestimating how many packages will need a
phase like this in the future. I would agree with this approach if it
were only needed incidentally, similar to the frequency of patching
version requirements in setup.py or requirements.txt for python
packages.
Pretty much everything except the '("node-tap") list will be identical
between packages; how do you propose we reduce this duplication? At this
point I feel like I'm rehasing the opposite of your last point, so let
me rephrase; how many times do you want to see/type/copy+paste the above
snippet before you would consider exposing this functionality on a
higher level?
>> I can see pros and cons to both approaches. I still like
>> `#:absent-dependencies` better, as I find it less verbose, more
>> declarative, ... trade-offs we probably don't need to rehash further.
>> But it sounds like you see a huge, prohibitive downside to
>> `#:absent-dependencies`, and I am just not managing to see what that
>> is.
> If you want something that's not verbose and declarative, implement
> #:strict? #f. #:absent-dependencies is extremely verbose for what it
> achieves, particularly when we think about the implementation as well.
>
This would be the equivalent to 'magically' patching out any dependency
that guix can't find. I like it in principle, but how is this
functionally different from the current approach of simply not checking
any node dependencies by deleting the configure phase? Perhaps I
misunderstood something somewhere along the way.
>> I don't know what further steps to take to resolve this disagreement
>> or how some decision ultimately gets made.
>>
>> More broadly, I agree with you that the current `node-build-system`
>> has some ugly code and is missing some useful utility functions. But
>> I don't feel like I can address all of those preexisting issues in
>> the scope of this patch series, which has already become somewhat
>> unwieldy.
>>
>> Maybe someone else could weigh in on how to proceed?
> To be clear, I never demanded you fix all the bad code in node-build-
> system or something like that. I only pointed out issues, which are
> adjacent to the patch set at hand and more importantly those that we
> could "easily" fix with tools that we already have at our disposal.
> Perhaps I am misjudging the difficulty of some tasks involved here, but
> I haven't really seen a call for help in your replies. If you do think
> I'm pushing unfair amounts of work onto you, please say so. If not,
> then happy hacking :)
I believe the best thing to do would be to push the earlier
uncontroversial node patches.
Perhaps we can get some of the gurus/victims of other build systems
involved on guix-devel as none of the fundamental issues you've been
talking about for a while are node-specific. As long as we want to reach
some kind on consensus, I believe writing/reviewing more code does not
get us to a desirable outcome at this time.
- Jelle
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument.
2021-12-20 23:10 ` Jelle Licht
@ 2021-12-20 23:33 ` Philip McGrath
0 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-20 23:33 UTC (permalink / raw)
To: Jelle Licht, Liliana Marie Prikler, Timothy Sample; +Cc: 51838, Pierre Langlois
Hi Jelle,
Here's a short answer to one specific question:
On 12/20/21 18:10, Jelle Licht wrote:
> Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
>> Am Montag, dem 20.12.2021 um 14:33 -0500 schrieb Philip McGrath:
>>> I can see pros and cons to both approaches. I still like
>>> `#:absent-dependencies` better, as I find it less verbose, more
>>> declarative, ... trade-offs we probably don't need to rehash further.
>>> But it sounds like you see a huge, prohibitive downside to
>>> `#:absent-dependencies`, and I am just not managing to see what that
>>> is.
>> If you want something that's not verbose and declarative, implement
>> #:strict? #f. #:absent-dependencies is extremely verbose for what it
>> achieves, particularly when we think about the implementation as well.
>>
>
> This would be the equivalent to 'magically' patching out any dependency
> that guix can't find. I like it in principle, but how is this
> functionally different from the current approach of simply not checking
> any node dependencies by deleting the configure phase? Perhaps I
> misunderstood something somewhere along the way.
One key difference between the proposed `#:strict? #f` and the current
status quo of `(delete 'configure)` is that, at least as I've understood
the proposal, the patch-dependencies phase would still remove the
(implicitly detected) absent dependencies from the "package.json", so
the configure phase would be able to run `npm install`. That would fix
the problem I described back in <https://issues.guix.gnu.org/51838#13>
(a month ago), and the native packages would successfully build.
I think it would be a less good option for the reasons you state, and
which I've argued for elsewhere, but it's important to be clear that it
would solve the problem building these packages.
Actually, in an ideal world, I would agree with Liliana that
#:absent-dependencies ought to be out of scope for this patch series.
However, the existing solution for the problem of missing
dependencies---deleting the configure phase entirely---does not work for
packages that need to build native add-ons. So, if I needed to solve the
problem for the native add-on packages, I thought I should find a
generally-applicable solution that, in my view, is an improvement for
the existing packages as well.
More soon,
Philip
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 08/45] gnu: node-semver-bootstrap: Use #:absent-dependencies.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (6 preceding siblings ...)
2021-12-17 2:02 ` [bug#51838] [PATCH v5 07/45] guix: node-build-system: Add #:absent-dependencies argument Philip McGrath
@ 2021-12-17 2:02 ` Philip McGrath
2021-12-17 2:02 ` [bug#51838] [PATCH v5 09/45] gnu: node-ms-bootstrap: " Philip McGrath
` (36 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:02 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node.scm (node-semver-bootstrap)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node.scm | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 51a393caab..95f5f28b3d 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -344,9 +344,8 @@ (define-public node-semver-bootstrap
(arguments
`(#:node ,node-bootstrap
#:tests? #f
- #:phases
- (modify-phases %standard-phases
- (delete 'configure))))
+ #:absent-dependencies
+ '("tap")))
(home-page "https://github.com/npm/node-semver")
(properties '((hidden? . #t)))
(synopsis "Parses semantic versions strings")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 09/45] gnu: node-ms-bootstrap: Use #:absent-dependencies.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (7 preceding siblings ...)
2021-12-17 2:02 ` [bug#51838] [PATCH v5 08/45] gnu: node-semver-bootstrap: Use #:absent-dependencies Philip McGrath
@ 2021-12-17 2:02 ` Philip McGrath
2021-12-17 2:02 ` [bug#51838] [PATCH v5 10/45] gnu: node-binary-search-bootstrap: " Philip McGrath
` (35 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:02 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node.scm (node-ms-bootstrap)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node.scm | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 95f5f28b3d..bec3f4620a 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -372,9 +372,12 @@ (define-public node-ms-bootstrap
(arguments
`(#:node ,node-bootstrap
#:tests? #f
- #:phases
- (modify-phases %standard-phases
- (delete 'configure))))
+ #:absent-dependencies
+ `("eslint"
+ "expect.js"
+ "husky"
+ "lint-staged"
+ "mocha")))
(home-page "https://github.com/zeit/ms#readme")
(properties '((hidden? . #t)))
(synopsis "Tiny millisecond conversion utility")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 10/45] gnu: node-binary-search-bootstrap: Use #:absent-dependencies.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (8 preceding siblings ...)
2021-12-17 2:02 ` [bug#51838] [PATCH v5 09/45] gnu: node-ms-bootstrap: " Philip McGrath
@ 2021-12-17 2:02 ` Philip McGrath
2021-12-17 2:02 ` [bug#51838] [PATCH v5 11/45] gnu: node-debug-bootstrap: " Philip McGrath
` (34 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:02 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node.scm (node-binary-search-bootstrap)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node.scm | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index bec3f4620a..0a66b032bb 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -403,9 +403,9 @@ (define-public node-binary-search-bootstrap
(arguments
`(#:node ,node-bootstrap
#:tests? #f
- #:phases
- (modify-phases %standard-phases
- (delete 'configure))))
+ #:absent-dependencies
+ `("chai"
+ "mocha")))
(home-page "https://github.com/darkskyapp/binary-search#readme")
(properties '((hidden? . #t)))
(synopsis "Tiny binary search function with comparators")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 11/45] gnu: node-debug-bootstrap: Use #:absent-dependencies.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (9 preceding siblings ...)
2021-12-17 2:02 ` [bug#51838] [PATCH v5 10/45] gnu: node-binary-search-bootstrap: " Philip McGrath
@ 2021-12-17 2:02 ` Philip McGrath
2021-12-17 2:02 ` [bug#51838] [PATCH v5 12/45] gnu: node-llparse-builder-bootstrap: " Philip McGrath
` (33 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:02 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node.scm (node-debug-bootstrap)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node.scm | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 0a66b032bb..985a2fdb20 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -430,9 +430,18 @@ (define-public node-debug-bootstrap
(arguments
`(#:node ,node-bootstrap
#:tests? #f
- #:phases
- (modify-phases %standard-phases
- (delete 'configure))))
+ #:absent-dependencies
+ `("brfs"
+ "browserify"
+ "coveralls"
+ "istanbul"
+ "karma"
+ "karma-browserify"
+ "karma-chrome-launcher"
+ "karma-mocha"
+ "mocha"
+ "mocha-lcov-reporter"
+ "xo")))
(inputs (list node-ms-bootstrap))
(home-page "https://github.com/visionmedia/debug#readme")
(properties '((hidden? . #t)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 12/45] gnu: node-llparse-builder-bootstrap: Use #:absent-dependencies.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (10 preceding siblings ...)
2021-12-17 2:02 ` [bug#51838] [PATCH v5 11/45] gnu: node-debug-bootstrap: " Philip McGrath
@ 2021-12-17 2:02 ` Philip McGrath
2021-12-17 2:02 ` [bug#51838] [PATCH v5 13/45] gnu: node-llparse-frontend-bootstrap: " Philip McGrath
` (32 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:02 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node.scm (node-llparse-builder-bootstrap)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node.scm | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 985a2fdb20..31df15ffc3 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -493,9 +493,15 @@ (define-public node-llparse-builder-bootstrap
(arguments
`(#:node ,node-bootstrap
#:tests? #f
+ #:absent-dependencies
+ `("@types/mocha"
+ "@types/node"
+ "mocha"
+ "ts-node"
+ "tslint"
+ "typescript")
#:phases
(modify-phases %standard-phases
- (delete 'configure)
(replace 'build
(lambda* (#:key inputs #:allow-other-keys)
(let ((esbuild (search-input-file inputs "/bin/esbuild")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 13/45] gnu: node-llparse-frontend-bootstrap: Use #:absent-dependencies.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (11 preceding siblings ...)
2021-12-17 2:02 ` [bug#51838] [PATCH v5 12/45] gnu: node-llparse-builder-bootstrap: " Philip McGrath
@ 2021-12-17 2:02 ` Philip McGrath
2021-12-17 2:02 ` [bug#51838] [PATCH v5 14/45] gnu: node-llparse-bootstrap: " Philip McGrath
` (31 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:02 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node.scm (node-llparse-frontend-bootstrap)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node.scm | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 31df15ffc3..4d3db6a8ea 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -553,9 +553,16 @@ (define-public node-llparse-frontend-bootstrap
(arguments
`(#:node ,node-bootstrap
#:tests? #f
+ #:absent-dependencies
+ `("@types/debug"
+ "@types/mocha"
+ "@types/node"
+ "mocha"
+ "ts-node"
+ "tslint"
+ "typescript")
#:phases
(modify-phases %standard-phases
- (delete 'configure)
(replace 'build
(lambda* (#:key inputs #:allow-other-keys)
(let ((esbuild (search-input-file inputs "/bin/esbuild")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 14/45] gnu: node-llparse-bootstrap: Use #:absent-dependencies.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (12 preceding siblings ...)
2021-12-17 2:02 ` [bug#51838] [PATCH v5 13/45] gnu: node-llparse-frontend-bootstrap: " Philip McGrath
@ 2021-12-17 2:02 ` Philip McGrath
2021-12-17 2:02 ` [bug#51838] [PATCH v5 15/45] gnu: node-semver: " Philip McGrath
` (30 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:02 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node.scm (node-llparse-bootstrap)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node.scm | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 4d3db6a8ea..f952119a9f 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -613,9 +613,18 @@ (define-public node-llparse-bootstrap
(arguments
`(#:node ,node-bootstrap
#:tests? #f
+ #:absent-dependencies
+ `("@types/debug"
+ "@types/mocha"
+ "@types/node"
+ "esm"
+ "llparse-test-fixture"
+ "mocha"
+ "ts-node"
+ "tslint"
+ "typescript")
#:phases
(modify-phases %standard-phases
- (delete 'configure)
(replace 'build
(lambda* (#:key inputs #:allow-other-keys)
(let ((esbuild (search-input-file inputs "/bin/esbuild")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 15/45] gnu: node-semver: Use #:absent-dependencies.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (13 preceding siblings ...)
2021-12-17 2:02 ` [bug#51838] [PATCH v5 14/45] gnu: node-llparse-bootstrap: " Philip McGrath
@ 2021-12-17 2:02 ` Philip McGrath
2021-12-17 2:02 ` [bug#51838] [PATCH v5 16/45] gnu: node-wrappy: " Philip McGrath
` (29 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:02 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node-xyz.scm (node-semver)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node-xyz.scm | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 9a0be96852..bd72eea807 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -288,11 +288,10 @@ (define-public node-semver
"06biknqb05r9xsmcflm3ygh50pjvdk84x6r79w43kmck4fn3qn5p"))))
(build-system node-build-system)
(arguments
- '(#:tests? #f ; FIXME: Tests depend on node-tap
- #:phases
- (modify-phases %standard-phases
- ;; The only dependency to check for is tap, which we don't have.
- (delete 'configure))))
+ '(#:absent-dependencies
+ '("tap")
+ ;; FIXME: Tests depend on node-tap
+ #:tests? #f))
(home-page "https://github.com/npm/node-semver")
(synopsis "Parses semantic versions strings")
(description
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 16/45] gnu: node-wrappy: Use #:absent-dependencies.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (14 preceding siblings ...)
2021-12-17 2:02 ` [bug#51838] [PATCH v5 15/45] gnu: node-semver: " Philip McGrath
@ 2021-12-17 2:02 ` Philip McGrath
2021-12-17 2:02 ` [bug#51838] [PATCH v5 17/45] gnu: node-once: " Philip McGrath
` (28 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:02 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node-xyz.scm (node-wrappy)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node-xyz.scm | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index bd72eea807..ceef48887e 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -315,10 +315,8 @@ (define-public node-wrappy
(build-system node-build-system)
(arguments
'(#:tests? #f ; FIXME: Tests depend on node-tap
- #:phases
- (modify-phases %standard-phases
- ;; The only dependency to check for is tap, which we don't have.
- (delete 'configure))))
+ #:absent-dependencies
+ '("tap")))
(home-page "https://github.com/npm/wrappy")
(synopsis "Callback wrapping utility")
(description "@code{wrappy} is a utility for Node.js to wrap callbacks.")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 17/45] gnu: node-once: Use #:absent-dependencies.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (15 preceding siblings ...)
2021-12-17 2:02 ` [bug#51838] [PATCH v5 16/45] gnu: node-wrappy: " Philip McGrath
@ 2021-12-17 2:02 ` Philip McGrath
2021-12-17 2:02 ` [bug#51838] [PATCH v5 18/45] gnu: node-irc-colors: " Philip McGrath
` (27 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:02 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node-xyz.scm (node-once)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node-xyz.scm | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index ceef48887e..9e602fd0e8 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -337,13 +337,10 @@ (define-public node-once
"1z8dcbf28dqdcp4wb0c53wrs90a07nkrax2c9kk26dsk1dhrnxav"))))
(build-system node-build-system)
(arguments
- '(#:tests? #f ; FIXME: tests depend on node-tap
- #:phases
- (modify-phases %standard-phases
- ;; The default configure phase fails due to tap being missing, as we do
- ;; not have tap packaged yet. It is used only for tests. This package
- ;; still works as a dependency of node-glob and node-inflight.
- (delete 'configure))))
+ '(#:absent-dependencies
+ '("tap")
+ ;; FIXME: Tests depend on node-tap
+ #:tests? #f))
(inputs
(list node-wrappy))
(home-page "https://github.com/isaacs/once")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 18/45] gnu: node-irc-colors: Use #:absent-dependencies.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (16 preceding siblings ...)
2021-12-17 2:02 ` [bug#51838] [PATCH v5 17/45] gnu: node-once: " Philip McGrath
@ 2021-12-17 2:02 ` Philip McGrath
2021-12-17 2:02 ` [bug#51838] [PATCH v5 19/45] gnu: node-irc: " Philip McGrath
` (26 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:02 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node-xyz.scm (node-irc-colors)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node-xyz.scm | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 9e602fd0e8..6c3811528a 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -366,12 +366,10 @@ (define-public node-irc-colors
"0q3y34rbnlc55jcakmdxkicwazyvyph9r6gaf6hi8k7wj2nfwfli"))))
(build-system node-build-system)
(arguments
- '(#:tests? #f ; FIXME: tests depend on node-istanbul
- #:phases
- (modify-phases %standard-phases
- ;; The default configure phase fails due to various packages
- ;; being missing, as we don't have them packaged yet.
- (delete 'configure))))
+ '(#:absent-dependencies
+ `("istanbul"
+ "vows")
+ #:tests? #f))
(home-page "https://github.com/fent/irc-colors.js")
(synopsis "Node.js module providing color and formatting for IRC")
(description "@code{node-irc-colors} is a Node.js module that
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 19/45] gnu: node-irc: Use #:absent-dependencies.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (17 preceding siblings ...)
2021-12-17 2:02 ` [bug#51838] [PATCH v5 18/45] gnu: node-irc-colors: " Philip McGrath
@ 2021-12-17 2:02 ` Philip McGrath
2021-12-17 2:03 ` [bug#51838] [PATCH v5 20/45] guix: node-build-system: Add implicit libuv input Philip McGrath
` (25 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:02 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
gnu/packages/node-xyz.scm (node-irc)[arguments]: Add
`#:absent-dependencies`. Stop deleting the `'configure` phase.
---
gnu/packages/node-xyz.scm | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 6c3811528a..93bd067311 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -393,12 +393,12 @@ (define-public node-irc
"1ln4qfx20jbwg4cp8lp0vf27m5281z2sz16d15xd6150n26cbi4x"))))
(build-system node-build-system)
(arguments
- '(#:tests? #f ; FIXME: tests depend on node-faucet
- #:phases
- (modify-phases %standard-phases
- ;; The default configure phase fails due to various packages
- ;; being missing, as we don't have them packaged yet.
- (delete 'configure))))
+ '(#:absent-dependencies
+ `("ansi-color"
+ "faucet"
+ "jscs"
+ "tape")
+ #:tests? #f))
(inputs
(list node-irc-colors))
(home-page "https://github.com/martynsmith/node-irc")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 20/45] guix: node-build-system: Add implicit libuv input.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (18 preceding siblings ...)
2021-12-17 2:02 ` [bug#51838] [PATCH v5 19/45] gnu: node-irc: " Philip McGrath
@ 2021-12-17 2:03 ` Philip McGrath
2021-12-17 5:08 ` Liliana Marie Prikler
2021-12-17 2:03 ` [bug#51838] [PATCH v5 21/45] guix: node-build-system: Add avoid-node-gyp-rebuild phase Philip McGrath
` (24 subsequent siblings)
44 siblings, 1 reply; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:03 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* guix/build-system/node.scm (lower): Add the version of libuv
used as an input to the #:node package as an additional implicit
input, so that packages needing libuv always get the correct version.
---
guix/build-system/node.scm | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/guix/build-system/node.scm b/guix/build-system/node.scm
index 330d10dca5..47af4bb9e2 100644
--- a/guix/build-system/node.scm
+++ b/guix/build-system/node.scm
@@ -2,6 +2,8 @@
;;; Copyright © 2016 Jelle Licht <jlicht@fsfe.org>
;;; Copyright © 2019 Timothy Sample <samplet@ngyro.com>
;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2021 Pierre Langlois <pierre.langlois@gmx.com>
+;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -62,10 +64,15 @@ (define private-keywords
`(("source" ,source))
'())
,@inputs
-
;; Keep the standard inputs of 'gnu-build-system'.
,@(standard-packages)))
(build-inputs `(("node" ,node)
+ ;; Many packages with native addons need
+ ;; libuv headers. The libuv version must
+ ;; be exactly the same as for the node
+ ;; package we are adding implicitly,
+ ;; so we take care of adding libuv, too.
+ ("libuv" ,@(assoc-ref (package-inputs node) "libuv"))
,@native-inputs))
(outputs outputs)
(build node-build)
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 20/45] guix: node-build-system: Add implicit libuv input.
2021-12-17 2:03 ` [bug#51838] [PATCH v5 20/45] guix: node-build-system: Add implicit libuv input Philip McGrath
@ 2021-12-17 5:08 ` Liliana Marie Prikler
2021-12-18 16:16 ` Philip McGrath
2021-12-18 17:07 ` Philip McGrath
0 siblings, 2 replies; 458+ messages in thread
From: Liliana Marie Prikler @ 2021-12-17 5:08 UTC (permalink / raw)
To: Philip McGrath, 51838; +Cc: Timothy Sample, Pierre Langlois, Jelle Licht
Am Donnerstag, dem 16.12.2021 um 21:03 -0500 schrieb Philip McGrath:
> * guix/build-system/node.scm (lower): Add the version of libuv
> used as an input to the #:node package as an additional implicit
> input, so that packages needing libuv always get the correct version.
> ---
> guix/build-system/node.scm | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/guix/build-system/node.scm b/guix/build-system/node.scm
> index 330d10dca5..47af4bb9e2 100644
> --- a/guix/build-system/node.scm
> +++ b/guix/build-system/node.scm
> @@ -2,6 +2,8 @@
> ;;; Copyright © 2016 Jelle Licht <jlicht@fsfe.org>
> ;;; Copyright © 2019 Timothy Sample <samplet@ngyro.com>
> ;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org>
> +;;; Copyright © 2021 Pierre Langlois <pierre.langlois@gmx.com>
> +;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
> ;;;
> ;;; This file is part of GNU Guix.
> ;;;
> @@ -62,10 +64,15 @@ (define private-keywords
> `(("source" ,source))
> '())
> ,@inputs
> -
> ;; Keep the standard inputs of 'gnu-build-
> system'.
> ,@(standard-packages)))
> (build-inputs `(("node" ,node)
> + ;; Many packages with native addons need
> + ;; libuv headers. The libuv version must
> + ;; be exactly the same as for the node
> + ;; package we are adding implicitly,
> + ;; so we take care of adding libuv, too.
> + ("libuv" ,@(assoc-ref (package-inputs node)
> "libuv"))
> ,@native-inputs))
> (outputs outputs)
> (build node-build)
Do this and #21 have to be separated so far from the rest? If not, I'd
do build system first, then new packages. Otherwise fair enough.
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 20/45] guix: node-build-system: Add implicit libuv input.
2021-12-17 5:08 ` Liliana Marie Prikler
@ 2021-12-18 16:16 ` Philip McGrath
2021-12-18 17:01 ` Liliana Marie Prikler
2021-12-18 17:07 ` Philip McGrath
1 sibling, 1 reply; 458+ messages in thread
From: Philip McGrath @ 2021-12-18 16:16 UTC (permalink / raw)
To: Liliana Marie Prikler, 51838; +Cc: Timothy Sample, Pierre Langlois, Jelle Licht
Hi,
On 12/17/21 00:08, Liliana Marie Prikler wrote:
> Am Donnerstag, dem 16.12.2021 um 21:03 -0500 schrieb Philip McGrath:
>> * guix/build-system/node.scm (lower): Add the version of libuv
>> used as an input to the #:node package as an additional implicit
>> input, so that packages needing libuv always get the correct version.
>> ---
>> guix/build-system/node.scm | 9 ++++++++-
>> 1 file changed, 8 insertions(+), 1 deletion(-)
>>
> Do this and #21 have to be separated so far from the rest? If not, I'd
> do build system first, then new packages. Otherwise fair enough.
I tried to follow Tim's suggestion in
<https://issues.guix.gnu.org/51838#59> to put the changes related to
#:absent-dependencies before the changes to support native addons, so
that the earlier changes could potentially be applied even if there was
more discussion needed for the later ones (if #:absent-dependencies were
less controversial.
But note that the patches before this one aren't adding new packages;
they are changing existing packages to use #:absent-dependencies rather
than deleting the configure phase. So the series is ordered overall as:
1. Changes to the `node` package itself
2. Build system changes for #:absent-dependencies
(including the delete-lockfiles phase, because un-deleting the
configure phase exposes those problems)
3. Packages changes to use #:absent-dependencies
4. Build system changes to support native addons
5. New packages to exercise the support for native addons
-Philip
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 20/45] guix: node-build-system: Add implicit libuv input.
2021-12-18 16:16 ` Philip McGrath
@ 2021-12-18 17:01 ` Liliana Marie Prikler
2021-12-19 20:34 ` Jelle Licht
0 siblings, 1 reply; 458+ messages in thread
From: Liliana Marie Prikler @ 2021-12-18 17:01 UTC (permalink / raw)
To: Philip McGrath, 51838; +Cc: Timothy Sample, Pierre Langlois, Jelle Licht
Hi,
Am Samstag, dem 18.12.2021 um 11:16 -0500 schrieb Philip McGrath:
> >
> > Do this and #21 have to be separated so far from the rest? If not,
> > I'd do build system first, then new packages. Otherwise fair
> > enough.
>
> I tried to follow Tim's suggestion in
> <https://issues.guix.gnu.org/51838#59> to put the changes related to
> #:absent-dependencies before the changes to support native addons, so
> that the earlier changes could potentially be applied even if there
> was more discussion needed for the later ones (if #:absent-
> dependencies were less controversial.
Fair enough, that does make sense. However, I do think that "add
package X" is not too big of a review burden, so I personally think the
fact we're deleting 'configure everywhere is holding back the change to
support native addons rather than the other way around.
> But note that the patches before this one aren't adding new packages;
> they are changing existing packages to use #:absent-dependencies
> rather than deleting the configure phase. So the series is ordered
> overall as:
>
> 1. Changes to the `node` package itself
> 2. Build system changes for #:absent-dependencies
> (including the delete-lockfiles phase, because un-deleting the
> configure phase exposes those problems)
> 3. Packages changes to use #:absent-dependencies
> 4. Build system changes to support native addons
> 5. New packages to exercise the support for native addons
There is an unspoken bit here in #5 in that those packages still need
to get rid of unwanted dependencies, which makes this set still
unsplittable in a sense.
If everyone else here agrees, I think we could at least upstream the
changes to node itself while we still discuss 2-5. Timothy, Pierre,
Jelle, WDYT?
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 20/45] guix: node-build-system: Add implicit libuv input.
2021-12-18 17:01 ` Liliana Marie Prikler
@ 2021-12-19 20:34 ` Jelle Licht
0 siblings, 0 replies; 458+ messages in thread
From: Jelle Licht @ 2021-12-19 20:34 UTC (permalink / raw)
To: Liliana Marie Prikler, Philip McGrath, 51838
Cc: Timothy Sample, Pierre Langlois
Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
> Hi,
>
> Am Samstag, dem 18.12.2021 um 11:16 -0500 schrieb Philip McGrath:
>> >
>> > Do this and #21 have to be separated so far from the rest? If not,
>> > I'd do build system first, then new packages. Otherwise fair
>> > enough.
>>
>> I tried to follow Tim's suggestion in
>> <https://issues.guix.gnu.org/51838#59> to put the changes related to
>> #:absent-dependencies before the changes to support native addons, so
>> that the earlier changes could potentially be applied even if there
>> was more discussion needed for the later ones (if #:absent-
>> dependencies were less controversial.
> Fair enough, that does make sense. However, I do think that "add
> package X" is not too big of a review burden, so I personally think the
> fact we're deleting 'configure everywhere is holding back the change to
> support native addons rather than the other way around.
>
>> But note that the patches before this one aren't adding new packages;
>> they are changing existing packages to use #:absent-dependencies
>> rather than deleting the configure phase. So the series is ordered
>> overall as:
>>
>> 1. Changes to the `node` package itself
>> 2. Build system changes for #:absent-dependencies
>> (including the delete-lockfiles phase, because un-deleting the
>> configure phase exposes those problems)
>> 3. Packages changes to use #:absent-dependencies
>> 4. Build system changes to support native addons
>> 5. New packages to exercise the support for native addons
> There is an unspoken bit here in #5 in that those packages still need
> to get rid of unwanted dependencies, which makes this set still
> unsplittable in a sense.
>
> If everyone else here agrees, I think we could at least upstream the
> changes to node itself while we still discuss 2-5. Timothy, Pierre,
> Jelle, WDYT?
Agreed, thanks for asking.
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 20/45] guix: node-build-system: Add implicit libuv input.
2021-12-17 5:08 ` Liliana Marie Prikler
2021-12-18 16:16 ` Philip McGrath
@ 2021-12-18 17:07 ` Philip McGrath
2021-12-19 20:41 ` Jelle Licht
1 sibling, 1 reply; 458+ messages in thread
From: Philip McGrath @ 2021-12-18 17:07 UTC (permalink / raw)
To: Liliana Marie Prikler, 51838; +Cc: Timothy Sample, Pierre Langlois, Jelle Licht
Hi again,
On 12/17/21 00:08, Liliana Marie Prikler wrote:
> Am Donnerstag, dem 16.12.2021 um 21:03 -0500 schrieb Philip McGrath:
>> * guix/build-system/node.scm (lower): Add the version of libuv
>> used as an input to the #:node package as an additional implicit
>> input, so that packages needing libuv always get the correct version.
>> ---
>> guix/build-system/node.scm | 9 ++++++++-
>> 1 file changed, 8 insertions(+), 1 deletion(-)
>>
Tangentially, for the record, I'd considered as an alternative approach
making libuv a propagated input of node. That might be worth considering
one day, when we unbundle npm, but for now I think libuv is only needed
in a small minority of cases.
-Philip
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 20/45] guix: node-build-system: Add implicit libuv input.
2021-12-18 17:07 ` Philip McGrath
@ 2021-12-19 20:41 ` Jelle Licht
2021-12-19 20:54 ` Liliana Marie Prikler
0 siblings, 1 reply; 458+ messages in thread
From: Jelle Licht @ 2021-12-19 20:41 UTC (permalink / raw)
To: Philip McGrath, Liliana Marie Prikler, 51838
Cc: Timothy Sample, Pierre Langlois
Philip McGrath <philip@philipmcgrath.com> writes:
> Hi again,
>
> On 12/17/21 00:08, Liliana Marie Prikler wrote:
>> Am Donnerstag, dem 16.12.2021 um 21:03 -0500 schrieb Philip McGrath:
>>> * guix/build-system/node.scm (lower): Add the version of libuv
>>> used as an input to the #:node package as an additional implicit
>>> input, so that packages needing libuv always get the correct version.
>>> ---
>>> guix/build-system/node.scm | 9 ++++++++-
>>> 1 file changed, 8 insertions(+), 1 deletion(-)
>>>
>
> Tangentially, for the record, I'd considered as an alternative approach
> making libuv a propagated input of node. That might be worth considering
> one day, when we unbundle npm, but for now I think libuv is only needed
> in a small minority of cases.
Not trying to dismiss this suggestion without a constructive
alternative, but I would prefer not having node's libuv be a propagated
input. What we need is some kind of 'propagated-for-builds-only-input'.
FWIW, I really like the current approach which works as long as we have
npm bundled, which realistically will still be the case for some
{weeks,months,years}.
- Jelle
^ permalink raw reply [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 21/45] guix: node-build-system: Add avoid-node-gyp-rebuild phase.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (19 preceding siblings ...)
2021-12-17 2:03 ` [bug#51838] [PATCH v5 20/45] guix: node-build-system: Add implicit libuv input Philip McGrath
@ 2021-12-17 2:03 ` Philip McGrath
2021-12-17 2:03 ` [bug#51838] [PATCH v5 22/45] gnu: Add node-inherits Philip McGrath
` (23 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:03 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* guix/build/node-build-system.scm (avoid-node-gyp-rebuild): New
function. Override the default install script for packages with
native addons to prevent it from attempting to write to the store
when such packages are used.
(%standard-phases): Add 'avoid-node-gyp-rebuild' after 'install'.
---
guix/build/node-build-system.scm | 59 +++++++++++++++++++++++++++++++-
1 file changed, 58 insertions(+), 1 deletion(-)
diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index 892104b6d2..f9ca515d58 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -175,6 +175,62 @@ (define* (install #:key outputs inputs #:allow-other-keys)
"install" "../package.tgz")
#t))
+(define* (avoid-node-gyp-rebuild #:key outputs #:allow-other-keys)
+ "Adjust the installed 'package.json' to remove an 'install' script that
+would try to run 'node-gyp rebuild'."
+ ;; We want to take advantage of `npm install`'s automatic support for
+ ;; building native addons with node-gyp: in particular, it helps us avoid
+ ;; hard-coding the specifics of how npm's internal copy of node-gyp is
+ ;; currently packaged. However, the mechanism by which the automatic support
+ ;; is implemented causes problems for us.
+ ;;
+ ;; If a package contains a 'binding.gyp' file and does not define an
+ ;; 'install' or 'preinstall' script, 'npm install' runs a default install
+ ;; script consisting of 'node-gyp rebuild'. In our 'install' phase, this
+ ;; implicit 'install' script, if it is applicable, is explicitly added to
+ ;; the "package.json" file. However, if another Guix package were to use a
+ ;; Node.js package with such an 'install' script, the dependent package's
+ ;; build process would fail, because 'node-gyp rebuild' would try to write
+ ;; to the store.
+ ;;
+ ;; Here, if the installed "package.json" defines scripts.install as
+ ;; "node-gyp rebuild", we replace it with a no-op. Importantly, deleting the
+ ;; install script definition would not be enough, because the default
+ ;; install script would cause the same problem.
+ ;;
+ ;; For further details, see:
+ ;; - https://docs.npmjs.com/cli/v8/configuring-npm/package-json#default-values
+ ;; - https://docs.npmjs.com/cli/v8/using-npm/scripts#best-practices
+ (let* ((package.json (string-append
+ (assoc-ref outputs "out")
+ "/lib/node_modules/"
+ (match (call-with-input-file "package.json" read-json)
+ (('@ . alist)
+ (assoc-ref alist "name")))
+ "/package.json"))
+ (meta-alist (match (call-with-input-file package.json read-json)
+ (('@ . alist)
+ alist)))
+ (scripts-alist (match (assoc-ref meta-alist "scripts")
+ (('@ . alist)
+ alist)
+ (#f
+ #f))))
+ (when (and scripts-alist
+ (equal? "node-gyp rebuild" (assoc-ref scripts-alist "install")))
+ (call-with-output-file package.json
+ (lambda (out)
+ (write-json
+ (cons '@ (assoc-set!
+ meta-alist
+ "scripts"
+ (cons '@ (assoc-set!
+ scripts-alist
+ "install"
+ "echo Guix: avoiding node-gyp rebuild"))))
+ out))))
+ #t))
+
(define %standard-phases
(modify-phases gnu:%standard-phases
(add-after 'unpack 'set-home set-home)
@@ -184,7 +240,8 @@ (define %standard-phases
(replace 'build build)
(replace 'check check)
(add-before 'install 'repack repack)
- (replace 'install install)))
+ (replace 'install install)
+ (add-after 'install 'avoid-node-gyp-rebuild avoid-node-gyp-rebuild)))
(define* (node-build #:key inputs (phases %standard-phases)
#:allow-other-keys #:rest args)
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 22/45] gnu: Add node-inherits.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (20 preceding siblings ...)
2021-12-17 2:03 ` [bug#51838] [PATCH v5 21/45] guix: node-build-system: Add avoid-node-gyp-rebuild phase Philip McGrath
@ 2021-12-17 2:03 ` Philip McGrath
2021-12-17 2:03 ` [bug#51838] [PATCH v5 23/45] gnu: Add node-safe-buffer Philip McGrath
` (22 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:03 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-inherits): New variable.
---
gnu/packages/node-xyz.scm | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 93bd067311..ce098e6e8c 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -3,6 +3,7 @@
;;; Copyright © 2020 Giacomo Leidi <goodoldpaul@autistici.org>
;;; Copyright © 2021 Noisytoot <noisytoot@disroot.org>
;;; Copyright © 2021 Charles <charles.b.jackson@protonmail.com>
+;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -351,6 +352,35 @@ (define-public node-once
if desired.")
(license license:isc)))
+(define-public node-inherits
+ (package
+ (name "node-inherits")
+ (version "2.0.4")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/isaacs/inherits")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0cpsr5yqwkxpbbbbl0rwk4mcby6zbx841k2zb4c3gb1579i5wq9p"))))
+ (build-system node-build-system)
+ (arguments
+ '(#:absent-dependencies
+ '("tap")
+ ;; FIXME: Tests depend on node-tap
+ #:tests? #f))
+ (home-page
+ "https://github.com/isaacs/inherits")
+ (synopsis
+ "Browser-friendly inheritance Node.js")
+ (description
+ "Browser-friendly inheritance fully compatible with standard Node.js
+@code{inherits()}.")
+ (license license:isc)))
+
(define-public node-irc-colors
(package
(name "node-irc-colors")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 23/45] gnu: Add node-safe-buffer.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (21 preceding siblings ...)
2021-12-17 2:03 ` [bug#51838] [PATCH v5 22/45] gnu: Add node-inherits Philip McGrath
@ 2021-12-17 2:03 ` Philip McGrath
2021-12-17 2:03 ` [bug#51838] [PATCH v5 24/45] gnu: Add node-string-decoder Philip McGrath
` (21 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:03 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-safe-buffer): New variable.
---
gnu/packages/node-xyz.scm | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index ce098e6e8c..410dfd6a62 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -381,6 +381,34 @@ (define-public node-inherits
@code{inherits()}.")
(license license:isc)))
+(define-public node-safe-buffer
+ (package
+ (name "node-safe-buffer")
+ (version "5.2.1")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/feross/safe-buffer")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0r26m0nl41h90ihnl2xf0cqs6z9z7jb87dl5j8yqb7887r9jlbpi"))))
+ (build-system node-build-system)
+ (arguments
+ '(#:absent-dependencies
+ '("tape"
+ "standard")
+ #:tests? #f))
+ (home-page
+ "https://github.com/feross/safe-buffer")
+ (synopsis "Safer Node.js Buffer API")
+ (description "A safe drop-in replacement the Node.js @code{Buffer} API
+that works in all versions of Node.js, using the built-in implementation when
+available.")
+ (license license:expat)))
+
(define-public node-irc-colors
(package
(name "node-irc-colors")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 24/45] gnu: Add node-string-decoder.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (22 preceding siblings ...)
2021-12-17 2:03 ` [bug#51838] [PATCH v5 23/45] gnu: Add node-safe-buffer Philip McGrath
@ 2021-12-17 2:03 ` Philip McGrath
2021-12-17 2:03 ` [bug#51838] [PATCH v5 25/45] gnu: Add node-readable-stream Philip McGrath
` (20 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:03 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-string-decoder): New variable.
---
gnu/packages/node-xyz.scm | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 410dfd6a62..5dbe2cf244 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -409,6 +409,39 @@ (define-public node-safe-buffer
available.")
(license license:expat)))
+(define-public node-string-decoder
+ (package
+ (name "node-string-decoder")
+ (version "1.3.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/nodejs/string_decoder")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0xxvyya9fl9rlkqwmxzqzbz4rdr3jgw4vf37hff7cgscxkhg266k"))))
+ (build-system node-build-system)
+ (arguments
+ '(#:absent-dependencies
+ '("tap"
+ "core-util-is"
+ "babel-polyfill")
+ ;; FIXME: Tests depend on node-tap
+ #:tests? #f))
+ (inputs
+ (list node-safe-buffer node-inherits))
+ (home-page
+ "https://github.com/nodejs/string_decoder")
+ (synopsis
+ "Node.js core @code{string_decoder} for userland")
+ (description
+ "This package is a mirror of the @code{string_decoder} implementation in
+Node-core.")
+ (license license:expat)))
+
(define-public node-irc-colors
(package
(name "node-irc-colors")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 25/45] gnu: Add node-readable-stream.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (23 preceding siblings ...)
2021-12-17 2:03 ` [bug#51838] [PATCH v5 24/45] gnu: Add node-string-decoder Philip McGrath
@ 2021-12-17 2:03 ` Philip McGrath
2021-12-17 2:03 ` [bug#51838] [PATCH v5 26/45] gnu: Add node-nan Philip McGrath
` (19 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:03 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-readable-stream): New variable.
---
gnu/packages/node-xyz.scm | 52 +++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 5dbe2cf244..87694c7d00 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -442,6 +442,58 @@ (define-public node-string-decoder
Node-core.")
(license license:expat)))
+(define-public node-readable-stream
+ (package
+ (name "node-readable-stream")
+ (version "3.6.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/nodejs/readable-stream")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0ybl4cdgsm9c5jq3xq8s01201jk8w0yakh63hlclsfbcdfqhd9ri"))))
+ (build-system node-build-system)
+ (arguments
+ `(#:absent-dependencies
+ `("@babel/cli"
+ "@babel/core"
+ "@babel/polyfill"
+ "@babel/preset-env"
+ "airtap"
+ "assert"
+ "bl"
+ "deep-strict-equal"
+ "events.once"
+ "glob"
+ "gunzip-maybe"
+ "hyperquest"
+ "lolex"
+ "nyc"
+ "pump"
+ "rimraf"
+ "tap"
+ "tape"
+ "tar-fs"
+ "util-promisify")
+ #:tests? #f))
+ (inputs
+ (list node-util-deprecate node-string-decoder node-inherits))
+ (home-page
+ "https://github.com/nodejs/readable-stream")
+ (synopsis
+ "Node.js core streams for userland")
+ (description
+ "This package is a mirror of the streams implementations in Node.js.
+
+If you want to guarantee a stable streams base, regardless of what version of
+Node you (or the users of your libraries) are using, use
+@code{readable-stream} only and avoid the @code{stream} module in Node-core.")
+ (license license:expat)))
+
(define-public node-irc-colors
(package
(name "node-irc-colors")
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 26/45] gnu: Add node-nan.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (24 preceding siblings ...)
2021-12-17 2:03 ` [bug#51838] [PATCH v5 25/45] gnu: Add node-readable-stream Philip McGrath
@ 2021-12-17 2:03 ` Philip McGrath
2021-12-17 2:03 ` [bug#51838] [PATCH v5 27/45] gnu: Add node-openzwave-shared Philip McGrath
` (18 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:03 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-nan): New variable.
---
gnu/packages/node-xyz.scm | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 87694c7d00..d8ce7248f8 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -549,3 +549,42 @@ (define-public node-irc
(description "@code{node-irc} is an IRC client library for Node.js.
It has functions for joining, parting, talking, and many other IRC commands.")
(license license:gpl3+)))
+
+(define-public node-nan
+ (package
+ (name "node-nan")
+ (version "2.15.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/nodejs/nan")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "18xslh9va5ld872scrp5y4251ax9s3c6qh0lnl1200lpzbsxy7yd"))))
+ (build-system node-build-system)
+ (arguments
+ `(#:absent-dependencies
+ '("bindings"
+ "commander"
+ "glob"
+ "request"
+ "node-gyp" ;; would be needed for tests
+ "tap"
+ "xtend")
+ ;; tests need tap and other dependencies
+ #:tests? #f))
+ (inputs
+ (list node-readable-stream))
+ (home-page "https://github.com/nodejs/nan")
+ (synopsis "Native Abstractions for Node.js")
+ (description "Native Abstractions for Node.js (``NaN'') provides a header
+file filled with macro and utility goodness for making add-on development for
+Node.js easier across versions. The goal of this project is to store all logic
+necessary to develop native Node.js addons without having to inspect
+@code{NODE_MODULE_VERSION} and get yourself into a macro-tangle.
+
+This project also contains some helper utilities that make addon development a
+bit more pleasant.")
+ (license license:expat)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 27/45] gnu: Add node-openzwave-shared.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (25 preceding siblings ...)
2021-12-17 2:03 ` [bug#51838] [PATCH v5 26/45] gnu: Add node-nan Philip McGrath
@ 2021-12-17 2:03 ` Philip McGrath
2021-12-17 2:03 ` [bug#51838] [PATCH v5 28/45] gnu: Add node-addon-api Philip McGrath
` (17 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:03 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/zwave.scm (node-openzwave-shared): New variable.
---
gnu/packages/zwave.scm | 66 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 66 insertions(+)
diff --git a/gnu/packages/zwave.scm b/gnu/packages/zwave.scm
index 4d8286e334..e247c8488e 100644
--- a/gnu/packages/zwave.scm
+++ b/gnu/packages/zwave.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -21,11 +22,14 @@ (define-module (gnu packages zwave)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix git-download)
#:use-module (guix build-system gnu)
+ #:use-module (guix build-system node)
#:use-module (gnu packages)
#:use-module (gnu packages base)
+ #:use-module (gnu packages node-xyz)
#:use-module (gnu packages libusb)
#:use-module (gnu packages linux)
#:use-module (gnu packages perl)
+ #:use-module (gnu packages python)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages xml))
@@ -85,3 +89,65 @@ (define-public open-zwave
and respond to devices on a Z-Wave network, without requiring in-depth
knowledge of the Z-Wave protocol.")
(license license:lgpl3+)))
+
+(define-public node-openzwave-shared
+ (package
+ (name "node-openzwave-shared")
+ (version "1.7.2")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/OpenZWave/node-openzwave-shared")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1bqqy12dzqj05j9wsh50dmn84dddmhz0gjzvd3y20z4hpy1v8rsc"))))
+ (inputs
+ (list open-zwave node-nan))
+ (native-inputs
+ (list which python pkg-config))
+ (build-system node-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (replace 'build
+ ;; For some reason, `npm install` doesn't build
+ ;; the addon automatically, so we do it explicitly here.
+ ;; We go through `npx` so the npmrc file sets the
+ ;; configuration up properly.
+ (lambda* (#:key inputs #:allow-other-keys)
+ (define node-dir
+ (assoc-ref inputs "node"))
+ (invoke (string-append node-dir "/bin/npx")
+ "--call"
+ (string-append
+ node-dir
+ "/lib/node_modules/npm/bin/node-gyp-bin/node-gyp"
+ " "
+ "rebuild")))))))
+ (home-page "https://github.com/OpenZWave/node-openzwave-shared")
+ (synopsis "Node.js bindings for OpenZWave")
+ (description
+ "With the @code{node-openzwave-shared} package, you can easily control
+and manage your Z-Wave devices (lights, dimmers, blinds, you name it) from
+within Node.js applications. This library also supports secure
+devices (e.g. door locks) that require encryption. All widely used Node.js
+versions are supported with the help of @code{node-nan}.
+
+This library is currently able to:
+@itemize @bullet
+@item
+scan a Z-Wave network and report on connected devices;
+@item
+write values to Z-Wave nodes;
+@item
+monitor the network for changes;
+@item
+heal nodes and/or the network; and
+@item
+perform management tasks: add or remove nodes, replace failed nodes,
+manage their group associations, etc.
+@end itemize")
+ (license license:isc)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 28/45] gnu: Add node-addon-api.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (26 preceding siblings ...)
2021-12-17 2:03 ` [bug#51838] [PATCH v5 27/45] gnu: Add node-openzwave-shared Philip McGrath
@ 2021-12-17 2:03 ` Philip McGrath
2021-12-17 2:03 ` [bug#51838] [PATCH v5 29/45] gnu: Add node-sqlite3 Philip McGrath
` (16 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:03 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-addon-api): New variable.
---
gnu/packages/node-xyz.scm | 62 +++++++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index d8ce7248f8..beebac7a40 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -22,6 +22,9 @@
(define-module (gnu packages node-xyz)
#:use-module ((guix licenses) #:prefix license:)
+ #:use-module (gnu packages sqlite)
+ #:use-module (gnu packages python)
+ #:use-module (guix gexp)
#:use-module (guix packages)
#:use-module (guix git-download)
#:use-module (guix build-system node))
@@ -588,3 +591,62 @@ (define-public node-nan
This project also contains some helper utilities that make addon development a
bit more pleasant.")
(license license:expat)))
+
+(define-public node-addon-api
+ (package
+ (name "node-addon-api")
+ (version "4.2.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/nodejs/node-addon-api")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "1bhvfi2m9nxfz418s619914vmidcnrzbjv6l9nid476c3zlpazch"))))
+ (inputs
+ (list python node-safe-buffer))
+ (build-system node-build-system)
+ (arguments
+ `(#:absent-dependencies
+ `("benchmark"
+ "bindings"
+ "clang-format"
+ "eslint"
+ "eslint-config-semistandard"
+ "eslint-config-standard"
+ "eslint-plugin-import"
+ "eslint-plugin-node"
+ "eslint-plugin-promise"
+ "fs-extra"
+ "path"
+ "pre-commit")
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'skip-js-tests
+ ;; We can't run the js-based tests,
+ ;; but we can still do the C++ parts
+ (lambda args
+ (substitute* "package.json"
+ (("\"test\": \"node test\"")
+ "\"test\": \"echo stopping after pretest on Guix\"")))))))
+ (home-page "https://github.com/nodejs/node-addon-api")
+ (synopsis "Node.js API (Node-API) header-only C++ wrappers")
+ (description "This module contains header-only C++ wrapper classes which
+simplify the use of the C based Node-API provided by Node.js when using C++.
+It provides a C++ object model and exception handling semantics with low
+overhead.
+
+Node-API is an ABI stable C interface provided by Node.js for building native
+addons. It is intended to insulate native addons from changes in the
+underlying JavaScript engine and allow modules compiled for one version to run
+on later versions of Node.js without recompilation. The @code{node-addon-api}
+module, which is not part of Node.js, preserves the benefits of the Node-API
+as it consists only of inline code that depends only on the stable API
+provided by Node-API.
+
+It is important to remember that @emph{other} Node.js interfaces such as
+@code{libuv} (included in a project via @code{#include <uv.h>}) are not
+ABI-stable across Node.js major versions.")
+ (license license:expat)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 29/45] gnu: Add node-sqlite3.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (27 preceding siblings ...)
2021-12-17 2:03 ` [bug#51838] [PATCH v5 28/45] gnu: Add node-addon-api Philip McGrath
@ 2021-12-17 2:03 ` Philip McGrath
2021-12-17 2:03 ` [bug#51838] [PATCH v5 30/45] gnu: Add node-file-uri-to-path Philip McGrath
` (15 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:03 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-sqlite3): New variable.
---
gnu/packages/node-xyz.scm | 130 ++++++++++++++++++++++++++++++++++++++
1 file changed, 130 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index beebac7a40..f5297c869b 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -650,3 +650,133 @@ (define-public node-addon-api
@code{libuv} (included in a project via @code{#include <uv.h>}) are not
ABI-stable across Node.js major versions.")
(license license:expat)))
+
+(define-public node-sqlite3
+ (package
+ (name "node-sqlite3")
+ (version "5.0.2")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/mapbox/node-sqlite3")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "0sbbzzli282nxyfha10zx0k5m8hdp0sf3ipl59khjb7wm449j86h"))
+ (snippet
+ (with-imported-modules '((guix build utils))
+ #~(begin
+ (use-modules (guix build utils))
+ ;; unbundle sqlite
+ (for-each delete-file-recursively
+ (find-files "deps"
+ (lambda (pth stat)
+ (gzip-file? pth)))))))))
+ (inputs
+ (list node-addon-api python sqlite))
+ (build-system node-build-system)
+ (arguments
+ `(#:tests?
+ #f ; FIXME: tests depend on node-mocha
+ #:modules
+ ((guix build node-build-system)
+ (guix build json)
+ (srfi srfi-1)
+ (ice-9 match)
+ (guix build utils))
+ #:absent-dependencies
+ `(;; Normally, this is "built" using @mapbox/node-pre-gyp,
+ ;; which publishes or downloads pre-built binaries
+ ;; or falls back to building from source.
+ ;; Here, we patch out all of that and just build directly.
+ ;; It would be better to patch a version of @mapbox/node-pre-gyp
+ ;; that always builds from source, as Debian does,
+ ;; but there are a number of dependencies that need
+ ;; to be packaged or removed.
+ "@mapbox/node-pre-gyp"
+ "node-pre-gyp" ;; deprecated name still used in some places
+ "aws-sdk"
+ "@mapbox/cloudfriend"
+ ;; Confusingly, this is only a dependency because of
+ ;; @mapbox/node-pre-gyp: with that removed,
+ ;; npm will use its own copy:
+ "node-gyp"
+ ;; These we'd like, we just don't have them yet:
+ "eslint"
+ "mocha")
+ #:phases
+ (modify-phases %standard-phases
+ (add-before 'configure 'npm-config-sqlite
+ ;; We need this step even if we do replace @mapbox/node-pre-gyp
+ ;; because the package expects to build its bundled sqlite
+ (lambda* (#:key inputs #:allow-other-keys)
+ (setenv "npm_config_sqlite" (assoc-ref inputs "sqlite"))))
+ (add-after 'install 'patch-binding-path
+ ;; We replace a file that dynamic searches for the addon using
+ ;; node-pre-gyp (which we don't have) with a version that
+ ;; simply uses the path to the addon we built directly.
+ ;; The exact path is supposed to depend on things like the
+ ;; architecture and napi_build_version, so, to avoid having
+ ;; hard-code the details accurately, we do this after the addon
+ ;; has been built so we can just find where it ended up.
+ (lambda* (#:key outputs #:allow-other-keys)
+ (with-directory-excursion
+ (string-append (assoc-ref outputs "out")
+ "/lib/node_modules/sqlite3/lib")
+ (match (find-files "binding" "\\.node$")
+ ((rel-path)
+ (with-atomic-file-replacement "sqlite3-binding.js"
+ (lambda (in out)
+ (format out "var binding = require('./~a');\n" rel-path)
+ (display "module.exports = exports = binding;\n" out))))))))
+ (add-after 'patch-dependencies 'avoid-node-pre-gyp
+ (lambda args
+ ;; We need to patch .npmignore before the 'repack phase
+ ;; so that the built addon is installed with in the package.
+ ;; (Upstream assumes node-pre-gyp will download a pre-built
+ ;; version when this package is installed.)
+ (substitute* ".npmignore"
+ (("lib/binding")
+ "#lib/binding # <- patched for Guix"))
+ ;; We need to remove the install script from "package.json",
+ ;; as it would try to use node-pre-gyp and would block the
+ ;; automatic building performed by `npm install`.
+ (with-atomic-file-replacement "package.json"
+ (lambda (in out)
+ (let* ((js (read-json in))
+ (alist (match js
+ (('@ . alist) alist)))
+ (scripts-alist (match (assoc-ref alist "scripts")
+ (('@ . alist) alist)))
+ (scripts-alist
+ ;; install script would use node-pre-gyp
+ (assoc-remove! scripts-alist "install"))
+ (alist
+ (assoc-set! alist "scripts" (cons '@ scripts-alist)))
+ (binary-alist (match (assoc-ref alist "binary")
+ (('@ . alist) alist)))
+ (js (cons '@ alist)))
+ ;; When it builds from source, node-pre-gyp supplies
+ ;; module_name and module_path based on the entries under
+ ;; "binary" from "package.json", so this package's
+ ;; "binding.gyp" doesn't define them. Thus, we also need
+ ;; to supply them. The GYP_DEFINES environment variable
+ ;; turns out to be the easiest way to make sure they are
+ ;; propagated from npm to node-gyp to gyp.
+ (setenv "GYP_DEFINES"
+ (string-append
+ "module_name="
+ (assoc-ref binary-alist "module_name")
+ " "
+ "module_path="
+ (assoc-ref binary-alist "module_path")))
+ (write-json js
+ out)))))))))
+ (home-page "https://github.com/mapbox/node-sqlite3")
+ (synopsis "Asynchronous, non-blocking SQLite3 bindings for Node.js")
+ (description
+ "The Node.js add-on @code{node-sqlite3} provides a set of a asynchronous,
+non-blocking bindings for SQLite3, written in modern C++ and tested for memory
+leaks.")
+ (license license:bsd-3)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 30/45] gnu: Add node-file-uri-to-path.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (28 preceding siblings ...)
2021-12-17 2:03 ` [bug#51838] [PATCH v5 29/45] gnu: Add node-sqlite3 Philip McGrath
@ 2021-12-17 2:03 ` Philip McGrath
2021-12-17 2:03 ` [bug#51838] [PATCH v5 31/45] gnu: Add node-bindings Philip McGrath
` (14 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:03 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-file-uri-to-path): New variable.
---
gnu/packages/node-xyz.scm | 55 +++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index f5297c869b..c9afe8ccd2 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -24,6 +24,7 @@ (define-module (gnu packages node-xyz)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (gnu packages sqlite)
#:use-module (gnu packages python)
+ #:use-module (gnu packages web)
#:use-module (guix gexp)
#:use-module (guix packages)
#:use-module (guix git-download)
@@ -780,3 +781,57 @@ (define-public node-sqlite3
non-blocking bindings for SQLite3, written in modern C++ and tested for memory
leaks.")
(license license:bsd-3)))
+
+(define-public node-file-uri-to-path
+ (package
+ (name "node-file-uri-to-path")
+ (version "2.0.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/TooTallNate/file-uri-to-path")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "08l779az44czm12xdhgcrnzpqw34s59hbrlfphs7g9y2k26drqav"))))
+ (native-inputs
+ (list esbuild))
+ (build-system node-build-system)
+ (arguments
+ `(#:absent-dependencies
+ `("@types/mocha"
+ "@types/node"
+ "@typescript-eslint/eslint-plugin"
+ "@typescript-eslint/parser"
+ "cpy-cli"
+ "eslint"
+ "eslint-config-airbnb"
+ "eslint-config-prettier"
+ "eslint-import-resolver-typescript"
+ "eslint-plugin-import"
+ "eslint-plugin-jsx-a11y"
+ "eslint-plugin-react"
+ "mocha"
+ "rimraf"
+ "typescript")
+ #:phases
+ (modify-phases %standard-phases
+ (replace 'build
+ (lambda* (#:key inputs native-inputs #:allow-other-keys)
+ (copy-recursively "src" "dist")
+ (invoke (string-append
+ (assoc-ref (or native-inputs inputs) "esbuild")
+ "/bin/esbuild")
+ "dist/index.ts"
+ "--outfile=dist/src/index.js"
+ "--format=cjs"
+ "--sourcemap"
+ "--platform=node"))))
+ #:tests? #f))
+ (home-page "https://github.com/TooTallNate/file-uri-to-path")
+ (synopsis "Convert a @code{file:} URI to a file path")
+ (description "This package provides a function to convert a @code{file:}
+URI to a file path. It accepts a @code{file:} URI and returns a file path
+suitable for use with the @code{fs} module functions.")
+ (license license:expat)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 31/45] gnu: Add node-bindings.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (29 preceding siblings ...)
2021-12-17 2:03 ` [bug#51838] [PATCH v5 30/45] gnu: Add node-file-uri-to-path Philip McGrath
@ 2021-12-17 2:03 ` Philip McGrath
2021-12-17 2:03 ` [bug#51838] [PATCH v5 32/45] gnu: Add node-segfault-handler Philip McGrath
` (13 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:03 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-bindings): New variable.
---
gnu/packages/node-xyz.scm | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index c9afe8ccd2..913bb7d149 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -835,3 +835,29 @@ (define-public node-file-uri-to-path
URI to a file path. It accepts a @code{file:} URI and returns a file path
suitable for use with the @code{fs} module functions.")
(license license:expat)))
+
+(define-public node-bindings
+ (package
+ (name "node-bindings")
+ (version "1.5.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/TooTallNate/node-bindings")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "100gp6kpjvd4j1dqnp0sbjr1hqx5mz7r61q9qy527jyhk9mj47wk"))))
+ (inputs
+ (list node-file-uri-to-path))
+ (build-system node-build-system)
+ (arguments
+ ;; there are no tests
+ `(#:tests? #f))
+ (home-page "https://github.com/TooTallNate/node-bindings")
+ (synopsis "Help for loading your native module's @code{.node} file")
+ (description "This is a helper module for authors of Node.js native addon
+modules. It is basically the ``swiss army knife'' of @code{require()}ing your
+native module's @code{.node} file.")
+ (license license:expat)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 32/45] gnu: Add node-segfault-handler.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (30 preceding siblings ...)
2021-12-17 2:03 ` [bug#51838] [PATCH v5 31/45] gnu: Add node-bindings Philip McGrath
@ 2021-12-17 2:03 ` Philip McGrath
2021-12-17 2:03 ` [bug#51838] [PATCH v5 33/45] gnu: Add node-ms Philip McGrath
` (12 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:03 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-segfault-handler): New variable.
---
gnu/packages/node-xyz.scm | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 913bb7d149..30a0174063 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -861,3 +861,32 @@ (define-public node-bindings
modules. It is basically the ``swiss army knife'' of @code{require()}ing your
native module's @code{.node} file.")
(license license:expat)))
+
+(define-public node-segfault-handler
+ (package
+ (name "node-segfault-handler")
+ (version "1.3.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/ddopson/node-segfault-handler")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "07nbw35wvrr18kmh8f388v4k5mpjgyy0260bx0xzjdv795i3xvfv"))))
+ (native-inputs
+ (list python))
+ (inputs
+ (list node-bindings node-nan))
+ (build-system node-build-system)
+ (arguments
+ ;; there are no tests
+ `(#:tests? #f))
+ (home-page "https://github.com/ddopson/node-segfault-handler")
+ (synopsis "Catches @code{SIGSEGV} and prints diagnostic information")
+ (description "This package is a tool for debugging Node.js C/C++ native
+code modules and getting stack traces when things go wrong. If a
+@code{SIGSEGV} signal is raised, the module will print a native stack trace to
+both @code{STDERR} and to a timestamped file.")
+ (license license:bsd-3)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 33/45] gnu: Add node-ms.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (31 preceding siblings ...)
2021-12-17 2:03 ` [bug#51838] [PATCH v5 32/45] gnu: Add node-segfault-handler Philip McGrath
@ 2021-12-17 2:03 ` Philip McGrath
2021-12-17 2:03 ` [bug#51838] [PATCH v5 34/45] gnu: Add node-debug Philip McGrath
` (11 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:03 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-ms): New variable.
---
gnu/packages/node-xyz.scm | 43 +++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 30a0174063..3103124bed 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -890,3 +890,46 @@ (define-public node-segfault-handler
@code{SIGSEGV} signal is raised, the module will print a native stack trace to
both @code{STDERR} and to a timestamped file.")
(license license:bsd-3)))
+
+(define-public node-ms
+ (package
+ (name "node-ms")
+ (version "2.1.3")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/vercel/ms")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "1l74kmmwffmzdz38lli0v5mdb9p9jmsjxpb48ncknqw2n74cgf08"))))
+ (build-system node-build-system)
+ (arguments
+ `(#:absent-dependencies
+ `("eslint"
+ "expect.js"
+ "husky"
+ "lint-staged"
+ "mocha"
+ "prettier")
+ #:tests? #f))
+ (home-page "https://github.com/vercel/ms")
+ (synopsis "Tiny millisecond conversion utility")
+ (description "Use this package to easily convert various time formats to
+milliseconds.
+
+Features:
+@itemize @bullet
+@item
+Works both in Node.js and in the browser.
+@item
+If a number is supplied to @code{ms}, a string with a unit is returned.
+@item
+If a string that contains the number is supplied, it returns it as a
+number (e.g. it returns @code{100} for @code{'100'}).
+@item
+If you pass a string with a number and a valid unit, the number of
+equivalent milliseconds is returned.
+@end itemize")
+ (license license:expat)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 34/45] gnu: Add node-debug.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (32 preceding siblings ...)
2021-12-17 2:03 ` [bug#51838] [PATCH v5 33/45] gnu: Add node-ms Philip McGrath
@ 2021-12-17 2:03 ` Philip McGrath
2021-12-17 2:03 ` [bug#51838] [PATCH v5 35/45] gnu: Add node-serialport-binding-abstract Philip McGrath
` (10 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:03 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-debug): New variable.
---
gnu/packages/node-xyz.scm | 42 +++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 3103124bed..8de98fe046 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -933,3 +933,45 @@ (define-public node-ms
equivalent milliseconds is returned.
@end itemize")
(license license:expat)))
+
+(define-public node-debug
+ (package
+ (name "node-debug")
+ (version "4.3.3")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/debug-js/debug")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "0ji0dmdl2xkgxqxvd6xjy7k3mmknmhvqjgc40vyly9ka1mpf20vb"))))
+ (inputs
+ (list node-ms))
+ (build-system node-build-system)
+ (arguments
+ `(#:absent-dependencies
+ `("brfs"
+ "browserify"
+ "coveralls"
+ "istanbul"
+ "karma"
+ "karma-browserify"
+ "karma-chrome-launcher"
+ "karma-mocha"
+ "mocha"
+ "mocha-lcov-reporter"
+ "xo"
+ "supports-color")
+ #:tests? #f))
+ (home-page "https://github.com/debug-js/debug")
+ (synopsis "Lightweight debugging utility for Node.js and the browser")
+ (description "A tiny JavaScript debugging utility modelled after Node.js
+core's debugging technique. orks in Node.js and web browsers.
+
+The @code{debug} module exposes a function; simply pass this function the name
+of your module, and it will return a decorated version of @code{console.error}
+for you to pass debug statements to. This will allow you to toggle the debug
+output for different parts of your module as well as the module as a whole.")
+ (license license:expat)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 35/45] gnu: Add node-serialport-binding-abstract.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (33 preceding siblings ...)
2021-12-17 2:03 ` [bug#51838] [PATCH v5 34/45] gnu: Add node-debug Philip McGrath
@ 2021-12-17 2:03 ` Philip McGrath
2021-12-17 2:03 ` [bug#51838] [PATCH v5 36/45] gnu: Add node-serialport-parser-delimiter Philip McGrath
` (9 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:03 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-binding-abstract): New variable.
---
gnu/packages/node-xyz.scm | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 8de98fe046..ef833678d1 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -975,3 +975,37 @@ (define-public node-debug
for you to pass debug statements to. This will allow you to toggle the debug
output for different parts of your module as well as the module as a whole.")
(license license:expat)))
+
+(define-public node-serialport-binding-abstract
+ (package
+ (name "node-serialport-binding-abstract")
+ (version "9.2.3")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/serialport/node-serialport")
+ (commit "v9.2.7")))
+ (file-name (git-file-name "serialport-monorepo" version))
+ (sha256
+ (base32 "0x7zm59a5ff5yygjyw15xs3r5m3rb8av1yfrh4snn44mrwq87yg8"))))
+ (inputs
+ (list node-debug))
+ (build-system node-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/binding-abstract"))))
+ #:tests? #f))
+ (home-page "https://serialport.io")
+ (synopsis "Abstract base class for Node SerialPort bindings")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+This package provides the @code{AbstractBinding} class, the base for all Node
+SerialPort bindings. You wouldn't use this class directly, but instead extend
+it to make a new binding for a different platform or underling technology.")
+ (license license:expat)))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 36/45] gnu: Add node-serialport-parser-delimiter.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (34 preceding siblings ...)
2021-12-17 2:03 ` [bug#51838] [PATCH v5 35/45] gnu: Add node-serialport-binding-abstract Philip McGrath
@ 2021-12-17 2:03 ` Philip McGrath
2021-12-17 2:03 ` [bug#51838] [PATCH v5 37/45] gnu: Add node-serialport-parser-readline Philip McGrath
` (8 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:03 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-parser-delimiter): New
variable.
---
gnu/packages/node-xyz.scm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index ef833678d1..abe0e9b291 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1009,3 +1009,25 @@ (define-public node-serialport-binding-abstract
SerialPort bindings. You wouldn't use this class directly, but instead extend
it to make a new binding for a different platform or underling technology.")
(license license:expat)))
+
+(define-public node-serialport-parser-delimiter
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-parser-delimiter")
+ (version "9.2.4")
+ (inputs `())
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/parser-delimiter"))))
+ #:tests? #f))
+ (synopsis "Node SerialPort parser to split data on a delimiter")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+Parsers are used to take raw binary data and transform them into usable
+messages. This package provides @code{Delimiter}, a parser that emits data
+each time a specified byte sequence is received.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 37/45] gnu: Add node-serialport-parser-readline.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (35 preceding siblings ...)
2021-12-17 2:03 ` [bug#51838] [PATCH v5 36/45] gnu: Add node-serialport-parser-delimiter Philip McGrath
@ 2021-12-17 2:03 ` Philip McGrath
2021-12-17 2:03 ` [bug#51838] [PATCH v5 38/45] gnu: Add node-serialport-bindings Philip McGrath
` (7 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:03 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-parser-readline): New
variable.
---
gnu/packages/node-xyz.scm | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index abe0e9b291..d117df1e81 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1031,3 +1031,26 @@ (define-public node-serialport-parser-delimiter
Parsers are used to take raw binary data and transform them into usable
messages. This package provides @code{Delimiter}, a parser that emits data
each time a specified byte sequence is received.")))
+
+(define-public node-serialport-parser-readline
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-parser-readline")
+ (version "9.2.4")
+ (inputs
+ (list node-serialport-parser-delimiter))
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/parser-readline"))))
+ #:tests? #f))
+ (synopsis "Node SerialPort parser to split data on newlines")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+Parsers are used to take raw binary data and transform them into usable
+messages. This package provides @code{Readline}, a parser that emits data
+after a (configurable) newline delimiter is received.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 38/45] gnu: Add node-serialport-bindings.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (36 preceding siblings ...)
2021-12-17 2:03 ` [bug#51838] [PATCH v5 37/45] gnu: Add node-serialport-parser-readline Philip McGrath
@ 2021-12-17 2:03 ` Philip McGrath
2021-12-17 2:03 ` [bug#51838] [PATCH v5 39/45] gnu: Add node-serialport-parser-regex Philip McGrath
` (6 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:03 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-bindings): New variable.
---
gnu/packages/node-xyz.scm | 53 +++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index d117df1e81..e56bccb895 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1054,3 +1054,56 @@ (define-public node-serialport-parser-readline
Parsers are used to take raw binary data and transform them into usable
messages. This package provides @code{Readline}, a parser that emits data
after a (configurable) newline delimiter is received.")))
+
+(define-public node-serialport-bindings
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-bindings")
+ (version "9.2.7")
+ (native-inputs
+ (list python))
+ (inputs
+ (list node-nan node-bindings node-serialport-binding-abstract
+ node-serialport-parser-readline node-debug))
+ (arguments
+ `(#:absent-dependencies
+ `("prebuild-install"
+ ;; devDependencies
+ "@serialport/binding-mock"
+ "node-abi")
+ #:modules
+ ((guix build node-build-system)
+ (guix build json)
+ (srfi srfi-1)
+ (ice-9 match)
+ (guix build utils))
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/bindings")))
+ (add-after 'chdir 'avoid-prebuild-install
+ (lambda args
+ (with-atomic-file-replacement "package.json"
+ (lambda (in out)
+ (match (read-json in)
+ (('@ . meta-alist)
+ (match (assoc-ref meta-alist "scripts")
+ (('@ . scripts-alist)
+ (write-json
+ (cons '@ (assoc-set!
+ meta-alist
+ "scripts"
+ (cons '@ (assoc-remove! scripts-alist
+ "install"))))
+ out))))))))))
+ #:tests? #f))
+ (synopsis "Abstract base class for Node SerialPort bindings")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+This package provides the @code{Binding} class, which uses a native addon to
+talk to the underlying system. You never have to use @code{Binding} objects
+directly. There is also a @code{MockBinding} available (but not yet packaged
+for Guix) to assist with testing.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 39/45] gnu: Add node-serialport-parser-regex.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (37 preceding siblings ...)
2021-12-17 2:03 ` [bug#51838] [PATCH v5 38/45] gnu: Add node-serialport-bindings Philip McGrath
@ 2021-12-17 2:03 ` Philip McGrath
2021-12-17 2:03 ` [bug#51838] [PATCH v5 40/45] gnu: Add node-serialport-parser-ready Philip McGrath
` (5 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:03 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-parser-regex): New variable.
---
gnu/packages/node-xyz.scm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index e56bccb895..be96a00a37 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1107,3 +1107,25 @@ (define-public node-serialport-bindings
talk to the underlying system. You never have to use @code{Binding} objects
directly. There is also a @code{MockBinding} available (but not yet packaged
for Guix) to assist with testing.")))
+
+(define-public node-serialport-parser-regex
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-parser-regex")
+ (version "9.2.4")
+ (inputs `())
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/parser-regex"))))
+ #:tests? #f))
+ (synopsis "Node SerialPort parser to split data on a regular expression")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+Parsers are used to take raw binary data and transform them into usable
+messages. This package provides @code{Regex}, a parser that uses a regular
+expression to split the incoming text.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 40/45] gnu: Add node-serialport-parser-ready.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (38 preceding siblings ...)
2021-12-17 2:03 ` [bug#51838] [PATCH v5 39/45] gnu: Add node-serialport-parser-regex Philip McGrath
@ 2021-12-17 2:03 ` Philip McGrath
2021-12-17 2:03 ` [bug#51838] [PATCH v5 41/45] gnu: Add node-serialport-parser-inter-byte-timeout Philip McGrath
` (4 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:03 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-parser-ready): New variable.
---
gnu/packages/node-xyz.scm | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index be96a00a37..412bb0a3bb 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1129,3 +1129,26 @@ (define-public node-serialport-parser-regex
Parsers are used to take raw binary data and transform them into usable
messages. This package provides @code{Regex}, a parser that uses a regular
expression to split the incoming text.")))
+
+(define-public node-serialport-parser-ready
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-parser-ready")
+ (version "9.2.4")
+ (inputs `())
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/parser-ready"))))
+ #:tests? #f))
+ (synopsis "Node SerialPort parser to wait for specified byte sequence")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+Parsers are used to take raw binary data and transform them into usable
+messages. This package provides @code{Ready}, a parser that waits for a
+specified sequence of ``ready'' bytes before emitting a ready event and
+emitting data events.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 41/45] gnu: Add node-serialport-parser-inter-byte-timeout.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (39 preceding siblings ...)
2021-12-17 2:03 ` [bug#51838] [PATCH v5 40/45] gnu: Add node-serialport-parser-ready Philip McGrath
@ 2021-12-17 2:03 ` Philip McGrath
2021-12-17 2:03 ` [bug#51838] [PATCH v5 42/45] gnu: Add node-serialport-parser-cctalk Philip McGrath
` (3 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:03 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm
(node-serialport-parser-inter-byte-timeout): New variable.
---
gnu/packages/node-xyz.scm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 412bb0a3bb..405bb92327 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1152,3 +1152,25 @@ (define-public node-serialport-parser-ready
messages. This package provides @code{Ready}, a parser that waits for a
specified sequence of ``ready'' bytes before emitting a ready event and
emitting data events.")))
+
+(define-public node-serialport-parser-inter-byte-timeout
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-parser-inter-byte-timeout")
+ (version "9.2.4")
+ (inputs `())
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/parser-inter-byte-timeout"))))
+ #:tests? #f))
+ (synopsis "Node SerialPort parser to detect pauses in data")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+Parsers are used to take raw binary data and transform them into usable
+messages. This package provides @code{InterByteTimeout}, a parser that emits
+data if there is a pause between packets for the specified amount of time.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 42/45] gnu: Add node-serialport-parser-cctalk.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (40 preceding siblings ...)
2021-12-17 2:03 ` [bug#51838] [PATCH v5 41/45] gnu: Add node-serialport-parser-inter-byte-timeout Philip McGrath
@ 2021-12-17 2:03 ` Philip McGrath
2021-12-17 2:03 ` [bug#51838] [PATCH v5 43/45] gnu: Add node-serialport-parser-byte-length Philip McGrath
` (2 subsequent siblings)
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:03 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-parser-cctalk): New variable.
---
gnu/packages/node-xyz.scm | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 405bb92327..4dd17aa20f 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1174,3 +1174,26 @@ (define-public node-serialport-parser-inter-byte-timeout
Parsers are used to take raw binary data and transform them into usable
messages. This package provides @code{InterByteTimeout}, a parser that emits
data if there is a pause between packets for the specified amount of time.")))
+
+(define-public node-serialport-parser-cctalk
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-parser-cctalk")
+ (version "9.2.4")
+ (inputs `())
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/parser-cctalk"))))
+ #:tests? #f))
+ (synopsis "Node SerialPort parser for the ccTalk protocol")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+Parsers are used to take raw binary data and transform them into usable
+messages. This package provides @code{CCTalk}, which emits packets for the
+ccTalk protocol (an open standard for currency detectors) as they are
+received.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 43/45] gnu: Add node-serialport-parser-byte-length.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (41 preceding siblings ...)
2021-12-17 2:03 ` [bug#51838] [PATCH v5 42/45] gnu: Add node-serialport-parser-cctalk Philip McGrath
@ 2021-12-17 2:03 ` Philip McGrath
2021-12-17 2:03 ` [bug#51838] [PATCH v5 44/45] gnu: Add node-serialport-stream Philip McGrath
2021-12-17 2:03 ` [bug#51838] [PATCH v5 45/45] gnu: Add node-serialport Philip McGrath
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:03 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-parser-byte-length): New
variable.
---
gnu/packages/node-xyz.scm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 4dd17aa20f..b2c2d62220 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1197,3 +1197,25 @@ (define-public node-serialport-parser-cctalk
messages. This package provides @code{CCTalk}, which emits packets for the
ccTalk protocol (an open standard for currency detectors) as they are
received.")))
+
+(define-public node-serialport-parser-byte-length
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-parser-byte-length")
+ (version "9.2.4")
+ (inputs `())
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/parser-byte-length"))))
+ #:tests? #f))
+ (synopsis "Node SerialPort parser for fixed-length buffers")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+Parsers are used to take raw binary data and transform them into usable
+messages. This package provides @code{ByteLength}, a parser that emits data
+as a buffer every time a specified number of bytes are received.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 44/45] gnu: Add node-serialport-stream.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (42 preceding siblings ...)
2021-12-17 2:03 ` [bug#51838] [PATCH v5 43/45] gnu: Add node-serialport-parser-byte-length Philip McGrath
@ 2021-12-17 2:03 ` Philip McGrath
2021-12-17 2:03 ` [bug#51838] [PATCH v5 45/45] gnu: Add node-serialport Philip McGrath
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:03 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport-stream): New variable.
---
gnu/packages/node-xyz.scm | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index b2c2d62220..083f43e33f 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1219,3 +1219,30 @@ (define-public node-serialport-parser-byte-length
Parsers are used to take raw binary data and transform them into usable
messages. This package provides @code{ByteLength}, a parser that emits data
as a buffer every time a specified number of bytes are received.")))
+
+(define-public node-serialport-stream
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport-stream")
+ (version "9.2.4")
+ (inputs
+ (list node-debug))
+ (arguments
+ `(#:absent-dependencies
+ `(;; devDependencies
+ "@serialport/binding-mock")
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/stream"))))
+ #:tests? #f))
+ (synopsis "Node.js stream interface for Node SerialPort")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. The Guix package @code{node-serialport} provides the
+recommended high-level interface.
+
+This package provides an interface for using Node SerialPort bindings via the
+Node.js Stream API. The stream is a duplex stream, allowing for reading and
+writing. It has additional methods for managing the SerialPort
+connection.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread
* [bug#51838] [PATCH v5 45/45] gnu: Add node-serialport.
2021-12-17 2:02 ` [bug#51838] [PATCH v5 00/45] guix: node-build-system: Support compiling add-ons with node-gyp Philip McGrath
` (43 preceding siblings ...)
2021-12-17 2:03 ` [bug#51838] [PATCH v5 44/45] gnu: Add node-serialport-stream Philip McGrath
@ 2021-12-17 2:03 ` Philip McGrath
44 siblings, 0 replies; 458+ messages in thread
From: Philip McGrath @ 2021-12-17 2:03 UTC (permalink / raw)
To: 51838
Cc: Timothy Sample, Pierre Langlois, Jelle Licht, Philip McGrath,
Liliana Marie Prikler
* gnu/packages/node-xyz.scm (node-serialport): New variable.
---
gnu/packages/node-xyz.scm | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 083f43e33f..52dec0423b 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1246,3 +1246,34 @@ (define-public node-serialport-stream
Node.js Stream API. The stream is a duplex stream, allowing for reading and
writing. It has additional methods for managing the SerialPort
connection.")))
+
+(define-public node-serialport
+ (package
+ (inherit node-serialport-binding-abstract)
+ (name "node-serialport")
+ (version "9.2.7")
+ (inputs
+ (list node-serialport-bindings
+ node-serialport-parser-delimiter
+ node-serialport-parser-readline
+ node-serialport-parser-regex
+ node-serialport-parser-ready
+ node-serialport-parser-inter-byte-timeout
+ node-serialport-parser-cctalk
+ node-serialport-parser-byte-length
+ node-serialport-stream
+ node-debug))
+ (arguments
+ `(#:absent-dependencies
+ `("@serialport/binding-mock")
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda args
+ (chdir "packages/serialport"))))
+ #:tests? #f))
+ (synopsis "Node.js package to access serial ports")
+ (description "Node SerialPort is a modular suite of Node.js packages for
+accessing serial ports. This package is the recommended entry point for most
+projects. It combines a high-level Node.js stream interface with a useful
+default set of parsers and bindings.")))
--
2.32.0
^ permalink raw reply related [flat|nested] 458+ messages in thread