aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/node.scm
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/packages/node.scm')
-rw-r--r--gnu/packages/node.scm280
1 files changed, 162 insertions, 118 deletions
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 6b543acf6f..ce94557a8c 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -5,11 +5,12 @@
;;; Copyright © 2016, 2021 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2017 Mike Gerwitz <mtg@gnu.org>
;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
-;;; Copyright © 2018, 2019, 2020, 2021 Marius Bakke <marius@gnu.org>
+;;; Copyright © 2018-2022 Marius Bakke <marius@gnu.org>
;;; 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 Guillaume Le Vaillant <glv@posteo.net>
+;;; Copyright © 2021, 2022 Philip McGrath <philip@philipmcgrath.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -57,17 +58,17 @@
(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
+ '(begin
;; Patch for compatibility with ICU 68 and newer, which
;; removed the public TRUE and FALSE macros.
(substitute* '("deps/v8/src/objects/intl-objects.cc"
@@ -89,8 +90,7 @@
(("deps/http_parser/http_parser.gyp") "")
(("deps/uv/include/\\*.h") "")
(("deps/uv/uv.gyp") "")
- (("deps/zlib/zlib.gyp") ""))
- #t))))
+ (("deps/zlib/zlib.gyp") ""))))))
(build-system gnu-build-system)
(arguments
`(#:configure-flags '("--shared-cares"
@@ -104,16 +104,29 @@
;; 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-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 +136,10 @@
"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.
@@ -136,6 +152,10 @@
;; This requires a DNS resolver.
(delete-file "test/parallel/test-dns.js")
+ ;; This test is timing-sensitive, and fails sporadically on
+ ;; slow, busy, or even very fast machines.
+ (delete-file "test/parallel/test-fs-utimes.js")
+
;; FIXME: This test fails randomly:
;; https://github.com/nodejs/node/issues/31213
(delete-file "test/parallel/test-net-listen-after-destroying-stdin.js")
@@ -218,45 +238,71 @@
(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))))
- (add-after 'patch-shebangs 'patch-npm-shebang
+ (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-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)))))
+ (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* ((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)))))))))
+ (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)
- ("http-parser" ,http-parser)
- ("icu4c" ,icu4c)
- ("libuv" ,libuv)
- ("nghttp2" ,nghttp2 "lib")
- ("openssl" ,openssl)
- ("zlib" ,zlib)
- ;; Regular build-time dependencies.
- ("perl" ,perl)
- ("pkg-config" ,pkg-config)
- ("procps" ,procps)
- ("python" ,python-2)
- ("util-linux" ,util-linux)))
+ ;; Runtime dependencies for binaries used as a bootstrap.
+ (list c-ares
+ http-parser
+ icu4c
+ libuv
+ `(,nghttp2 "lib")
+ openssl
+ zlib
+ ;; Regular build-time dependencies.
+ perl
+ pkg-config
+ procps
+ python-2
+ util-linux))
(native-search-paths
(list (search-path-specification
(variable "NODE_PATH")
(files '("lib/node_modules")))))
(inputs
- (list bash
+ (list bash-minimal
coreutils
c-ares
http-parser
@@ -264,9 +310,11 @@
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
+ (description
+ "Node.js is a platform built on Chrome's JavaScript runtime
for easily building fast, scalable network applications. Node.js uses an
event-driven, non-blocking I/O model that makes it lightweight and efficient,
perfect for data-intensive real-time applications that run across distributed
@@ -302,7 +350,9 @@ devices.")
#:tests? #f
#:phases
(modify-phases %standard-phases
- (delete 'configure))))
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (delete-dependencies '("tap")))))))
(home-page "https://github.com/npm/node-semver")
(properties '((hidden? . #t)))
(synopsis "Parses semantic versions strings")
@@ -331,7 +381,13 @@ devices.")
#:tests? #f
#:phases
(modify-phases %standard-phases
- (delete 'configure))))
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (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")
@@ -359,7 +415,9 @@ formats to milliseconds.")
#:tests? #f
#:phases
(modify-phases %standard-phases
- (delete 'configure))))
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (delete-dependencies `("chai" "mocha")))))))
(home-page "https://github.com/darkskyapp/binary-search#readme")
(properties '((hidden? . #t)))
(synopsis "Tiny binary search function with comparators")
@@ -386,7 +444,19 @@ formats to milliseconds.")
#:tests? #f
#:phases
(modify-phases %standard-phases
- (delete 'configure))))
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (delete-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)))
@@ -440,7 +510,14 @@ Node.js and web browsers.")
#:tests? #f
#:phases
(modify-phases %standard-phases
- (delete 'configure)
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda _
+ (delete-dependencies `("@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")))
@@ -494,7 +571,15 @@ Node.js and web browsers.")
#:tests? #f
#:phases
(modify-phases %standard-phases
- (delete 'configure)
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (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")))
@@ -547,7 +632,17 @@ Node.js and web browsers.")
#:tests? #f
#:phases
(modify-phases %standard-phases
- (delete 'configure)
+ (add-after 'patch-dependencies 'delete-dependencies
+ (lambda args
+ (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")))
@@ -640,14 +735,14 @@ source files.")
(define-public node-lts
(package
(inherit node)
- (version "14.18.1")
+ (version "14.18.3")
(source (origin
(method url-fetch)
(uri (string-append "https://nodejs.org/dist/v" version
"/node-v" version ".tar.xz"))
(sha256
(base32
- "1vc9rypkgr5i5y946jnyr9jjpydxvm74p1s17rg2zayzvlddg89z"))
+ "026nd6vihjdqz4jn0slg89m8m5vvkvjzgg1aip3dcg9lrm1w8fkq"))
(modules '((guix build utils)))
(snippet
`(begin
@@ -705,65 +800,8 @@ source files.")
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
@@ -778,6 +816,10 @@ source files.")
;; These tests require networking.
(delete-file "test/parallel/test-https-agent-unref-socket.js")
+ ;; This test is timing-sensitive, and fails sporadically on
+ ;; slow, busy, or even very fast machines.
+ (delete-file "test/parallel/test-fs-utimes.js")
+
;; FIXME: This test fails randomly:
;; https://github.com/nodejs/node/issues/31213
(delete-file "test/parallel/test-net-listen-after-destroying-stdin.js")
@@ -802,8 +844,9 @@ source files.")
;; 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 +873,7 @@ source files.")
python
util-linux))
(inputs
- (list bash
+ (list bash-minimal
coreutils
c-ares-for-node
icu4c-67
@@ -839,6 +882,7 @@ source files.")
brotli
`(,nghttp2 "lib")
openssl
+ python-wrapper ;; for node-gyp (supports python3)
zlib))))
(define-public libnode
@@ -850,5 +894,5 @@ source files.")
`(cons* "--shared" "--without-npm" ,flags))
((#:phases phases '%standard-phases)
`(modify-phases ,phases
- (delete 'patch-npm-shebang)
- (delete 'patch-node-shebang)))))))
+ (delete 'install-npmrc)
+ (delete 'patch-nested-shebangs)))))))