a2f85e0fa8
infinite recursion was due to autoPatchelfHook being in buildInputs of platform-tools, i will add a lint for it in nix-community/nixpkgs-lint. ``` $ nix build ".#pkgsCross.aarch64-android-prebuilt.hello" --show-trace 2>&1 | rg 'while evaluating the attr.+deriv' … while evaluating the attribute 'stdenv' of the derivation 'zlib-aarch64-unknown-linux-android-1.2.13' … while evaluating the attribute 'CPPFLAGS' of the derivation 'python3-aarch64-unknown-linux-android-3.10.8' … while evaluating the attribute 'setuptools' of the derivation 'python-catch-conflicts-hook' … while evaluating the attribute 'nativeBuildInputs' of the derivation 'python3.10-pyelftools-0.28' … while evaluating the attribute 'passAsFile' of the derivation 'python3-3.10.8-env' … while evaluating the attribute 'pythonInterpreter' of the derivation 'auto-patchelf-hook' … while evaluating the attribute 'buildInputs' of the derivation 'platform-tools-33.0.2' … while evaluating the attribute 'installPhase' of the derivation 'ndk-24.0.8215888' … while evaluating the attribute 'installPhase' of the derivation 'aarch64-unknown-linux-android-ndk-toolchain-24.0.8215888' … while evaluating the attribute 'bintools_bin' of the derivation 'aarch64-unknown-linux-android-ndk-toolchain-wrapper-24.0.8215888' … while evaluating the attribute 'bintools' of the derivation 'aarch64-unknown-linux-android-ndk-toolchain-wrapper-24.0.8215888' … while evaluating the attribute 'defaultNativeBuildInputs' of the derivation 'stdenv-linux' … while evaluating the attribute 'stdenv' of the derivation 'hello-aarch64-unknown-linux-android-2.12.1' ``` stdenv -> stdenv.cc -> bintools -> android-ndk-toolchain -> ndk -> platform-tools -> auto-patchelf-hook -> python3 -> zlib -> stdenv -> stdenv.cc -> ... autoPatchelfHook was in buildInputs of platform-tools so we needed the host tools to build it but platform-tools was a required tool
45 lines
1.3 KiB
Nix
45 lines
1.3 KiB
Nix
{deployAndroidPackage, lib, package, autoPatchelfHook, makeWrapper, os, pkgs, pkgsi686Linux, postInstall ? ""}:
|
|
|
|
deployAndroidPackage {
|
|
name = "androidsdk";
|
|
inherit os package;
|
|
nativeBuildInputs = [ makeWrapper ]
|
|
++ lib.optionals (os == "linux") [ autoPatchelfHook ];
|
|
buildInputs = lib.optional (os == "linux") (
|
|
(with pkgs; [ glibc freetype fontconfig fontconfig.lib])
|
|
++ (with pkgs.xorg; [ libX11 libXrender libXext ])
|
|
++ (with pkgsi686Linux; [ glibc xorg.libX11 xorg.libXrender xorg.libXext fontconfig.lib freetype zlib ])
|
|
);
|
|
|
|
patchInstructions = ''
|
|
${lib.optionalString (os == "linux") ''
|
|
# Auto patch all binaries
|
|
autoPatchelf .
|
|
''}
|
|
|
|
# Wrap all scripts that require JAVA_HOME
|
|
for i in bin
|
|
do
|
|
find $i -maxdepth 1 -type f -executable | while read program
|
|
do
|
|
if grep -q "JAVA_HOME" $program
|
|
then
|
|
wrapProgram $PWD/$program --prefix PATH : ${pkgs.jdk8}/bin
|
|
fi
|
|
done
|
|
done
|
|
|
|
# Wrap monitor script
|
|
wrapProgram $PWD/monitor \
|
|
--prefix PATH : ${pkgs.jdk8}/bin \
|
|
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ pkgs.xorg.libX11 pkgs.xorg.libXtst ]}
|
|
|
|
# Patch all script shebangs
|
|
patchShebangs .
|
|
|
|
cd ..
|
|
${postInstall}
|
|
'';
|
|
|
|
meta.license = lib.licenses.unfree;
|
|
}
|