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 { }
21 ++ [
22 ./gyp-patches-set-fallback-value-for-CLT.patch
23 ]
24 else
25 [ ];
26in
27buildNodejs {
28 inherit enableNpm;
29 version = "22.19.0";
30 sha256 = "0272acfce50ce9ad060288321b1092719a7f19966f81419835410c59c09daa46";
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 ++ gypPatches
57 ++ [
58 ./configure-armv6-vfpv2.patch
59 ./node-npm-build-npm-package-logic.patch
60 ./use-correct-env-in-tests.patch
61 ./bin-sh-node-run-v22.patch
62 ./use-nix-codesign.patch
63
64 # TODO: remove when included in a release
65 (fetchpatch2 {
66 url = "https://github.com/nodejs/node/commit/499a5c345165f0d4a94b98d08f1ace7268781564.patch?full_index=1";
67 hash = "sha256-wF4+CytC1OB5egJGOfLm1USsYY12f9kADymVrxotezE=";
68 })
69 ];
70}