android-dev archetype: ship the Android SDK and nix-ld so a Gradle build runs
The archetype installed Gradle, a JDK and android-tools but no SDK, no ANDROID_HOME/JAVA_HOME and no nix-ld, so the aapt2 Gradle downloads could not start on NixOS and an agent could not build an app. It now builds an SDK (build-tools 36.1.0, platform 35, no emulator or system images), sets ANDROID_HOME, ANDROID_SDK_ROOT and JAVA_HOME, and enables programs.nix-ld. The SDK's unfree names are read off the SDK and added to allowUnfreePackages, which adds to the claude-code allowance instead of replacing it. Closes #6696
This commit is contained in:
parent
0e147618d0
commit
c9204ad0e0
1 changed files with 134 additions and 5 deletions
|
|
@ -30,6 +30,33 @@
|
|||
android-dev = {
|
||||
module =
|
||||
{ pkgs, lib, ... }:
|
||||
let
|
||||
# build-tools 36.1.0 and platform 35: the pair the damocles agent builds
|
||||
# with. No emulator and no system images; they are large, and a build
|
||||
# is run against a device or an emulator elsewhere.
|
||||
sdk = pkgs.androidenv.composeAndroidPackages {
|
||||
buildToolsVersions = [ "36.1.0" ];
|
||||
platformVersions = [ "35" ];
|
||||
includeEmulator = false;
|
||||
includeSystemImages = false;
|
||||
};
|
||||
sdkRoot = "${sdk.androidsdk}/libexec/android-sdk";
|
||||
# The unfree names the SDK needs: each package it is built from and
|
||||
# the archives those fetch. Read off the SDK itself, because the
|
||||
# archive names carry versions that change with every nixpkgs bump.
|
||||
asDrvs =
|
||||
v:
|
||||
if lib.isDerivation v then
|
||||
[ v ]
|
||||
else if lib.isList v then
|
||||
lib.concatMap asDrvs v
|
||||
else
|
||||
[ ];
|
||||
sdkParts = lib.concatMap asDrvs (lib.attrValues (removeAttrs sdk [ "recurseForDerivations" ]));
|
||||
sdkUnfree = lib.unique (
|
||||
map lib.getName (lib.concatMap (part: [ part ] ++ asDrvs (part.src or [ ])) sdkParts)
|
||||
);
|
||||
in
|
||||
{
|
||||
services.hyperhive.agent.icon = lib.mkDefault ./icons/android-dev.svg;
|
||||
environment.systemPackages = [
|
||||
|
|
@ -37,10 +64,26 @@
|
|||
pkgs.gradle
|
||||
pkgs.jdk
|
||||
];
|
||||
environment.variables = {
|
||||
ANDROID_HOME = sdkRoot;
|
||||
ANDROID_SDK_ROOT = sdkRoot;
|
||||
JAVA_HOME = "${pkgs.jdk.home}";
|
||||
};
|
||||
# Gradle downloads and runs its own prebuilt `aapt2`, a foreign dynamic
|
||||
# binary that NixOS cannot start without a loader at /lib64. nix-ld is
|
||||
# that loader. Its default library set already carries the C++ runtime
|
||||
# and zlib that the download links against, and the module-eval check
|
||||
# asserts it still does.
|
||||
programs.nix-ld.enable = true;
|
||||
# The SDK packages are unfree and ask for their licence to be accepted.
|
||||
# `allowUnfreePackages` adds to the claude-code allowance the agent
|
||||
# modules set, where a second `allowUnfreePredicate` would replace it.
|
||||
nixpkgs.config.android_sdk.accept_license = true;
|
||||
nixpkgs.config.allowUnfreePackages = sdkUnfree;
|
||||
};
|
||||
meta = {
|
||||
icon = builtins.readFile ./icons/android-dev.svg;
|
||||
description = "Builds Android apps: adb and fastboot (android-tools), Gradle and a JDK are installed. It holds the default permissions.";
|
||||
description = "Builds Android apps: adb and fastboot (android-tools), Gradle, a JDK, the Android SDK (build-tools 36.1.0, platform 35) and nix-ld, so Gradle's downloaded aapt2 runs. ANDROID_HOME and JAVA_HOME are set. It holds the default permissions.";
|
||||
prompt = builtins.readFile ./prompts/android-dev.md;
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue