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