···
, licenseAccepted ? false
5
-
{ toolsVersion ? "26.1.1"
5
+
{ cmdLineToolsVersion ? "8.0"
6
+
, toolsVersion ? "26.1.1"
, platformToolsVersion ? "33.0.3"
, buildToolsVersions ? [ "33.0.1" ]
, includeEmulator ? false
···
inherit deployAndroidPackage;
os = if stdenv.system == "aarch64-darwin" then "macosx" else os; # "macosx" is a universal binary here
package = packages.platform-tools.${platformToolsVersion};
136
+
tools = callPackage ./tools.nix {
137
+
inherit deployAndroidPackage os;
138
+
package = packages.tools.${toolsVersion};
141
+
${linkPlugin { name = "platform-tools"; plugin = platform-tools; }}
142
+
${linkPlugin { name = "patcher"; plugin = patcher; }}
143
+
${linkPlugin { name = "emulator"; plugin = emulator; }}
147
+
patcher = callPackage ./patcher.nix {
148
+
inherit deployAndroidPackage os;
149
+
package = packages.patcher."1";
build-tools = map (version:
callPackage ./build-tools.nix {
inherit deployAndroidPackage os;
package = packages.build-tools.${version};
158
+
${linkPlugin { name = "tools"; plugin = tools; check = toolsVersion != null; }}
emulator = callPackage ./emulator.nix {
inherit deployAndroidPackage os;
package = packages.emulator.${emulatorVersion};
168
+
${linkSystemImages { images = system-images; check = includeSystemImages; }}
platforms = map (version:
···
# Function that automatically links a plugin for which only one version exists
linkPlugin = {name, plugin, check ? true}:
lib.optionalString check ''
241
-
ln -s ${plugin}/libexec/android-sdk/* ${name}
266
+
ln -s ${plugin}/libexec/android-sdk/${name} ${name}
269
+
linkSystemImages = { images, check }: lib.optionalString check ''
270
+
mkdir -p system-images
271
+
${lib.concatMapStrings (system-image: ''
272
+
apiVersion=$(basename $(echo ${system-image}/libexec/android-sdk/system-images/*))
273
+
type=$(basename $(echo ${system-image}/libexec/android-sdk/system-images/*/*))
274
+
mkdir -p system-images/$apiVersion/$type
275
+
ln -s ${system-image}/libexec/android-sdk/system-images/$apiVersion/$type/* system-images/$apiVersion/$type
# Links all plugins related to a requested platform
linkPlatformPlugins = {name, plugins, check}:
lib.optionalString check ''
···
${lib.concatMapStringsSep "\n" (str: " - ${str}") licenseNames}
by setting nixpkgs config option 'android_sdk.accept_license = true;'.
263
-
'' else callPackage ./tools.nix {
264
-
inherit deployAndroidPackage packages toolsVersion os;
298
+
'' else callPackage ./cmdline-tools.nix {
299
+
inherit deployAndroidPackage os cmdLineToolsVersion;
301
+
package = packages.cmdline-tools.${cmdLineToolsVersion};
# Symlink all requested plugins
${linkPlugin { name = "platform-tools"; plugin = platform-tools; }}
306
+
${linkPlugin { name = "tools"; plugin = tools; check = toolsVersion != null; }}
307
+
${linkPlugin { name = "patcher"; plugin = patcher; }}
${linkPlugins { name = "build-tools"; plugins = build-tools; }}
${linkPlugin { name = "emulator"; plugin = emulator; check = includeEmulator; }}
${linkPlugins { name = "platforms"; plugins = platforms; }}
···
${linkPlugins { name = "cmake"; plugins = cmake; }}
${linkNdkPlugins { name = "ndk-bundle"; rootName = "ndk"; plugins = ndk-bundles; }}
${linkNdkPlugin { name = "ndk-bundle"; plugin = ndk-bundle; check = includeNDK; }}
277
-
${lib.optionalString includeSystemImages ''
278
-
mkdir -p system-images
279
-
${lib.concatMapStrings (system-image: ''
280
-
apiVersion=$(basename $(echo ${system-image}/libexec/android-sdk/system-images/*))
281
-
type=$(basename $(echo ${system-image}/libexec/android-sdk/system-images/*/*))
282
-
mkdir -p system-images/$apiVersion/$type
283
-
ln -s ${system-image}/libexec/android-sdk/system-images/$apiVersion/$type/* system-images/$apiVersion/$type
315
+
${linkSystemImages { images = system-images; check = includeSystemImages; }}
${linkPlatformPlugins { name = "add-ons"; plugins = google-apis; check = useGoogleAPIs; }}
${linkPlatformPlugins { name = "add-ons"; plugins = google-apis; check = useGoogleTVAddOns; }}
···
# Expose common executables in bin/
307
-
find $PWD/tools -not -path '*/\.*' -type f -executable -mindepth 1 -maxdepth 1 | while read i
337
+
for i in ${platform-tools}/bin/*; do
312
-
find $PWD/tools/bin -not -path '*/\.*' -type f -executable -mindepth 1 -maxdepth 1 | while read i
341
+
for i in ${emulator}/bin/*; do
317
-
for i in ${platform-tools}/bin/*
345
+
find $ANDROID_SDK_ROOT/cmdline-tools/${cmdLineToolsVersion}/bin -type f -executable | while read i; do
322
-
# the emulator auto-linked from platform-tools does not find its local qemu, while this one does
323
-
${lib.optionalString includeEmulator ''
324
-
rm $out/bin/emulator
325
-
ln -s $out/libexec/android-sdk/emulator/emulator $out/bin