diff --git a/nix/deps/nodejs-patched/default.nix b/nix/deps/nodejs-patched/default.nix index aaf3eb8b950f..6588b61df561 100644 --- a/nix/deps/nodejs-patched/default.nix +++ b/nix/deps/nodejs-patched/default.nix @@ -4,16 +4,16 @@ { stdenv, deps, nodejs, patchMavenSources }: +let + patchesDir = ./../../../patches; + patches = builtins.attrNames (builtins.readDir patchesDir); +in stdenv.mkDerivation { name = "${deps.nodejs.name}-patched"; phases = [ "unpackPhase" "patchGradlePhase" - "patchBuildIdPhase" - "patchKeyChainPhase" - "patchGlogPhase" - "patchNativeNavigationPhase" - "patchRNScriptPhase" + "patchNodeLibsPhase" "installPhase" ]; @@ -50,49 +50,15 @@ stdenv.mkDerivation { done ''; - # Do not add a BuildId to the generated libraries, for reproducibility - patchBuildIdPhase = '' - substituteInPlace ./node_modules/react-native/ReactAndroid/src/main/jni/CMakeLists.txt --replace \ - '-Wl,--build-id' \ - '-Wl,--build-id=none' - ''; - installPhase = '' mkdir -p $out cp -R node_modules $out/ ''; - # Remove gradle-test-logger-plugin: - # https://github.com/oblador/react-native-keychain/issues/595 - # TODO: remove this patch when we this library fixes above issue - patchKeyChainPhase = '' - sed -i -e '/classpath/d' \ - -e '/apply plugin: "com\.adarshr\.test-logger"/d' \ - ./node_modules/react-native-keychain/android/build.gradle - ''; - - # Fix pod issue after upgrading to MacOS Sonoma and Xcode 15 - # https://github.com/status-im/status-mobile/issues/17682 - patchGlogPhase = '' - substituteInPlace ./node_modules/react-native/scripts/ios-configure-glog.sh \ - --replace 'export CC="' '#export CC="' \ - --replace 'export CXX="' '#export CXX="' - ''; - - # https://github.com/wix/react-native-navigation/issues/7819 - patchNativeNavigationPhase = '' - substituteInPlace ./node_modules/react-native-navigation/lib/android/app/build.gradle \ - --replace 'JavaVersion.VERSION_1_8' 'JavaVersion.VERSION_17' - - substituteInPlace ./node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/topbar/button/ButtonPresenter.kt \ - --replace 'host: View?,' 'host: View,' \ - --replace 'info: AccessibilityNodeInfoCompat?' 'info: AccessibilityNodeInfoCompat' - ''; - - # to fix https://github.com/status-im/status-mobile/issues/18548 - patchRNScriptPhase = '' - substituteInPlace ./node_modules/react-native/scripts/react_native_pods_utils/script_phases.sh \ - --replace 'cp -R -X' 'cp -R' + patchNodeLibsPhase = '' + for patch in ${toString patches}; do + patch -p1 < ${patchesDir}/$patch + done ''; # The ELF types are incompatible with the host platform, so let's not even try diff --git a/patches/react-native-android.patch b/patches/react-native-android.patch new file mode 100644 index 000000000000..5818d14d96fb --- /dev/null +++ b/patches/react-native-android.patch @@ -0,0 +1,11 @@ +--- ./node_modules/react-native/ReactAndroid/src/main/jni/CMakeLists.txt 2024-03-29 18:48:40 ++++ ./node_modules/react-native/ReactAndroid/src/main/jni/CMakeLists-patched.txt 2024-03-29 18:51:54 +@@ -21,7 +21,7 @@ + endif(CCACHE_FOUND) + + # Make sure every shared lib includes a .note.gnu.build-id header +-add_link_options(-Wl,--build-id) ++add_link_options(-Wl,--build-id=none) + add_compile_options(-Wall -Werror -std=c++20) + + function(add_react_android_subdir relative_path) diff --git a/patches/react-native-keychain.patch b/patches/react-native-keychain.patch new file mode 100644 index 000000000000..c3ddcd41ae0a --- /dev/null +++ b/patches/react-native-keychain.patch @@ -0,0 +1,20 @@ +# Remove gradle-test-logger-plugin: +# https://github.com/oblador/react-native-keychain/issues/595 +# TODO: remove this patch when we this library fixes above issue + +--- ./node_modules/react-native-keychain/android/build.gradle 2024-03-29 16:45:37 ++++ ./node_modules/react-native-keychain/android/build-patched.gradle 2024-03-29 18:44:12 +@@ -4,13 +4,9 @@ + url 'https://plugins.gradle.org/m2/' + } + } +- dependencies { +- classpath 'com.adarshr:gradle-test-logger-plugin:2.0.0' +- } + } + + apply plugin: 'com.android.library' +-apply plugin: "com.adarshr.test-logger" + + def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback diff --git a/patches/react-native-navigation-button-presenter.patch b/patches/react-native-navigation-button-presenter.patch new file mode 100644 index 000000000000..4827ccb0e571 --- /dev/null +++ b/patches/react-native-navigation-button-presenter.patch @@ -0,0 +1,22 @@ +# https://github.com/wix/react-native-navigation/issues/7819 + +--- ./node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/topbar/button/ButtonPresenter.kt 2024-03-29 15:35:03 ++++ ./node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/topbar/button/ButtonPresenter-patched.kt 2024-03-29 16:05:15 +@@ -194,8 +194,8 @@ + + class WixAccessibilityDelegateCompat: AccessibilityDelegateCompat(){ + override fun onInitializeAccessibilityNodeInfo( +- host: View?, +- info: AccessibilityNodeInfoCompat? ++ host: View, ++ info: AccessibilityNodeInfoCompat + ) { + super.onInitializeAccessibilityNodeInfo(host, info) + +@@ -216,4 +216,4 @@ + } + + +-} +\ No newline at end of file ++} diff --git a/patches/react-native-navigation.patch b/patches/react-native-navigation.patch new file mode 100644 index 000000000000..8b858764f8b6 --- /dev/null +++ b/patches/react-native-navigation.patch @@ -0,0 +1,19 @@ +# https://github.com/wix/react-native-navigation/issues/7819 + +--- ./node_modules/react-native-navigation/lib/android/app/build.gradle 2024-03-29 15:35:04 ++++ ./node_modules/react-native-navigation/lib/android/app/build-patched.gradle 2024-03-29 15:39:48 +@@ -62,11 +62,11 @@ + } + } + compileOptions { +- sourceCompatibility JavaVersion.VERSION_1_8 +- targetCompatibility JavaVersion.VERSION_1_8 ++ sourceCompatibility JavaVersion.VERSION_17 ++ targetCompatibility JavaVersion.VERSION_17 + } + kotlinOptions { +- jvmTarget = JavaVersion.VERSION_1_8 ++ jvmTarget = JavaVersion.VERSION_17 + } + + flavorDimensions "RNN.reactNativeVersion" diff --git a/patches/react-native-script.patch b/patches/react-native-script.patch new file mode 100644 index 000000000000..e0b6dc397fa4 --- /dev/null +++ b/patches/react-native-script.patch @@ -0,0 +1,13 @@ +# to fix https://github.com/status-im/status-mobile/issues/18548 + +--- ./node_modules/react-native/scripts/react_native_pods_utils/script_phases.sh 2024-03-29 17:16:30 ++++ ./node_modules/react-native/scripts/react_native_pods_utils/script_phases-patched.sh 2024-03-29 17:16:46 +@@ -104,7 +104,7 @@ + mkdir -p "$RCT_SCRIPT_OUTPUT_DIR" + + # Copy all output to output_dir +- cp -R -X "$TEMP_OUTPUT_DIR/." "$RCT_SCRIPT_OUTPUT_DIR" || exit 1 ++ cp -R "$TEMP_OUTPUT_DIR/." "$RCT_SCRIPT_OUTPUT_DIR" || exit 1 + echo "$LIBRARY_NAME output has been written to $RCT_SCRIPT_OUTPUT_DIR:" >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1 + ls -1 "$RCT_SCRIPT_OUTPUT_DIR" >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1 + } diff --git a/patches/react-native.patch b/patches/react-native.patch new file mode 100755 index 000000000000..51c90243530d --- /dev/null +++ b/patches/react-native.patch @@ -0,0 +1,15 @@ +# Fix pod issue after upgrading to MacOS Sonoma and Xcode 15 +# https://github.com/status-im/status-mobile/issues/17682 + +--- ./node_modules/react-native/scripts/ios-configure-glog.sh 2024-03-29 14:43:11 ++++ ./node_modules/react-native/scripts/ios-configure-glog-patched.sh 2024-03-29 14:43:11 +@@ -42,9 +42,6 @@ + patch -p1 config.sub fix_glog_0.3.5_apple_silicon.patch + fi + +-export CC="$(xcrun -find -sdk $PLATFORM_NAME cc) -arch $CURRENT_ARCH -isysroot $(xcrun -sdk $PLATFORM_NAME --show-sdk-path)" +-export CXX="$CC" +- + # Remove automake symlink if it exists + if [ -h "test-driver" ]; then + rm test-driver