diff options
Diffstat (limited to 'pkgs/development/web/nodejs')
-rw-r--r-- | pkgs/development/web/nodejs/bin-sh-node-run-v22.patch | 14 | ||||
-rw-r--r-- | pkgs/development/web/nodejs/bypass-xcodebuild.diff | 28 | ||||
-rw-r--r-- | pkgs/development/web/nodejs/gyp-patches-pre-v22-import-sys.patch | 24 | ||||
-rw-r--r-- | pkgs/development/web/nodejs/gyp-patches-v22-import-sys.patch | 14 | ||||
-rw-r--r-- | pkgs/development/web/nodejs/gyp-patches.nix | 22 | ||||
-rw-r--r-- | pkgs/development/web/nodejs/nodejs.nix | 104 | ||||
-rw-r--r-- | pkgs/development/web/nodejs/use-correct-env-in-tests.patch | 17 | ||||
-rw-r--r-- | pkgs/development/web/nodejs/v18-openssl-3.0.14.patch | 24 | ||||
-rw-r--r-- | pkgs/development/web/nodejs/v18.nix | 29 | ||||
-rw-r--r-- | pkgs/development/web/nodejs/v20.nix | 30 | ||||
-rw-r--r-- | pkgs/development/web/nodejs/v22.nix | 18 |
11 files changed, 270 insertions, 54 deletions
diff --git a/pkgs/development/web/nodejs/bin-sh-node-run-v22.patch b/pkgs/development/web/nodejs/bin-sh-node-run-v22.patch new file mode 100644 index 0000000000000..3fd142a3e440d --- /dev/null +++ b/pkgs/development/web/nodejs/bin-sh-node-run-v22.patch @@ -0,0 +1,14 @@ +Fixes test/parallel/test-node-run.js subtest. + +Note that this techinically depends on an impurity during build, see +also https://github.com/NixOS/nix/issues/6081. Currently stdenv allows +/bin/sh as an impure host dependency on Darwin, so we are guaranteed to +have it to certain degree, although it is very hacky. + +--- a/test/fixtures/run-script/node_modules/.bin/positional-args ++++ b/test/fixtures/run-script/node_modules/.bin/positional-args +@@ -1,3 +1,3 @@ +-#!/bin/bash ++#!/bin/sh + echo "Arguments: '$@'" + echo "The total number of arguments are: $#" diff --git a/pkgs/development/web/nodejs/bypass-xcodebuild.diff b/pkgs/development/web/nodejs/bypass-xcodebuild.diff deleted file mode 100644 index 5c900dd2143f4..0000000000000 --- a/pkgs/development/web/nodejs/bypass-xcodebuild.diff +++ /dev/null @@ -1,28 +0,0 @@ -diff -Naur node-v12.18.4/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py node-v12.18.4-new/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py ---- node-v12.18.4/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py 2020-09-15 09:08:46.000000000 +0200 -+++ node-v12.18.4-new/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py 2020-12-03 16:55:43.781860687 +0100 -@@ -436,7 +436,14 @@ - # Since the CLT has no SDK paths anyway, returning None is the - # most sensible route and should still do the right thing. - try: -- return GetStdoutQuiet(['xcodebuild', '-version', '-sdk', sdk, infoitem]) -+ # Return fake data that xcodebuild would normally return -+ -+ xcodedata = { -+ "Path": "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk", -+ "ProductBuildVersion": "19A547", -+ "ProductVersion": "10.15" -+ } -+ return xcodedata[infoitem] - except GypError: - pass - -@@ -1271,7 +1278,7 @@ - version = "" - build = "" - try: -- version_list = GetStdoutQuiet(['xcodebuild', '-version']).splitlines() -+ version_list = [] - # In some circumstances xcodebuild exits 0 but doesn't return - # the right results; for example, a user on 10.7 or 10.8 with - # a bogus path set via xcode-select diff --git a/pkgs/development/web/nodejs/gyp-patches-pre-v22-import-sys.patch b/pkgs/development/web/nodejs/gyp-patches-pre-v22-import-sys.patch new file mode 100644 index 0000000000000..fa499c6491c76 --- /dev/null +++ b/pkgs/development/web/nodejs/gyp-patches-pre-v22-import-sys.patch @@ -0,0 +1,24 @@ +Add missing import statement for gyp-patches.nix. + +--- a/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py ++++ b/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +@@ -25,6 +25,7 @@ + import os + import re + import subprocess ++import sys + import gyp + import gyp.common + import gyp.xcode_emulation + +--- a/tools/gyp/pylib/gyp/generator/make.py ++++ b/tools/gyp/pylib/gyp/generator/make.py +@@ -25,6 +25,7 @@ + import os + import re + import subprocess ++import sys + import gyp + import gyp.common + import gyp.xcode_emulation + diff --git a/pkgs/development/web/nodejs/gyp-patches-v22-import-sys.patch b/pkgs/development/web/nodejs/gyp-patches-v22-import-sys.patch new file mode 100644 index 0000000000000..4f1abea901c0f --- /dev/null +++ b/pkgs/development/web/nodejs/gyp-patches-v22-import-sys.patch @@ -0,0 +1,14 @@ +For some reason Node.js v22 has two different GYP versions vendored, and +only one of them contains `import sys`. + +--- a/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py ++++ b/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +@@ -25,6 +25,7 @@ + import os + import re + import subprocess ++import sys + import gyp + import gyp.common + import gyp.xcode_emulation + diff --git a/pkgs/development/web/nodejs/gyp-patches.nix b/pkgs/development/web/nodejs/gyp-patches.nix new file mode 100644 index 0000000000000..67a2a2a128440 --- /dev/null +++ b/pkgs/development/web/nodejs/gyp-patches.nix @@ -0,0 +1,22 @@ +{ fetchpatch2 }: +let + name = "gyp-darwin-sandbox.patch"; + url = "https://github.com/nodejs/gyp-next/commit/706d04aba5bd18f311dc56f84720e99f64c73466.patch"; +in +[ + # Fixes builds with Nix sandbox on Darwin for gyp. + # See https://github.com/NixOS/nixpkgs/issues/261820 + # and https://github.com/nodejs/gyp-next/pull/216 + (fetchpatch2 { + inherit name url; + hash = "sha256-l8FzgLq9CbVJCkXfnTyDQ+vXKCz65wpaffE74oSU+kY="; + stripLen = 1; + extraPrefix = "tools/gyp/"; + }) + (fetchpatch2 { + inherit name url; + hash = "sha256-UVUn4onXfJgFoAdApLAbliiBgM9rxDdIo53WjFryoBI="; + stripLen = 1; + extraPrefix = "deps/npm/node_modules/node-gyp/gyp/"; + }) +] diff --git a/pkgs/development/web/nodejs/nodejs.nix b/pkgs/development/web/nodejs/nodejs.nix index 962bc3e246bec..c6ed6a116a37f 100644 --- a/pkgs/development/web/nodejs/nodejs.nix +++ b/pkgs/development/web/nodejs/nodejs.nix @@ -1,5 +1,6 @@ { lib, stdenv, fetchurl, openssl, python, zlib, libuv, util-linux, http-parser, bash , pkg-config, which, buildPackages +, testers # for `.pkgs` attribute , callPackage # Updater dependencies @@ -7,6 +8,7 @@ , gnupg , darwin, xcbuild , procps, icu +, installShellFiles }: { enableNpm ? true, version, sha256, patches ? [] } @args: @@ -43,7 +45,13 @@ let (builtins.attrNames sharedLibDeps); extraConfigFlags = lib.optionals (!enableNpm) [ "--without-npm" ]; - self = stdenv.mkDerivation { + + package = stdenv.mkDerivation (finalAttrs: + let + /** the final package fixed point, after potential overrides */ + self = finalAttrs.finalPackage; + in + { inherit pname version; src = fetchurl { @@ -59,8 +67,6 @@ let NIX_CFLAGS_COMPILE = "-D__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__=101300"; }; - CC_host = "cc"; - CXX_host = "c++"; depsBuildBuild = [ buildPackages.stdenv.cc openssl libuv zlib icu ]; # NB: technically, we do not need bash in build inputs since all scripts are @@ -69,7 +75,7 @@ let buildInputs = lib.optionals stdenv.isDarwin [ CoreServices ApplicationServices ] ++ [ zlib libuv openssl http-parser icu bash ]; - nativeBuildInputs = [ which pkg-config python ] + nativeBuildInputs = [ installShellFiles pkg-config python which ] ++ lib.optionals stdenv.isDarwin [ xcbuild ]; outputs = [ "out" "libv8" ]; @@ -105,6 +111,11 @@ let dontDisableStatic = true; + configureScript = writeScript "nodejs-configure" '' + export CC_host="$CC_FOR_BUILD" CXX_host="$CXX_FOR_BUILD" + exec ${python.executable} configure.py "$@" + ''; + enableParallelBuilding = true; # Don't allow enabling content addressed conversion as `nodejs` @@ -127,24 +138,86 @@ let inherit patches; - doCheck = lib.versionAtLeast version "16"; # some tests fail on v14 + __darwinAllowLocalNetworking = true; # for tests + + # TODO: what about tests when cross-compiling? + # Note that currently stdenv does not run check phase if build ≠ host. + doCheck = true; # Some dependencies required for tools/doc/node_modules (and therefore # test-addons, jstest and others) target are not included in the tarball. # Run test targets that do not require network access. - checkTarget = lib.concatStringsSep " " [ + checkTarget = lib.concatStringsSep " " ([ "build-js-native-api-tests" "build-node-api-tests" "tooltest" "cctest" + ] ++ lib.optionals (!stdenv.buildPlatform.isDarwin || lib.versionAtLeast version "20") [ + # There are some test failures on macOS before v20 that are not worth the + # time to debug for a version that would be eventually removed in less + # than a year (Node.js 18 will be EOL at 2025-04-30). Note that these + # failures are specific to Nix sandbox on macOS and should not affect + # actual functionality. + ] ++ lib.optionals (!stdenv.isDarwin) [ + # TODO: JS test suite is too flaky on Darwin; revisit at a later date. + "test-ci-js" + ]); + + checkFlags = [ + # Do not create __pycache__ when running tests. + "PYTHONDONTWRITEBYTECODE=1" + ] ++ lib.optionals (!stdenv.buildPlatform.isDarwin || lib.versionAtLeast version "20") [ + "FLAKY_TESTS=skip" + # Skip some tests that are not passing in this context + "CI_SKIP_TESTS=${lib.concatStringsSep "," ([ + "test-child-process-exec-env" + "test-child-process-uid-gid" + "test-fs-write-stream-eagain" + "test-https-foafssl" + "test-process-euid-egid" + "test-process-initgroups" + "test-process-setgroups" + "test-process-uid-gid" + "test-setproctitle" + "test-tls-cli-max-version-1.3" + "test-tls-client-auth" + "test-tls-sni-option" + ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ + # Disable tests that don’t work under macOS sandbox. + "test-macos-app-sandbox" + "test-os" + "test-os-process-priority" + # This is a bit weird, but for some reason fs watch tests fail with + # sandbox. + "test-fs-promises-watch" + "test-fs-watch" + "test-fs-watch-encoding" + "test-fs-watch-non-recursive" + "test-fs-watch-recursive-add-file" + "test-fs-watch-recursive-add-file-to-existing-subfolder" + "test-fs-watch-recursive-add-file-to-new-folder" + "test-fs-watch-recursive-add-file-with-url" + "test-fs-watch-recursive-add-folder" + "test-fs-watch-recursive-assert-leaks" + "test-fs-watch-recursive-promise" + "test-fs-watch-recursive-symlink" + "test-fs-watch-recursive-sync-write" + "test-fs-watch-recursive-update-file" + "test-fs-watchfile" + "test-runner-run" + "test-runner-watch-mode" + "test-watch-mode-files_watcher" + ])}" ]; - # Do not create __pycache__ when running tests. - checkFlags = [ "PYTHONDONTWRITEBYTECODE=1" ]; - postInstall = '' HOST_PATH=$out/bin patchShebangs --host $out + ${lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' + $out/bin/${self.meta.mainProgram} --completion-bash > ${self.meta.mainProgram}.bash + installShellCompletion ${self.meta.mainProgram}.bash + ''} + ${lib.optionalString (enableNpm) '' mkdir -p $out/share/bash-completion/completions ln -s $out/lib/node_modules/npm/lib/utils/completion.sh \ @@ -195,6 +268,13 @@ let EOF ''; + passthru.tests = { + version = testers.testVersion { + package = self; + version = "v${version}"; + }; + }; + passthru.updateScript = import ./update.nix { inherit writeScript coreutils gnugrep jq curl common-updater-scripts gnupg nix runtimeShell; inherit lib; @@ -206,7 +286,7 @@ let homepage = "https://nodejs.org"; changelog = "https://github.com/nodejs/node/releases/tag/v${version}"; license = licenses.mit; - maintainers = with maintainers; [ goibhniu cko aduh95 ]; + maintainers = with maintainers; [ aduh95 ]; platforms = platforms.linux ++ platforms.darwin; mainProgram = "node"; knownVulnerabilities = optional (versionOlder version "18") "This NodeJS release has reached its end of life. See https://nodejs.org/en/about/releases/."; @@ -221,5 +301,5 @@ let }; passthru.python = python; # to ensure nodeEnv uses the same version - }; -in self + }); +in package diff --git a/pkgs/development/web/nodejs/use-correct-env-in-tests.patch b/pkgs/development/web/nodejs/use-correct-env-in-tests.patch new file mode 100644 index 0000000000000..070d0e1ddfc34 --- /dev/null +++ b/pkgs/development/web/nodejs/use-correct-env-in-tests.patch @@ -0,0 +1,17 @@ +`/usr/bin/env` is not available. + +--- old/test/parallel/test-child-process-default-options.js ++++ new/test/parallel/test-child-process-default-options.js +@@ -35 +35 @@ if (isWindows) { +- child = spawn('/usr/bin/env', [], {}); ++ child = spawn('env', [], {}); +--- old/test/parallel/test-child-process-env.js ++++ new/test/parallel/test-child-process-env.js +@@ -51 +51 @@ if (isWindows) { +- child = spawn('/usr/bin/env', [], { env }); ++ child = spawn('env', [], { env }); +--- old/test/parallel/test-child-process-exec-env.js ++++ new/test/parallel/test-child-process-exec-env.js +@@ -47 +47 @@ if (!isWindows) { +- child = exec('/usr/bin/env', { env: { 'HELLO': 'WORLD' } }, after); ++ child = exec('env', { env: { 'HELLO': 'WORLD' } }, after); diff --git a/pkgs/development/web/nodejs/v18-openssl-3.0.14.patch b/pkgs/development/web/nodejs/v18-openssl-3.0.14.patch new file mode 100644 index 0000000000000..b63fb8ad1303f --- /dev/null +++ b/pkgs/development/web/nodejs/v18-openssl-3.0.14.patch @@ -0,0 +1,24 @@ +diff --git a/test/parallel/test-tls-alpn-server-client.js b/test/parallel/test-tls-alpn-server-client.js +index 522dd34ad2..3f0ee2a0f9 100644 +--- a/test/parallel/test-tls-alpn-server-client.js ++++ b/test/parallel/test-tls-alpn-server-client.js +@@ -195,7 +195,8 @@ function TestALPNCallback() { + + // Callback picks 2nd preference => undefined => ALPN rejected: + assert.strictEqual(results[1].server, undefined); +- assert.strictEqual(results[1].client.error.code, 'ECONNRESET'); ++ const allowedErrors = ['ECONNRESET', 'ERR_SSL_TLSV1_ALERT_NO_APPLICATION_PROTOCOL']; ++ assert.ok(allowedErrors.includes(results[1].client.error.code), `'${results[1].client.error.code}' was not one of ${allowedErrors}.`); + + TestBadALPNCallback(); + }); +@@ -218,7 +219,8 @@ function TestBadALPNCallback() { + runTest(clientsOptions, serverOptions, function(results) { + // Callback returns 'http/5' => doesn't match client ALPN => error & reset + assert.strictEqual(results[0].server, undefined); +- assert.strictEqual(results[0].client.error.code, 'ECONNRESET'); ++ const allowedErrors = ['ECONNRESET', 'ERR_SSL_TLSV1_ALERT_NO_APPLICATION_PROTOCOL']; ++ assert.ok(allowedErrors.includes(results[0].client.error.code), `'${results[0].client.error.code}' was not one of ${allowedErrors}.`); + + TestALPNOptionsCallback(); + }); diff --git a/pkgs/development/web/nodejs/v18.nix b/pkgs/development/web/nodejs/v18.nix index 6b3ca7635e436..ab2edcf5e8c9a 100644 --- a/pkgs/development/web/nodejs/v18.nix +++ b/pkgs/development/web/nodejs/v18.nix @@ -1,4 +1,4 @@ -{ callPackage, lib, overrideCC, pkgs, buildPackages, openssl, python3, enableNpm ? true }: +{ callPackage, lib, overrideCC, pkgs, buildPackages, openssl, python311, fetchpatch2, enableNpm ? true }: let # Clang 16+ cannot build Node v18 due to -Wenum-constexpr-conversion errors. @@ -14,18 +14,37 @@ let inherit openssl; stdenv = ensureCompatibleCC pkgs; buildPackages = buildPackages // { stdenv = ensureCompatibleCC buildPackages; }; - python = python3; + python = python311; }; + + gypPatches = callPackage ./gyp-patches.nix { } ++ [ + ./gyp-patches-pre-v22-import-sys.patch + ]; in buildNodejs { inherit enableNpm; - version = "18.20.2"; - sha256 = "sha256-iq6nycfpJ/sJ2RSY2jEbbk0YIzOQ4jxyOlO4kfrUxz8="; + version = "18.20.4"; + sha256 = "sha256-p2x+oblq62ljoViAYmDICUtiRNZKaWUp0CBUe5qVyio="; patches = [ ./disable-darwin-v8-system-instrumentation.patch ./bypass-darwin-xcrun-node16.patch ./revert-arm64-pointer-auth.patch ./node-npm-build-npm-package-logic.patch ./trap-handler-backport.patch - ]; + ./use-correct-env-in-tests.patch + ./v18-openssl-3.0.14.patch + (fetchpatch2 { + url = "https://github.com/nodejs/node/commit/534c122de166cb6464b489f3e6a9a544ceb1c913.patch"; + hash = "sha256-4q4LFsq4yU1xRwNsM1sJoNVphJCnxaVe2IyL6AeHJ/I="; + }) + (fetchpatch2 { + url = "https://github.com/nodejs/node/commit/87598d4b63ef2c827a2bebdfa0f1540c35718519.patch"; + hash = "sha256-JJi8z9aaWnu/y3nZGOSUfeNzNSCYzD9dzoHXaGkeaEA="; + includes = ["test/common/assertSnapshot.js"]; + }) + (fetchpatch2 { + url = "https://github.com/nodejs/node/commit/d0a6b605fba6cd69a82e6f12ff0363eef8fe1ee9.patch"; + hash = "sha256-TfYal/PikRZHL6zpAlC3SmkYXCe+/8Gs83dLX/X/P/k="; + }) + ] ++ gypPatches; } diff --git a/pkgs/development/web/nodejs/v20.nix b/pkgs/development/web/nodejs/v20.nix index b716f9bdd1ed5..1688eca1d2da8 100644 --- a/pkgs/development/web/nodejs/v20.nix +++ b/pkgs/development/web/nodejs/v20.nix @@ -1,19 +1,39 @@ -{ callPackage, openssl, python3, enableNpm ? true }: +{ callPackage, fetchpatch2, openssl, python3, enableNpm ? true }: let buildNodejs = callPackage ./nodejs.nix { inherit openssl; python = python3; }; + + gypPatches = callPackage ./gyp-patches.nix { } ++ [ + ./gyp-patches-pre-v22-import-sys.patch + ]; in buildNodejs { inherit enableNpm; - version = "20.12.2"; - sha256 = "sha256-18vMX7+zHpAB8/AVC77aWavl3XE3qqYnOVjNWc41ztc="; + version = "20.15.1"; + sha256 = "sha256-/dU6VynZNmkaKhFRBG+0iXchy4sPyir5V4I6m0D+DDQ="; patches = [ - ./revert-arm64-pointer-auth.patch ./disable-darwin-v8-system-instrumentation-node19.patch ./bypass-darwin-xcrun-node16.patch ./node-npm-build-npm-package-logic.patch - ]; + ./use-correct-env-in-tests.patch + (fetchpatch2 { + url = "https://github.com/nodejs/node/commit/534c122de166cb6464b489f3e6a9a544ceb1c913.patch"; + hash = "sha256-4q4LFsq4yU1xRwNsM1sJoNVphJCnxaVe2IyL6AeHJ/I="; + }) + (fetchpatch2 { + url = "https://github.com/nodejs/node/commit/14863e80584e579fd48c55f6373878c821c7ff7e.patch"; + hash = "sha256-I7Wjc7DE059a/ZyXAvAqEGvDudPjxQqtkBafckHCFzo="; + }) + (fetchpatch2 { + url = "https://github.com/nodejs/node/commit/87598d4b63ef2c827a2bebdfa0f1540c35718519.patch"; + hash = "sha256-efRJ2nN9QXaT91SQTB+ESkHvXtBq30Cb9BEDEZU9M/8="; + }) + (fetchpatch2 { + url = "https://github.com/nodejs/node/commit/d0a6b605fba6cd69a82e6f12ff0363eef8fe1ee9.patch"; + hash = "sha256-TfYal/PikRZHL6zpAlC3SmkYXCe+/8Gs83dLX/X/P/k="; + }) + ] ++ gypPatches; } diff --git a/pkgs/development/web/nodejs/v22.nix b/pkgs/development/web/nodejs/v22.nix index ec5cc40cc9c2d..9b3fa4fa0d8b7 100644 --- a/pkgs/development/web/nodejs/v22.nix +++ b/pkgs/development/web/nodejs/v22.nix @@ -1,18 +1,28 @@ -{ callPackage, openssl, python3, enableNpm ? true }: +{ callPackage, fetchpatch2, openssl, python3, enableNpm ? true }: let buildNodejs = callPackage ./nodejs.nix { inherit openssl; python = python3; }; + + gypPatches = callPackage ./gyp-patches.nix { } ++ [ + ./gyp-patches-v22-import-sys.patch + ]; in buildNodejs { inherit enableNpm; - version = "22.3.0"; - sha256 = "0k0h4s9s2y0ms3g6xhynsqsrkl9hz001dmj6j0gpc5x5vk8mpf5z"; + version = "22.5.1"; + sha256 = "924f381a32cf26b6bedbe95feedde348450f4fd321283d3bf3f7965aa45ce831"; patches = [ ./disable-darwin-v8-system-instrumentation-node19.patch ./bypass-darwin-xcrun-node16.patch ./node-npm-build-npm-package-logic.patch - ]; + ./use-correct-env-in-tests.patch + ./bin-sh-node-run-v22.patch + (fetchpatch2 { + url = "https://github.com/nodejs/node/commit/d0a6b605fba6cd69a82e6f12ff0363eef8fe1ee9.patch"; + hash = "sha256-TfYal/PikRZHL6zpAlC3SmkYXCe+/8Gs83dLX/X/P/k="; + }) + ] ++ gypPatches; } |