From 88ef7a859897a84bd526b0cdeae034daf03ce1c2 Mon Sep 17 00:00:00 2001 From: Morgan Jones Date: Mon, 27 May 2024 03:15:47 -0700 Subject: {android-studio,androidenv}: add withSdk passthru and androidPkgs Rename androidPkgs_9_0 to androidPkgs, and treat it more like a "full" androidenv package. --- .../applications/editors/android-studio/common.nix | 48 ++++++++++++++++++---- 1 file changed, 40 insertions(+), 8 deletions(-) (limited to 'pkgs/applications/editors') diff --git a/pkgs/applications/editors/android-studio/common.nix b/pkgs/applications/editors/android-studio/common.nix index 291a280bdf0f2..ac210d20d2f84 100644 --- a/pkgs/applications/editors/android-studio/common.nix +++ b/pkgs/applications/editors/android-studio/common.nix @@ -1,7 +1,7 @@ { channel, pname, version, sha256Hash }: { alsa-lib -, bash +, runtimeShell , buildFHSEnv , cacert , coreutils @@ -214,17 +214,48 @@ let '') ]; }; -in runCommand - drvName - { - startScript = '' - #!${bash}/bin/bash - ${fhsEnv}/bin/${drvName}-fhs-env ${androidStudio}/bin/studio.sh "$@" + mkAndroidStudioWrapper = {androidStudio, androidSdk ? null}: runCommand drvName { + startScript = let + hasAndroidSdk = androidSdk != null; + androidSdkRoot = lib.optionalString hasAndroidSdk "${androidSdk}/libexec/android-sdk"; + in '' + #!${runtimeShell} + ${lib.optionalString hasAndroidSdk '' + 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 "$@" ''; preferLocalBuild = true; allowSubstitutes = false; passthru = { unwrapped = androidStudio; + withSdk = androidSdk: mkAndroidStudioWrapper { inherit androidStudio androidSdk; }; }; meta = with lib; { description = "The Official IDE for Android (${channel} channel)"; @@ -261,4 +292,5 @@ in runCommand ln -s ${androidStudio}/bin/studio.png $out/share/pixmaps/${pname}.png ln -s ${desktopItem}/share/applications $out/share/applications - '' + ''; +in mkAndroidStudioWrapper { inherit androidStudio; } -- cgit 1.4.1 From 2ac0fcce4232bb501ae44c1a741da5f4b586eb90 Mon Sep 17 00:00:00 2001 From: Morgan Jones Date: Mon, 27 May 2024 03:19:29 -0700 Subject: android-studio: add numinit as maintainer --- pkgs/applications/editors/android-studio/common.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'pkgs/applications/editors') diff --git a/pkgs/applications/editors/android-studio/common.nix b/pkgs/applications/editors/android-studio/common.nix index ac210d20d2f84..b47c1ff9b0cd5 100644 --- a/pkgs/applications/editors/android-studio/common.nix +++ b/pkgs/applications/editors/android-studio/common.nix @@ -276,9 +276,9 @@ let # source-code itself). platforms = [ "x86_64-linux" ]; maintainers = with maintainers; rec { - stable = [ alapshin ]; - beta = [ alapshin ]; - canary = [ alapshin ]; + stable = [ alapshin numinit ]; + beta = [ alapshin numinit ]; + canary = [ alapshin numinit ]; dev = canary; }."${channel}"; mainProgram = pname; -- cgit 1.4.1 From 859a6056d3311b4292b8585b86d3b35fbe483b9e Mon Sep 17 00:00:00 2001 From: Morgan Jones Date: Mon, 27 May 2024 03:21:50 -0700 Subject: android-studio-full: init This package provides Android Studio with a relatively complete set of SDK and emulator packages. --- pkgs/applications/editors/android-studio/common.nix | 8 ++++++-- pkgs/top-level/all-packages.nix | 5 +++-- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'pkgs/applications/editors') diff --git a/pkgs/applications/editors/android-studio/common.nix b/pkgs/applications/editors/android-studio/common.nix index b47c1ff9b0cd5..ca7c4aa1bbdd1 100644 --- a/pkgs/applications/editors/android-studio/common.nix +++ b/pkgs/applications/editors/android-studio/common.nix @@ -65,6 +65,7 @@ , zlib , makeDesktopItem , tiling_wm # if we are using a tiling wm, need to set _JAVA_AWT_WM_NONREPARENTING in wrapper +, androidenv }: let @@ -253,9 +254,12 @@ let ''; preferLocalBuild = true; allowSubstitutes = false; - passthru = { - unwrapped = androidStudio; + passthru = let withSdk = androidSdk: mkAndroidStudioWrapper { inherit androidStudio androidSdk; }; + in { + unwrapped = androidStudio; + full = withSdk androidenv.androidPkgs.androidsdk; + inherit withSdk; }; meta = with lib; { description = "The Official IDE for Android (${channel} channel)"; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 84826faa30c96..1ca4c1dd9b46a 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -4069,7 +4069,7 @@ with pkgs; adbfs-rootless = callPackage ../development/mobile/adbfs-rootless { }; adb-sync = callPackage ../development/mobile/adb-sync { - inherit (androidenv.androidPkgs_9_0) platform-tools; + inherit (androidenv.androidPkgs) platform-tools; }; amoco = callPackage ../tools/security/amoco { }; @@ -4085,7 +4085,7 @@ with pkgs; androidndkPkgs_23b = (callPackage ../development/androidndk-pkgs {})."23b"; androidndkPkgs_24 = (callPackage ../development/androidndk-pkgs {})."24"; - androidsdk_9_0 = androidenv.androidPkgs_9_0.androidsdk; + androidsdk = androidenv.androidPkgs.androidsdk; webos = recurseIntoAttrs { cmake-modules = callPackage ../development/mobile/webos/cmake-modules.nix { }; @@ -29556,6 +29556,7 @@ with pkgs; androidStudioPackages = recurseIntoAttrs (callPackage ../applications/editors/android-studio { }); android-studio = androidStudioPackages.stable; + android-studio-full = android-studio.full; antfs-cli = callPackage ../applications/misc/antfs-cli { }; -- cgit 1.4.1 From c1adf2f6c0f59af2502ae5d8ce45cf679193fe17 Mon Sep 17 00:00:00 2001 From: Morgan Jones Date: Mon, 3 Jun 2024 23:03:05 -0700 Subject: android-studio: add sdk passthru --- pkgs/applications/editors/android-studio/common.nix | 1 + 1 file changed, 1 insertion(+) (limited to 'pkgs/applications/editors') diff --git a/pkgs/applications/editors/android-studio/common.nix b/pkgs/applications/editors/android-studio/common.nix index ca7c4aa1bbdd1..e18d19ad257fa 100644 --- a/pkgs/applications/editors/android-studio/common.nix +++ b/pkgs/applications/editors/android-studio/common.nix @@ -260,6 +260,7 @@ let unwrapped = androidStudio; full = withSdk androidenv.androidPkgs.androidsdk; inherit withSdk; + sdk = androidSdk; }; meta = with lib; { description = "The Official IDE for Android (${channel} channel)"; -- cgit 1.4.1