From 21f34620be8a6e4746cdb48749854f0b2d623713 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Tue, 2 Sep 2025 08:12:14 +0200 Subject: [PATCH] nodejs: patch away absolute paths from GYP script --- ...es-set-fallback-value-for-CLT-darwin.patch | 63 +++++++++++++++++++ pkgs/development/web/nodejs/gyp-patches.nix | 4 ++ 2 files changed, 67 insertions(+) create mode 100644 pkgs/development/web/nodejs/gyp-patches-set-fallback-value-for-CLT-darwin.patch diff --git a/pkgs/development/web/nodejs/gyp-patches-set-fallback-value-for-CLT-darwin.patch b/pkgs/development/web/nodejs/gyp-patches-set-fallback-value-for-CLT-darwin.patch new file mode 100644 index 000000000000..028214bc2fbf --- /dev/null +++ b/pkgs/development/web/nodejs/gyp-patches-set-fallback-value-for-CLT-darwin.patch @@ -0,0 +1,63 @@ +Sandboxed builds need a fallback value for the version of the Command Line Tools +being used. + +diff --git a/tools/gyp/pylib/gyp/xcode_emulation.py b/tools/gyp/pylib/gyp/xcode_emulation.py +index 508f6ccac3e..44bcd988c4c 100644 +--- a/tools/gyp/pylib/gyp/xcode_emulation.py ++++ b/tools/gyp/pylib/gyp/xcode_emulation.py +@@ -1495,24 +1495,8 @@ def XcodeVersion(): + global XCODE_VERSION_CACHE + if XCODE_VERSION_CACHE: + return XCODE_VERSION_CACHE +- version = "" ++ version = "11.0.0.0.1.1567737322" + build = "" +- try: +- version_list = GetStdoutQuiet(["xcodebuild", "-version"]).splitlines() +- # 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 +- # In that case this may be a CLT-only install so fall back to +- # checking that version. +- if len(version_list) < 2: +- raise GypError("xcodebuild returned unexpected results") +- version = version_list[0].split()[-1] # Last word on first line +- build = version_list[-1].split()[-1] # Last word on last line +- except (GypError, OSError): +- # Xcode not installed so look for XCode Command Line Tools +- version = CLTVersion() # macOS Catalina returns 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": + version = version.split(".")[:3] # Just major, minor, micro + version[0] = version[0].zfill(2) # Add a leading zero if major is one digit + + +--- 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 +@@ -1495,24 +1495,8 @@ def XcodeVersion(): + global XCODE_VERSION_CACHE + if XCODE_VERSION_CACHE: + return XCODE_VERSION_CACHE +- version = "" ++ version = "11.0.0.0.1.1567737322" + build = "" +- try: +- version_list = GetStdoutQuiet(["xcodebuild", "-version"]).splitlines() +- # 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 +- # In that case this may be a CLT-only install so fall back to +- # checking that version. +- if len(version_list) < 2: +- raise GypError("xcodebuild returned unexpected results") +- version = version_list[0].split()[-1] # Last word on first line +- build = version_list[-1].split()[-1] # Last word on last line +- except (GypError, OSError): +- # Xcode not installed so look for XCode Command Line Tools +- version = CLTVersion() # macOS Catalina returns 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": + version = version.split(".")[:3] # Just major, minor, micro + version[0] = version[0].zfill(2) # Add a leading zero if major is one digit diff --git a/pkgs/development/web/nodejs/gyp-patches.nix b/pkgs/development/web/nodejs/gyp-patches.nix index 48b47d19f7dc..d3939887e0fd 100644 --- a/pkgs/development/web/nodejs/gyp-patches.nix +++ b/pkgs/development/web/nodejs/gyp-patches.nix @@ -47,3 +47,7 @@ lib.optionals patch_tools_catch_oserror ([ extraPrefix = "deps/npm/node_modules/node-gyp/gyp/"; }) ]) +# TODO: remove the Darwin conditionals from this file +++ lib.optionals stdenv.buildPlatform.isDarwin ([ + ./gyp-patches-set-fallback-value-for-CLT-darwin.patch +])