From 88dc152e73f8420e3d0bd7a7364aedcf4fbcf482 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Thu, 22 Jul 2021 12:51:05 +0200 Subject: [PATCH] nix: rafactor android-sdk to provide sdk/ndk outputs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes path shorter. Signed-off-by: Jakub SokoĊ‚owski --- nix/mobile/android/default.nix | 4 ++-- nix/mobile/android/release.nix | 4 ++-- nix/pkgs/android-sdk/pkgs.nix | 10 +++++----- nix/pkgs/android-sdk/shell.nix | 6 +++--- nix/pkgs/gomobile/default.nix | 4 ++-- nix/status-go/mobile/build.nix | 5 ++--- 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/nix/mobile/android/default.nix b/nix/mobile/android/default.nix index 3ba07c7aad..a092234c04 100644 --- a/nix/mobile/android/default.nix +++ b/nix/mobile/android/default.nix @@ -34,8 +34,8 @@ in { ]; shellHook = '' - export ANDROID_SDK_ROOT="${androidPkgs}" - export ANDROID_NDK_ROOT="${androidPkgs}/ndk-bundle" + export ANDROID_SDK_ROOT="${androidPkgs.sdk}" + export ANDROID_NDK_ROOT="${androidPkgs.ndk}" export STATUS_NIX_MAVEN_REPO="${deps.gradle}" diff --git a/nix/mobile/android/release.nix b/nix/mobile/android/release.nix index a42c750e19..1d165c7af8 100644 --- a/nix/mobile/android/release.nix +++ b/nix/mobile/android/release.nix @@ -80,8 +80,8 @@ in stdenv.mkDerivation rec { ANDROID_ABI_INCLUDE = androidAbiInclude; # Android SDK/NDK for use by Gradle - ANDROID_SDK_ROOT = "${androidPkgs}"; - ANDROID_NDK_ROOT = "${androidPkgs}/ndk-bundle"; + ANDROID_SDK_ROOT = "${androidPkgs.sdk}"; + ANDROID_NDK_ROOT = "${androidPkgs.ndk}"; # Used by the Android Gradle build script in android/build.gradle STATUS_GO_ANDROID_LIBDIR = "${status-go}"; diff --git a/nix/pkgs/android-sdk/pkgs.nix b/nix/pkgs/android-sdk/pkgs.nix index 78dfdd7ce5..645987b3a8 100644 --- a/nix/pkgs/android-sdk/pkgs.nix +++ b/nix/pkgs/android-sdk/pkgs.nix @@ -3,15 +3,15 @@ # # This derivation simply symlinks some stuff to get # shorter paths as libexec/android-sdk is quite the mouthful. +# With this you can just do `androidPkgs.sdk` and `androidPkgs.ndk`. # stdenv.mkDerivation { name = "${compose.androidsdk.name}-mod"; phases = [ "symlinkPhase" ]; + outputs = [ "out" "sdk" "ndk" ]; symlinkPhase = '' - mkdir -p $out - ln -s "${compose.androidsdk}/bin" $out/bin - for d in ${compose.androidsdk}/libexec/android-sdk/*; do - ln -s $d $out/$(basename $d) - done + ln -s ${compose.androidsdk} $out + ln -s ${compose.androidsdk}/libexec/android-sdk $sdk + ln -s ${compose.androidsdk}/libexec/android-sdk/ndk-bundle $ndk ''; } diff --git a/nix/pkgs/android-sdk/shell.nix b/nix/pkgs/android-sdk/shell.nix index b204623a78..ac537c827c 100644 --- a/nix/pkgs/android-sdk/shell.nix +++ b/nix/pkgs/android-sdk/shell.nix @@ -5,9 +5,9 @@ mkShell { shellHook = '' export JAVA_HOME="${openjdk}" - export ANDROID_HOME="${androidPkgs}" - export ANDROID_SDK_ROOT="${androidPkgs}" - export ANDROID_NDK_ROOT="${androidPkgs}/ndk-bundle" + export ANDROID_HOME="${androidPkgs.sdk}" + export ANDROID_NDK_ROOT="${androidPkgs.ndk}" + export ANDROID_SDK_ROOT="$ANDROID_HOME" export PATH="$ANDROID_HOME/bin:$PATH" export PATH="$ANDROID_NDK_ROOT:$PATH" diff --git a/nix/pkgs/gomobile/default.nix b/nix/pkgs/gomobile/default.nix index f6f5d3a549..341eef6570 100644 --- a/nix/pkgs/gomobile/default.nix +++ b/nix/pkgs/gomobile/default.nix @@ -40,8 +40,8 @@ buildGo116Module { wrapProgram $out/bin/gomobile \ --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ zlib ]}" \ --prefix PATH : "${androidPkgs}/bin" \ - --set ANDROID_NDK_HOME "${androidPkgs}/ndk-bundle" \ - --set ANDROID_HOME "${androidPkgs}" + --set ANDROID_NDK_ROOT "${androidPkgs.ndk}" \ + --set ANDROID_HOME "${androidPkgs.sdk}" ''; meta = with lib; { diff --git a/nix/status-go/mobile/build.nix b/nix/status-go/mobile/build.nix index cd981005ba..e77a6e3de6 100644 --- a/nix/status-go/mobile/build.nix +++ b/nix/status-go/mobile/build.nix @@ -46,10 +46,9 @@ in buildGo116Package { export GO111MODULE=off export GOPATH=${gomobile}:$GOPATH export NIX_GOWORKDIR=${NIX_GOWORKDIR} - '' + optionalString (platform == "android") '' - export ANDROID_HOME=${androidPkgs} - export ANDROID_NDK_HOME=${androidPkgs}/ndk-bundle + export ANDROID_SDK_ROOT="${androidPkgs.sdk}" + export ANDROID_NDK_HOME="${androidPkgs.ndk}" export PATH="${makeBinPath [ openjdk ]}:$PATH" '';