diff --git a/nix/mobile/android/default.nix b/nix/mobile/android/default.nix index d069737044..69fe75016b 100644 --- a/nix/mobile/android/default.nix +++ b/nix/mobile/android/default.nix @@ -15,19 +15,11 @@ rec { ]; inputsFrom = [ - release + (release {}) androidShell ]; shellHook = '' - export ANDROID_SDK_ROOT="${androidPkgs.sdk}" - export ANDROID_NDK_ROOT="${androidPkgs.ndk}" - - export STATUS_NIX_MAVEN_REPO="${deps.gradle}" - - # required by some makefile targets - export STATUS_GO_ANDROID_LIBDIR=${status-go} - # check if node modules changed and if so install them $STATUS_MOBILE_HOME/nix/scripts/node_modules.sh ${deps.nodejs-patched} ''; diff --git a/nix/mobile/android/release.nix b/nix/mobile/android/release.nix index 53541c5e15..f0b478f155 100644 --- a/nix/mobile/android/release.nix +++ b/nix/mobile/android/release.nix @@ -30,6 +30,9 @@ let # Pass secretsFile for POKT_TOKEN to jsbundle build builtJsBundle = jsbundle { inherit secretsFile; }; + # Map ANDROID_ABI_INCLUDE to status-go targets + androidAbiIncludeSplit = lib.splitString ";" androidAbiInclude; + envFileName = if androidAbiInclude == "x86" then ".env.e2e" @@ -77,20 +80,25 @@ in stdenv.mkDerivation rec { ANDROID_ABI_SPLIT = androidAbiSplit; ANDROID_ABI_INCLUDE = androidAbiInclude; - # Android SDK/NDK for use by Gradle - ANDROID_SDK_ROOT = "${androidPkgs.sdk}"; - ANDROID_NDK_ROOT = "${androidPkgs.ndk}"; - # Fix for ERR_OSSL_EVP_UNSUPPORTED error. NODE_OPTIONS = "--openssl-legacy-provider"; - # Used by the Android Gradle build script in android/build.gradle - STATUS_GO_ANDROID_LIBDIR = status-go; - phases = [ - "unpackPhase" "secretsPhase" "buildPhase" "checkPhase" "installPhase" + "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 ./ diff --git a/nix/shells.nix b/nix/shells.nix index 6d15dc66e4..031ec7da65 100644 --- a/nix/shells.nix +++ b/nix/shells.nix @@ -66,7 +66,7 @@ let # helpers for use with target argument ios = targets.mobile.ios.shell; android = targets.mobile.android.shell; - status-go = targets.status-go.mobile.android; + status-go = targets.status-go.mobile.android {}; }; # for merging the default shell with others diff --git a/nix/status-go/mobile/default.nix b/nix/status-go/mobile/default.nix index 8252d27252..731a373cae 100644 --- a/nix/status-go/mobile/default.nix +++ b/nix/status-go/mobile/default.nix @@ -1,10 +1,18 @@ { callPackage, meta, source, goBuildLdFlags }: { - android = callPackage ./build.nix { + android = {abis ? [ "armeabi-v7a" "arm64-v8a" "x86" ]}: callPackage ./build.nix { platform = "android"; platformVersion = "23"; - targets = [ "android/arm" "android/arm64" "android/386" ]; + # Hide different arch naming in gomobile from Android builds. + targets = let + abiMap = { + "armeabi-v7a" = "android/arm"; + "arm64-v8a" = "android/arm64"; + "x86" = "android/386"; + "x86_64" = "android/amd64"; + }; + in map (arch: abiMap."${arch}") abis; outputFileName = "status-go-${source.shortRev}.aar"; inherit meta source goBuildLdFlags; };