Commit | Line | Data |
---|---|---|
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> |
458c3ff5 | 8 | ;;; Copyright © 2018, 2019, 2020 Marius Bakke <mbakke@fastmail.com> |
235093fe | 9 | ;;; Copyright © 2020 Pierre Langlois <pierre.langlois@gmx.com> |
1d77141f | 10 | ;;; Copyright © 2020 Ricardo Wurmus <rekado@elephly.net> |
41134f91 | 11 | ;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com> |
ed02caff CS |
12 | ;;; |
13 | ;;; This file is part of GNU Guix. | |
14 | ;;; | |
15 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
16 | ;;; under the terms of the GNU General Public License as published by | |
17 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
18 | ;;; your option) any later version. | |
19 | ;;; | |
20 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
21 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
22 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
23 | ;;; GNU General Public License for more details. | |
24 | ;;; | |
25 | ;;; You should have received a copy of the GNU General Public License | |
26 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
27 | ||
28 | (define-module (gnu packages node) | |
7728aa24 | 29 | #:use-module ((guix licenses) #:prefix license:) |
92db0d39 | 30 | #:use-module ((guix build utils) #:select (alist-replace)) |
ed02caff CS |
31 | #:use-module (guix packages) |
32 | #:use-module (guix derivations) | |
33 | #:use-module (guix download) | |
972f2a2a | 34 | #:use-module (guix git-download) |
bb310a19 | 35 | #:use-module (guix utils) |
1eca745b | 36 | #:use-module (guix build-system gnu) |
972f2a2a | 37 | #:use-module (guix build-system node) |
dd04f56a | 38 | #:use-module (gnu packages) |
ea584538 | 39 | #:use-module (gnu packages adns) |
1eca745b DT |
40 | #:use-module (gnu packages base) |
41 | #:use-module (gnu packages compression) | |
42 | #:use-module (gnu packages gcc) | |
fe5d4f81 | 43 | #:use-module (gnu packages icu4c) |
1eca745b DT |
44 | #:use-module (gnu packages libevent) |
45 | #:use-module (gnu packages linux) | |
f540ee5e | 46 | #:use-module (gnu packages node-xyz) |
1eca745b | 47 | #:use-module (gnu packages perl) |
fe5d4f81 | 48 | #:use-module (gnu packages pkg-config) |
1eca745b | 49 | #:use-module (gnu packages python) |
ea584538 JL |
50 | #:use-module (gnu packages tls) |
51 | #:use-module (gnu packages web)) | |
ed02caff CS |
52 | |
53 | (define-public node | |
54 | (package | |
55 | (name "node") | |
d0a0215c | 56 | (version "10.24.0") |
ed02caff CS |
57 | (source (origin |
58 | (method url-fetch) | |
e9027160 | 59 | (uri (string-append "https://nodejs.org/dist/v" version |
70248461 | 60 | "/node-v" version ".tar.xz")) |
ed02caff CS |
61 | (sha256 |
62 | (base32 | |
d0a0215c | 63 | "1k1srdis23782hnd1ymgczs78x9gqhv77v0am7yb54gqcspp70hm")) |
fe5d4f81 JL |
64 | (modules '((guix build utils))) |
65 | (snippet | |
66 | `(begin | |
67 | ;; Remove bundled software. | |
68 | (for-each delete-file-recursively | |
69 | '("deps/cares" | |
70 | "deps/http_parser" | |
71 | "deps/icu-small" | |
72 | "deps/nghttp2" | |
73 | "deps/openssl" | |
74 | "deps/uv" | |
75 | "deps/zlib")) | |
76 | (substitute* "Makefile" | |
5112238f | 77 | ;; Remove references to bundled software. |
fe5d4f81 JL |
78 | (("deps/http_parser/http_parser.gyp") "") |
79 | (("deps/uv/include/\\*.h") "") | |
80 | (("deps/uv/uv.gyp") "") | |
6cbee49d MW |
81 | (("deps/zlib/zlib.gyp") "")) |
82 | #t)))) | |
ed02caff CS |
83 | (build-system gnu-build-system) |
84 | (arguments | |
2f38e38f | 85 | `(#:configure-flags '("--shared-cares" |
ea584538 | 86 | "--shared-http-parser" |
fe5d4f81 JL |
87 | "--shared-libuv" |
88 | "--shared-nghttp2" | |
89 | "--shared-openssl" | |
90 | "--shared-zlib" | |
91 | "--without-snapshot" | |
92 | "--with-intl=system-icu") | |
70248461 MB |
93 | ;; Run only the CI tests. The default test target requires additional |
94 | ;; add-ons from NPM that are not distributed with the source. | |
95 | #:test-target "test-ci-js" | |
1eca745b DT |
96 | #:phases |
97 | (modify-phases %standard-phases | |
c5b5e275 DT |
98 | (add-before 'configure 'patch-files |
99 | (lambda* (#:key inputs #:allow-other-keys) | |
100 | ;; Fix hardcoded /bin/sh references. | |
101 | (substitute* '("lib/child_process.js" | |
102 | "lib/internal/v8_prof_polyfill.js" | |
3759deab | 103 | "test/parallel/test-child-process-spawnsync-shell.js" |
4c482696 MB |
104 | "test/parallel/test-stdio-closed.js" |
105 | "test/sequential/test-child-process-emfile.js") | |
c5b5e275 | 106 | (("'/bin/sh'") |
f2ea722a | 107 | (string-append "'" (which "sh") "'"))) |
c5b5e275 DT |
108 | |
109 | ;; Fix hardcoded /usr/bin/env references. | |
110 | (substitute* '("test/parallel/test-child-process-default-options.js" | |
111 | "test/parallel/test-child-process-env.js" | |
112 | "test/parallel/test-child-process-exec-env.js") | |
113 | (("'/usr/bin/env'") | |
114 | (string-append "'" (which "env") "'"))) | |
115 | ||
c5b5e275 DT |
116 | ;; FIXME: These tests fail in the build container, but they don't |
117 | ;; seem to be indicative of real problems in practice. | |
70248461 | 118 | (for-each delete-file |
4c482696 | 119 | '("test/parallel/test-cluster-master-error.js" |
c5b5e275 | 120 | "test/parallel/test-cluster-master-kill.js" |
4c482696 MB |
121 | ;; See also <https://github.com/nodejs/node/issues/25903>. |
122 | "test/sequential/test-performance.js")) | |
123 | ||
124 | ;; This requires a DNS resolver. | |
125 | (delete-file "test/parallel/test-dns.js") | |
020c4ef1 | 126 | |
51583265 MB |
127 | ;; FIXME: This test fails randomly: |
128 | ;; https://github.com/nodejs/node/issues/31213 | |
129 | (delete-file "test/parallel/test-net-listen-after-destroying-stdin.js") | |
130 | ||
5cfc6a88 MB |
131 | ;; FIXME: These tests fail on armhf-linux: |
132 | ;; https://github.com/nodejs/node/issues/31970 | |
133 | ,@(if (string-prefix? "arm" (%current-system)) | |
134 | '((for-each delete-file | |
135 | '("test/parallel/test-zlib.js" | |
136 | "test/parallel/test-zlib-brotli.js" | |
137 | "test/parallel/test-zlib-brotli-flush.js" | |
138 | "test/parallel/test-zlib-brotli-from-brotli.js" | |
139 | "test/parallel/test-zlib-brotli-from-string.js" | |
140 | "test/parallel/test-zlib-convenience-methods.js" | |
141 | "test/parallel/test-zlib-random-byte-pipes.js" | |
142 | "test/parallel/test-zlib-write-after-flush.js"))) | |
143 | '()) | |
144 | ||
020c4ef1 MB |
145 | ;; These tests have an expiry date: they depend on the validity of |
146 | ;; TLS certificates that are bundled with the source. We want this | |
147 | ;; package to be reproducible forever, so remove those. | |
148 | ;; TODO: Regenerate certs instead. | |
70248461 | 149 | (for-each delete-file |
020c4ef1 MB |
150 | '("test/parallel/test-tls-passphrase.js" |
151 | "test/parallel/test-tls-server-verify.js")) | |
c5b5e275 DT |
152 | #t)) |
153 | (replace 'configure | |
154 | ;; Node's configure script is actually a python script, so we can't | |
155 | ;; run it with bash. | |
156 | (lambda* (#:key outputs (configure-flags '()) inputs | |
157 | #:allow-other-keys) | |
158 | (let* ((prefix (assoc-ref outputs "out")) | |
159 | (flags (cons (string-append "--prefix=" prefix) | |
160 | configure-flags))) | |
161 | (format #t "build directory: ~s~%" (getcwd)) | |
162 | (format #t "configure flags: ~s~%" flags) | |
163 | ;; Node's configure script expects the CC environment variable to | |
164 | ;; be set. | |
165 | (setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc")) | |
5112238f TGR |
166 | (apply invoke |
167 | (string-append (assoc-ref inputs "python") | |
168 | "/bin/python") | |
169 | "configure" flags)))) | |
dd04f56a AM |
170 | (add-after 'patch-shebangs 'patch-npm-shebang |
171 | (lambda* (#:key outputs #:allow-other-keys) | |
172 | (let* ((bindir (string-append (assoc-ref outputs "out") | |
173 | "/bin")) | |
174 | (npm (string-append bindir "/npm")) | |
2de091f0 | 175 | (target (readlink npm))) |
dd04f56a AM |
176 | (with-directory-excursion bindir |
177 | (patch-shebang target (list bindir)) | |
1d77141f RW |
178 | #t)))) |
179 | (add-after 'install 'patch-node-shebang | |
180 | (lambda* (#:key outputs #:allow-other-keys) | |
181 | (let* ((bindir (string-append (assoc-ref outputs "out") | |
182 | "/bin")) | |
183 | (npx (readlink (string-append bindir "/npx")))) | |
184 | (with-directory-excursion bindir | |
185 | (patch-shebang npx (list bindir)) | |
dd04f56a | 186 | #t))))))) |
1eca745b DT |
187 | (native-inputs |
188 | `(("python" ,python-2) | |
189 | ("perl" ,perl) | |
fe5d4f81 | 190 | ("pkg-config" ,pkg-config) |
c5b5e275 | 191 | ("procps" ,procps) |
1eca745b DT |
192 | ("util-linux" ,util-linux) |
193 | ("which" ,which))) | |
45c18f85 JL |
194 | (native-search-paths |
195 | (list (search-path-specification | |
196 | (variable "NODE_PATH") | |
197 | (files '("lib/node_modules"))))) | |
1eca745b | 198 | (inputs |
ea584538 JL |
199 | `(("c-ares" ,c-ares) |
200 | ("http-parser" ,http-parser) | |
fe5d4f81 | 201 | ("icu4c" ,icu4c) |
70248461 | 202 | ("libuv" ,libuv) |
6b7cba0f | 203 | ("nghttp2" ,nghttp2 "lib") |
d9bbfe04 | 204 | ("openssl" ,openssl) |
1eca745b | 205 | ("zlib" ,zlib))) |
2d094239 | 206 | (synopsis "Evented I/O for V8 JavaScript") |
ed02caff CS |
207 | (description "Node.js is a platform built on Chrome's JavaScript runtime |
208 | for easily building fast, scalable network applications. Node.js uses an | |
209 | event-driven, non-blocking I/O model that makes it lightweight and efficient, | |
210 | perfect for data-intensive real-time applications that run across distributed | |
211 | devices.") | |
e9027160 | 212 | (home-page "https://nodejs.org/") |
7728aa24 | 213 | (license license:expat) |
b4481f2d MB |
214 | (properties '((max-silent-time . 7200) ;2h, needed on ARM |
215 | (timeout . 21600))))) ;6h | |
bb310a19 | 216 | |
0c0c4846 JL |
217 | ;; This should be the latest version of node that still builds without |
218 | ;; depending on llhttp. | |
219 | (define-public node-bootstrap | |
220 | (hidden-package node)) | |
221 | ||
f540ee5e JL |
222 | ;; Duplicate of node-semver |
223 | (define-public node-semver-bootstrap | |
224 | (package | |
225 | (name "node-semver") | |
226 | (version "7.2.1") | |
227 | (source (origin | |
228 | (method git-fetch) | |
229 | (uri (git-reference | |
230 | (url "https://github.com/npm/node-semver") | |
231 | (commit (string-append "v" version)))) | |
232 | (file-name (git-file-name name version)) | |
233 | (sha256 | |
234 | (base32 | |
235 | "06biknqb05r9xsmcflm3ygh50pjvdk84x6r79w43kmck4fn3qn5p")))) | |
236 | (build-system node-build-system) | |
237 | (arguments | |
238 | `(#:node ,node-bootstrap | |
239 | #:tests? #f | |
240 | #:phases | |
241 | (modify-phases %standard-phases | |
242 | (delete 'configure)))) | |
243 | (home-page "https://github.com/npm/node-semver") | |
244 | (properties '((hidden? . #t))) | |
245 | (synopsis "Parses semantic versions strings") | |
246 | (description | |
247 | "@code{node-semver} is a JavaScript implementation of the | |
248 | @uref{https://semver.org/, SemVer.org} specification.") | |
249 | (license license:isc))) | |
250 | ||
972f2a2a JL |
251 | (define-public node-ms-bootstrap |
252 | (package | |
253 | (name "node-ms") | |
254 | (version "2.1.2") | |
255 | (source | |
256 | (origin | |
257 | (method git-fetch) | |
258 | (uri (git-reference | |
259 | (url "https://github.com/vercel/ms.git") | |
260 | (commit version))) | |
261 | (file-name (git-file-name name version)) | |
262 | (sha256 | |
263 | (base32 | |
264 | "1pjxzbi4j8pinlsc7yxvfrh0b47kb2dc4lfc2rjq4wx5bdwl33fj")))) | |
265 | (build-system node-build-system) | |
266 | (arguments | |
267 | `(#:node ,node-bootstrap | |
268 | #:tests? #f | |
269 | #:phases | |
270 | (modify-phases %standard-phases | |
271 | (delete 'configure)))) | |
272 | (home-page "https://github.com/zeit/ms#readme") | |
273 | (properties '((hidden? . #t))) | |
274 | (synopsis "Tiny millisecond conversion utility") | |
275 | (description "Use this package to easily convert various time | |
276 | formats to milliseconds.") | |
277 | (license license:expat))) | |
278 | ||
bb310a19 | 279 | (define-public libnode |
1a265842 | 280 | (package/inherit node |
bb310a19 RW |
281 | (name "libnode") |
282 | (arguments | |
283 | (substitute-keyword-arguments (package-arguments node) | |
284 | ((#:configure-flags flags ''()) | |
e8521f0b RW |
285 | `(cons* "--shared" "--without-npm" ,flags)) |
286 | ((#:phases phases '%standard-phases) | |
287 | `(modify-phases ,phases | |
41134f91 | 288 | (delete 'patch-npm-shebang) |
289 | (delete 'patch-node-shebang))))))) |