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 ;;; Copyright © 2017 Mike Gerwitz <mtg@gnu.org>
8 ;;; This file is part of GNU Guix.
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.
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.
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/>.
23 (define-module (gnu packages node)
24 #:use-module ((guix licenses) #:select (expat))
25 #:use-module (guix packages)
26 #:use-module (guix derivations)
27 #:use-module (guix download)
28 #:use-module (guix build-system gnu)
29 #:use-module (gnu packages)
30 #:use-module (gnu packages adns)
31 #:use-module (gnu packages base)
32 #:use-module (gnu packages compression)
33 #:use-module (gnu packages gcc)
34 #:use-module (gnu packages icu4c)
35 #:use-module (gnu packages libevent)
36 #:use-module (gnu packages linux)
37 #:use-module (gnu packages perl)
38 #:use-module (gnu packages pkg-config)
39 #:use-module (gnu packages python)
40 #:use-module (gnu packages tls)
41 #:use-module (gnu packages web))
49 (uri (string-append "http://nodejs.org/dist/v" version
50 "/node-v" version ".tar.gz"))
53 "1vjh9zvw7wkdz6b0l99ya7mqjk0l8lbg9isr1q8rxwp400dhkk32"))
54 (modules '((guix build utils)))
57 ;; Remove bundled software.
58 (for-each delete-file-recursively
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") ""))))))
72 (build-system gnu-build-system)
74 ;; TODO: Purge the bundled copies from the source.
75 '(#:configure-flags '("--shared-cares"
76 "--shared-http-parser"
82 "--with-intl=system-icu")
84 (modify-phases %standard-phases
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"
90 "test/parallel/test-child-process-spawnsync-shell.js"
91 "test/parallel/test-stdio-closed.js")
93 (string-append "'" (which "sh") "'")))
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")
100 (string-append "'" (which "env") "'")))
102 ;; FIXME: These tests depend on being able to install eslint.
103 ;; See https://github.com/nodejs/node/issues/17098.
104 (for-each delete-file
105 '("test/parallel/test-eslint-alphabetize-errors.js"
106 "test/parallel/test-eslint-buffer-constructor.js"
107 "test/parallel/test-eslint-documented-errors.js"
108 "test/parallel/test-eslint-inspector-check.js"))
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
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"
117 "test/parallel/test-dns-cancel-reverse-lookup.js"
118 "test/parallel/test-dns-resolveany.js"
119 "test/parallel/test-cluster-master-error.js"
120 "test/parallel/test-cluster-master-kill.js"
121 "test/parallel/test-net-listen-after-destroying-stdin.js"
122 "test/parallel/test-npm-install.js"
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"))
128 ;; Node's configure script is actually a python script, so we can't
130 (lambda* (#:key outputs (configure-flags '()) inputs
132 (let* ((prefix (assoc-ref outputs "out"))
133 (flags (cons (string-append "--prefix=" prefix)
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
139 (setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc"))
140 (zero? (apply system*
141 (string-append (assoc-ref inputs "python")
143 "configure" flags)))))
144 (add-after 'patch-shebangs 'patch-npm-shebang
145 (lambda* (#:key outputs #:allow-other-keys)
146 (let* ((bindir (string-append (assoc-ref outputs "out")
148 (npm (string-append bindir "/npm"))
149 (target (readlink npm)))
150 (with-directory-excursion bindir
151 (patch-shebang target (list bindir))
154 `(("python" ,python-2)
156 ("pkg-config" ,pkg-config)
158 ("util-linux" ,util-linux)
161 (list (search-path-specification
162 (variable "NODE_PATH")
163 (files '("lib/node_modules")))))
166 ("http-parser" ,http-parser)
169 ("nghttp2" ,nghttp2 "lib")
172 (synopsis "Evented I/O for V8 JavaScript")
173 (description "Node.js is a platform built on Chrome's JavaScript runtime
174 for easily building fast, scalable network applications. Node.js uses an
175 event-driven, non-blocking I/O model that makes it lightweight and efficient,
176 perfect for data-intensive real-time applications that run across distributed
178 (home-page "http://nodejs.org/")
180 (properties '((timeout . 3600))))) ; 1 h