nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
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 = false; }
21 else
22 [ ];
23in
24buildNodejs {
25 inherit enableNpm;
26 version = "22.22.0";
27 sha256 = "4c138012bb5352f49822a8f3e6d1db71e00639d0c36d5b6756f91e4c6f30b683";
28 patches =
29 (
30 if (stdenv.hostPlatform.emulatorAvailable buildPackages) then
31 [
32 ./configure-emulator.patch
33 ]
34 else
35 [
36 (fetchpatch2 {
37 url = "https://raw.githubusercontent.com/buildroot/buildroot/2f0c31bffdb59fb224387e35134a6d5e09a81d57/package/nodejs/nodejs-src/0003-include-obj-name-in-shared-intermediate.patch";
38 hash = "sha256-3g4aS+NmmUYNOYRNc6UMJKYoaTlpP5Knt9UHegx+o0Y=";
39 })
40 ]
41 )
42 ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform && stdenv.hostPlatform.isFreeBSD) [
43 # This patch is concerning.
44 # https://github.com/nodejs/node/issues/54576
45 # It is only supposed to affect clang >= 17, but I'm seeing it on clang 19.
46 # I'm keeping the predicate for this patch pretty strict out of caution,
47 # so if you see the error it's supposed to prevent, feel free to loosen it.
48 (fetchpatch2 {
49 url = "https://raw.githubusercontent.com/rubyjs/libv8-node/62476a398d4c9c1a670240a3b070d69544be3761/patch/v8-no-assert-trivially-copyable.patch";
50 hash = "sha256-hSTLljmVzYmc3WAVeRq9EPYluXGXFeWVXkykufGQPVw=";
51 })
52 ]
53 ++ gypPatches
54 ++ [
55 ./configure-armv6-vfpv2.patch
56 ./node-npm-build-npm-package-logic.patch
57 ./use-correct-env-in-tests.patch
58 ./bin-sh-node-run-v22.patch
59 ./use-nix-codesign.patch
60 ]
61 ++ lib.optionals (!stdenv.hostPlatform.isStatic) [
62 # Fix builds with shared llhttp
63 (fetchpatch2 {
64 url = "https://github.com/nodejs/node/commit/ff3a028f8bf88da70dc79e1d7b7947a8d5a8548a.patch?full_index=1";
65 hash = "sha256-LJcO3RXVPnpbeuD87fiJ260m3BQXNk3+vvZkBMFUz5w=";
66 })
67 # update tests for nghttp2 1.65
68 ./deprecate-http2-priority-signaling.patch
69 (fetchpatch2 {
70 url = "https://github.com/nodejs/node/commit/a63126409ad4334dd5d838c39806f38c020748b9.diff?full_index=1";
71 hash = "sha256-lfq8PMNvrfJjlp0oE3rJkIsihln/Gcs1T/qgI3wW2kQ=";
72 includes = [ "test/*" ];
73 })
74 ];
75}