mirror of
https://github.com/status-im/status-react.git
synced 2025-01-24 09:49:51 +00:00
0f15c0192d
Revisions from develop: - 59ceddbaa develop origin/develop fix(wallet): fix bridge transactions (#20902) - 99ccbc338 Cover wallet send events with tests Part 2 #20411 #20533 (#20721) - 8c2d5398b Enabling WalletConnect feature flag (#20906) - 67c83b13e fix(wallet): remove edit routes button in bridging (#20874) - 11a84ba14 feat(wallet): disable complex routing (#20901) - 1f5bb579c chore(wallet): disable bridging on unsupported tokens (#20846) - 4586f8007 Add toggle in advanced settings for mobile data - 55c620e59 fix: create password for small screen (#20645) - 525609f0a Wallet Activity: transactions are not sorted by time #20808 (#20862) - 90653955a chore(settings): Disable telemetry option (#20881) - d27ab756d fix_:display group message using the new ui (#20787) - c6a1db633 ci: enable split apks & build only for arm64-v8a (#20683) - 73777e052 Ensure keycard account can send transaction after upgrading from v1 to v2 #20552 (#20845) - a6d3fc374 [#20524] fix: the missed keypairs are shown in the key pair list screen (#20888) - a671c7083 fix broken screen and navigation when syncing fails (#20887) - a45991b6d 🥅 Filter connected dapps based on testnet mode, reject proposals and requests gracefully (#20799) - 2e9fa22e4 feat: wallet router v2 (#20631) - 737d8c4d5 rename sub to fix error when requesting to join community (#20868) - 3aa7e103f Sync process is blocked on Enabled notifications screen (#20883) - c1d2d44da perf: Fix app freeze after login (#20729) - 0fed8113d e2e: updated testnet switching and added one test into smoke - 53c35cb55 fix(wallet): Linear gradient exception on invalid colors for watched account cards (#20854) - be8236554 chore(settings)_: Remove testnet toggle from legacy advanced settings (#20875) - eae8a6559 feat(wallet)_: Add beta info box in activity tab (#20873) - fe54a25a3 fix: not clearing network & web3-wallet on logout (#20886) - 15a4219ef Reject wallet-connect request by dragging the modal down (#20763) (#20836) - 2ffbdac89 WalletConnect show expired toast (#20857) - 402eb8397 fix Issue with scrolling WalletConnect transaction on Android (#20867) - ff88049a0 Fix WalletConnect header alignment on Android (#20860) - cee21241d WalletConnect no internet edge-cases (#20826) - 60ad7c8a2 chore(tests): New match-strict? cljs.test directive (#20825) - 4989c9278 fix_: Adding own address as saved addresses (#20839)
191 lines
6.2 KiB
Nix
191 lines
6.2 KiB
Nix
{ stdenv, pkgs, deps, lib
|
|
, androidPkgs, patchMavenSources, jsbundle, status-go }:
|
|
|
|
{
|
|
# Value for BUILD_ENV checked by Clojure code at compile time
|
|
buildEnv ? "prod",
|
|
# Path to the file containing secret environment variables
|
|
secretsFile ? "",
|
|
# Build type (influences which .env file gets used for feature flags)
|
|
buildType ? lib.getEnvWithDefault "BUILD_TYPE" "release",
|
|
# Used for versionCode
|
|
versionCode ? lib.getEnvWithDefault "ORG_GRADLE_PROJECT_versionCode" 9999,
|
|
# Included in APK Manifest for easier identification.
|
|
commitHash ? lib.getEnvWithDefault "ORG_GRADLE_PROJECT_commitHash" "unknown",
|
|
# Disabled for debug builds to avoid 'maximum call stack exceeded' errors.
|
|
# https://github.com/status-im/status-mobile/issues/18493
|
|
hermesEnabled ? lib.getEnvWithDefault "ORG_GRADLE_PROJECT_hermesEnabled" "true",
|
|
buildUrl ? lib.getEnvWithDefault "ORG_GRADLE_PROJECT_buildUrl" null,
|
|
statusGoSrcOverride ? lib.getEnvWithDefault "STATUS_GO_SRC_OVERRIDE" null,
|
|
# If APKs should be split based on architectures
|
|
androidAbiSplit ? lib.getEnvWithDefault "ANDROID_ABI_SPLIT" "true",
|
|
# Android architectures to build for
|
|
# Used to detect end-to-end builds
|
|
androidAbiInclude ? lib.getEnvWithDefault "ANDROID_ABI_INCLUDE" "arm64-v8a",
|
|
}:
|
|
|
|
let
|
|
inherit (lib) toLower optionalString stringLength makeLibraryPath elem;
|
|
notDebug = (buildType != "debug");
|
|
|
|
# Pass secretsFile for POKT_TOKEN to jsbundle build
|
|
builtJsBundle = lib.optionals notDebug jsbundle { inherit secretsFile; };
|
|
|
|
# Map ANDROID_ABI_INCLUDE to status-go targets
|
|
androidAbiIncludeSplit = lib.splitString ";" androidAbiInclude;
|
|
|
|
|
|
envFileName =
|
|
if (elem androidAbiInclude ["x86" "x86_64" "x86;x86_64"]) then ".env.e2e"
|
|
else if (elem buildType ["release" "nightly"]) then ".env.${buildType}"
|
|
else if (elem buildType ["pr" "manual"]) then ".env.jenkins"
|
|
else ".env";
|
|
|
|
gradleBuildType =
|
|
if buildType == "pr" then "Pr"
|
|
else if buildType == "debug" then "Debug"
|
|
else "Release";
|
|
|
|
apksPath = "./android/app/build/outputs/apk/${toLower gradleBuildType}";
|
|
|
|
baseName = "${buildType}-android";
|
|
in stdenv.mkDerivation rec {
|
|
name = "status-mobile-build-${baseName}";
|
|
|
|
src = let path = ./../../..;
|
|
# We use builtins.path so that we can name the resulting derivation
|
|
in builtins.path {
|
|
inherit path;
|
|
name = "status-mobile-source-${baseName}";
|
|
# Keep this filter as restrictive as possible in order to avoid unnecessary rebuilds and limit closure size
|
|
filter = lib.mkFilter {
|
|
root = path;
|
|
include = [
|
|
"package.json" "yarn.lock" "metro.config.js" "babel.config.js"
|
|
"resources/.*" "translations/.*" "src/js/.*" "index.js"
|
|
"modules/react-native-status/android.*" "android/.*"
|
|
envFileName "VERSION" "status-go-version.json" "react-native.config.js"
|
|
];
|
|
};
|
|
};
|
|
|
|
buildInputs = with pkgs; [ nodejs openjdk ];
|
|
nativeBuildInputs = with pkgs; [ bash gradle unzip ]
|
|
++ lib.optionals stdenv.isDarwin [ file gnumake ];
|
|
|
|
# Disable metro watching for file changes. (#13783)
|
|
CI = true;
|
|
|
|
# Used by Clojure at compile time to include JS modules
|
|
BUILD_ENV = buildEnv;
|
|
|
|
STATUS_GO_SRC_OVERRIDE = statusGoSrcOverride;
|
|
ANDROID_ABI_SPLIT = androidAbiSplit;
|
|
ANDROID_ABI_INCLUDE = androidAbiInclude;
|
|
# Disabled for debug builds to avoid 'maximum call stack exceeded' errors.
|
|
# https://github.com/status-im/status-mobile/issues/18493
|
|
ORG_GRADLE_PROJECT_versionCode = versionCode;
|
|
ORG_GRADLE_PROJECT_commitHash = commitHash;
|
|
ORG_GRADLE_PROJECT_buildUrl = buildUrl;
|
|
ORG_GRADLE_PROJECT_hermesEnabled = hermesEnabled;
|
|
|
|
# Fix for ERR_OSSL_EVP_UNSUPPORTED error.
|
|
NODE_OPTIONS = "--openssl-legacy-provider";
|
|
|
|
phases = [
|
|
"shellHook" "unpackPhase" "secretsPhase" "buildPhase" "checkPhase" "installPhase"
|
|
];
|
|
|
|
# We use shellHook as a single place to setup env vars for both build derivation and shell
|
|
shellHook = ''
|
|
# Used by the Android Gradle build script in android/build.gradle
|
|
export STATUS_GO_ANDROID_LIBDIR=${ status-go { abis = androidAbiIncludeSplit; } }
|
|
|
|
# Android SDK/NDK for use by Gradle
|
|
export ANDROID_SDK_ROOT="${androidPkgs.sdk}"
|
|
export ANDROID_NDK_ROOT="${androidPkgs.ndk}"
|
|
|
|
export STATUS_NIX_MAVEN_REPO="${deps.gradle}"
|
|
'';
|
|
|
|
unpackPhase = ''
|
|
cp -ar $src/. ./
|
|
chmod u+w -R ./
|
|
runHook postUnpack
|
|
'';
|
|
postUnpack = ''
|
|
# Ensure we have the right .env file
|
|
cp -bf ./${envFileName} ./.env
|
|
|
|
# Export all vars from .env file
|
|
export $(cut -d= -f1 .env)
|
|
|
|
${lib.optionalString notDebug ''
|
|
# Symlink React Native entrypoint.
|
|
cp -Lr ${builtJsBundle} ./result
|
|
''}
|
|
|
|
# Copy android/ directory
|
|
mkdir -p ./android/build
|
|
chmod -R +w ./android
|
|
|
|
# Copy node_modules/ directory. The -L is CRUCIAL!
|
|
# Otherwise Metro failes to find modules due to symlinks.
|
|
cp -aL ${deps.nodejs-patched}/node_modules/ ./
|
|
chmod +w -R ./node_modules
|
|
|
|
# Patch build.gradle to use local repo
|
|
${patchMavenSources} ./android/build.gradle
|
|
'';
|
|
|
|
# Secrets file is passed to sandbox using extra-sandbox-paths.
|
|
secretsPhase = if (secretsFile != "") then ''
|
|
source "${secretsFile}"
|
|
'' else ''
|
|
echo 'WARNING: No secrets provided!' >&2
|
|
'';
|
|
|
|
buildPhase = let
|
|
adhocEnvVars = optionalString stdenv.isLinux
|
|
"LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${makeLibraryPath [ pkgs.zlib ]}";
|
|
gradleCommand = ''
|
|
${pkgs.gradle}/bin/gradle \
|
|
--console=plain \
|
|
--offline \
|
|
--no-daemon \
|
|
--no-scan \
|
|
--no-watch-fs \
|
|
--no-build-cache \
|
|
--parallel \
|
|
-Dmaven.repo.local='${deps.gradle}' \
|
|
assemble${gradleBuildType}
|
|
'';
|
|
in
|
|
assert ANDROID_ABI_SPLIT != null && ANDROID_ABI_SPLIT != "";
|
|
assert stringLength ANDROID_ABI_INCLUDE > 0;
|
|
''
|
|
# Fixes issue with failing to load libnative-platform.so
|
|
export GRADLE_USER_HOME=$(mktemp -d)
|
|
export ANDROID_SDK_HOME=$(mktemp -d)
|
|
|
|
echo "Adhoc ENV: ${adhocEnvVars}"
|
|
echo "Running: ${gradleCommand}"
|
|
|
|
pushd ./android
|
|
${adhocEnvVars} ${gradleCommand}
|
|
popd > /dev/null
|
|
'';
|
|
|
|
doCheck = buildType != "debug";
|
|
checkPhase = ''
|
|
ls ${apksPath}/*.apk \
|
|
| xargs -n1 ${pkgs.unzip}/bin/unzip -qql \
|
|
| grep 'index.android.bundle'
|
|
'';
|
|
|
|
installPhase = ''
|
|
mkdir -p $out
|
|
cp ${apksPath}/*.apk $out/
|
|
'';
|
|
}
|