gnu: cross-base: Return #t from all phases.
[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>
ed02caff
CS
7;;;
8;;; This file is part of GNU Guix.
9;;;
10;;; GNU Guix is free software; you can redistribute it and/or modify it
11;;; under the terms of the GNU General Public License as published by
12;;; the Free Software Foundation; either version 3 of the License, or (at
13;;; your option) any later version.
14;;;
15;;; GNU Guix is distributed in the hope that it will be useful, but
16;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;;; GNU General Public License for more details.
19;;;
20;;; You should have received a copy of the GNU General Public License
21;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
22
23(define-module (gnu packages node)
1eca745b 24 #:use-module ((guix licenses) #:select (expat))
ed02caff
CS
25 #:use-module (guix packages)
26 #:use-module (guix derivations)
27 #:use-module (guix download)
1eca745b 28 #:use-module (guix build-system gnu)
dd04f56a 29 #:use-module (gnu packages)
ea584538 30 #:use-module (gnu packages adns)
1eca745b
DT
31 #:use-module (gnu packages base)
32 #:use-module (gnu packages compression)
33 #:use-module (gnu packages gcc)
fe5d4f81 34 #:use-module (gnu packages icu4c)
1eca745b
DT
35 #:use-module (gnu packages libevent)
36 #:use-module (gnu packages linux)
37 #:use-module (gnu packages perl)
fe5d4f81 38 #:use-module (gnu packages pkg-config)
1eca745b 39 #:use-module (gnu packages python)
ea584538
JL
40 #:use-module (gnu packages tls)
41 #:use-module (gnu packages web))
ed02caff
CS
42
43(define-public node
44 (package
45 (name "node")
f06e3913 46 (version "9.8.0")
ed02caff
CS
47 (source (origin
48 (method url-fetch)
49 (uri (string-append "http://nodejs.org/dist/v" version
50 "/node-v" version ".tar.gz"))
51 (sha256
52 (base32
fe5d4f81
JL
53 "1mjr1rm5w26c0yb4zq6z5yv3zbvqk18lwbswhwn1sha8hapinjp8"))
54 (modules '((guix build utils)))
55 (snippet
56 `(begin
57 ;; Remove bundled software.
58 (for-each delete-file-recursively
59 '("deps/cares"
60 "deps/http_parser"
61 "deps/icu-small"
62 "deps/nghttp2"
63 "deps/openssl"
64 "deps/uv"
65 "deps/zlib"))
66 (substitute* "Makefile"
67 ;; Remove references to bundled software
68 (("deps/http_parser/http_parser.gyp") "")
69 (("deps/uv/include/\\*.h") "")
70 (("deps/uv/uv.gyp") "")
71 (("deps/zlib/zlib.gyp") ""))))))
ed02caff
CS
72 (build-system gnu-build-system)
73 (arguments
ea584538 74 ;; TODO: Purge the bundled copies from the source.
fe5d4f81 75 '(#:configure-flags '("--shared-cares"
ea584538 76 "--shared-http-parser"
fe5d4f81
JL
77 "--shared-libuv"
78 "--shared-nghttp2"
79 "--shared-openssl"
80 "--shared-zlib"
81 "--without-snapshot"
82 "--with-intl=system-icu")
1eca745b
DT
83 #:phases
84 (modify-phases %standard-phases
c5b5e275
DT
85 (add-before 'configure 'patch-files
86 (lambda* (#:key inputs #:allow-other-keys)
87 ;; Fix hardcoded /bin/sh references.
88 (substitute* '("lib/child_process.js"
89 "lib/internal/v8_prof_polyfill.js"
3759deab 90 "test/parallel/test-child-process-spawnsync-shell.js"
c5b5e275
DT
91 "test/parallel/test-stdio-closed.js")
92 (("'/bin/sh'")
f2ea722a 93 (string-append "'" (which "sh") "'")))
c5b5e275
DT
94
95 ;; Fix hardcoded /usr/bin/env references.
96 (substitute* '("test/parallel/test-child-process-default-options.js"
97 "test/parallel/test-child-process-env.js"
98 "test/parallel/test-child-process-exec-env.js")
99 (("'/usr/bin/env'")
100 (string-append "'" (which "env") "'")))
101
80f642ac
JL
102 ;; FIXME: These tests depend on being able to install eslint.
103 ;; See https://github.com/nodejs/node/issues/17098.
aafcfffd 104 (for-each delete-file
f06e3913 105 '("test/parallel/test-eslint-alphabetize-errors.js"
80f642ac
JL
106 "test/parallel/test-eslint-buffer-constructor.js"
107 "test/parallel/test-eslint-documented-errors.js"
f06e3913 108 "test/parallel/test-eslint-inspector-check.js"))
80f642ac 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.
112 (for-each delete-file
aafcfffd
JL
113 '("test/async-hooks/test-ttywrap.readstream.js"
114 "test/parallel/test-util-inspect.js"
115 "test/parallel/test-v8-serdes.js"
116 "test/parallel/test-dgram-membership.js"
bc709e03 117 "test/parallel/test-dns-cancel-reverse-lookup.js"
44833970 118 "test/parallel/test-dns-resolveany.js"
dd04f56a 119 "test/parallel/test-cluster-master-error.js"
c5b5e275 120 "test/parallel/test-cluster-master-kill.js"
b0881e0b 121 "test/parallel/test-net-listen-after-destroying-stdin.js"
c5b5e275 122 "test/parallel/test-npm-install.js"
1fdb8830
JL
123 "test/sequential/test-child-process-emfile.js"
124 "test/sequential/test-benchmark-child-process.js"
125 "test/sequential/test-http-regr-gh-2928.js"))
c5b5e275
DT
126 #t))
127 (replace 'configure
128 ;; Node's configure script is actually a python script, so we can't
129 ;; run it with bash.
130 (lambda* (#:key outputs (configure-flags '()) inputs
131 #:allow-other-keys)
132 (let* ((prefix (assoc-ref outputs "out"))
133 (flags (cons (string-append "--prefix=" prefix)
134 configure-flags)))
135 (format #t "build directory: ~s~%" (getcwd))
136 (format #t "configure flags: ~s~%" flags)
137 ;; Node's configure script expects the CC environment variable to
138 ;; be set.
139 (setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc"))
140 (zero? (apply system*
141 (string-append (assoc-ref inputs "python")
142 "/bin/python")
2de091f0 143 "configure" flags)))))
dd04f56a
AM
144 (add-after 'patch-shebangs 'patch-npm-shebang
145 (lambda* (#:key outputs #:allow-other-keys)
146 (let* ((bindir (string-append (assoc-ref outputs "out")
147 "/bin"))
148 (npm (string-append bindir "/npm"))
2de091f0 149 (target (readlink npm)))
dd04f56a
AM
150 (with-directory-excursion bindir
151 (patch-shebang target (list bindir))
152 #t)))))))
1eca745b
DT
153 (native-inputs
154 `(("python" ,python-2)
155 ("perl" ,perl)
fe5d4f81 156 ("pkg-config" ,pkg-config)
c5b5e275 157 ("procps" ,procps)
1eca745b
DT
158 ("util-linux" ,util-linux)
159 ("which" ,which)))
45c18f85
JL
160 (native-search-paths
161 (list (search-path-specification
162 (variable "NODE_PATH")
163 (files '("lib/node_modules")))))
1eca745b 164 (inputs
ea584538
JL
165 `(("c-ares" ,c-ares)
166 ("http-parser" ,http-parser)
fe5d4f81 167 ("icu4c" ,icu4c)
ea584538 168 ("libuv" ,libuv)
fe5d4f81 169 ("nghttp2" ,nghttp2 "lib")
1eca745b
DT
170 ("openssl" ,openssl)
171 ("zlib" ,zlib)))
2d094239 172 (synopsis "Evented I/O for V8 JavaScript")
ed02caff
CS
173 (description "Node.js is a platform built on Chrome's JavaScript runtime
174for easily building fast, scalable network applications. Node.js uses an
175event-driven, non-blocking I/O model that makes it lightweight and efficient,
176perfect for data-intensive real-time applications that run across distributed
177devices.")
1eca745b 178 (home-page "http://nodejs.org/")
3759deab 179 (license expat)
e5f0563d 180 (properties '((timeout . 3600))))) ; 1 h