ios: fix xcode using system Node.js version

As discovered in:
https://github.com/status-im/status-mobile/pull/15225

The attempt to fix this in:
https://github.com/status-im/status-mobile/pull/15180

But it doesn't appear to work, so instead I'm allowing an override of
`NODE_BINARY` variable and spetting it when defining the Nix shell.

The key things here are:

* Xcode injects its own paths into `PATH` which breaks Nix env.
* Combining Nix shells with `inputsFrom` does not inherit all vars.

It's important to set these variables in `shellHook` and not elsewhere.

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2023-03-01 17:27:43 +01:00
parent 4dfd3af7f5
commit 4fe8b81bf6
No known key found for this signature in database
GPG Key ID: FE65CD384D5BF7B4
3 changed files with 11 additions and 7 deletions

View File

@ -526,7 +526,7 @@
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
shellPath = "/usr/bin/env sh"; shellPath = "/usr/bin/env sh";
shellScript = "set -o errexit\nexport NODE_BINARY=\"node\"\nexport NODE_ARGS=\" --openssl-legacy-provider --max-old-space-size=16384 \"\n\nbash -x ../node_modules/react-native/scripts/react-native-xcode.sh > ./react-native-xcode.log 2>&1"; shellScript = "set -o errexit\nexport NODE_BINARY=\"${NODE_BINARY:-node}\"\nexport NODE_ARGS=\" --openssl-legacy-provider --max-old-space-size=16384 \"\n\nbash -x ../node_modules/react-native/scripts/react-native-xcode.sh > ./react-native-xcode.log 2>&1";
}; };
0F876BD5356F61BF142A01A0 /* [CP] Check Pods Manifest.lock */ = { 0F876BD5356F61BF142A01A0 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
@ -584,7 +584,7 @@
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
shellPath = "/usr/bin/env sh"; shellPath = "/usr/bin/env sh";
shellScript = "set -o errexit\nexport NODE_BINARY=\"node\"\nexport NODE_ARGS=\" --openssl-legacy-provider --max-old-space-size=16384 \"\n\nbash -x ../node_modules/react-native/scripts/react-native-xcode.sh > ./react-native-xcode.log 2>&1"; shellScript = "set -o errexit\nexport NODE_BINARY=\"${NODE_BINARY:-node}\"\nexport NODE_ARGS=\" --openssl-legacy-provider --max-old-space-size=16384 \"\n\nbash -x ../node_modules/react-native/scripts/react-native-xcode.sh > ./react-native-xcode.log 2>&1";
}; };
3AAD2AD724A3A60E0075D594 /* Run Script */ = { 3AAD2AD724A3A60E0075D594 /* Run Script */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;

View File

@ -20,6 +20,7 @@ in {
]; ];
# WARNING: Executes shellHook in reverse order. # WARNING: Executes shellHook in reverse order.
# WARNING: Only some variables are merged.
inputsFrom = [ inputsFrom = [
fastlane.shell fastlane.shell
cocoapods-sh cocoapods-sh

View File

@ -1,11 +1,14 @@
{ mkShell, deps }: { mkShell, nodejs, deps }:
mkShell { mkShell {
# Fix for ERR_OSSL_EVP_UNSUPPORTED error. # Check if node modules changed and if so install them.
NODE_OPTIONS = "--openssl-legacy-provider";
# check if node modules changed and if so install them
shellHook = '' shellHook = ''
# Fix for ERR_OSSL_EVP_UNSUPPORTED error.
export NODE_OPTIONS="--openssl-legacy-provider";
# Fix Xcode using system Node.js version.
export NODE_BINARY="${nodejs}/bin/node";
export STATUS_MOBILE_HOME=$(git rev-parse --show-toplevel) export STATUS_MOBILE_HOME=$(git rev-parse --show-toplevel)
"$STATUS_MOBILE_HOME/nix/scripts/node_modules.sh" ${deps.nodejs-patched} "$STATUS_MOBILE_HOME/nix/scripts/node_modules.sh" ${deps.nodejs-patched}
''; '';