d4415fc501d11a18c666c4d86b923455537f2abc
[jackhill/guix/guix.git] / gnu / packages / node.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014 Cyrill Schenkel <cyrill.schenkel@gmail.com>
3 ;;; Copyright © 2015 Andreas Enge <andreas@enge.fr>
4 ;;; Copyright © 2015, 2016 David Thompson <davet@gnu.org>
5 ;;; Copyright © 2016 Ludovic Courtès <ludo@gnu.org>
6 ;;;
7 ;;; This file is part of GNU Guix.
8 ;;;
9 ;;; GNU Guix is free software; you can redistribute it and/or modify it
10 ;;; under the terms of the GNU General Public License as published by
11 ;;; the Free Software Foundation; either version 3 of the License, or (at
12 ;;; your option) any later version.
13 ;;;
14 ;;; GNU Guix is distributed in the hope that it will be useful, but
15 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;;; GNU General Public License for more details.
18 ;;;
19 ;;; You should have received a copy of the GNU General Public License
20 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21
22 (define-module (gnu packages node)
23 #:use-module ((guix licenses) #:select (expat))
24 #:use-module (guix packages)
25 #:use-module (guix derivations)
26 #:use-module (guix download)
27 #:use-module (guix build-system gnu)
28 #:use-module (gnu packages)
29 #:use-module (gnu packages adns)
30 #:use-module (gnu packages base)
31 #:use-module (gnu packages compression)
32 #:use-module (gnu packages gcc)
33 #:use-module (gnu packages libevent)
34 #:use-module (gnu packages linux)
35 #:use-module (gnu packages perl)
36 #:use-module (gnu packages python)
37 #:use-module (gnu packages tls)
38 #:use-module (gnu packages web))
39
40 (define-public node
41 (package
42 (name "node")
43 (version "8.1.2")
44 (source (origin
45 (method url-fetch)
46 (uri (string-append "http://nodejs.org/dist/v" version
47 "/node-v" version ".tar.gz"))
48 (sha256
49 (base32
50 "0l92gar1pivzaiwffiiiz2f2m5k39sl5fphlfnvy0ml9hrjb65yp"))
51 ;; https://github.com/nodejs/node/pull/9077
52 (patches (search-patches "node-9077.patch"))))
53 (build-system gnu-build-system)
54 (arguments
55 ;; TODO: Purge the bundled copies from the source.
56 '(#:configure-flags '("--shared-openssl"
57 "--shared-zlib"
58 "--shared-libuv"
59 "--shared-cares"
60 "--shared-http-parser"
61 "--without-snapshot")
62 #:phases
63 (modify-phases %standard-phases
64 (add-before 'configure 'patch-files
65 (lambda* (#:key inputs #:allow-other-keys)
66 ;; Fix hardcoded /bin/sh references.
67 (substitute* '("lib/child_process.js"
68 "lib/internal/v8_prof_polyfill.js"
69 "test/parallel/test-child-process-spawnsync-shell.js"
70 "test/parallel/test-stdio-closed.js")
71 (("'/bin/sh'")
72 (string-append "'" (which "sh") "'")))
73
74 ;; Fix hardcoded /usr/bin/env references.
75 (substitute* '("test/parallel/test-child-process-default-options.js"
76 "test/parallel/test-child-process-env.js"
77 "test/parallel/test-child-process-exec-env.js")
78 (("'/usr/bin/env'")
79 (string-append "'" (which "env") "'")))
80
81 ;; Having the build fail because of linter errors is insane!
82 (substitute* '("Makefile")
83 ((" \\$\\(MAKE\\) jslint") "")
84 ((" \\$\\(MAKE\\) cpplint\n") ""))
85
86 ;; FIXME: This test seems to depends on files that are not
87 ;; available in the bundled v8. See
88 ;; https://github.com/nodejs/node/issues/13344
89 (for-each delete-file
90 '("test/addons-napi/test_general/testInstanceOf.js"))
91 ;; FIXME: These tests fail in the build container, but they don't
92 ;; seem to be indicative of real problems in practice.
93 (for-each delete-file
94 '("test/async-hooks/test-ttywrap.readstream.js"
95 "test/parallel/test-util-inspect.js"
96 "test/parallel/test-v8-serdes.js"
97 "test/parallel/test-dgram-membership.js"
98 "test/parallel/test-cluster-master-error.js"
99 "test/parallel/test-cluster-master-kill.js"
100 "test/parallel/test-npm-install.js"
101 "test/sequential/test-child-process-emfile.js"
102 "test/sequential/test-benchmark-child-process.js"
103 "test/sequential/test-http-regr-gh-2928.js"))
104 #t))
105 (replace 'configure
106 ;; Node's configure script is actually a python script, so we can't
107 ;; run it with bash.
108 (lambda* (#:key outputs (configure-flags '()) inputs
109 #:allow-other-keys)
110 (let* ((prefix (assoc-ref outputs "out"))
111 (flags (cons (string-append "--prefix=" prefix)
112 configure-flags)))
113 (format #t "build directory: ~s~%" (getcwd))
114 (format #t "configure flags: ~s~%" flags)
115 ;; Node's configure script expects the CC environment variable to
116 ;; be set.
117 (setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc"))
118 (zero? (apply system*
119 (string-append (assoc-ref inputs "python")
120 "/bin/python")
121 "configure" flags)))))
122 (add-after 'patch-shebangs 'patch-npm-shebang
123 (lambda* (#:key outputs #:allow-other-keys)
124 (let* ((bindir (string-append (assoc-ref outputs "out")
125 "/bin"))
126 (npm (string-append bindir "/npm"))
127 (target (readlink npm)))
128 (with-directory-excursion bindir
129 (patch-shebang target (list bindir))
130 #t)))))))
131 (native-inputs
132 `(("python" ,python-2)
133 ("perl" ,perl)
134 ("procps" ,procps)
135 ("util-linux" ,util-linux)
136 ("which" ,which)))
137 (inputs
138 `(("c-ares" ,c-ares)
139 ("http-parser" ,http-parser)
140 ("libuv" ,libuv)
141 ("openssl" ,openssl)
142 ("zlib" ,zlib)))
143 (synopsis "Evented I/O for V8 JavaScript")
144 (description "Node.js is a platform built on Chrome's JavaScript runtime
145 for easily building fast, scalable network applications. Node.js uses an
146 event-driven, non-blocking I/O model that makes it lightweight and efficient,
147 perfect for data-intensive real-time applications that run across distributed
148 devices.")
149 (home-page "http://nodejs.org/")
150 (license expat)
151 (properties '((timeout . 3600))))) ; 1 h