diff --git a/pkgs/development/web/nodejs/nodejs.nix b/pkgs/development/web/nodejs/nodejs.nix index b7ad9305d68e7..e2910b14a46c8 100644 --- a/pkgs/development/web/nodejs/nodejs.nix +++ b/pkgs/development/web/nodejs/nodejs.nix @@ -45,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 { @@ -55,10 +61,17 @@ let strictDeps = true; - env = lib.optionalAttrs (stdenv.isDarwin && stdenv.isx86_64) { + env = { + # Tell ninja to avoid ANSI sequences, otherwise we don’t see build + # progress in Nix logs. + # + # Note: do not set TERM=dumb environment variable globally, it is used in + # test-ci-js test suite to skip tests that otherwise run fine. + NINJA = "TERM=dumb ninja"; + } // lib.optionalAttrs (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) { # Make sure libc++ uses `posix_memalign` instead of `aligned_alloc` on x86_64-darwin. # Otherwise, nodejs would require the 11.0 SDK and macOS 10.15+. - NIX_CFLAGS_COMPILE = "-D__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__=101300"; + NIX_CFLAGS_COMPILE = "-D__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__=101300 -Wno-macro-redefined"; }; depsBuildBuild = [ buildPackages.stdenv.cc openssl libuv zlib icu ]; @@ -138,6 +151,9 @@ let # Note that currently stdenv does not run check phase if build ≠ host. doCheck = true; + # See https://github.com/nodejs/node/issues/22006 + enableParallelChecking = false; + # 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. @@ -176,11 +192,6 @@ let "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" @@ -201,6 +212,16 @@ let "test-runner-run" "test-runner-watch-mode" "test-watch-mode-files_watcher" + ] ++ lib.optionals stdenv.buildPlatform.isDarwin [ + # Disable tests that don’t work under macOS sandbox. + "test-macos-app-sandbox" + "test-os" + "test-os-process-priority" + ] ++ lib.optionals (stdenv.buildPlatform.isDarwin && stdenv.buildPlatform.isx86_64) [ + # These tests fail on x86_64-darwin (even without sandbox). + # TODO: revisit at a later date. + "test-fs-readv" + "test-fs-readv-sync" ])}" ]; @@ -295,5 +316,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 index d2fda8d2ceadf..070d0e1ddfc34 100644 --- a/pkgs/development/web/nodejs/use-correct-env-in-tests.patch +++ b/pkgs/development/web/nodejs/use-correct-env-in-tests.patch @@ -1,12 +1,5 @@ `/usr/bin/env` is not available. ---- old/test/common/assertSnapshot.js -+++ new/test/common/assertSnapshot.js -@@ -81,2 +81,2 @@ async function spawnAndAssert(filename, transform = (x) => x, { tty = false, ... -- const executable = tty ? 'tools/pseudo-tty.py' : process.execPath; -- const args = tty ? [process.execPath, ...flags, filename] : [...flags, filename]; -+ const executable = tty ? 'python3' : process.execPath; -+ const args = tty ? ['tools/pseudo-tty.py', process.execPath, ...flags, filename] : [...flags, filename]; --- old/test/parallel/test-child-process-default-options.js +++ new/test/parallel/test-child-process-default-options.js @@ -35 +35 @@ if (isWindows) { 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 c1c087f173577..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, fetchpatch2, 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,7 +14,7 @@ let inherit openssl; stdenv = ensureCompatibleCC pkgs; buildPackages = buildPackages // { stdenv = ensureCompatibleCC buildPackages; }; - python = python3; + python = python311; }; gypPatches = callPackage ./gyp-patches.nix { } ++ [ @@ -32,9 +32,19 @@ buildNodejs { ./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 d8471cc0cc321..84b39868e611e 100644 --- a/pkgs/development/web/nodejs/v20.nix +++ b/pkgs/development/web/nodejs/v20.nix @@ -1,4 +1,4 @@ -{ callPackage, fetchpatch2, openssl, python3, enableNpm ? true }: +{ callPackage, openssl, python3, enableNpm ? true }: let buildNodejs = callPackage ./nodejs.nix { @@ -12,16 +12,12 @@ let in buildNodejs { inherit enableNpm; - version = "20.15.1"; - sha256 = "sha256-/dU6VynZNmkaKhFRBG+0iXchy4sPyir5V4I6m0D+DDQ="; + version = "20.17.0"; + sha256 = "9abf03ac23362c60387ebb633a516303637145cb3c177be3348b16880fd8b28c"; 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 - (fetchpatch2 { - url = "https://github.com/nodejs/node/commit/534c122de166cb6464b489f3e6a9a544ceb1c913.patch"; - hash = "sha256-4q4LFsq4yU1xRwNsM1sJoNVphJCnxaVe2IyL6AeHJ/I="; - }) ] ++ gypPatches; } diff --git a/pkgs/development/web/nodejs/v22.nix b/pkgs/development/web/nodejs/v22.nix index 44737d2ba8eca..6f03749e2d22d 100644 --- a/pkgs/development/web/nodejs/v22.nix +++ b/pkgs/development/web/nodejs/v22.nix @@ -1,4 +1,4 @@ -{ callPackage, fetchpatch2, openssl, python3, enableNpm ? true }: +{ callPackage, openssl, python3, enableNpm ? true }: let buildNodejs = callPackage ./nodejs.nix { @@ -12,8 +12,8 @@ let in buildNodejs { inherit enableNpm; - version = "22.4.1"; - sha256 = "sha256-ZfyFf1qoJWqvyQCzRMARXJrq4loCVB/Vzg29Tf0cX7k="; + version = "22.8.0"; + sha256 = "f130e82176d1ee0702d99afc1995d0061bf8ed357c38834a32a08c9ef74f1ac7"; patches = [ ./disable-darwin-v8-system-instrumentation-node19.patch ./bypass-darwin-xcrun-node16.patch