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