diff options
| author | Efraim Flashner <efraim@flashner.co.il> | 2023-07-02 10:45:18 +0300 |
|---|---|---|
| committer | Efraim Flashner <efraim@flashner.co.il> | 2025-03-13 14:34:58 +0200 |
| commit | 845d5c9f3765e5340590946d4d88ec1d68e4b87d (patch) | |
| tree | e2e7c0be776b9c44533e188a514f7bacca912445 | |
| parent | d706c1b1e6ac3e24555fa57df2745018e750bd2d (diff) | |
gnu: Add node-12.
* gnu/packages/node.scm (node-12): New variable.
Change-Id: If749149358338ef8852e2218512031a73804d2ab
| -rw-r--r-- | gnu/packages/node.scm | 327 |
1 files changed, 327 insertions, 0 deletions
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm index 3d0a86b4fbe..6822599c9cb 100644 --- a/gnu/packages/node.scm +++ b/gnu/packages/node.scm | |||
| @@ -350,6 +350,333 @@ devices.") | |||
| 350 | (cpe-name . "node.js") | 350 | (cpe-name . "node.js") |
| 351 | (hidden? . #t))))) | 351 | (hidden? . #t))))) |
| 352 | 352 | ||
| 353 | (define-public node-12 | ||
| 354 | (package | ||
| 355 | (name "node") | ||
| 356 | (version "12.22.12") | ||
| 357 | (source (origin | ||
| 358 | (method url-fetch) | ||
| 359 | (uri (string-append "https://nodejs.org/dist/v" version | ||
| 360 | "/node-v" version ".tar.xz")) | ||
| 361 | (sha256 | ||
| 362 | (base32 | ||
| 363 | "1whl0zi6fs9ay33bhcn2kh9xynran05iipahg1zzr6sv97wbfhmw")) | ||
| 364 | (modules '((guix build utils))) | ||
| 365 | (snippet | ||
| 366 | '(begin | ||
| 367 | ;; Remove bundled software. | ||
| 368 | (for-each delete-file-recursively | ||
| 369 | '("deps/cares" | ||
| 370 | "deps/http_parser" | ||
| 371 | "deps/icu-small" | ||
| 372 | "deps/llhttp" | ||
| 373 | "deps/nghttp2" | ||
| 374 | "deps/openssl" | ||
| 375 | ;"deps/uv" ; Needed by uvwasi | ||
| 376 | "deps/zlib")) | ||
| 377 | (substitute* "Makefile" | ||
| 378 | ;; Remove references to bundled software. | ||
| 379 | (("deps/http_parser/http_parser.gyp") "") | ||
| 380 | (("deps/uv/include/\\*.h") "") | ||
| 381 | (("deps/uv/uv.gyp") "") | ||
| 382 | (("deps/zlib/zlib.gyp") "")))))) | ||
| 383 | (build-system gnu-build-system) | ||
| 384 | (arguments | ||
| 385 | `(#:configure-flags | ||
| 386 | (list "--shared-brotli" | ||
| 387 | "--shared-cares" | ||
| 388 | "--shared-http-parser" | ||
| 389 | (string-append "--shared-http-parser-includes=" | ||
| 390 | (assoc-ref %build-inputs "http-parser") | ||
| 391 | "/include") | ||
| 392 | (string-append "--shared-http-parser-libpath=" | ||
| 393 | (assoc-ref %build-inputs "http-parser") | ||
| 394 | "/lib") | ||
| 395 | "--shared-libuv" | ||
| 396 | "--shared-nghttp2" | ||
| 397 | "--shared-openssl" | ||
| 398 | "--shared-zlib" | ||
| 399 | "--without-snapshot" | ||
| 400 | "--without-inspector" ; build without llhttp | ||
| 401 | "--with-intl=system-icu") | ||
| 402 | ;; Run only the CI tests. The default test target requires additional | ||
| 403 | ;; add-ons from NPM that are not distributed with the source. | ||
| 404 | #:test-target "test-ci-js" | ||
| 405 | ;; Some of the tests can timeout under heavy load. | ||
| 406 | #:parallel-tests? ,(target-x86?) | ||
| 407 | #:modules | ||
| 408 | ((guix build gnu-build-system) | ||
| 409 | (guix build utils) | ||
| 410 | (srfi srfi-1) | ||
| 411 | (ice-9 match)) | ||
| 412 | #:phases | ||
| 413 | (modify-phases %standard-phases | ||
| 414 | (add-after 'unpack 'remove-dependency-on-llhttp | ||
| 415 | (lambda _ | ||
| 416 | ;; This file unconditionally defines NODE_EXPERIMENTAL_HTTP | ||
| 417 | (substitute* "node.gyp" | ||
| 418 | (("src/node_http_parser_llhttp\\.cc") "")) | ||
| 419 | ;; These unconditionally depend upon/add llhttp. | ||
| 420 | (substitute* '("lib/internal/bootstrap/loaders.js" | ||
| 421 | "src/node_binding.cc" | ||
| 422 | "src/node_metadata.h" | ||
| 423 | "src/node_metadata.cc") | ||
| 424 | ((".*llhttp.*") "")) | ||
| 425 | ;; '--http-parser=legacy' or not, only use http_parser. | ||
| 426 | (substitute* '("lib/_http_common.js" | ||
| 427 | "test/parallel/test-http-parser-lazy-loaded.js") | ||
| 428 | (("http_parser_llhttp") "http_parser")) | ||
| 429 | |||
| 430 | ;; This test expects to use llhttp. | ||
| 431 | (delete-file "test/sequential/test-set-http-max-http-headers.js"))) | ||
| 432 | (add-before 'configure 'patch-hardcoded-program-references | ||
| 433 | (lambda* (#:key inputs #:allow-other-keys) | ||
| 434 | |||
| 435 | ;; Fix hardcoded /bin/sh references. | ||
| 436 | (substitute* '("deps/npm/node_modules/cross-spawn/lib/parse.js" | ||
| 437 | "deps/npm/node_modules/execa/index.js" | ||
| 438 | "lib/child_process.js" | ||
| 439 | "lib/internal/v8_prof_polyfill.js" | ||
| 440 | "test/parallel/test-child-process-spawnsync-shell.js" | ||
| 441 | "test/parallel/test-fs-write-sigxfsz.js" | ||
| 442 | "test/parallel/test-stdio-closed.js" | ||
| 443 | "test/sequential/test-child-process-emfile.js") | ||
| 444 | (("'/bin/sh'") | ||
| 445 | (string-append "'" (search-input-file inputs "/bin/sh") "'"))) | ||
| 446 | |||
| 447 | ;; Fix hardcoded /usr/bin/env references. | ||
| 448 | (substitute* '("test/parallel/test-child-process-default-options.js" | ||
| 449 | "test/parallel/test-child-process-env.js" | ||
| 450 | "test/parallel/test-child-process-exec-env.js") | ||
| 451 | (("'/usr/bin/env'") | ||
| 452 | (string-append "'" (search-input-file inputs "/bin/env") "'"))))) | ||
| 453 | (add-after 'patch-hardcoded-program-references 'delete-problematic-tests | ||
| 454 | (lambda* (#:key inputs #:allow-other-keys) | ||
| 455 | |||
| 456 | ;; FIXME: These tests fail in the build container, but they don't | ||
| 457 | ;; seem to be indicative of real problems in practice. | ||
| 458 | (for-each delete-file | ||
| 459 | '("test/parallel/test-cluster-master-error.js" | ||
| 460 | "test/parallel/test-cluster-master-kill.js")) | ||
| 461 | |||
| 462 | ;; These require a DNS resolver. | ||
| 463 | (for-each delete-file | ||
| 464 | '("test/parallel/test-dns.js" | ||
| 465 | "test/parallel/test-dns-lookupService-promises.js")) | ||
| 466 | |||
| 467 | ;; These tests are timing-sensitive, and fail sporadically on | ||
| 468 | ;; slow, busy, or even very fast machines. | ||
| 469 | (for-each delete-file '("test/parallel/test-fs-utimes.js" | ||
| 470 | "test/sequential/test-perf-hooks.js")) | ||
| 471 | |||
| 472 | ;; FIXME: This test fails randomly: | ||
| 473 | ;; https://github.com/nodejs/node/issues/31213 | ||
| 474 | (delete-file "test/parallel/test-net-listen-after-destroying-stdin.js") | ||
| 475 | |||
| 476 | ;; VM Modules is an experimental feature | ||
| 477 | (delete-file "test/parallel/test-vm-module-dynamic-import.js") | ||
| 478 | |||
| 479 | ;; These tests need looking into: | ||
| 480 | (for-each delete-file | ||
| 481 | '("test/async-hooks/test-filehandle-no-reuse.js" | ||
| 482 | "test/async-hooks/test-graph.http.js" | ||
| 483 | "test/async-hooks/test-http-agent-handle-reuse.js" | ||
| 484 | "test/parallel/test-cli-options-precedence.js" | ||
| 485 | "test/parallel/test-http-methods.js" | ||
| 486 | "test/parallel/test-process-versions.js" | ||
| 487 | "test/parallel/test-uv-errno.js" | ||
| 488 | "test/report/test-report-uv-handles.js")) | ||
| 489 | |||
| 490 | ;; [DEP0131] DeprecationWarning: The legacy HTTP parser is deprecated. | ||
| 491 | ;; These are due to our blocking llhttp. | ||
| 492 | (for-each | ||
| 493 | delete-file | ||
| 494 | '("test/parallel/test-domain-http-server.js" | ||
| 495 | "test/parallel/test-domain-multi.js" | ||
| 496 | "test/parallel/test-http-chunked-smuggling.js" | ||
| 497 | "test/parallel/test-http-client-error-rawbytes.js" | ||
| 498 | "test/parallel/test-http-client-parse-error.js" | ||
| 499 | "test/parallel/test-http-deprecated-urls.js" | ||
| 500 | "test/parallel/test-http-header-overflow.js" | ||
| 501 | "test/parallel/test-http-outgoing-internal-headernames-getter.js" | ||
| 502 | "test/parallel/test-http-outgoing-internal-headernames-setter.js" | ||
| 503 | "test/parallel/test-http-outgoing-internal-headers.js" | ||
| 504 | "test/parallel/test-http-request-smuggling-content-length.js" | ||
| 505 | "test/parallel/test-http-server-client-error.js" | ||
| 506 | "test/parallel/test-http-server-destroy-socket-on-client-error.js" | ||
| 507 | "test/parallel/test-http-timeout-client-warning.js" | ||
| 508 | "test/parallel/test-http2-client-http1-server.js" | ||
| 509 | "test/parallel/test-http2-client-request-listeners-warning.js" | ||
| 510 | "test/parallel/test-http2-server-set-header.js" | ||
| 511 | "test/parallel/test-https-simple.js" | ||
| 512 | "test/parallel/test-https-strict.js" | ||
| 513 | "test/parallel/test-release-npm.js")) | ||
| 514 | |||
| 515 | ;; These tests have an expiry date: they depend on the validity of | ||
| 516 | ;; TLS certificates that are bundled with the source. We want this | ||
| 517 | ;; package to be reproducible forever, so remove those. | ||
| 518 | (for-each delete-file | ||
| 519 | '("test/parallel/test-tls-passphrase.js" | ||
| 520 | "test/parallel/test-tls-server-verify.js")))) | ||
| 521 | (add-before 'configure 'set-bootstrap-host-rpath | ||
| 522 | (lambda* (#:key native-inputs inputs #:allow-other-keys) | ||
| 523 | (let* ((inputs (or native-inputs inputs)) | ||
| 524 | (brotli (assoc-ref inputs "brotli")) | ||
| 525 | (c-ares (assoc-ref inputs "c-ares")) | ||
| 526 | (http-parser (assoc-ref inputs "http-parser")) | ||
| 527 | (icu4c (assoc-ref inputs "icu4c")) | ||
| 528 | (nghttp2 (assoc-ref inputs "nghttp2")) | ||
| 529 | (openssl (assoc-ref inputs "openssl")) | ||
| 530 | (libuv (assoc-ref inputs "libuv")) | ||
| 531 | (zlib (assoc-ref inputs "zlib")) | ||
| 532 | (host-binaries '("torque" | ||
| 533 | "bytecode_builtins_list_generator" | ||
| 534 | "gen-regexp-special-case" | ||
| 535 | "node_mksnapshot" | ||
| 536 | "mksnapshot"))) | ||
| 537 | (substitute* '("node.gyp" "tools/v8_gypfiles/v8.gyp") | ||
| 538 | (((string-append "'target_name': '(" | ||
| 539 | (string-join host-binaries "|") | ||
| 540 | ")',") | ||
| 541 | target) | ||
| 542 | (string-append target | ||
| 543 | "'ldflags': ['-Wl,-rpath=" | ||
| 544 | c-ares "/lib:" | ||
| 545 | brotli "/lib:" | ||
| 546 | http-parser "/lib:" | ||
| 547 | icu4c "/lib:" | ||
| 548 | nghttp2 "/lib:" | ||
| 549 | openssl "/lib:" | ||
| 550 | libuv "/lib:" | ||
| 551 | zlib "/lib" | ||
| 552 | "'],")))))) | ||
| 553 | (replace 'configure | ||
| 554 | ;; Node's configure script is actually a python script, so we can't | ||
| 555 | ;; run it with bash. | ||
| 556 | (lambda* (#:key outputs (configure-flags '()) native-inputs inputs | ||
| 557 | #:allow-other-keys) | ||
| 558 | (let* ((prefix (assoc-ref outputs "out")) | ||
| 559 | (xflags ,(if (%current-target-system) | ||
| 560 | `'("--cross-compiling" | ||
| 561 | ,(string-append | ||
| 562 | "--dest-cpu=" | ||
| 563 | (match (%current-target-system) | ||
| 564 | ((? (cut string-prefix? "arm" <>)) | ||
| 565 | "arm") | ||
| 566 | ((? (cut string-prefix? "aarch64" <>)) | ||
| 567 | "arm64") | ||
| 568 | ((? (cut string-prefix? "i686" <>)) | ||
| 569 | "ia32") | ||
| 570 | ((? (cut string-prefix? "x86_64" <>)) | ||
| 571 | "x64") | ||
| 572 | ((? (cut string-prefix? "powerpc64" <>)) | ||
| 573 | "ppc64") | ||
| 574 | ((? (cut string-prefix? "riscv64" <>)) | ||
| 575 | "riscv64") | ||
| 576 | (_ "unsupported")))) | ||
| 577 | ''())) | ||
| 578 | (flags (cons (string-append "--prefix=" prefix) | ||
| 579 | (append xflags configure-flags)))) | ||
| 580 | (format #t "build directory: ~s~%" (getcwd)) | ||
| 581 | (format #t "configure flags: ~s~%" flags) | ||
| 582 | ;; Node's configure script expects the CC environment variable to | ||
| 583 | ;; be set. | ||
| 584 | (setenv "CC_host" "gcc") | ||
| 585 | (setenv "CXX_host" "g++") | ||
| 586 | (setenv "CC" ,(cc-for-target)) | ||
| 587 | (setenv "CXX" ,(cxx-for-target)) | ||
| 588 | (setenv "PKG_CONFIG" ,(pkg-config-for-target)) | ||
| 589 | (apply invoke | ||
| 590 | (let ((inpts (or native-inputs inputs))) | ||
| 591 | (with-exception-handler | ||
| 592 | (lambda (e) | ||
| 593 | (if (search-error? e) | ||
| 594 | (search-input-file inpts "/bin/python2") | ||
| 595 | (raise-exception e))) | ||
| 596 | (lambda () | ||
| 597 | (search-input-file inpts "/bin/python")) | ||
| 598 | #:unwind? #t)) | ||
| 599 | "configure" | ||
| 600 | flags)))) | ||
| 601 | (add-after 'patch-shebangs 'patch-nested-shebangs | ||
| 602 | (lambda* (#:key inputs outputs #:allow-other-keys) | ||
| 603 | ;; Based on the implementation of patch-shebangs | ||
| 604 | ;; from (guix build gnu-build-system). | ||
| 605 | (let ((path (append-map (match-lambda | ||
| 606 | ((_ . dir) | ||
| 607 | (list (string-append dir "/bin") | ||
| 608 | (string-append dir "/sbin") | ||
| 609 | (string-append dir "/libexec")))) | ||
| 610 | (append outputs inputs)))) | ||
| 611 | (for-each | ||
| 612 | (lambda (file) | ||
| 613 | (patch-shebang file path)) | ||
| 614 | (find-files (search-input-directory outputs "lib/node_modules") | ||
| 615 | (lambda (file stat) | ||
| 616 | (executable-file? file)) | ||
| 617 | #:stat lstat))))) | ||
| 618 | (add-after 'install 'install-npmrc | ||
| 619 | ;; Note: programs like node-gyp only receive these values if | ||
| 620 | ;; they are started via `npm` or `npx`. | ||
| 621 | ;; See: https://github.com/nodejs/node-gyp#npm-configuration | ||
| 622 | (lambda* (#:key outputs #:allow-other-keys) | ||
| 623 | (let* ((out (assoc-ref outputs "out"))) | ||
| 624 | (with-output-to-file | ||
| 625 | ;; Use the config file "primarily for distribution | ||
| 626 | ;; maintainers" rather than "{prefix}/etc/npmrc", | ||
| 627 | ;; especially because node-build-system uses --prefix | ||
| 628 | ;; to install things to their store paths: | ||
| 629 | (string-append out "/lib/node_modules/npm/npmrc") | ||
| 630 | (lambda () | ||
| 631 | ;; Tell npm (mostly node-gyp) where to find our | ||
| 632 | ;; installed headers so it doesn't try to | ||
| 633 | ;; download them from the internet: | ||
| 634 | (format #t "nodedir=~a\n" out))))))))) | ||
| 635 | (native-inputs | ||
| 636 | ;; Runtime dependencies for binaries used as a bootstrap. | ||
| 637 | (list brotli | ||
| 638 | c-ares | ||
| 639 | http-parser | ||
| 640 | icu4c | ||
| 641 | libuv | ||
| 642 | `(,nghttp2 "lib") | ||
| 643 | openssl-1.1 | ||
| 644 | zlib | ||
| 645 | ;; Regular build-time dependencies. | ||
| 646 | perl | ||
| 647 | pkg-config | ||
| 648 | procps | ||
| 649 | python-2 | ||
| 650 | util-linux)) | ||
| 651 | (inputs | ||
| 652 | (list bash-minimal | ||
| 653 | coreutils | ||
| 654 | c-ares | ||
| 655 | http-parser | ||
| 656 | icu4c | ||
| 657 | libuv | ||
| 658 | `(,nghttp2 "lib") | ||
| 659 | openssl-1.1 | ||
| 660 | python-wrapper ;for node-gyp (supports python3) | ||
| 661 | zlib)) | ||
| 662 | (native-search-paths | ||
| 663 | (list (search-path-specification | ||
| 664 | (variable "NODE_PATH") | ||
| 665 | (files '("lib/node_modules"))))) | ||
| 666 | (synopsis "Evented I/O for V8 JavaScript") | ||
| 667 | (description | ||
| 668 | "Node.js is a platform built on Chrome's JavaScript runtime | ||
| 669 | for easily building fast, scalable network applications. Node.js uses an | ||
| 670 | event-driven, non-blocking I/O model that makes it lightweight and efficient, | ||
| 671 | perfect for data-intensive real-time applications that run across distributed | ||
| 672 | devices.") | ||
| 673 | (home-page "https://nodejs.org/") | ||
| 674 | (license license:expat) | ||
| 675 | (properties '((max-silent-time . 7200) ;2h, needed on ARM | ||
| 676 | (timeout . 21600) ;6h | ||
| 677 | (hidden? . #t) | ||
| 678 | (cpe-name . "node.js"))))) | ||
| 679 | |||
| 353 | ;; Duplicate of node-semver | 680 | ;; Duplicate of node-semver |
| 354 | (define-public node-semver-bootstrap | 681 | (define-public node-semver-bootstrap |
| 355 | (package | 682 | (package |
