gnu: node: Update to 10.16.0.
[jackhill/guix/guix.git] / gnu / packages / node.scm
CommitLineData
ed02caff
CS
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2014 Cyrill Schenkel <cyrill.schenkel@gmail.com>
20fbd209 3;;; Copyright © 2015 Andreas Enge <andreas@enge.fr>
c5b5e275 4;;; Copyright © 2015, 2016 David Thompson <davet@gnu.org>
2de091f0 5;;; Copyright © 2016 Ludovic Courtès <ludo@gnu.org>
797d2387 6;;; Copyright © 2017 Mike Gerwitz <mtg@gnu.org>
5112238f 7;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
70248461 8;;; Copyright © 2018, 2019 Marius Bakke <mbakke@fastmail.com>
ed02caff
CS
9;;;
10;;; This file is part of GNU Guix.
11;;;
12;;; GNU Guix is free software; you can redistribute it and/or modify it
13;;; under the terms of the GNU General Public License as published by
14;;; the Free Software Foundation; either version 3 of the License, or (at
15;;; your option) any later version.
16;;;
17;;; GNU Guix is distributed in the hope that it will be useful, but
18;;; WITHOUT ANY WARRANTY; without even the implied warranty of
19;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20;;; GNU General Public License for more details.
21;;;
22;;; You should have received a copy of the GNU General Public License
23;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
24
25(define-module (gnu packages node)
1eca745b 26 #:use-module ((guix licenses) #:select (expat))
ed02caff
CS
27 #:use-module (guix packages)
28 #:use-module (guix derivations)
29 #:use-module (guix download)
1eca745b 30 #:use-module (guix build-system gnu)
dd04f56a 31 #:use-module (gnu packages)
ea584538 32 #:use-module (gnu packages adns)
1eca745b
DT
33 #:use-module (gnu packages base)
34 #:use-module (gnu packages compression)
35 #:use-module (gnu packages gcc)
fe5d4f81 36 #:use-module (gnu packages icu4c)
1eca745b
DT
37 #:use-module (gnu packages libevent)
38 #:use-module (gnu packages linux)
39 #:use-module (gnu packages perl)
fe5d4f81 40 #:use-module (gnu packages pkg-config)
1eca745b 41 #:use-module (gnu packages python)
ea584538
JL
42 #:use-module (gnu packages tls)
43 #:use-module (gnu packages web))
ed02caff
CS
44
45(define-public node
46 (package
47 (name "node")
4c482696 48 (version "10.16.0")
ed02caff
CS
49 (source (origin
50 (method url-fetch)
e9027160 51 (uri (string-append "https://nodejs.org/dist/v" version
70248461 52 "/node-v" version ".tar.xz"))
ed02caff
CS
53 (sha256
54 (base32
4c482696 55 "0236jlb1hxhzqjlmmlxipcycrndiq92c8434iyy7zshh3n4pzqqq"))
fe5d4f81
JL
56 (modules '((guix build utils)))
57 (snippet
58 `(begin
59 ;; Remove bundled software.
60 (for-each delete-file-recursively
61 '("deps/cares"
62 "deps/http_parser"
63 "deps/icu-small"
64 "deps/nghttp2"
65 "deps/openssl"
66 "deps/uv"
67 "deps/zlib"))
68 (substitute* "Makefile"
5112238f 69 ;; Remove references to bundled software.
fe5d4f81
JL
70 (("deps/http_parser/http_parser.gyp") "")
71 (("deps/uv/include/\\*.h") "")
72 (("deps/uv/uv.gyp") "")
6cbee49d
MW
73 (("deps/zlib/zlib.gyp") ""))
74 #t))))
ed02caff
CS
75 (build-system gnu-build-system)
76 (arguments
ea584538 77 ;; TODO: Purge the bundled copies from the source.
fe5d4f81 78 '(#:configure-flags '("--shared-cares"
ea584538 79 "--shared-http-parser"
fe5d4f81
JL
80 "--shared-libuv"
81 "--shared-nghttp2"
82 "--shared-openssl"
83 "--shared-zlib"
84 "--without-snapshot"
85 "--with-intl=system-icu")
70248461
MB
86 ;; Run only the CI tests. The default test target requires additional
87 ;; add-ons from NPM that are not distributed with the source.
88 #:test-target "test-ci-js"
1eca745b
DT
89 #:phases
90 (modify-phases %standard-phases
c5b5e275
DT
91 (add-before 'configure 'patch-files
92 (lambda* (#:key inputs #:allow-other-keys)
e789b858 93
c5b5e275
DT
94 ;; Fix hardcoded /bin/sh references.
95 (substitute* '("lib/child_process.js"
96 "lib/internal/v8_prof_polyfill.js"
3759deab 97 "test/parallel/test-child-process-spawnsync-shell.js"
4c482696
MB
98 "test/parallel/test-stdio-closed.js"
99 "test/sequential/test-child-process-emfile.js")
c5b5e275 100 (("'/bin/sh'")
f2ea722a 101 (string-append "'" (which "sh") "'")))
c5b5e275
DT
102
103 ;; Fix hardcoded /usr/bin/env references.
104 (substitute* '("test/parallel/test-child-process-default-options.js"
105 "test/parallel/test-child-process-env.js"
106 "test/parallel/test-child-process-exec-env.js")
107 (("'/usr/bin/env'")
108 (string-append "'" (which "env") "'")))
109
c5b5e275
DT
110 ;; FIXME: These tests fail in the build container, but they don't
111 ;; seem to be indicative of real problems in practice.
70248461 112 (for-each delete-file
4c482696 113 '("test/parallel/test-cluster-master-error.js"
c5b5e275 114 "test/parallel/test-cluster-master-kill.js"
4c482696
MB
115 ;; See also <https://github.com/nodejs/node/issues/25903>.
116 "test/sequential/test-performance.js"))
117
118 ;; This requires a DNS resolver.
119 (delete-file "test/parallel/test-dns.js")
020c4ef1
MB
120
121 ;; These tests have an expiry date: they depend on the validity of
122 ;; TLS certificates that are bundled with the source. We want this
123 ;; package to be reproducible forever, so remove those.
124 ;; TODO: Regenerate certs instead.
70248461 125 (for-each delete-file
020c4ef1
MB
126 '("test/parallel/test-tls-passphrase.js"
127 "test/parallel/test-tls-server-verify.js"))
c5b5e275
DT
128 #t))
129 (replace 'configure
130 ;; Node's configure script is actually a python script, so we can't
131 ;; run it with bash.
132 (lambda* (#:key outputs (configure-flags '()) inputs
133 #:allow-other-keys)
134 (let* ((prefix (assoc-ref outputs "out"))
135 (flags (cons (string-append "--prefix=" prefix)
136 configure-flags)))
137 (format #t "build directory: ~s~%" (getcwd))
138 (format #t "configure flags: ~s~%" flags)
139 ;; Node's configure script expects the CC environment variable to
140 ;; be set.
141 (setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc"))
5112238f
TGR
142 (apply invoke
143 (string-append (assoc-ref inputs "python")
144 "/bin/python")
145 "configure" flags))))
dd04f56a
AM
146 (add-after 'patch-shebangs 'patch-npm-shebang
147 (lambda* (#:key outputs #:allow-other-keys)
148 (let* ((bindir (string-append (assoc-ref outputs "out")
149 "/bin"))
150 (npm (string-append bindir "/npm"))
2de091f0 151 (target (readlink npm)))
dd04f56a
AM
152 (with-directory-excursion bindir
153 (patch-shebang target (list bindir))
154 #t)))))))
1eca745b
DT
155 (native-inputs
156 `(("python" ,python-2)
157 ("perl" ,perl)
fe5d4f81 158 ("pkg-config" ,pkg-config)
c5b5e275 159 ("procps" ,procps)
1eca745b
DT
160 ("util-linux" ,util-linux)
161 ("which" ,which)))
45c18f85
JL
162 (native-search-paths
163 (list (search-path-specification
164 (variable "NODE_PATH")
165 (files '("lib/node_modules")))))
1eca745b 166 (inputs
ea584538
JL
167 `(("c-ares" ,c-ares)
168 ("http-parser" ,http-parser)
fe5d4f81 169 ("icu4c" ,icu4c)
70248461 170 ("libuv" ,libuv)
fe5d4f81 171 ("nghttp2" ,nghttp2 "lib")
d9bbfe04 172 ("openssl" ,openssl)
1eca745b 173 ("zlib" ,zlib)))
2d094239 174 (synopsis "Evented I/O for V8 JavaScript")
ed02caff
CS
175 (description "Node.js is a platform built on Chrome's JavaScript runtime
176for easily building fast, scalable network applications. Node.js uses an
177event-driven, non-blocking I/O model that makes it lightweight and efficient,
178perfect for data-intensive real-time applications that run across distributed
179devices.")
e9027160 180 (home-page "https://nodejs.org/")
3759deab 181 (license expat)
e5f0563d 182 (properties '((timeout . 3600))))) ; 1 h