diff --git a/README.md b/README.md index 27b597c..cd30d97 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,14 @@ composeApp/ Requirements: JDK 21, Android SDK 35 for the app target, Node (Kotlin downloads its own for web). +With Nix, everything is provided by `shell.nix` (JDK 21, Gradle 8, Node 22, Android SDK 35 with build-tools 35.0.0, and the desktop runtime libraries): + +```bash +nix-shell +``` + +The shell accepts the unfree Android SDK license for you; see the comment at the top of `shell.nix`. Without Nix, point `ANDROID_HOME` at an SDK containing platform 35 and build-tools 35.0.0. + ```bash export ANDROID_HOME=/opt/android-sdk diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..05e682b --- /dev/null +++ b/shell.nix @@ -0,0 +1,67 @@ +{ pkgs ? import { + # The Android SDK is unfree and requires accepting Google's license. + # Setting this here asserts that you accept it for this dev shell. + config = { + allowUnfree = true; + android_sdk.accept_license = true; + }; + } +}: + +let + jdk = pkgs.jdk21; + gradle = pkgs.gradle_8; + node = pkgs.nodejs_22; + + androidPackages = pkgs.androidenv.composeAndroidPackages { + platformVersions = [ "35" ]; + buildToolsVersions = [ "35.0.0" ]; + includeEmulator = false; + includeSystemImages = false; + includeNDK = false; + }; + + androidSdk = "${androidPackages.androidsdk}/libexec/android-sdk"; + + desktopLibs = with pkgs; [ + libGL + xorg.libX11 + xorg.libXext + xorg.libXrender + fontconfig + freetype + alsa-lib + ]; +in +pkgs.mkShell { + packages = with pkgs; [ + jdk + gradle + node + zip + unzip + git + curl + python3 + ] ++ desktopLibs; + + JAVA_HOME = jdk.home; + ANDROID_HOME = androidSdk; + ANDROID_SDK_ROOT = androidSdk; + LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath desktopLibs; + + shellHook = '' + export PATH="$ANDROID_HOME/platform-tools:$ANDROID_HOME/cmdline-tools/latest/bin:$PATH" + echo "AudioManager client dev shell" + echo " Java: $(java -version 2>&1 | head -1)" + echo " Gradle: $(gradle --version | grep '^Gradle' | head -1)" + echo " Node: $(node --version)" + echo " Android SDK: $ANDROID_HOME" + echo "" + echo "Build:" + echo " gradle :composeApp:desktopTest" + echo " gradle :composeApp:assembleDebug" + echo " gradle :composeApp:run" + echo " gradle :composeApp:wasmJsBrowserDevelopmentExecutableDistribution" + ''; +}