diff --git a/pkgs/development/web/nodejs/bypass-darwin-xcrun-node16.patch b/pkgs/development/web/nodejs/bypass-darwin-xcrun-node16.patch deleted file mode 100644 index ba998c0510be..000000000000 --- a/pkgs/development/web/nodejs/bypass-darwin-xcrun-node16.patch +++ /dev/null @@ -1,76 +0,0 @@ -Avoids needing xcrun or xcodebuild in PATH for native package builds - ---- a/tools/gyp/pylib/gyp/xcode_emulation.py -+++ b/tools/gyp/pylib/gyp/xcode_emulation.py -@@ -522,7 +522,13 @@ class XcodeSettings: - # Since the CLT has no SDK paths anyway, returning None is the - # most sensible route and should still do the right thing. - try: -- return GetStdoutQuiet(["xcrun", "--sdk", sdk, infoitem]) -+ #return GetStdoutQuiet(["xcrun", "--sdk", sdk, infoitem]) -+ return { -+ "--show-sdk-platform-path": "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform", -+ "--show-sdk-path": "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk", -+ "--show-sdk-build-version": "19A547", -+ "--show-sdk-version": "10.15" -+ }[infoitem] - except GypError: - pass - -@@ -1499,7 +1505,8 @@ def XcodeVersion(): - version = "" - build = "" - try: -- version_list = GetStdoutQuiet(["xcodebuild", "-version"]).splitlines() -+ #version_list = GetStdoutQuiet(["xcodebuild", "-version"]).splitlines() -+ version_list = [] - # In some circumstances xcodebuild exits 0 but doesn't return - # the right results; for example, a user on 10.7 or 10.8 with - # a bogus path set via xcode-select -@@ -1510,7 +1517,8 @@ def XcodeVersion(): - version = version_list[0].split()[-1] # Last word on first line - build = version_list[-1].split()[-1] # Last word on last line - except GypError: # Xcode not installed so look for XCode Command Line Tools -- version = CLTVersion() # macOS Catalina returns 11.0.0.0.1.1567737322 -+ #version = CLTVersion() # macOS Catalina returns 11.0.0.0.1.1567737322 -+ version = "11.0.0.0.1.1567737322" - if not version: - raise GypError("No Xcode or CLT version detected!") - # Be careful to convert "4.2.3" to "0423" and "11.0.0" to "1100": ---- a/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py -+++ b/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py -@@ -522,7 +522,13 @@ class XcodeSettings: - # Since the CLT has no SDK paths anyway, returning None is the - # most sensible route and should still do the right thing. - try: -- return GetStdoutQuiet(["xcrun", "--sdk", sdk, infoitem]) -+ #return GetStdoutQuiet(["xcrun", "--sdk", sdk, infoitem]) -+ return { -+ "--show-sdk-platform-path": "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform", -+ "--show-sdk-path": "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk", -+ "--show-sdk-build-version": "19A547", -+ "--show-sdk-version": "10.15" -+ }[infoitem] - except GypError: - pass - -@@ -1499,7 +1505,8 @@ def XcodeVersion(): - version = "" - build = "" - try: -- version_list = GetStdoutQuiet(["xcodebuild", "-version"]).splitlines() -+ #version_list = GetStdoutQuiet(["xcodebuild", "-version"]).splitlines() -+ version_list = [] - # In some circumstances xcodebuild exits 0 but doesn't return - # the right results; for example, a user on 10.7 or 10.8 with - # a bogus path set via xcode-select -@@ -1510,7 +1517,8 @@ def XcodeVersion(): - version = version_list[0].split()[-1] # Last word on first line - build = version_list[-1].split()[-1] # Last word on last line - except GypError: # Xcode not installed so look for XCode Command Line Tools -- version = CLTVersion() # macOS Catalina returns 11.0.0.0.1.1567737322 -+ #version = CLTVersion() # macOS Catalina returns 11.0.0.0.1.1567737322 -+ version = "11.0.0.0.1.1567737322" - if not version: - raise GypError("No Xcode or CLT version detected!") - # Be careful to convert "4.2.3" to "0423" and "11.0.0" to "1100": diff --git a/pkgs/development/web/nodejs/gyp-patches-set-fallback-value-for-CLT.patch b/pkgs/development/web/nodejs/gyp-patches-set-fallback-value-for-CLT.patch new file mode 100644 index 000000000000..cf094fdacc46 --- /dev/null +++ b/pkgs/development/web/nodejs/gyp-patches-set-fallback-value-for-CLT.patch @@ -0,0 +1,25 @@ +Sandboxed builds need a fallback value for the version of the Command Line Tools +being used. + +--- a/tools/gyp/pylib/gyp/xcode_emulation.py ++++ b/tools/gyp/pylib/gyp/xcode_emulation.py +@@ -1552,7 +1552,7 @@ def CLTVersion(): + output = GetStdout(["/usr/sbin/softwareupdate", "--history"]) + return re.search(regex, output).groupdict()["version"] + except (GypError, OSError): +- return None ++ return "11.0.0.0.1.1567737322" + + + def GetStdoutQuiet(cmdlist): +--- a/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py ++++ b/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py +@@ -1552,7 +1552,7 @@ def CLTVersion(): + output = GetStdout(["/usr/sbin/softwareupdate", "--history"]) + return re.search(regex, output).groupdict()["version"] + except (GypError, OSError): +- return None ++ return "11.0.0.0.1.1567737322" + + + def GetStdoutQuiet(cmdlist): diff --git a/pkgs/development/web/nodejs/gyp-patches.nix b/pkgs/development/web/nodejs/gyp-patches.nix index 9b8f98f0630f..b1d074df437f 100644 --- a/pkgs/development/web/nodejs/gyp-patches.nix +++ b/pkgs/development/web/nodejs/gyp-patches.nix @@ -5,15 +5,13 @@ patch_tools ? true, }: let - url = "https://github.com/nodejs/gyp-next/commit/706d04aba5bd18f311dc56f84720e99f64c73466.patch?full_index=1"; + url = "https://github.com/nodejs/gyp-next/commit/8224deef984add7e7afe846cfb82c9d3fa6da1fb.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 url; - hash = "sha256-iV9qvj0meZkgRzFNur2v1jtLZahbqvSJ237NoM8pPZc="; + hash = "sha256-kvCMpedjrY64BlaC1R0NVjk/vIVivYAGVgWwMEGeP6k="; stripLen = 1; extraPrefix = "tools/gyp/"; }) @@ -21,7 +19,7 @@ lib.optionals patch_tools ([ ++ lib.optionals patch_npm ([ (fetchpatch2 { inherit url; - hash = "sha256-1iyeeAprmWpmLafvOOXW45iZ4jWFSloWJxQ0reAKBOo="; + hash = "sha256-cXTwmCRHrNhuY1+3cD/EvU0CJ+1Nk4TRh6c3twvfaW8="; stripLen = 1; extraPrefix = "deps/npm/node_modules/node-gyp/gyp/"; }) diff --git a/pkgs/development/web/nodejs/v20.nix b/pkgs/development/web/nodejs/v20.nix index a00dccfaf968..90fe7f8b112a 100644 --- a/pkgs/development/web/nodejs/v20.nix +++ b/pkgs/development/web/nodejs/v20.nix @@ -13,7 +13,24 @@ let }; gypPatches = callPackage ./gyp-patches.nix { } ++ [ + # 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 { + url = "https://github.com/nodejs/gyp-next/commit/706d04aba5bd18f311dc56f84720e99f64c73466.patch?full_index=1"; + hash = "sha256-iV9qvj0meZkgRzFNur2v1jtLZahbqvSJ237NoM8pPZc="; + stripLen = 1; + extraPrefix = "tools/gyp/"; + }) + (fetchpatch2 { + 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/"; + }) + ./gyp-patches-pre-v22-import-sys.patch + ./gyp-patches-set-fallback-value-for-CLT.patch ]; in buildNodejs { @@ -24,7 +41,6 @@ buildNodejs { ./configure-emulator.patch ./configure-armv6-vfpv2.patch ./disable-darwin-v8-system-instrumentation-node19.patch - ./bypass-darwin-xcrun-node16.patch ./node-npm-build-npm-package-logic.patch ./use-correct-env-in-tests.patch diff --git a/pkgs/development/web/nodejs/v22.nix b/pkgs/development/web/nodejs/v22.nix index 47cb3f1702dd..21c70e049faa 100644 --- a/pkgs/development/web/nodejs/v22.nix +++ b/pkgs/development/web/nodejs/v22.nix @@ -14,6 +14,15 @@ let inherit openssl; python = python3; }; + + gypPatches = + if stdenv.buildPlatform.isDarwin then + callPackage ./gyp-patches.nix { } + ++ [ + ./gyp-patches-set-fallback-value-for-CLT.patch + ] + else + [ ]; in buildNodejs { inherit enableNpm; @@ -44,10 +53,10 @@ buildNodejs { hash = "sha256-hSTLljmVzYmc3WAVeRq9EPYluXGXFeWVXkykufGQPVw="; }) ] + ++ gypPatches ++ [ ./configure-armv6-vfpv2.patch ./disable-darwin-v8-system-instrumentation-node19.patch - ./bypass-darwin-xcrun-node16.patch ./node-npm-build-npm-package-logic.patch ./use-correct-env-in-tests.patch ./bin-sh-node-run-v22.patch diff --git a/pkgs/development/web/nodejs/v24.nix b/pkgs/development/web/nodejs/v24.nix index 3e4a128d368b..99ba1a30a308 100644 --- a/pkgs/development/web/nodejs/v24.nix +++ b/pkgs/development/web/nodejs/v24.nix @@ -14,6 +14,15 @@ let inherit openssl; python = python3; }; + + gypPatches = + if stdenv.buildPlatform.isDarwin then + callPackage ./gyp-patches.nix { patch_tools = false; } + ++ [ + ./gyp-patches-set-fallback-value-for-CLT.patch + ] + else + [ ]; in buildNodejs { inherit enableNpm; @@ -50,16 +59,8 @@ buildNodejs { ./node-npm-build-npm-package-logic.patch ./use-correct-env-in-tests.patch ./bin-sh-node-run-v22.patch - - # TODO: newer GYP versions have been patched to be more compatible with Nix sandbox. We need - # to adapt our patch to this newer version, see https://github.com/NixOS/nixpkgs/pull/434742. - (fetchpatch2 { - url = "https://github.com/nodejs/node/commit/886e4b3b534a9f3ad2facbc99097419e06615900.patch?full_index=1"; - hash = "sha256-HFTabl92NPkBwXD0mUGDN+Gzabyi+Ph0kL0FEHHknbk="; - revert = true; - }) - ./bypass-darwin-xcrun-node16.patch ] + ++ gypPatches ++ lib.optionals (!stdenv.buildPlatform.isDarwin) [ # test-icu-env is failing without the reverts (fetchpatch2 {