1{
2 lib,
3 stdenv,
4 buildPackages,
5 callPackage,
6 fetchpatch2,
7 openssl,
8 python3,
9 enableNpm ? true,
10}:
11
12let
13 buildNodejs = callPackage ./nodejs.nix {
14 inherit openssl;
15 python = python3;
16 };
17
18 gypPatches = callPackage ./gyp-patches.nix {
19 patch_tools = false;
20 };
21in
22buildNodejs {
23 inherit enableNpm;
24 version = "22.17.0";
25 sha256 = "7a3ef2aedb905ea7926e5209157266e2376a5db619d9ac0cba3c967f6f5db4f9";
26 patches =
27 (
28 if (stdenv.hostPlatform.emulatorAvailable buildPackages) then
29 [
30 ./configure-emulator.patch
31 ]
32 else
33 [
34 (fetchpatch2 {
35 url = "https://raw.githubusercontent.com/buildroot/buildroot/2f0c31bffdb59fb224387e35134a6d5e09a81d57/package/nodejs/nodejs-src/0003-include-obj-name-in-shared-intermediate.patch";
36 hash = "sha256-3g4aS+NmmUYNOYRNc6UMJKYoaTlpP5Knt9UHegx+o0Y=";
37 })
38 ]
39 )
40 ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform && stdenv.hostPlatform.isFreeBSD) [
41 # This patch is concerning.
42 # https://github.com/nodejs/node/issues/54576
43 # It is only supposed to affect clang >= 17, but I'm seeing it on clang 19.
44 # I'm keeping the predicate for this patch pretty strict out of caution,
45 # so if you see the error it's supposed to prevent, feel free to loosen it.
46 (fetchpatch2 {
47 url = "https://raw.githubusercontent.com/rubyjs/libv8-node/62476a398d4c9c1a670240a3b070d69544be3761/patch/v8-no-assert-trivially-copyable.patch";
48 hash = "sha256-hSTLljmVzYmc3WAVeRq9EPYluXGXFeWVXkykufGQPVw=";
49 })
50 ]
51 ++ gypPatches
52 ++ [
53 ./configure-armv6-vfpv2.patch
54 ./disable-darwin-v8-system-instrumentation-node19.patch
55 ./bypass-darwin-xcrun-node16.patch
56 ./node-npm-build-npm-package-logic.patch
57 ./use-correct-env-in-tests.patch
58 ./bin-sh-node-run-v22.patch
59
60 # Fix for flaky test
61 # TODO: remove when included in a release
62 (fetchpatch2 {
63 url = "https://github.com/nodejs/node/commit/cd685fe3b6b18d2a1433f2635470513896faebe6.patch?full_index=1";
64 hash = "sha256-KA7WBFnLXCKx+QVDGxFixsbj3Y7uJkAKEUTeLShI1Xo=";
65 })
66 ];
67}