| 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> |
| 7 | ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr> |
| 8 | ;;; Copyright © 2018, 2019, 2020 Marius Bakke <mbakke@fastmail.com> |
| 9 | ;;; Copyright © 2020 Pierre Langlois <pierre.langlois@gmx.com> |
| 10 | ;;; Copyright © 2020 Ricardo Wurmus <rekado@elephly.net> |
| 11 | ;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com> |
| 12 | ;;; |
| 13 | ;;; This file is part of GNU Guix. |
| 14 | ;;; |
| 15 | ;;; GNU Guix is free software; you can redistribute it and/or modify it |
| 16 | ;;; under the terms of the GNU General Public License as published by |
| 17 | ;;; the Free Software Foundation; either version 3 of the License, or (at |
| 18 | ;;; your option) any later version. |
| 19 | ;;; |
| 20 | ;;; GNU Guix is distributed in the hope that it will be useful, but |
| 21 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 | ;;; GNU General Public License for more details. |
| 24 | ;;; |
| 25 | ;;; You should have received a copy of the GNU General Public License |
| 26 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. |
| 27 | |
| 28 | (define-module (gnu packages node) |
| 29 | #:use-module ((guix licenses) #:prefix license:) |
| 30 | #:use-module ((guix build utils) #:select (alist-replace)) |
| 31 | #:use-module (guix packages) |
| 32 | #:use-module (guix derivations) |
| 33 | #:use-module (guix download) |
| 34 | #:use-module (guix git-download) |
| 35 | #:use-module (guix utils) |
| 36 | #:use-module (guix build-system gnu) |
| 37 | #:use-module (guix build-system node) |
| 38 | #:use-module (gnu packages) |
| 39 | #:use-module (gnu packages adns) |
| 40 | #:use-module (gnu packages base) |
| 41 | #:use-module (gnu packages compression) |
| 42 | #:use-module (gnu packages gcc) |
| 43 | #:use-module (gnu packages icu4c) |
| 44 | #:use-module (gnu packages libevent) |
| 45 | #:use-module (gnu packages linux) |
| 46 | #:use-module (gnu packages node-xyz) |
| 47 | #:use-module (gnu packages perl) |
| 48 | #:use-module (gnu packages pkg-config) |
| 49 | #:use-module (gnu packages python) |
| 50 | #:use-module (gnu packages tls) |
| 51 | #:use-module (gnu packages web)) |
| 52 | |
| 53 | (define-public node |
| 54 | (package |
| 55 | (name "node") |
| 56 | (version "10.24.0") |
| 57 | (source (origin |
| 58 | (method url-fetch) |
| 59 | (uri (string-append "https://nodejs.org/dist/v" version |
| 60 | "/node-v" version ".tar.xz")) |
| 61 | (sha256 |
| 62 | (base32 |
| 63 | "1k1srdis23782hnd1ymgczs78x9gqhv77v0am7yb54gqcspp70hm")) |
| 64 | (modules '((guix build utils))) |
| 65 | (snippet |
| 66 | `(begin |
| 67 | ;; Remove bundled software. |
| 68 | (for-each delete-file-recursively |
| 69 | '("deps/cares" |
| 70 | "deps/http_parser" |
| 71 | "deps/icu-small" |
| 72 | "deps/nghttp2" |
| 73 | "deps/openssl" |
| 74 | "deps/uv" |
| 75 | "deps/zlib")) |
| 76 | (substitute* "Makefile" |
| 77 | ;; Remove references to bundled software. |
| 78 | (("deps/http_parser/http_parser.gyp") "") |
| 79 | (("deps/uv/include/\\*.h") "") |
| 80 | (("deps/uv/uv.gyp") "") |
| 81 | (("deps/zlib/zlib.gyp") "")) |
| 82 | #t)))) |
| 83 | (build-system gnu-build-system) |
| 84 | (arguments |
| 85 | `(#:configure-flags '("--shared-cares" |
| 86 | "--shared-http-parser" |
| 87 | "--shared-libuv" |
| 88 | "--shared-nghttp2" |
| 89 | "--shared-openssl" |
| 90 | "--shared-zlib" |
| 91 | "--without-snapshot" |
| 92 | "--with-intl=system-icu") |
| 93 | ;; Run only the CI tests. The default test target requires additional |
| 94 | ;; add-ons from NPM that are not distributed with the source. |
| 95 | #:test-target "test-ci-js" |
| 96 | #:phases |
| 97 | (modify-phases %standard-phases |
| 98 | (add-before 'configure 'patch-files |
| 99 | (lambda* (#:key inputs #:allow-other-keys) |
| 100 | ;; Fix hardcoded /bin/sh references. |
| 101 | (substitute* '("lib/child_process.js" |
| 102 | "lib/internal/v8_prof_polyfill.js" |
| 103 | "test/parallel/test-child-process-spawnsync-shell.js" |
| 104 | "test/parallel/test-stdio-closed.js" |
| 105 | "test/sequential/test-child-process-emfile.js") |
| 106 | (("'/bin/sh'") |
| 107 | (string-append "'" (which "sh") "'"))) |
| 108 | |
| 109 | ;; Fix hardcoded /usr/bin/env references. |
| 110 | (substitute* '("test/parallel/test-child-process-default-options.js" |
| 111 | "test/parallel/test-child-process-env.js" |
| 112 | "test/parallel/test-child-process-exec-env.js") |
| 113 | (("'/usr/bin/env'") |
| 114 | (string-append "'" (which "env") "'"))) |
| 115 | |
| 116 | ;; FIXME: These tests fail in the build container, but they don't |
| 117 | ;; seem to be indicative of real problems in practice. |
| 118 | (for-each delete-file |
| 119 | '("test/parallel/test-cluster-master-error.js" |
| 120 | "test/parallel/test-cluster-master-kill.js" |
| 121 | ;; See also <https://github.com/nodejs/node/issues/25903>. |
| 122 | "test/sequential/test-performance.js")) |
| 123 | |
| 124 | ;; This requires a DNS resolver. |
| 125 | (delete-file "test/parallel/test-dns.js") |
| 126 | |
| 127 | ;; FIXME: This test fails randomly: |
| 128 | ;; https://github.com/nodejs/node/issues/31213 |
| 129 | (delete-file "test/parallel/test-net-listen-after-destroying-stdin.js") |
| 130 | |
| 131 | ;; FIXME: These tests fail on armhf-linux: |
| 132 | ;; https://github.com/nodejs/node/issues/31970 |
| 133 | ,@(if (string-prefix? "arm" (%current-system)) |
| 134 | '((for-each delete-file |
| 135 | '("test/parallel/test-zlib.js" |
| 136 | "test/parallel/test-zlib-brotli.js" |
| 137 | "test/parallel/test-zlib-brotli-flush.js" |
| 138 | "test/parallel/test-zlib-brotli-from-brotli.js" |
| 139 | "test/parallel/test-zlib-brotli-from-string.js" |
| 140 | "test/parallel/test-zlib-convenience-methods.js" |
| 141 | "test/parallel/test-zlib-random-byte-pipes.js" |
| 142 | "test/parallel/test-zlib-write-after-flush.js"))) |
| 143 | '()) |
| 144 | |
| 145 | ;; These tests have an expiry date: they depend on the validity of |
| 146 | ;; TLS certificates that are bundled with the source. We want this |
| 147 | ;; package to be reproducible forever, so remove those. |
| 148 | ;; TODO: Regenerate certs instead. |
| 149 | (for-each delete-file |
| 150 | '("test/parallel/test-tls-passphrase.js" |
| 151 | "test/parallel/test-tls-server-verify.js")) |
| 152 | #t)) |
| 153 | (replace 'configure |
| 154 | ;; Node's configure script is actually a python script, so we can't |
| 155 | ;; run it with bash. |
| 156 | (lambda* (#:key outputs (configure-flags '()) inputs |
| 157 | #:allow-other-keys) |
| 158 | (let* ((prefix (assoc-ref outputs "out")) |
| 159 | (flags (cons (string-append "--prefix=" prefix) |
| 160 | configure-flags))) |
| 161 | (format #t "build directory: ~s~%" (getcwd)) |
| 162 | (format #t "configure flags: ~s~%" flags) |
| 163 | ;; Node's configure script expects the CC environment variable to |
| 164 | ;; be set. |
| 165 | (setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc")) |
| 166 | (apply invoke |
| 167 | (string-append (assoc-ref inputs "python") |
| 168 | "/bin/python") |
| 169 | "configure" flags)))) |
| 170 | (add-after 'patch-shebangs 'patch-npm-shebang |
| 171 | (lambda* (#:key outputs #:allow-other-keys) |
| 172 | (let* ((bindir (string-append (assoc-ref outputs "out") |
| 173 | "/bin")) |
| 174 | (npm (string-append bindir "/npm")) |
| 175 | (target (readlink npm))) |
| 176 | (with-directory-excursion bindir |
| 177 | (patch-shebang target (list bindir)) |
| 178 | #t)))) |
| 179 | (add-after 'install 'patch-node-shebang |
| 180 | (lambda* (#:key outputs #:allow-other-keys) |
| 181 | (let* ((bindir (string-append (assoc-ref outputs "out") |
| 182 | "/bin")) |
| 183 | (npx (readlink (string-append bindir "/npx")))) |
| 184 | (with-directory-excursion bindir |
| 185 | (patch-shebang npx (list bindir)) |
| 186 | #t))))))) |
| 187 | (native-inputs |
| 188 | `(("python" ,python-2) |
| 189 | ("perl" ,perl) |
| 190 | ("pkg-config" ,pkg-config) |
| 191 | ("procps" ,procps) |
| 192 | ("util-linux" ,util-linux) |
| 193 | ("which" ,which))) |
| 194 | (native-search-paths |
| 195 | (list (search-path-specification |
| 196 | (variable "NODE_PATH") |
| 197 | (files '("lib/node_modules"))))) |
| 198 | (inputs |
| 199 | `(("c-ares" ,c-ares) |
| 200 | ("http-parser" ,http-parser) |
| 201 | ("icu4c" ,icu4c) |
| 202 | ("libuv" ,libuv) |
| 203 | ("nghttp2" ,nghttp2 "lib") |
| 204 | ("openssl" ,openssl) |
| 205 | ("zlib" ,zlib))) |
| 206 | (synopsis "Evented I/O for V8 JavaScript") |
| 207 | (description "Node.js is a platform built on Chrome's JavaScript runtime |
| 208 | for easily building fast, scalable network applications. Node.js uses an |
| 209 | event-driven, non-blocking I/O model that makes it lightweight and efficient, |
| 210 | perfect for data-intensive real-time applications that run across distributed |
| 211 | devices.") |
| 212 | (home-page "https://nodejs.org/") |
| 213 | (license license:expat) |
| 214 | (properties '((max-silent-time . 7200) ;2h, needed on ARM |
| 215 | (timeout . 21600))))) ;6h |
| 216 | |
| 217 | ;; This should be the latest version of node that still builds without |
| 218 | ;; depending on llhttp. |
| 219 | (define-public node-bootstrap |
| 220 | (hidden-package node)) |
| 221 | |
| 222 | ;; Duplicate of node-semver |
| 223 | (define-public node-semver-bootstrap |
| 224 | (package |
| 225 | (name "node-semver") |
| 226 | (version "7.2.1") |
| 227 | (source (origin |
| 228 | (method git-fetch) |
| 229 | (uri (git-reference |
| 230 | (url "https://github.com/npm/node-semver") |
| 231 | (commit (string-append "v" version)))) |
| 232 | (file-name (git-file-name name version)) |
| 233 | (sha256 |
| 234 | (base32 |
| 235 | "06biknqb05r9xsmcflm3ygh50pjvdk84x6r79w43kmck4fn3qn5p")))) |
| 236 | (build-system node-build-system) |
| 237 | (arguments |
| 238 | `(#:node ,node-bootstrap |
| 239 | #:tests? #f |
| 240 | #:phases |
| 241 | (modify-phases %standard-phases |
| 242 | (delete 'configure)))) |
| 243 | (home-page "https://github.com/npm/node-semver") |
| 244 | (properties '((hidden? . #t))) |
| 245 | (synopsis "Parses semantic versions strings") |
| 246 | (description |
| 247 | "@code{node-semver} is a JavaScript implementation of the |
| 248 | @uref{https://semver.org/, SemVer.org} specification.") |
| 249 | (license license:isc))) |
| 250 | |
| 251 | (define-public node-ms-bootstrap |
| 252 | (package |
| 253 | (name "node-ms") |
| 254 | (version "2.1.2") |
| 255 | (source |
| 256 | (origin |
| 257 | (method git-fetch) |
| 258 | (uri (git-reference |
| 259 | (url "https://github.com/vercel/ms.git") |
| 260 | (commit version))) |
| 261 | (file-name (git-file-name name version)) |
| 262 | (sha256 |
| 263 | (base32 |
| 264 | "1pjxzbi4j8pinlsc7yxvfrh0b47kb2dc4lfc2rjq4wx5bdwl33fj")))) |
| 265 | (build-system node-build-system) |
| 266 | (arguments |
| 267 | `(#:node ,node-bootstrap |
| 268 | #:tests? #f |
| 269 | #:phases |
| 270 | (modify-phases %standard-phases |
| 271 | (delete 'configure)))) |
| 272 | (home-page "https://github.com/zeit/ms#readme") |
| 273 | (properties '((hidden? . #t))) |
| 274 | (synopsis "Tiny millisecond conversion utility") |
| 275 | (description "Use this package to easily convert various time |
| 276 | formats to milliseconds.") |
| 277 | (license license:expat))) |
| 278 | |
| 279 | (define-public node-binary-search-bootstrap |
| 280 | (package |
| 281 | (name "node-binary-search") |
| 282 | (version "1.3.6") |
| 283 | (source |
| 284 | (origin |
| 285 | (method git-fetch) |
| 286 | (uri (git-reference |
| 287 | (url "https://github.com/darkskyapp/binary-search.git") |
| 288 | (commit (string-append "v" version)))) |
| 289 | (file-name (git-file-name name version)) |
| 290 | (sha256 |
| 291 | (base32 |
| 292 | "1xr2msdc143cd3xwgq7n3rhzy7j8wrnaidxl0r6l6b6g3mpbpjig")))) |
| 293 | (build-system node-build-system) |
| 294 | (arguments |
| 295 | `(#:node ,node-bootstrap |
| 296 | #:tests? #f |
| 297 | #:phases |
| 298 | (modify-phases %standard-phases |
| 299 | (delete 'configure)))) |
| 300 | (home-page "https://github.com/darkskyapp/binary-search#readme") |
| 301 | (properties '((hidden? . #t))) |
| 302 | (synopsis "Tiny binary search function with comparators") |
| 303 | (description "This package is a binary search function for Node.js.") |
| 304 | (license license:cc0))) |
| 305 | |
| 306 | (define-public node-debug-bootstrap |
| 307 | (package |
| 308 | (name "node-debug") |
| 309 | (version "4.3.0") |
| 310 | (source |
| 311 | (origin |
| 312 | (method git-fetch) |
| 313 | (uri (git-reference |
| 314 | (url "https://github.com/visionmedia/debug.git") |
| 315 | (commit version))) |
| 316 | (file-name (git-file-name name version)) |
| 317 | (sha256 |
| 318 | (base32 |
| 319 | "08g52r1d4yqcsfdfb7n5if33d4cghaq75gx5n9hj6m6fd8jfp2pi")))) |
| 320 | (build-system node-build-system) |
| 321 | (arguments |
| 322 | `(#:node ,node-bootstrap |
| 323 | #:tests? #f |
| 324 | #:phases |
| 325 | (modify-phases %standard-phases |
| 326 | (delete 'configure)))) |
| 327 | (inputs `(("node-ms" ,node-ms-bootstrap))) |
| 328 | (home-page "https://github.com/visionmedia/debug#readme") |
| 329 | (properties '((hidden? . #t))) |
| 330 | (synopsis "Small debugging utility") |
| 331 | (description "This package contains a tiny JavaScript debugging |
| 332 | utility modelled after Node.js core's debugging technique. It works in |
| 333 | Node.js and web browsers.") |
| 334 | (license license:expat))) |
| 335 | |
| 336 | (define-public node-llparse-builder-bootstrap |
| 337 | (package |
| 338 | (name "node-llparse-builder") |
| 339 | (version "1.5.2") |
| 340 | (source |
| 341 | (origin |
| 342 | (method git-fetch) |
| 343 | (uri (git-reference |
| 344 | (url "https://github.com/indutny/llparse-builder.git") |
| 345 | (commit (string-append "v" version)))) |
| 346 | (file-name (git-file-name name version)) |
| 347 | (sha256 |
| 348 | (base32 |
| 349 | "0r82iiwqsb73k2fxw7842rjjiixllxpyc6yl9cq4ma6ybkf6xmzm")) |
| 350 | (modules '((guix build utils))) |
| 351 | (snippet |
| 352 | '(begin |
| 353 | ;; FIXME: Unneeded runtime dependency. |
| 354 | ;; https://github.com/indutny/llparse-builder/pull/2 |
| 355 | (substitute* "package.json" |
| 356 | (("\"@types/debug.*,") "")) |
| 357 | ;; Fix imports for esbuild. |
| 358 | ;; https://github.com/evanw/esbuild/issues/477 |
| 359 | (substitute* '("src/node/invoke.ts" |
| 360 | "src/node/base.ts" |
| 361 | "src/node/consume.ts" |
| 362 | "src/node/match.ts" |
| 363 | "src/node/error.ts" |
| 364 | "src/node/pause.ts" |
| 365 | "src/edge.ts" |
| 366 | "src/utils.ts" |
| 367 | "src/loop-checker/index.ts" |
| 368 | "src/loop-checker/lattice.ts" |
| 369 | "src/code/field.ts" |
| 370 | "src/span-allocator.ts") |
| 371 | (("\\* as assert") "assert") |
| 372 | (("\\* as debugAPI") "debugAPI")) |
| 373 | #t)))) |
| 374 | (build-system node-build-system) |
| 375 | (arguments |
| 376 | `(#:node ,node-bootstrap |
| 377 | #:tests? #f |
| 378 | #:phases |
| 379 | (modify-phases %standard-phases |
| 380 | (delete 'configure) |
| 381 | (replace 'build |
| 382 | (lambda* (#:key inputs #:allow-other-keys) |
| 383 | (let ((esbuild (string-append (assoc-ref inputs "esbuild") |
| 384 | "/bin/esbuild"))) |
| 385 | (invoke esbuild |
| 386 | "--platform=node" |
| 387 | "--outfile=lib/builder.js" |
| 388 | "--bundle" |
| 389 | "src/builder.ts"))))))) |
| 390 | (inputs |
| 391 | `(("node-binary-search" ,node-binary-search-bootstrap) |
| 392 | ("node-debug" ,node-debug-bootstrap))) |
| 393 | (native-inputs |
| 394 | `(("esbuild" ,esbuild))) |
| 395 | (home-page "https://github.com/indutny/llparse-builder#readme") |
| 396 | (properties '((hidden? . #t))) |
| 397 | (synopsis "Graph builder for consumption by llparse") |
| 398 | (description "This package builds graphs for consumption by llparse.") |
| 399 | (license license:expat))) |
| 400 | |
| 401 | (define-public node-llparse-frontend-bootstrap |
| 402 | (package |
| 403 | (name "node-llparse-frontend") |
| 404 | (version "3.0.0") |
| 405 | (source |
| 406 | (origin |
| 407 | (method git-fetch) |
| 408 | (uri (git-reference |
| 409 | (url "https://github.com/indutny/llparse-frontend.git") |
| 410 | (commit (string-append "v" version)))) |
| 411 | (file-name (git-file-name name version)) |
| 412 | (sha256 |
| 413 | (base32 "1rm9g4ifyip30svm5cgnf0gx7d45jgh4mpf2hkd092xhngmfvicc")) |
| 414 | (modules '((guix build utils))) |
| 415 | (snippet |
| 416 | '(begin |
| 417 | ;; Fix imports for esbuild. |
| 418 | ;; https://github.com/evanw/esbuild/issues/477 |
| 419 | (substitute* '("src/frontend.ts" |
| 420 | "src/code/field-value.ts" |
| 421 | "src/container/index.ts" |
| 422 | "src/container/wrap.ts" |
| 423 | "src/node/sequence.ts" |
| 424 | "src/node/single.ts" |
| 425 | "src/node/table-lookup.ts" |
| 426 | "src/trie/index.ts") |
| 427 | (("\\* as assert") "assert") |
| 428 | (("\\* as debugAPI") "debugAPI")) |
| 429 | #t)))) |
| 430 | (build-system node-build-system) |
| 431 | (arguments |
| 432 | `(#:node ,node-bootstrap |
| 433 | #:tests? #f |
| 434 | #:phases |
| 435 | (modify-phases %standard-phases |
| 436 | (delete 'configure) |
| 437 | (replace 'build |
| 438 | (lambda* (#:key inputs #:allow-other-keys) |
| 439 | (let ((esbuild (string-append (assoc-ref inputs "esbuild") |
| 440 | "/bin/esbuild"))) |
| 441 | (invoke esbuild |
| 442 | "--platform=node" |
| 443 | "--outfile=lib/frontend.js" |
| 444 | "--bundle" |
| 445 | "src/frontend.ts"))))))) |
| 446 | (inputs |
| 447 | `(("node-debug" ,node-debug-bootstrap) |
| 448 | ("node-llparse-builder" ,node-llparse-builder-bootstrap))) |
| 449 | (native-inputs |
| 450 | `(("esbuild" ,esbuild))) |
| 451 | (home-page "https://github.com/indutny/llparse-frontend#readme") |
| 452 | (properties '((hidden? . #t))) |
| 453 | (synopsis "Frontend for the llparse compiler") |
| 454 | (description "This package is a frontend for the llparse compiler.") |
| 455 | (license license:expat))) |
| 456 | |
| 457 | (define-public node-llparse-bootstrap |
| 458 | (package |
| 459 | (name "node-llparse") |
| 460 | (version "7.1.0") |
| 461 | (source |
| 462 | (origin |
| 463 | (method git-fetch) |
| 464 | (uri (git-reference |
| 465 | (url "https://github.com/indutny/llparse.git") |
| 466 | (commit (string-append "v" version)))) |
| 467 | (file-name (git-file-name name version)) |
| 468 | (sha256 |
| 469 | (base32 |
| 470 | "10da273iy2if88hp79cwms6c8qpsl1fkgzll6gmqyx5yxv5mkyp6")) |
| 471 | (modules '((guix build utils))) |
| 472 | (snippet |
| 473 | '(begin |
| 474 | ;; Fix imports for esbuild. |
| 475 | ;; https://github.com/evanw/esbuild/issues/477 |
| 476 | (substitute* '("src/compiler/index.ts" |
| 477 | "src/implementation/c/node/base.ts" |
| 478 | "src/implementation/c/node/table-lookup.ts" |
| 479 | "src/implementation/c/compilation.ts" |
| 480 | "src/implementation/c/helpers/match-sequence.ts" |
| 481 | "src/implementation/c/code/mul-add.ts") |
| 482 | (("\\* as assert") "assert") |
| 483 | (("\\* as debugAPI") "debugAPI")) |
| 484 | #t)))) |
| 485 | (build-system node-build-system) |
| 486 | (arguments |
| 487 | `(#:node ,node-bootstrap |
| 488 | #:tests? #f |
| 489 | #:phases |
| 490 | (modify-phases %standard-phases |
| 491 | (delete 'configure) |
| 492 | (replace 'build |
| 493 | (lambda* (#:key inputs #:allow-other-keys) |
| 494 | (let ((esbuild (string-append (assoc-ref inputs "esbuild") |
| 495 | "/bin/esbuild"))) |
| 496 | (invoke esbuild |
| 497 | "--platform=node" |
| 498 | "--outfile=lib/api.js" |
| 499 | "--bundle" |
| 500 | "src/api.ts"))))))) |
| 501 | (inputs |
| 502 | `(("node-debug" ,node-debug-bootstrap) |
| 503 | ("node-llparse-frontend" ,node-llparse-frontend-bootstrap))) |
| 504 | (native-inputs |
| 505 | `(("esbuild" ,esbuild))) |
| 506 | (home-page "https://github.com/nodejs/llparse#readme") |
| 507 | (properties '((hidden? . #t))) |
| 508 | (synopsis "Compile incremental parsers to C code") |
| 509 | (description "This package offers an API for compiling an incremental |
| 510 | parser definition into a C output.") |
| 511 | (license license:expat))) |
| 512 | |
| 513 | (define-public llhttp-bootstrap |
| 514 | (package |
| 515 | (name "llhttp") |
| 516 | (version "2.1.3") |
| 517 | (source (origin |
| 518 | (method git-fetch) |
| 519 | (uri (git-reference |
| 520 | (url "https://github.com/nodejs/llhttp.git") |
| 521 | (commit (string-append "v" version)))) |
| 522 | (file-name (git-file-name name version)) |
| 523 | (sha256 |
| 524 | (base32 |
| 525 | "0pqj7kyyzr1zs4h9yzn5rdxnxspm3wqgsv00765dd42fszlmrmk8")) |
| 526 | (patches (search-patches "llhttp-bootstrap-CVE-2020-8287.patch")) |
| 527 | (modules '((guix build utils))) |
| 528 | (snippet |
| 529 | '(begin |
| 530 | ;; Fix imports for esbuild. |
| 531 | ;; https://github.com/evanw/esbuild/issues/477 |
| 532 | (substitute* "src/llhttp/http.ts" |
| 533 | (("\\* as assert") "assert")) |
| 534 | (substitute* "Makefile" |
| 535 | (("npx ts-node bin/generate.ts") |
| 536 | "node bin/generate.js")) |
| 537 | #t)))) |
| 538 | (build-system gnu-build-system) |
| 539 | (arguments |
| 540 | `(#:tests? #f ; no tests |
| 541 | #:make-flags (list (string-append "CLANG=" ,(cc-for-target)) |
| 542 | (string-append "DESTDIR=" (assoc-ref %outputs "out")) |
| 543 | "PREFIX=") |
| 544 | #:phases |
| 545 | (modify-phases %standard-phases |
| 546 | (replace 'configure |
| 547 | (lambda* (#:key inputs #:allow-other-keys) |
| 548 | (let ((esbuild (string-append (assoc-ref inputs "esbuild") |
| 549 | "/bin/esbuild"))) |
| 550 | (invoke esbuild |
| 551 | "--platform=node" |
| 552 | "--outfile=bin/generate.js" |
| 553 | "--bundle" "bin/generate.ts")))) |
| 554 | (add-before 'install 'create-install-directories |
| 555 | (lambda* (#:key outputs #:allow-other-keys) |
| 556 | (let ((out (assoc-ref outputs "out"))) |
| 557 | (for-each (lambda (dir) |
| 558 | (mkdir-p (string-append out dir))) |
| 559 | (list "/lib" "/include" "/src")) |
| 560 | #t))) |
| 561 | (add-after 'install 'install-src |
| 562 | (lambda* (#:key outputs #:allow-other-keys) |
| 563 | (let* ((out (assoc-ref outputs "out")) |
| 564 | (src-dir (string-append out "/src"))) |
| 565 | (install-file "build/c/llhttp.c" src-dir) |
| 566 | (install-file "src/native/api.c" src-dir) |
| 567 | (install-file "src/native/http.c" src-dir) |
| 568 | #t)))))) |
| 569 | (native-inputs |
| 570 | `(("esbuild" ,esbuild) |
| 571 | ("node" ,node-bootstrap) |
| 572 | ("node-semver" ,node-semver-bootstrap) |
| 573 | ("node-llparse-bootstrap" ,node-llparse-bootstrap))) |
| 574 | (home-page "https://github.com/nodejs/llhttp") |
| 575 | (properties '((hidden? . #t))) |
| 576 | (synopsis "Parser for HTTP messages") |
| 577 | (description "This is a rewrite of |
| 578 | @url{https://github.com/nodejs/http-parser, http-parser} using |
| 579 | @url{https://github.com/nodejs/llparse, llparse} to generate the C |
| 580 | source files.") |
| 581 | (license license:expat))) |
| 582 | |
| 583 | (define-public node-lts |
| 584 | (package |
| 585 | (inherit node) |
| 586 | (version "14.16.0") |
| 587 | (source (origin |
| 588 | (method url-fetch) |
| 589 | (uri (string-append "https://nodejs.org/dist/v" version |
| 590 | "/node-v" version ".tar.xz")) |
| 591 | (sha256 |
| 592 | (base32 |
| 593 | "19nz2mhmn6ikahxqyna1dn25pb5v3z9vsz9zb2flb6zp2yk4hxjf")) |
| 594 | (modules '((guix build utils))) |
| 595 | (snippet |
| 596 | `(begin |
| 597 | ;; Remove bundled software, where possible |
| 598 | (for-each delete-file-recursively |
| 599 | '("deps/cares" |
| 600 | "deps/icu-small" |
| 601 | "deps/nghttp2" |
| 602 | "deps/openssl" |
| 603 | "deps/zlib")) |
| 604 | (substitute* "Makefile" |
| 605 | ;; Remove references to bundled software. |
| 606 | (("deps/uv/uv.gyp") "") |
| 607 | (("deps/zlib/zlib.gyp") "")) |
| 608 | #t)))) |
| 609 | (arguments |
| 610 | (substitute-keyword-arguments (package-arguments node) |
| 611 | ((#:configure-flags configure-flags) |
| 612 | ''("--shared-cares" |
| 613 | "--shared-libuv" |
| 614 | "--shared-nghttp2" |
| 615 | "--shared-openssl" |
| 616 | "--shared-zlib" |
| 617 | "--shared-brotli" |
| 618 | "--with-intl=system-icu")) |
| 619 | ((#:phases phases) |
| 620 | `(modify-phases ,phases |
| 621 | (replace 'configure |
| 622 | ;; Node's configure script is actually a python script, so we can't |
| 623 | ;; run it with bash. |
| 624 | (lambda* (#:key outputs (configure-flags '()) inputs |
| 625 | #:allow-other-keys) |
| 626 | (let* ((prefix (assoc-ref outputs "out")) |
| 627 | (flags (cons (string-append "--prefix=" prefix) |
| 628 | configure-flags))) |
| 629 | (format #t "build directory: ~s~%" (getcwd)) |
| 630 | (format #t "configure flags: ~s~%" flags) |
| 631 | ;; Node's configure script expects the CC environment variable to |
| 632 | ;; be set. |
| 633 | (setenv "CC" ,(cc-for-target)) |
| 634 | (apply invoke |
| 635 | (string-append (assoc-ref inputs "python") |
| 636 | "/bin/python3") |
| 637 | "configure" flags)))) |
| 638 | (replace 'patch-files |
| 639 | (lambda* (#:key inputs #:allow-other-keys) |
| 640 | ;; Fix hardcoded /bin/sh references. |
| 641 | (substitute* '("lib/child_process.js" |
| 642 | "lib/internal/v8_prof_polyfill.js" |
| 643 | "test/parallel/test-child-process-spawnsync-shell.js" |
| 644 | "test/parallel/test-fs-write-sigxfsz.js" |
| 645 | "test/parallel/test-stdio-closed.js" |
| 646 | "test/sequential/test-child-process-emfile.js") |
| 647 | (("'/bin/sh'") |
| 648 | (string-append "'" (which "sh") "'"))) |
| 649 | |
| 650 | ;; Fix hardcoded /usr/bin/env references. |
| 651 | (substitute* '("test/parallel/test-child-process-default-options.js" |
| 652 | "test/parallel/test-child-process-env.js" |
| 653 | "test/parallel/test-child-process-exec-env.js") |
| 654 | (("'/usr/bin/env'") |
| 655 | (string-append "'" (which "env") "'"))) |
| 656 | |
| 657 | ;; FIXME: These tests fail in the build container, but they don't |
| 658 | ;; seem to be indicative of real problems in practice. |
| 659 | (for-each delete-file |
| 660 | '("test/parallel/test-cluster-master-error.js" |
| 661 | "test/parallel/test-cluster-master-kill.js")) |
| 662 | |
| 663 | ;; These require a DNS resolver. |
| 664 | (for-each delete-file |
| 665 | '("test/parallel/test-dns.js" |
| 666 | "test/parallel/test-dns-lookupService-promises.js")) |
| 667 | |
| 668 | ;; FIXME: This test fails randomly: |
| 669 | ;; https://github.com/nodejs/node/issues/31213 |
| 670 | (delete-file "test/parallel/test-net-listen-after-destroying-stdin.js") |
| 671 | |
| 672 | ;; FIXME: These tests fail on armhf-linux: |
| 673 | ;; https://github.com/nodejs/node/issues/31970 |
| 674 | ,@(if (target-arm32?) |
| 675 | '((for-each delete-file |
| 676 | '("test/parallel/test-zlib.js" |
| 677 | "test/parallel/test-zlib-brotli.js" |
| 678 | "test/parallel/test-zlib-brotli-flush.js" |
| 679 | "test/parallel/test-zlib-brotli-from-brotli.js" |
| 680 | "test/parallel/test-zlib-brotli-from-string.js" |
| 681 | "test/parallel/test-zlib-convenience-methods.js" |
| 682 | "test/parallel/test-zlib-random-byte-pipes.js" |
| 683 | "test/parallel/test-zlib-write-after-flush.js"))) |
| 684 | '()) |
| 685 | |
| 686 | ;; These tests have an expiry date: they depend on the validity of |
| 687 | ;; TLS certificates that are bundled with the source. We want this |
| 688 | ;; package to be reproducible forever, so remove those. |
| 689 | ;; TODO: Regenerate certs instead. |
| 690 | (for-each delete-file |
| 691 | '("test/parallel/test-tls-passphrase.js" |
| 692 | "test/parallel/test-tls-server-verify.js")) |
| 693 | |
| 694 | ;; Replace pre-generated llhttp sources |
| 695 | (let ((llhttp (assoc-ref inputs "llhttp"))) |
| 696 | (copy-file (string-append llhttp "/src/llhttp.c") |
| 697 | "deps/llhttp/src/llhttp.c") |
| 698 | (copy-file (string-append llhttp "/src/api.c") |
| 699 | "deps/llhttp/src/api.c") |
| 700 | (copy-file (string-append llhttp "/src/http.c") |
| 701 | "deps/llhttp/src/http.c") |
| 702 | (copy-file (string-append llhttp "/include/llhttp.h") |
| 703 | "deps/llhttp/include/llhttp.h")) |
| 704 | #t)))))) |
| 705 | (inputs |
| 706 | `(("c-ares" ,c-ares) |
| 707 | ("icu4c" ,icu4c-67) |
| 708 | ("libuv" ,libuv-for-node) |
| 709 | ("llhttp" ,llhttp-bootstrap) |
| 710 | ("google-brotli" ,google-brotli) |
| 711 | ("nghttp2" ,nghttp2 "lib") |
| 712 | ("openssl" ,openssl) |
| 713 | ("zlib" ,zlib))) |
| 714 | (native-inputs |
| 715 | (alist-replace "python" (list python-3) |
| 716 | (package-native-inputs node))))) |
| 717 | |
| 718 | (define-public libnode |
| 719 | (package/inherit node |
| 720 | (name "libnode") |
| 721 | (arguments |
| 722 | (substitute-keyword-arguments (package-arguments node) |
| 723 | ((#:configure-flags flags ''()) |
| 724 | `(cons* "--shared" "--without-npm" ,flags)) |
| 725 | ((#:phases phases '%standard-phases) |
| 726 | `(modify-phases ,phases |
| 727 | (delete 'patch-npm-shebang) |
| 728 | (delete 'patch-node-shebang))))))) |