From bb68b7269158a10df78c30cd097a723d32ee6a2a Mon Sep 17 00:00:00 2001 From: Jacob Chvatal Date: Fri, 27 Jan 2023 08:16:12 -0500 Subject: [PATCH] fix android developmetn environment --- README.md | 2 +- hosts/work/default.nix | 3 ++- modules/dev/android.nix | 32 ++++++++++++++++++++------------ 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index fdba3871..5ada447b 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Started as a fork of [hlissner's dotfiles](https://github.com/hlissner/dotfiles) -Feel free to poke around and contact me if you have any questions : ) +Feel free to poke around. Contact me if you have any questions! ## Installation diff --git a/hosts/work/default.nix b/hosts/work/default.nix index 304b56c9..91184766 100644 --- a/hosts/work/default.nix +++ b/hosts/work/default.nix @@ -70,7 +70,8 @@ }; }; dev = { - clojure.enable = true; + clojure.enable = true; + android.enable = true; }; hardware = { audio.enable = true; diff --git a/modules/dev/android.nix b/modules/dev/android.nix index f9986087..6da70a37 100644 --- a/modules/dev/android.nix +++ b/modules/dev/android.nix @@ -11,7 +11,8 @@ in { config = mkIf cfg.enable { user.packages = with pkgs; [ - android-studio + # use the development version of android-studio (needed for StreetComplete) + androidStudioPackages.dev androidSdk platformTools glibc @@ -20,18 +21,25 @@ in { programs.adb.enable = true; user.extraGroups = [ "adbusers" ]; services.udev.packages = [ pkgs.android-udev-rules ]; - environment.variables.ANDROID_JAVA_HOME = "${pkgs.openjdk8.home}"; - environment.variables.ANDROID_SDK_ROOT = "${androidSdk}"; - environment.variables.GRADLE_OPTS = - "-Dorg.gradle.project.android.aapt2FromMavenOverride=${androidSdk}/libexec/android-sdk/build-tools/28.0.3/aapt2"; - # https://github.com/swaywm/sway/issues/595 - environment.variables._JAVA_AWT_WM_NONREPARENTING = "1"; - env.ANDROID_JAVA_HOME = "${pkgs.openjdk8.home}"; - env.ANDROID_SDK_ROOT = "${androidSdk}"; + environment.variables = { + ANDROID_JAVA_HOME = "${pkgs.openjdk8.home}"; + ANDROID_SDK_ROOT = "${androidSdk}"; + GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${androidSdk}/libexec/android-sdk/build-tools/28.0.3/aapt2"; + # Increase max memory sizes for gradle builds + JAVA_OPTIONS = "-Xms1024m -Xmx4096m"; + # https://github.com/swaywm/sway/issues/595 + _JAVA_AWT_WM_NONREPARENTING = "1"; + }; - # override the aapt2 that gradle uses with the nix-shipped version - env.GRADLE_OPTS = - "-Dorg.gradle.project.android.aapt2FromMavenOverride=${androidSdk}/libexec/android-sdk/build-tools/28.0.3/aapt2"; + # TODO: Redundant? + env = { + ANDROID_JAVA_HOME = "${pkgs.openjdk8.home}"; + ANDROID_SDK_ROOT = "${androidSdk}"; + + # override the aapt2 that gradle uses with the nix-shipped version + GRADLE_OPTS = + "-Dorg.gradle.project.android.aapt2FromMavenOverride=${androidSdk}/libexec/android-sdk/build-tools/28.0.3/aapt2"; + }; }; }