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