androidenv: rename stdenv.lib -> lib
Removes some visual clutter.
This commit is contained in:
parent
2ec43d3509
commit
1b81302d49
@ -1,4 +1,4 @@
|
|||||||
{ composeAndroidPackages, stdenv, ant, jdk, gnumake, gawk }:
|
{ composeAndroidPackages, stdenv, lib, ant, jdk, gnumake, gawk }:
|
||||||
|
|
||||||
{ name
|
{ name
|
||||||
, release ? false, keyStore ? null, keyAlias ? null, keyStorePassword ? null, keyAliasPassword ? null
|
, release ? false, keyStore ? null, keyAlias ? null, keyStorePassword ? null, keyAliasPassword ? null
|
||||||
@ -16,11 +16,11 @@ let
|
|||||||
extraArgs = removeAttrs args ([ "name" ] ++ builtins.attrNames androidSdkFormalArgs);
|
extraArgs = removeAttrs args ([ "name" ] ++ builtins.attrNames androidSdkFormalArgs);
|
||||||
in
|
in
|
||||||
stdenv.mkDerivation ({
|
stdenv.mkDerivation ({
|
||||||
name = stdenv.lib.replaceChars [" "] [""] name; # Android APKs may contain white spaces in their names, but Nix store paths cannot
|
name = lib.replaceChars [" "] [""] name; # Android APKs may contain white spaces in their names, but Nix store paths cannot
|
||||||
ANDROID_HOME = "${androidsdk}/libexec/android-sdk";
|
ANDROID_HOME = "${androidsdk}/libexec/android-sdk";
|
||||||
buildInputs = [ jdk ant ];
|
buildInputs = [ jdk ant ];
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
${stdenv.lib.optionalString release ''
|
${lib.optionalString release ''
|
||||||
# Provide key singing attributes
|
# Provide key singing attributes
|
||||||
( echo "key.store=${keyStore}"
|
( echo "key.store=${keyStore}"
|
||||||
echo "key.alias=${keyAlias}"
|
echo "key.alias=${keyAlias}"
|
||||||
@ -31,7 +31,7 @@ stdenv.mkDerivation ({
|
|||||||
|
|
||||||
export ANDROID_SDK_HOME=`pwd` # Key files cannot be stored in the user's home directory. This overrides it.
|
export ANDROID_SDK_HOME=`pwd` # Key files cannot be stored in the user's home directory. This overrides it.
|
||||||
|
|
||||||
${stdenv.lib.optionalString (args ? includeNDK && args.includeNDK) ''
|
${lib.optionalString (args ? includeNDK && args.includeNDK) ''
|
||||||
export GNUMAKE=${gnumake}/bin/make
|
export GNUMAKE=${gnumake}/bin/make
|
||||||
export NDK_HOST_AWK=${gawk}/bin/gawk
|
export NDK_HOST_AWK=${gawk}/bin/gawk
|
||||||
${androidsdk}/libexec/android-sdk/ndk-bundle/ndk-build
|
${androidsdk}/libexec/android-sdk/ndk-bundle/ndk-build
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (pkgs) stdenv fetchurl makeWrapper unzip;
|
inherit (pkgs) stdenv lib fetchurl makeWrapper unzip;
|
||||||
|
|
||||||
# Determine the Android os identifier from Nix's system identifier
|
# Determine the Android os identifier from Nix's system identifier
|
||||||
os = if stdenv.system == "x86_64-linux" then "linux"
|
os = if stdenv.system == "x86_64-linux" then "linux"
|
||||||
@ -59,12 +59,12 @@ let
|
|||||||
};
|
};
|
||||||
|
|
||||||
system-images-packages =
|
system-images-packages =
|
||||||
stdenv.lib.recursiveUpdate
|
lib.recursiveUpdate
|
||||||
system-images-packages-android
|
system-images-packages-android
|
||||||
(stdenv.lib.recursiveUpdate system-images-packages-android-tv
|
(lib.recursiveUpdate system-images-packages-android-tv
|
||||||
(stdenv.lib.recursiveUpdate system-images-packages-android-wear
|
(lib.recursiveUpdate system-images-packages-android-wear
|
||||||
(stdenv.lib.recursiveUpdate system-images-packages-android-wear-cn
|
(lib.recursiveUpdate system-images-packages-android-wear-cn
|
||||||
(stdenv.lib.recursiveUpdate system-images-packages-google_apis system-images-packages-google_apis_playstore))));
|
(lib.recursiveUpdate system-images-packages-google_apis system-images-packages-google_apis_playstore))));
|
||||||
|
|
||||||
# Generated addons
|
# Generated addons
|
||||||
addons = import ./generated/addons.nix {
|
addons = import ./generated/addons.nix {
|
||||||
@ -77,15 +77,13 @@ rec {
|
|||||||
};
|
};
|
||||||
|
|
||||||
platform-tools = import ./platform-tools.nix {
|
platform-tools = import ./platform-tools.nix {
|
||||||
inherit deployAndroidPackage os autoPatchelfHook pkgs;
|
inherit deployAndroidPackage os autoPatchelfHook pkgs lib;
|
||||||
inherit (stdenv) lib;
|
|
||||||
package = packages.platform-tools."${platformToolsVersion}";
|
package = packages.platform-tools."${platformToolsVersion}";
|
||||||
};
|
};
|
||||||
|
|
||||||
build-tools = map (version:
|
build-tools = map (version:
|
||||||
import ./build-tools.nix {
|
import ./build-tools.nix {
|
||||||
inherit deployAndroidPackage os autoPatchelfHook makeWrapper pkgs pkgs_i686;
|
inherit deployAndroidPackage os autoPatchelfHook makeWrapper pkgs pkgs_i686 lib;
|
||||||
inherit (stdenv) lib;
|
|
||||||
package = packages.build-tools."${version}";
|
package = packages.build-tools."${version}";
|
||||||
}
|
}
|
||||||
) buildToolsVersions;
|
) buildToolsVersions;
|
||||||
@ -96,8 +94,7 @@ rec {
|
|||||||
};
|
};
|
||||||
|
|
||||||
emulator = import ./emulator.nix {
|
emulator = import ./emulator.nix {
|
||||||
inherit deployAndroidPackage os autoPatchelfHook makeWrapper pkgs pkgs_i686;
|
inherit deployAndroidPackage os autoPatchelfHook makeWrapper pkgs pkgs_i686 lib;
|
||||||
inherit (stdenv) lib;
|
|
||||||
package = packages.emulator."${emulatorVersion}"."${os}";
|
package = packages.emulator."${emulatorVersion}"."${os}";
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -115,7 +112,7 @@ rec {
|
|||||||
}
|
}
|
||||||
) platformVersions;
|
) platformVersions;
|
||||||
|
|
||||||
system-images = stdenv.lib.flatten (map (apiVersion:
|
system-images = lib.flatten (map (apiVersion:
|
||||||
map (type:
|
map (type:
|
||||||
map (abiVersion:
|
map (abiVersion:
|
||||||
deployAndroidPackage {
|
deployAndroidPackage {
|
||||||
@ -124,7 +121,7 @@ rec {
|
|||||||
# Patch 'google_apis' system images so they're recognized by the sdk.
|
# Patch 'google_apis' system images so they're recognized by the sdk.
|
||||||
# Without this, `android list targets` shows 'Tag/ABIs : no ABIs' instead
|
# Without this, `android list targets` shows 'Tag/ABIs : no ABIs' instead
|
||||||
# of 'Tag/ABIs : google_apis*/*' and the emulator fails with an ABI-related error.
|
# of 'Tag/ABIs : google_apis*/*' and the emulator fails with an ABI-related error.
|
||||||
patchInstructions = stdenv.lib.optionalString (stdenv.lib.hasPrefix "google_apis" type) ''
|
patchInstructions = lib.optionalString (lib.hasPrefix "google_apis" type) ''
|
||||||
sed -i '/^Addon.Vendor/d' source.properties
|
sed -i '/^Addon.Vendor/d' source.properties
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
@ -134,23 +131,20 @@ rec {
|
|||||||
|
|
||||||
lldb = map (version:
|
lldb = map (version:
|
||||||
import ./lldb.nix {
|
import ./lldb.nix {
|
||||||
inherit deployAndroidPackage os autoPatchelfHook pkgs;
|
inherit deployAndroidPackage os autoPatchelfHook pkgs lib;
|
||||||
inherit (stdenv) lib;
|
|
||||||
package = packages.lldb."${version}";
|
package = packages.lldb."${version}";
|
||||||
}
|
}
|
||||||
) lldbVersions;
|
) lldbVersions;
|
||||||
|
|
||||||
cmake = map (version:
|
cmake = map (version:
|
||||||
import ./cmake.nix {
|
import ./cmake.nix {
|
||||||
inherit deployAndroidPackage os autoPatchelfHook pkgs;
|
inherit deployAndroidPackage os autoPatchelfHook pkgs lib;
|
||||||
inherit (stdenv) lib;
|
|
||||||
package = packages.cmake."${version}";
|
package = packages.cmake."${version}";
|
||||||
}
|
}
|
||||||
) cmakeVersions;
|
) cmakeVersions;
|
||||||
|
|
||||||
ndk-bundle = import ./ndk-bundle {
|
ndk-bundle = import ./ndk-bundle {
|
||||||
inherit deployAndroidPackage os autoPatchelfHook makeWrapper pkgs platform-tools;
|
inherit deployAndroidPackage os autoPatchelfHook makeWrapper pkgs lib platform-tools;
|
||||||
inherit (stdenv) lib;
|
|
||||||
package = packages.ndk-bundle."${ndkVersion}";
|
package = packages.ndk-bundle."${ndkVersion}";
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -170,24 +164,24 @@ rec {
|
|||||||
|
|
||||||
# Function that automatically links all plugins for which multiple versions can coexist
|
# Function that automatically links all plugins for which multiple versions can coexist
|
||||||
linkPlugins = {name, plugins}:
|
linkPlugins = {name, plugins}:
|
||||||
stdenv.lib.optionalString (plugins != []) ''
|
lib.optionalString (plugins != []) ''
|
||||||
mkdir -p ${name}
|
mkdir -p ${name}
|
||||||
${stdenv.lib.concatMapStrings (plugin: ''
|
${lib.concatMapStrings (plugin: ''
|
||||||
ln -s ${plugin}/libexec/android-sdk/${name}/* ${name}
|
ln -s ${plugin}/libexec/android-sdk/${name}/* ${name}
|
||||||
'') plugins}
|
'') plugins}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# Function that automatically links a plugin for which only one version exists
|
# Function that automatically links a plugin for which only one version exists
|
||||||
linkPlugin = {name, plugin, check ? true}:
|
linkPlugin = {name, plugin, check ? true}:
|
||||||
stdenv.lib.optionalString check ''
|
lib.optionalString check ''
|
||||||
ln -s ${plugin}/libexec/android-sdk/* ${name}
|
ln -s ${plugin}/libexec/android-sdk/* ${name}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# Links all plugins related to a requested platform
|
# Links all plugins related to a requested platform
|
||||||
linkPlatformPlugins = {name, plugins, check}:
|
linkPlatformPlugins = {name, plugins, check}:
|
||||||
stdenv.lib.optionalString check ''
|
lib.optionalString check ''
|
||||||
mkdir -p ${name}
|
mkdir -p ${name}
|
||||||
${stdenv.lib.concatMapStrings (plugin: ''
|
${lib.concatMapStrings (plugin: ''
|
||||||
ln -s ${plugin}/libexec/android-sdk/${name}/* ${name}
|
ln -s ${plugin}/libexec/android-sdk/${name}/* ${name}
|
||||||
'') plugins}
|
'') plugins}
|
||||||
''; # */
|
''; # */
|
||||||
@ -200,8 +194,7 @@ rec {
|
|||||||
https://developer.android.com/studio/terms
|
https://developer.android.com/studio/terms
|
||||||
by setting nixpkgs config option 'android_sdk.accept_license = true;'
|
by setting nixpkgs config option 'android_sdk.accept_license = true;'
|
||||||
'' else import ./tools.nix {
|
'' else import ./tools.nix {
|
||||||
inherit deployAndroidPackage requireFile packages toolsVersion autoPatchelfHook makeWrapper os pkgs pkgs_i686;
|
inherit deployAndroidPackage requireFile packages toolsVersion autoPatchelfHook makeWrapper os pkgs pkgs_i686 lib;
|
||||||
inherit (stdenv) lib;
|
|
||||||
|
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
# Symlink all requested plugins
|
# Symlink all requested plugins
|
||||||
@ -216,9 +209,9 @@ rec {
|
|||||||
${linkPlugins { name = "cmake"; plugins = cmake; }}
|
${linkPlugins { name = "cmake"; plugins = cmake; }}
|
||||||
${linkPlugin { name = "ndk-bundle"; plugin = ndk-bundle; check = includeNDK; }}
|
${linkPlugin { name = "ndk-bundle"; plugin = ndk-bundle; check = includeNDK; }}
|
||||||
|
|
||||||
${stdenv.lib.optionalString includeSystemImages ''
|
${lib.optionalString includeSystemImages ''
|
||||||
mkdir -p system-images
|
mkdir -p system-images
|
||||||
${stdenv.lib.concatMapStrings (system-image: ''
|
${lib.concatMapStrings (system-image: ''
|
||||||
apiVersion=$(basename $(echo ${system-image}/libexec/android-sdk/system-images/*))
|
apiVersion=$(basename $(echo ${system-image}/libexec/android-sdk/system-images/*))
|
||||||
type=$(basename $(echo ${system-image}/libexec/android-sdk/system-images/*/*))
|
type=$(basename $(echo ${system-image}/libexec/android-sdk/system-images/*/*))
|
||||||
mkdir -p system-images/$apiVersion/$type
|
mkdir -p system-images/$apiVersion/$type
|
||||||
@ -230,7 +223,7 @@ rec {
|
|||||||
${linkPlatformPlugins { name = "add-ons"; plugins = google-apis; check = useGoogleTVAddOns; }}
|
${linkPlatformPlugins { name = "add-ons"; plugins = google-apis; check = useGoogleTVAddOns; }}
|
||||||
|
|
||||||
# Link extras
|
# Link extras
|
||||||
${stdenv.lib.concatMapStrings (identifier:
|
${lib.concatMapStrings (identifier:
|
||||||
let
|
let
|
||||||
path = addons.extras."${identifier}".path;
|
path = addons.extras."${identifier}".path;
|
||||||
addon = deployAndroidPackage {
|
addon = deployAndroidPackage {
|
||||||
|
@ -10,12 +10,12 @@ rec {
|
|||||||
};
|
};
|
||||||
|
|
||||||
buildApp = import ./build-app.nix {
|
buildApp = import ./build-app.nix {
|
||||||
inherit (pkgs) stdenv jdk ant gnumake gawk;
|
inherit (pkgs) stdenv lib jdk ant gnumake gawk;
|
||||||
inherit composeAndroidPackages;
|
inherit composeAndroidPackages;
|
||||||
};
|
};
|
||||||
|
|
||||||
emulateApp = import ./emulate-app.nix {
|
emulateApp = import ./emulate-app.nix {
|
||||||
inherit (pkgs) stdenv;
|
inherit (pkgs) stdenv lib;
|
||||||
inherit composeAndroidPackages;
|
inherit composeAndroidPackages;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{ composeAndroidPackages, stdenv }:
|
{ composeAndroidPackages, stdenv, lib }:
|
||||||
{ name, app ? null
|
{ name, app ? null
|
||||||
, platformVersion ? "16", abiVersion ? "armeabi-v7a", systemImageType ? "default"
|
, platformVersion ? "16", abiVersion ? "armeabi-v7a", systemImageType ? "default"
|
||||||
, enableGPU ? false, extraAVDFiles ? []
|
, enableGPU ? false, extraAVDFiles ? []
|
||||||
@ -74,12 +74,12 @@ stdenv.mkDerivation {
|
|||||||
# Create a virtual android device
|
# Create a virtual android device
|
||||||
yes "" | ${sdk}/libexec/android-sdk/tools/android create avd -n device -t 1 --abi ${systemImageType}/${abiVersion} $NIX_ANDROID_AVD_FLAGS
|
yes "" | ${sdk}/libexec/android-sdk/tools/android create avd -n device -t 1 --abi ${systemImageType}/${abiVersion} $NIX_ANDROID_AVD_FLAGS
|
||||||
|
|
||||||
${stdenv.lib.optionalString enableGPU ''
|
${lib.optionalString enableGPU ''
|
||||||
# Enable GPU acceleration
|
# Enable GPU acceleration
|
||||||
echo "hw.gpu.enabled=yes" >> $ANDROID_SDK_HOME/.android/avd/device.avd/config.ini
|
echo "hw.gpu.enabled=yes" >> $ANDROID_SDK_HOME/.android/avd/device.avd/config.ini
|
||||||
''}
|
''}
|
||||||
|
|
||||||
${stdenv.lib.concatMapStrings (extraAVDFile: ''
|
${lib.concatMapStrings (extraAVDFile: ''
|
||||||
ln -sf ${extraAVDFile} $ANDROID_SDK_HOME/.android/avd/device.avd
|
ln -sf ${extraAVDFile} $ANDROID_SDK_HOME/.android/avd/device.avd
|
||||||
'') extraAVDFiles}
|
'') extraAVDFiles}
|
||||||
fi
|
fi
|
||||||
@ -110,7 +110,7 @@ stdenv.mkDerivation {
|
|||||||
|
|
||||||
echo "ready" >&2
|
echo "ready" >&2
|
||||||
|
|
||||||
${stdenv.lib.optionalString (app != null) ''
|
${lib.optionalString (app != null) ''
|
||||||
# Install the App through the debugger, if it has not been installed yet
|
# Install the App through the debugger, if it has not been installed yet
|
||||||
|
|
||||||
if [ -z "${package}" ] || [ "$(${sdk}/libexec/android-sdk/platform-tools/adb -s emulator-$port shell pm list packages | grep package:${package})" = "" ]
|
if [ -z "${package}" ] || [ "$(${sdk}/libexec/android-sdk/platform-tools/adb -s emulator-$port shell pm list packages | grep package:${package})" = "" ]
|
||||||
@ -126,7 +126,7 @@ stdenv.mkDerivation {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Start the application
|
# Start the application
|
||||||
${stdenv.lib.optionalString (package != null && activity != null) ''
|
${lib.optionalString (package != null && activity != null) ''
|
||||||
${sdk}/libexec/android-sdk/platform-tools/adb -s emulator-$port shell am start -a android.intent.action.MAIN -n ${package}/${activity}
|
${sdk}/libexec/android-sdk/platform-tools/adb -s emulator-$port shell am start -a android.intent.action.MAIN -n ${package}/${activity}
|
||||||
''}
|
''}
|
||||||
''}
|
''}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user