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> |
ed02caff CS |
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) | |
1eca745b | 23 | #:use-module ((guix licenses) #:select (expat)) |
ed02caff CS |
24 | #:use-module (guix packages) |
25 | #:use-module (guix derivations) | |
26 | #:use-module (guix download) | |
1eca745b | 27 | #:use-module (guix build-system gnu) |
dd04f56a | 28 | #:use-module (gnu packages) |
1eca745b DT |
29 | #:use-module (gnu packages base) |
30 | #:use-module (gnu packages compression) | |
31 | #:use-module (gnu packages gcc) | |
32 | #:use-module (gnu packages libevent) | |
33 | #:use-module (gnu packages linux) | |
34 | #:use-module (gnu packages perl) | |
35 | #:use-module (gnu packages python) | |
36 | #:use-module (gnu packages tls)) | |
ed02caff CS |
37 | |
38 | (define-public node | |
39 | (package | |
40 | (name "node") | |
dd04f56a | 41 | (version "6.8.0") |
ed02caff CS |
42 | (source (origin |
43 | (method url-fetch) | |
44 | (uri (string-append "http://nodejs.org/dist/v" version | |
45 | "/node-v" version ".tar.gz")) | |
46 | (sha256 | |
47 | (base32 | |
dd04f56a AM |
48 | "0lj3250hglz4w5ic4svd7wlg2r3qc49hnasvbva1v69l8yvx98m8")) |
49 | ;; https://github.com/nodejs/node/pull/9077 | |
50 | (patches (search-patches "node-9077.patch")))) | |
ed02caff CS |
51 | (build-system gnu-build-system) |
52 | (arguments | |
1eca745b | 53 | ;; TODO: Package http_parser and add --shared-http-parser. |
c5b5e275 DT |
54 | '(#:configure-flags '("--shared-openssl" |
55 | "--shared-zlib" | |
56 | "--shared-libuv" | |
57 | "--without-snapshot") | |
1eca745b DT |
58 | #:phases |
59 | (modify-phases %standard-phases | |
c5b5e275 DT |
60 | (add-before 'configure 'patch-files |
61 | (lambda* (#:key inputs #:allow-other-keys) | |
62 | ;; Fix hardcoded /bin/sh references. | |
63 | (substitute* '("lib/child_process.js" | |
64 | "lib/internal/v8_prof_polyfill.js" | |
65 | "test/parallel/test-stdio-closed.js") | |
66 | (("'/bin/sh'") | |
67 | (string-append "'" (which "bash") "'"))) | |
68 | ||
69 | ;; Fix hardcoded /usr/bin/env references. | |
70 | (substitute* '("test/parallel/test-child-process-default-options.js" | |
71 | "test/parallel/test-child-process-env.js" | |
72 | "test/parallel/test-child-process-exec-env.js") | |
73 | (("'/usr/bin/env'") | |
74 | (string-append "'" (which "env") "'"))) | |
75 | ||
76 | ;; Having the build fail because of linter errors is insane! | |
77 | (substitute* '("Makefile") | |
78 | ((" \\$\\(MAKE\\) jslint") "") | |
79 | ((" \\$\\(MAKE\\) cpplint\n") "")) | |
80 | ||
81 | ;; FIXME: These tests fail in the build container, but they don't | |
82 | ;; seem to be indicative of real problems in practice. | |
83 | (for-each delete-file | |
dd04f56a AM |
84 | '("test/parallel/test-dgram-membership.js" |
85 | "test/parallel/test-cluster-master-error.js" | |
c5b5e275 DT |
86 | "test/parallel/test-cluster-master-kill.js" |
87 | "test/parallel/test-npm-install.js" | |
c5b5e275 DT |
88 | "test/sequential/test-child-process-emfile.js")) |
89 | #t)) | |
90 | (replace 'configure | |
91 | ;; Node's configure script is actually a python script, so we can't | |
92 | ;; run it with bash. | |
93 | (lambda* (#:key outputs (configure-flags '()) inputs | |
94 | #:allow-other-keys) | |
95 | (let* ((prefix (assoc-ref outputs "out")) | |
96 | (flags (cons (string-append "--prefix=" prefix) | |
97 | configure-flags))) | |
98 | (format #t "build directory: ~s~%" (getcwd)) | |
99 | (format #t "configure flags: ~s~%" flags) | |
100 | ;; Node's configure script expects the CC environment variable to | |
101 | ;; be set. | |
102 | (setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc")) | |
103 | (zero? (apply system* | |
104 | (string-append (assoc-ref inputs "python") | |
105 | "/bin/python") | |
2de091f0 | 106 | "configure" flags))))) |
dd04f56a AM |
107 | (add-after 'patch-shebangs 'patch-npm-shebang |
108 | (lambda* (#:key outputs #:allow-other-keys) | |
109 | (let* ((bindir (string-append (assoc-ref outputs "out") | |
110 | "/bin")) | |
111 | (npm (string-append bindir "/npm")) | |
2de091f0 | 112 | (target (readlink npm))) |
dd04f56a AM |
113 | (with-directory-excursion bindir |
114 | (patch-shebang target (list bindir)) | |
115 | #t))))))) | |
1eca745b DT |
116 | (native-inputs |
117 | `(("python" ,python-2) | |
118 | ("perl" ,perl) | |
c5b5e275 | 119 | ("procps" ,procps) |
1eca745b DT |
120 | ("util-linux" ,util-linux) |
121 | ("which" ,which))) | |
122 | (inputs | |
123 | `(("libuv" ,libuv) | |
124 | ("openssl" ,openssl) | |
125 | ("zlib" ,zlib))) | |
2d094239 | 126 | (synopsis "Evented I/O for V8 JavaScript") |
ed02caff CS |
127 | (description "Node.js is a platform built on Chrome's JavaScript runtime |
128 | for easily building fast, scalable network applications. Node.js uses an | |
129 | event-driven, non-blocking I/O model that makes it lightweight and efficient, | |
130 | perfect for data-intensive real-time applications that run across distributed | |
131 | devices.") | |
1eca745b DT |
132 | (home-page "http://nodejs.org/") |
133 | (license expat))) |