| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 |
|
| 26 | (define-module (gnu packages node)
|
| 27 | #:use-module ((guix licenses) #:select (expat))
|
| 28 | #:use-module ((guix build utils) #:select (alist-replace))
|
| 29 | #:use-module (guix packages)
|
| 30 | #:use-module (guix derivations)
|
| 31 | #:use-module (guix download)
|
| 32 | #:use-module (guix utils)
|
| 33 | #:use-module (guix build-system gnu)
|
| 34 | #:use-module (gnu packages)
|
| 35 | #:use-module (gnu packages adns)
|
| 36 | #:use-module (gnu packages base)
|
| 37 | #:use-module (gnu packages compression)
|
| 38 | #:use-module (gnu packages gcc)
|
| 39 | #:use-module (gnu packages icu4c)
|
| 40 | #:use-module (gnu packages libevent)
|
| 41 | #:use-module (gnu packages linux)
|
| 42 | #:use-module (gnu packages perl)
|
| 43 | #:use-module (gnu packages pkg-config)
|
| 44 | #:use-module (gnu packages python)
|
| 45 | #:use-module (gnu packages tls)
|
| 46 | #:use-module (gnu packages web))
|
| 47 |
|
| 48 | (define-public node
|
| 49 | (package
|
| 50 | (name "node")
|
| 51 | (version "10.20.0")
|
| 52 | (source (origin
|
| 53 | (method url-fetch)
|
| 54 | (uri (string-append "https://nodejs.org/dist/v" version
|
| 55 | "/node-v" version ".tar.xz"))
|
| 56 | (sha256
|
| 57 | (base32
|
| 58 | "0cvjwnl0wkcsyw3kannbdv01s235wrnp11n2s6swzjx95gpichfi"))
|
| 59 | (modules '((guix build utils)))
|
| 60 | (snippet
|
| 61 | `(begin
|
| 62 | |
| 63 | (for-each delete-file-recursively
|
| 64 | '("deps/cares"
|
| 65 | "deps/http_parser"
|
| 66 | "deps/icu-small"
|
| 67 | "deps/nghttp2"
|
| 68 | "deps/openssl"
|
| 69 | "deps/uv"
|
| 70 | "deps/zlib"))
|
| 71 | (substitute* "Makefile"
|
| 72 | |
| 73 | (("deps/http_parser/http_parser.gyp") "")
|
| 74 | (("deps/uv/include/\\*.h") "")
|
| 75 | (("deps/uv/uv.gyp") "")
|
| 76 | (("deps/zlib/zlib.gyp") ""))
|
| 77 | #t))))
|
| 78 | (build-system gnu-build-system)
|
| 79 | (arguments
|
| 80 | `(#:configure-flags '("--shared-cares"
|
| 81 | "--shared-http-parser"
|
| 82 | "--shared-libuv"
|
| 83 | "--shared-nghttp2"
|
| 84 | "--shared-openssl"
|
| 85 | "--shared-zlib"
|
| 86 | "--without-snapshot"
|
| 87 | "--with-intl=system-icu")
|
| 88 | |
| 89 | |
| 90 | #:test-target "test-ci-js"
|
| 91 | #:phases
|
| 92 | (modify-phases %standard-phases
|
| 93 | (add-before 'configure 'patch-files
|
| 94 | (lambda* (#:key inputs #:allow-other-keys)
|
| 95 | |
| 96 | (substitute* '("lib/child_process.js"
|
| 97 | "lib/internal/v8_prof_polyfill.js"
|
| 98 | "test/parallel/test-child-process-spawnsync-shell.js"
|
| 99 | "test/parallel/test-stdio-closed.js"
|
| 100 | "test/sequential/test-child-process-emfile.js")
|
| 101 | (("'/bin/sh'")
|
| 102 | (string-append "'" (which "sh") "'")))
|
| 103 |
|
| 104 | |
| 105 | (substitute* '("test/parallel/test-child-process-default-options.js"
|
| 106 | "test/parallel/test-child-process-env.js"
|
| 107 | "test/parallel/test-child-process-exec-env.js")
|
| 108 | (("'/usr/bin/env'")
|
| 109 | (string-append "'" (which "env") "'")))
|
| 110 |
|
| 111 | |
| 112 | |
| 113 | (for-each delete-file
|
| 114 | '("test/parallel/test-cluster-master-error.js"
|
| 115 | "test/parallel/test-cluster-master-kill.js"
|
| 116 | |
| 117 | "test/sequential/test-performance.js"))
|
| 118 |
|
| 119 | |
| 120 | (delete-file "test/parallel/test-dns.js")
|
| 121 |
|
| 122 | |
| 123 | |
| 124 | (delete-file "test/parallel/test-net-listen-after-destroying-stdin.js")
|
| 125 |
|
| 126 | |
| 127 | |
| 128 | ,@(if (string-prefix? "arm" (%current-system))
|
| 129 | '((for-each delete-file
|
| 130 | '("test/parallel/test-zlib.js"
|
| 131 | "test/parallel/test-zlib-brotli.js"
|
| 132 | "test/parallel/test-zlib-brotli-flush.js"
|
| 133 | "test/parallel/test-zlib-brotli-from-brotli.js"
|
| 134 | "test/parallel/test-zlib-brotli-from-string.js"
|
| 135 | "test/parallel/test-zlib-convenience-methods.js"
|
| 136 | "test/parallel/test-zlib-random-byte-pipes.js"
|
| 137 | "test/parallel/test-zlib-write-after-flush.js")))
|
| 138 | '())
|
| 139 |
|
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | (for-each delete-file
|
| 145 | '("test/parallel/test-tls-passphrase.js"
|
| 146 | "test/parallel/test-tls-server-verify.js"))
|
| 147 | #t))
|
| 148 | (replace 'configure
|
| 149 | |
| 150 | |
| 151 | (lambda* (#:key outputs (configure-flags '()) inputs
|
| 152 | #:allow-other-keys)
|
| 153 | (let* ((prefix (assoc-ref outputs "out"))
|
| 154 | (flags (cons (string-append "--prefix=" prefix)
|
| 155 | configure-flags)))
|
| 156 | (format #t "build directory: ~s~%" (getcwd))
|
| 157 | (format #t "configure flags: ~s~%" flags)
|
| 158 | |
| 159 | |
| 160 | (setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc"))
|
| 161 | (apply invoke
|
| 162 | (string-append (assoc-ref inputs "python")
|
| 163 | "/bin/python")
|
| 164 | "configure" flags))))
|
| 165 | (add-after 'patch-shebangs 'patch-npm-shebang
|
| 166 | (lambda* (#:key outputs #:allow-other-keys)
|
| 167 | (let* ((bindir (string-append (assoc-ref outputs "out")
|
| 168 | "/bin"))
|
| 169 | (npm (string-append bindir "/npm"))
|
| 170 | (target (readlink npm)))
|
| 171 | (with-directory-excursion bindir
|
| 172 | (patch-shebang target (list bindir))
|
| 173 | #t)))))))
|
| 174 | (native-inputs
|
| 175 | `(("python" ,python-2)
|
| 176 | ("perl" ,perl)
|
| 177 | ("pkg-config" ,pkg-config)
|
| 178 | ("procps" ,procps)
|
| 179 | ("util-linux" ,util-linux)
|
| 180 | ("which" ,which)))
|
| 181 | (native-search-paths
|
| 182 | (list (search-path-specification
|
| 183 | (variable "NODE_PATH")
|
| 184 | (files '("lib/node_modules")))))
|
| 185 | (inputs
|
| 186 | `(("c-ares" ,c-ares)
|
| 187 | ("http-parser" ,http-parser)
|
| 188 | ("icu4c" ,icu4c)
|
| 189 | ("libuv" ,libuv)
|
| 190 | ("nghttp2" ,nghttp2 "lib")
|
| 191 | ("openssl" ,openssl)
|
| 192 | ("zlib" ,zlib)))
|
| 193 | (synopsis "Evented I/O for V8 JavaScript")
|
| 194 | (description "Node.js is a platform built on Chrome's JavaScript runtime
|
| 195 | for easily building fast, scalable network applications. Node.js uses an
|
| 196 | event-driven, non-blocking I/O model that makes it lightweight and efficient,
|
| 197 | perfect for data-intensive real-time applications that run across distributed
|
| 198 | devices.")
|
| 199 | (home-page "https://nodejs.org/")
|
| 200 | (license expat)
|
| 201 | (properties '((max-silent-time . 7200) |
| 202 | (timeout . 21600))))) |
| 203 |
|
| 204 | |
| 205 | |
| 206 | |
| 207 | (define-public node-10.22
|
| 208 | (package
|
| 209 | (inherit node)
|
| 210 | (version "10.22.0")
|
| 211 | (source (origin
|
| 212 | (inherit (package-source node))
|
| 213 | (uri (string-append "https://nodejs.org/dist/v" version
|
| 214 | "/node-v" version ".tar.xz"))
|
| 215 | (sha256
|
| 216 | (base32
|
| 217 | "1nz18fa550li10r0kzsm28c2rvvq61nq8bqdygip0rmvbi2paxg0"))))
|
| 218 | (inputs
|
| 219 | (alist-replace "nghttp2" (list nghttp2-1.41 "lib")
|
| 220 | (package-inputs node)))))
|
| 221 |
|
| 222 | (define-public libnode
|
| 223 | (package
|
| 224 | (inherit node)
|
| 225 | (name "libnode")
|
| 226 | (arguments
|
| 227 | (substitute-keyword-arguments (package-arguments node)
|
| 228 | ((#:configure-flags flags ''())
|
| 229 | `(cons* "--shared" "--without-npm" ,flags))
|
| 230 | ((#:phases phases '%standard-phases)
|
| 231 | `(modify-phases ,phases
|
| 232 | (delete 'patch-npm-shebang)))))))
|