Unexpected-Keyboard/shell.nix
Jules Aguillon d073523125 shell.nix: Update dependencies and add Gradle
Update OpenJDK to version 17, Android build tools to 33.0.1 and platform to 33.
These are required to build with Gradle.

Add Gradle to the environment, which must be wrapped to fix a
permissions issue. Setting `GRADLE_OPTS` has no effect as it seems not
to be passed down to the daemon.
2023-11-25 20:13:24 +01:00

34 lines
1021 B
Nix

{ pkgs ? import <nixpkgs> {
config.android_sdk.accept_license = true;
config.allowUnfree = true;
} }:
let
jdk = pkgs.openjdk17;
build_tools_version = "33.0.1";
android = pkgs.androidenv.composeAndroidPackages {
buildToolsVersions = [ build_tools_version ];
platformVersions = [ "33" ];
abiVersions = [ "armeabi-v7a" ];
};
ANDROID_SDK_ROOT = "${android.androidsdk}/libexec/android-sdk";
# Without this option, aapt2 fails to run with a permissions error.
gradle_wrapped = pkgs.runCommandLocal "gradle-wrapped" {
nativeBuildInputs = with pkgs; [ makeBinaryWrapper ];
} ''
mkdir -p $out/bin
ln -s ${pkgs.gradle}/bin/gradle $out/bin/gradle
wrapProgram $out/bin/gradle \
--add-flags "-Dorg.gradle.project.android.aapt2FromMavenOverride=${ANDROID_SDK_ROOT}/build-tools/${build_tools_version}/aapt2"
'';
in pkgs.mkShell {
buildInputs =
[ pkgs.findutils pkgs.fontforge jdk android.androidsdk gradle_wrapped ];
JAVA_HOME = jdk.home;
inherit ANDROID_SDK_ROOT;
}