projects/guix·blob version-0.15.0 · refs

182 lines · 8.2 KiB

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