Skip to content

Commit

Permalink
[staging-next-24.11] Node.js backports (#371149)
Browse files Browse the repository at this point in the history
  • Loading branch information
emilazy authored Jan 5, 2025
2 parents fa0d5a3 + 0f893f1 commit ea2f362
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 31 deletions.
4 changes: 4 additions & 0 deletions pkgs/development/web/nodejs/nodejs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ let
"FLAKY_TESTS=skip"
# Skip some tests that are not passing in this context
"CI_SKIP_TESTS=${lib.concatStringsSep "," ([
# Tests don't work in sandbox.
"test-child-process-exec-env"
"test-child-process-uid-gid"
"test-fs-write-stream-eagain"
Expand Down Expand Up @@ -321,6 +322,9 @@ let
"test-watch-mode-files_watcher"
] ++ lib.optionals (!lib.versionAtLeast version "22") [
"test-tls-multi-key"
] ++ lib.optionals stdenv.hostPlatform.is32bit [
# utime (actually utimensat) fails with EINVAL on 2038 timestamp
"test-fs-utimes-y2K38"
] ++ lib.optionals stdenv.buildPlatform.isDarwin [
# Disable tests that don’t work under macOS sandbox.
"test-macos-app-sandbox"
Expand Down
52 changes: 32 additions & 20 deletions pkgs/development/web/nodejs/v18.nix
Original file line number Diff line number Diff line change
@@ -1,35 +1,15 @@
{
callPackage,
lib,
overrideCC,
pkgs,
buildPackages,
openssl,
python311,
fetchpatch2,
enableNpm ? true,
}:

let
# Clang 16+ cannot build Node v18 due to -Wenum-constexpr-conversion errors.
# Use an older version of clang with the current libc++ for compatibility (e.g., with icu).
ensureCompatibleCC =
packages:
if packages.stdenv.cc.isClang && lib.versionAtLeast (lib.getVersion packages.stdenv.cc.cc) "16" then
overrideCC packages.llvmPackages_15.stdenv (
packages.llvmPackages_15.stdenv.cc.override {
inherit (packages.llvmPackages) libcxx;
}
)
else
packages.stdenv;

buildNodejs = callPackage ./nodejs.nix {
inherit openssl;
stdenv = ensureCompatibleCC pkgs;
buildPackages = buildPackages // {
stdenv = ensureCompatibleCC buildPackages;
};
python = python311;
};

Expand Down Expand Up @@ -63,5 +43,37 @@ buildNodejs {
url = "https://github.com/nodejs/node/commit/d0a6b605fba6cd69a82e6f12ff0363eef8fe1ee9.patch";
hash = "sha256-TfYal/PikRZHL6zpAlC3SmkYXCe+/8Gs83dLX/X/P/k=";
})
# Remove unused `fdopen` in vendored zlib, which causes compilation failures with clang 18 on Darwin.
(fetchpatch2 {
url = "https://github.com/madler/zlib/commit/4bd9a71f3539b5ce47f0c67ab5e01f3196dc8ef9.patch?full_index=1";
extraPrefix = "deps/v8/third_party/zlib/";
stripLen = 1;
hash = "sha256-WVxsoEcJu0WBTyelNrVQFTZxJhnekQb1GrueeRBRdnY=";
})
# Backport V8 fixes for LLVM 19.
(fetchpatch2 {
url = "https://chromium.googlesource.com/v8/v8/+/182d9c05e78b1ddb1cb8242cd3628a7855a0336f%5E%21/?format=TEXT";
decode = "base64 -d";
extraPrefix = "deps/v8/";
stripLen = 1;
hash = "sha256-bDTwFbATPn5W4VifWz/SqaiigXYDWHq785C64VezuUE=";
})
(fetchpatch2 {
url = "https://chromium.googlesource.com/v8/v8/+/1a3ecc2483b2dba6ab9f7e9f8f4b60dbfef504b7%5E%21/?format=TEXT";
decode = "base64 -d";
extraPrefix = "deps/v8/";
stripLen = 1;
hash = "sha256-6y3aEqxNC4iTQEv1oewodJrhOHxjp5xZMq1P1QL94Rg=";
})
# Fix for https://github.com/NixOS/nixpkgs/issues/355919
# FIXME: remove after a minor point release
(fetchpatch2 {
url = "https://github.com/nodejs/node/commit/a094a8166cd772f89e92b5deef168e5e599fa815.patch?full_index=1";
hash = "sha256-5FZfozYWRa1ZI/f+e+xpdn974Jg2DbiHbua13XUQP5E=";
})
(fetchpatch2 {
url = "https://github.com/nodejs/node/commit/f270462c09ddfd770291a7c8a2cd204b2c63d730.patch?full_index=1";
hash = "sha256-Err0i5g7WtXcnhykKgrS3ocX7/3oV9UrT0SNeRtMZNU=";
})
] ++ gypPatches;
}
38 changes: 38 additions & 0 deletions pkgs/development/web/nodejs/v20.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,43 @@ buildNodejs {
./bypass-darwin-xcrun-node16.patch
./node-npm-build-npm-package-logic.patch
./use-correct-env-in-tests.patch

# Remove unused `fdopen` in vendored zlib, which causes compilation failures with clang 18 on Darwin.
(fetchpatch2 {
url = "https://github.com/madler/zlib/commit/4bd9a71f3539b5ce47f0c67ab5e01f3196dc8ef9.patch?full_index=1";
extraPrefix = "deps/v8/third_party/zlib/";
stripLen = 1;
hash = "sha256-WVxsoEcJu0WBTyelNrVQFTZxJhnekQb1GrueeRBRdnY=";
})
# Fix for https://github.com/NixOS/nixpkgs/issues/355919
# FIXME: remove after a minor point release
(fetchpatch2 {
url = "https://github.com/nodejs/node/commit/a094a8166cd772f89e92b5deef168e5e599fa815.patch?full_index=1";
hash = "sha256-5FZfozYWRa1ZI/f+e+xpdn974Jg2DbiHbua13XUQP5E=";
})
(fetchpatch2 {
url = "https://github.com/nodejs/node/commit/f270462c09ddfd770291a7c8a2cd204b2c63d730.patch?full_index=1";
hash = "sha256-Err0i5g7WtXcnhykKgrS3ocX7/3oV9UrT0SNeRtMZNU=";
})
# Backport V8 fixes for LLVM 19.
(fetchpatch2 {
url = "https://chromium.googlesource.com/v8/v8/+/182d9c05e78b1ddb1cb8242cd3628a7855a0336f%5E%21/?format=TEXT";
decode = "base64 -d";
extraPrefix = "deps/v8/";
stripLen = 1;
hash = "sha256-bDTwFbATPn5W4VifWz/SqaiigXYDWHq785C64VezuUE=";
})
(fetchpatch2 {
url = "https://chromium.googlesource.com/v8/v8/+/1a3ecc2483b2dba6ab9f7e9f8f4b60dbfef504b7%5E%21/?format=TEXT";
decode = "base64 -d";
extraPrefix = "deps/v8/";
stripLen = 1;
hash = "sha256-6y3aEqxNC4iTQEv1oewodJrhOHxjp5xZMq1P1QL94Rg=";
})
# fixes test failure, remove when included in release
(fetchpatch2 {
url = "https://github.com/nodejs/node/commit/b6fe731c55eb4cb9d14042a23e5002ed39b7c8b7.patch?full_index=1";
hash = "sha256-KoKsQBFKUji0GeEPTR8ixBflCiHBhPqd2cPVPuKyua8=";
})
] ++ gypPatches;
}
16 changes: 14 additions & 2 deletions pkgs/development/web/nodejs/v22.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ let
in
buildNodejs {
inherit enableNpm;
version = "22.10.0";
sha256 = "3180710d3130ad9df01466abf010e408d41b374be54301d1480d10eca73558e0";
version = "22.12.0";
sha256 = "fe1bc4be004dc12721ea2cb671b08a21de01c6976960ef8a1248798589679e16";
patches = [
./configure-emulator.patch
./configure-armv6-vfpv2.patch
Expand All @@ -18,5 +18,17 @@ buildNodejs {
./node-npm-build-npm-package-logic.patch
./use-correct-env-in-tests.patch
./bin-sh-node-run-v22.patch

# Fix for https://github.com/NixOS/nixpkgs/issues/355919
# FIXME: remove after a minor point release
(fetchpatch2 {
url = "https://github.com/nodejs/node/commit/f270462c09ddfd770291a7c8a2cd204b2c63d730.patch?full_index=1";
hash = "sha256-Err0i5g7WtXcnhykKgrS3ocX7/3oV9UrT0SNeRtMZNU=";
})
# fixes test failure, remove when included in release
(fetchpatch2 {
url = "https://github.com/nodejs/node/commit/b6fe731c55eb4cb9d14042a23e5002ed39b7c8b7.patch?full_index=1";
hash = "sha256-KoKsQBFKUji0GeEPTR8ixBflCiHBhPqd2cPVPuKyua8=";
})
];
}
13 changes: 4 additions & 9 deletions pkgs/development/web/nodejs/v23.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ let
in
buildNodejs {
inherit enableNpm;
version = "23.2.0";
sha256 = "3cf7a8a36682775693691f1de901bb5973ad3c0ae2aa87b1add9de515e7b2fc7";
version = "23.5.0";
sha256 = "32e77b36c0774c68baab41bc7c2acc58663ca0a2b7c4d3e9bec6f761c15fdac0";
patches = [
./configure-emulator.patch
./configure-armv6-vfpv2.patch
Expand Down Expand Up @@ -53,15 +53,10 @@ buildNodejs {
hash = "sha256-gmIyiSyNzC3pClL1SM2YicckWM+/2tsbV1xv2S3d5G0=";
revert = true;
})
# Fix for https://github.com/NixOS/nixpkgs/issues/355919
# FIXME: remove after a minor point release
(fetchpatch2 {
url = "https://github.com/nodejs/node/commit/a094a8166cd772f89e92b5deef168e5e599fa815.patch?full_index=1";
hash = "sha256-5FZfozYWRa1ZI/f+e+xpdn974Jg2DbiHbua13XUQP5E=";
})
(fetchpatch2 {
url = "https://github.com/nodejs/node/commit/f270462c09ddfd770291a7c8a2cd204b2c63d730.patch?full_index=1";
hash = "sha256-Err0i5g7WtXcnhykKgrS3ocX7/3oV9UrT0SNeRtMZNU=";
url = "https://github.com/nodejs/node/commit/49acdc8748fe9fe83bc1b444e24c456dff00ecc5.patch?full_index=1";
hash = "sha256-iK7bj4KswTeQ9I3jJ22ZPTsvCU8xeGGXEOo43dxg3Mk=";
})
];
}

0 comments on commit ea2f362

Please sign in to comment.