Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[24.05 backport] nodejs changes #336570

Merged
merged 12 commits into from
Sep 13, 2024
41 changes: 31 additions & 10 deletions pkgs/development/web/nodejs/nodejs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 ];
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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"
Expand All @@ -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"
])}"
];

Expand Down Expand Up @@ -295,5 +316,5 @@ let
};

passthru.python = python; # to ensure nodeEnv uses the same version
};
in self
});
in package
7 changes: 0 additions & 7 deletions pkgs/development/web/nodejs/use-correct-env-in-tests.patch
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
24 changes: 24 additions & 0 deletions pkgs/development/web/nodejs/v18-openssl-3.0.14.patch
Original file line number Diff line number Diff line change
@@ -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();
});
14 changes: 12 additions & 2 deletions pkgs/development/web/nodejs/v18.nix
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -14,7 +14,7 @@ let
inherit openssl;
stdenv = ensureCompatibleCC pkgs;
buildPackages = buildPackages // { stdenv = ensureCompatibleCC buildPackages; };
python = python3;
python = python311;
};

gypPatches = callPackage ./gyp-patches.nix { } ++ [
Expand All @@ -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;
}
10 changes: 3 additions & 7 deletions pkgs/development/web/nodejs/v20.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ callPackage, fetchpatch2, openssl, python3, enableNpm ? true }:
{ callPackage, openssl, python3, enableNpm ? true }:

let
buildNodejs = callPackage ./nodejs.nix {
Expand All @@ -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;
}
6 changes: 3 additions & 3 deletions pkgs/development/web/nodejs/v22.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ callPackage, fetchpatch2, openssl, python3, enableNpm ? true }:
{ callPackage, openssl, python3, enableNpm ? true }:

let
buildNodejs = callPackage ./nodejs.nix {
Expand All @@ -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
Expand Down
Loading