nix: fix Android SDK on Darwin with nixpkgs system override
Android SDK in nixpkg doesn't support `aarch64-darwin`, for details see https://github.com/status-im/status-mobile/issues/12794 The workaround was to run terminal application with Rosetta or make with `aarch` tool. This PR overrides system architecture to always be `x86_64` for Android shell and build targets ran by make. CI is not affected as it runs `nix` directly. Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
6d6e6b1eff
commit
5dcd64c478
11
nix/pkgs.nix
11
nix/pkgs.nix
|
@ -17,9 +17,20 @@ let
|
|||
|
||||
# Override some packages and utilities
|
||||
pkgsOverlay = import ./overlay.nix;
|
||||
|
||||
# Fix for lack of Android SDK for M1 Macs.
|
||||
systemOverride = let
|
||||
inherit (builtins) currentSystem getEnv;
|
||||
envSystemOverride = getEnv "NIXPKGS_SYSTEM_OVERRIDE";
|
||||
in
|
||||
if envSystemOverride != "" then
|
||||
envSystemOverride
|
||||
else
|
||||
currentSystem;
|
||||
in
|
||||
# import nixpkgs with a config override
|
||||
(import nixpkgsSrc) {
|
||||
config = defaultConfig // config;
|
||||
system = systemOverride;
|
||||
overlays = [ pkgsOverlay ];
|
||||
}
|
||||
|
|
|
@ -3,7 +3,10 @@
|
|||
# for the Android development environment.
|
||||
#
|
||||
|
||||
{ androidenv }:
|
||||
{ androidenv, lib, stdenv }:
|
||||
|
||||
assert lib.assertMsg (stdenv.system != "aarch64-darwin")
|
||||
"aarch64-darwin not supported for Android SDK. Use: NIXPKGS_SYSTEM_OVERRIDE=x86_64-darwin";
|
||||
|
||||
# The "android-sdk-license" license is accepted
|
||||
# by setting android_sdk.accept_license = true.
|
||||
|
|
|
@ -25,7 +25,7 @@ cleanup() {
|
|||
|
||||
# If you want to clean after every build set _NIX_CLEAN=true
|
||||
if [[ -n "${_NIX_CLEAN}" ]]; then
|
||||
trap cleanup EXIT ERR INT QUIT
|
||||
trap cleanup EXIT ERR INT QUIT
|
||||
fi
|
||||
|
||||
# build output will end up under /nix, we have to extract it
|
||||
|
@ -44,6 +44,12 @@ if [[ -z "${TARGET}" ]]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Hack fix for missing Android SDK for aarch64 on Darwin. See systemOverride in `nix/pkgs.nix`.
|
||||
if [[ "${TARGET}" =~ ^(targets.status-go.mobile.android|targets.mobile.android.release)$ ]]; then
|
||||
os=$(uname -s | tr '[:upper:]' '[:lower:]')
|
||||
export NIXPKGS_SYSTEM_OVERRIDE="x86_64-${os}"
|
||||
fi
|
||||
|
||||
# Some defaults flags, --pure could be optional in the future.
|
||||
# NOTE: The --keep-failed flag can be used for debugging issues.
|
||||
nixOpts=(
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
#
|
||||
# This script is used by the Makefile to have an implicit nix-shell.
|
||||
# The following environment variables modify the script behavior:
|
||||
# - TARGET: This attribute is passed via --attr to Nix, defining the scope.
|
||||
|
@ -64,6 +63,12 @@ if [[ -n "${_NIX_PURE}" ]]; then
|
|||
pureDesc='pure '
|
||||
fi
|
||||
|
||||
# Hack fix for missing Android SDK for aarch64 on Darwin. See systemOverride in `nix/pkgs.nix`.
|
||||
if [[ "${TARGET}" =~ ^(android-sdk|android|gradle|keytool|status-go)$ ]]; then
|
||||
os=$(uname -s | tr '[:upper:]' '[:lower:]')
|
||||
export NIXPKGS_SYSTEM_OVERRIDE="x86_64-${os}"
|
||||
fi
|
||||
|
||||
echo -e "${GRN}Configuring ${pureDesc}Nix shell for target '${TARGET}'...${RST}" 1>&2
|
||||
|
||||
# Save derivation from being garbage collected
|
||||
|
|
Loading…
Reference in New Issue