androidsdk: Make AVD storage dir configurable and make activation step optional
This commit is contained in:
parent
fb448ba4a1
commit
416db1de92
@ -2,9 +2,9 @@
|
|||||||
{ name, app ? null
|
{ name, app ? null
|
||||||
, platformVersion ? "8", abiVersion ? "armeabi-v7a", useGoogleAPIs ? false
|
, platformVersion ? "8", abiVersion ? "armeabi-v7a", useGoogleAPIs ? false
|
||||||
, enableGPU ? false, extraAVDFiles ? []
|
, enableGPU ? false, extraAVDFiles ? []
|
||||||
, package ? null, activity ? null}:
|
, package ? null, activity ? null
|
||||||
|
, avdHomeDir ? null
|
||||||
assert app != null -> package != null && activity != null;
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
androidsdkComposition = androidsdk {
|
androidsdkComposition = androidsdk {
|
||||||
@ -28,8 +28,12 @@ stdenv.mkDerivation {
|
|||||||
export TMPDIR=/tmp
|
export TMPDIR=/tmp
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Store the virtual devices somewhere else, instead of polluting a user's HOME directory
|
${if avdHomeDir == null then ''
|
||||||
export ANDROID_SDK_HOME=$(mktemp -d $TMPDIR/nix-android-vm-XXXX)
|
# Store the virtual devices somewhere else, instead of polluting a user's HOME directory
|
||||||
|
export ANDROID_SDK_HOME=$(mktemp -d $TMPDIR/nix-android-vm-XXXX)
|
||||||
|
'' else ''
|
||||||
|
export ANDROID_SDK_HOME=${avdHomeDir}
|
||||||
|
''}
|
||||||
|
|
||||||
# We have to look for a free TCP port
|
# We have to look for a free TCP port
|
||||||
|
|
||||||
@ -106,7 +110,9 @@ stdenv.mkDerivation {
|
|||||||
${androidsdkComposition}/libexec/android-sdk-*/platform-tools/adb -s emulator-$port install "$appPath"
|
${androidsdkComposition}/libexec/android-sdk-*/platform-tools/adb -s emulator-$port install "$appPath"
|
||||||
|
|
||||||
# Start the application
|
# Start the application
|
||||||
${androidsdkComposition}/libexec/android-sdk-*/platform-tools/adb -s emulator-$port shell am start -a android.intent.action.MAIN -n ${package}/.${activity}
|
${stdenv.lib.optionalString (package != null && activity != null) ''
|
||||||
|
${androidsdkComposition}/libexec/android-sdk-*/platform-tools/adb -s emulator-$port shell am start -a android.intent.action.MAIN -n ${package}/${activity}
|
||||||
|
''}
|
||||||
''}
|
''}
|
||||||
EOF
|
EOF
|
||||||
chmod +x $out/bin/run-test-emulator
|
chmod +x $out/bin/run-test-emulator
|
||||||
|
Loading…
x
Reference in New Issue
Block a user