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 =
19 if stdenv.buildPlatform.isDarwin then
20 callPackage ./gyp-patches.nix { patch_tools_catch_oserror = false; }
21 ++ [
22 ./gyp-patches-set-fallback-value-for-CLT.patch
23 ]
24 else
25 [ ];
26in
27buildNodejs {
28 inherit enableNpm;
29 version = "24.9.0";
30 sha256 = "f17bc4cb01f59098c34a288c1bb109a778867c14eeb0ebbd608d0617b1193bbf";
31 patches =
32 (
33 if (stdenv.hostPlatform.emulatorAvailable buildPackages) then
34 [
35 ./configure-emulator.patch
36 ]
37 else
38 [
39 (fetchpatch2 {
40 url = "https://raw.githubusercontent.com/buildroot/buildroot/2f0c31bffdb59fb224387e35134a6d5e09a81d57/package/nodejs/nodejs-src/0003-include-obj-name-in-shared-intermediate.patch";
41 hash = "sha256-3g4aS+NmmUYNOYRNc6UMJKYoaTlpP5Knt9UHegx+o0Y=";
42 })
43 ]
44 )
45 ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform && stdenv.hostPlatform.isFreeBSD) [
46 # This patch is concerning.
47 # https://github.com/nodejs/node/issues/54576
48 # It is only supposed to affect clang >= 17, but I'm seeing it on clang 19.
49 # I'm keeping the predicate for this patch pretty strict out of caution,
50 # so if you see the error it's supposed to prevent, feel free to loosen it.
51 (fetchpatch2 {
52 url = "https://raw.githubusercontent.com/rubyjs/libv8-node/62476a398d4c9c1a670240a3b070d69544be3761/patch/v8-no-assert-trivially-copyable.patch";
53 hash = "sha256-hSTLljmVzYmc3WAVeRq9EPYluXGXFeWVXkykufGQPVw=";
54 })
55 ]
56 ++ [
57 ./configure-armv6-vfpv2.patch
58 ./node-npm-build-npm-package-logic.patch
59 ./use-correct-env-in-tests.patch
60 ./bin-sh-node-run-v22.patch
61 ./use-nix-codesign.patch
62 ]
63 ++ gypPatches
64 ++ lib.optionals (!stdenv.buildPlatform.isDarwin) [
65 # test-icu-env is failing without the reverts
66 (fetchpatch2 {
67 url = "https://github.com/nodejs/node/commit/869d0cbca3b0b5e594b3254869a34d549664e089.patch?full_index=1";
68 hash = "sha256-BBBShQwU20TSY8GtPehQ9i3AH4ZKUGIr8O0bRsgrpNo=";
69 revert = true;
70 })
71 ];
72}