diff --git a/pkgs/development/web/nodejs/gyp-patches.nix b/pkgs/development/web/nodejs/gyp-patches.nix index 67a2a2a128440..9b8f98f0630fb 100644 --- a/pkgs/development/web/nodejs/gyp-patches.nix +++ b/pkgs/development/web/nodejs/gyp-patches.nix @@ -1,22 +1,28 @@ -{ fetchpatch2 }: +{ + lib, + fetchpatch2, + patch_npm ? true, + patch_tools ? true, +}: let - name = "gyp-darwin-sandbox.patch"; - url = "https://github.com/nodejs/gyp-next/commit/706d04aba5bd18f311dc56f84720e99f64c73466.patch"; + url = "https://github.com/nodejs/gyp-next/commit/706d04aba5bd18f311dc56f84720e99f64c73466.patch?full_index=1"; in -[ +lib.optionals patch_tools ([ # Fixes builds with Nix sandbox on Darwin for gyp. # See https://github.com/NixOS/nixpkgs/issues/261820 # and https://github.com/nodejs/gyp-next/pull/216 (fetchpatch2 { - inherit name url; - hash = "sha256-l8FzgLq9CbVJCkXfnTyDQ+vXKCz65wpaffE74oSU+kY="; + inherit url; + hash = "sha256-iV9qvj0meZkgRzFNur2v1jtLZahbqvSJ237NoM8pPZc="; stripLen = 1; extraPrefix = "tools/gyp/"; }) +]) +++ lib.optionals patch_npm ([ (fetchpatch2 { - inherit name url; - hash = "sha256-UVUn4onXfJgFoAdApLAbliiBgM9rxDdIo53WjFryoBI="; + inherit url; + hash = "sha256-1iyeeAprmWpmLafvOOXW45iZ4jWFSloWJxQ0reAKBOo="; stripLen = 1; extraPrefix = "deps/npm/node_modules/node-gyp/gyp/"; }) -] +]) diff --git a/pkgs/development/web/nodejs/v22.nix b/pkgs/development/web/nodejs/v22.nix index f850d04d575d5..5a23b348221ff 100644 --- a/pkgs/development/web/nodejs/v22.nix +++ b/pkgs/development/web/nodejs/v22.nix @@ -14,6 +14,10 @@ let inherit openssl; python = python3; }; + + gypPatches = callPackage ./gyp-patches.nix { + patch_tools = false; + }; in buildNodejs { inherit enableNpm; @@ -44,6 +48,7 @@ buildNodejs { hash = "sha256-hSTLljmVzYmc3WAVeRq9EPYluXGXFeWVXkykufGQPVw="; }) ] + ++ gypPatches ++ [ ./configure-armv6-vfpv2.patch ./disable-darwin-v8-system-instrumentation-node19.patch @@ -58,15 +63,5 @@ buildNodejs { hash = "sha256-k3h8mPgvaIYGAkGmaL+ix7kUnyLw4/PF7wXMAWrPMXo="; revert = true; }) - # Fixes builds with Nix sandbox on Darwin for gyp. - # See https://github.com/NixOS/nixpkgs/issues/261820 - # and https://github.com/nodejs/gyp-next/pull/216 - (fetchpatch2 { - name = "gyp-darwin-sandbox.patch"; - url = "https://github.com/nodejs/gyp-next/commit/706d04aba5bd18f311dc56f84720e99f64c73466.patch?full_index=1"; - hash = "sha256-1iyeeAprmWpmLafvOOXW45iZ4jWFSloWJxQ0reAKBOo="; - stripLen = 1; - extraPrefix = "deps/npm/node_modules/node-gyp/gyp/"; - }) ]; }