Skip to content

Commit

Permalink
android-studio: improve wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
numinit committed May 28, 2024
1 parent 3a56eb1 commit 18800cb
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions pkgs/applications/editors/android-studio/common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,35 @@ let
in ''
#!${runtimeShell}
${lib.optionalString hasAndroidSdk ''
# Default ANDROID_SDK_ROOT to the packaged one.
export ANDROID_SDK_ROOT="''${ANDROID_SDK_ROOT-${androidSdkRoot}}"
export ANDROID_HOME="$ANDROID_SDK_ROOT"
echo "Android Studio wrapper started with ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT" >&2
echo "=== nixpkgs Android Studio wrapper ===" >&2
# Default ANDROID_SDK_ROOT to the packaged one, if not provided.
ANDROID_SDK_ROOT="''${ANDROID_SDK_ROOT-${androidSdkRoot}}"
if [ -d "$ANDROID_SDK_ROOT" ]; then
export ANDROID_SDK_ROOT
# Legacy compatibility.
export ANDROID_HOME="$ANDROID_SDK_ROOT"
echo " - ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT" >&2
# See if we can export ANDROID_NDK_ROOT too.
ANDROID_NDK_ROOT="$ANDROID_SDK_ROOT/ndk-bundle"
if [ ! -d "$ANDROID_NDK_ROOT" ]; then
ANDROID_NDK_ROOT="$(ls "$ANDROID_SDK_ROOT/ndk/"* 2>/dev/null | head -n1)"
fi
if [ -d "$ANDROID_NDK_ROOT" ]; then
export ANDROID_NDK_ROOT
echo " - ANDROID_NDK_ROOT=$ANDROID_NDK_ROOT" >&2
else
unset ANDROID_NDK_ROOT
fi
else
unset ANDROID_SDK_ROOT
unset ANDROID_HOME
fi
''}
exec ${fhsEnv}/bin/${drvName}-fhs-env ${androidStudio}/bin/studio.sh "$@"
'';
Expand Down

0 comments on commit 18800cb

Please sign in to comment.