-
-
Notifications
You must be signed in to change notification settings - Fork 14k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
androidenv: Replace deploy-androidpackage.nix with deploy-androidpack…
…ages.nix
- Loading branch information
Showing
3 changed files
with
70 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 0 additions & 46 deletions
46
pkgs/development/mobile/androidenv/deploy-androidpackage.nix
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
pkgs/development/mobile/androidenv/deploy-androidpackages.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{stdenv, lib, unzip, mkLicenses}: | ||
{packages, os ? null, buildInputs ? [], patchesInstructions ? {}, meta ? {}, ...}@args: | ||
|
||
let | ||
extraParams = removeAttrs args [ "packages" "os" "buildInputs" "patchesInstructions" ]; | ||
sortedPackages = builtins.sort (x: y: builtins.lessThan x.name y.name) packages; | ||
in | ||
stdenv.mkDerivation ({ | ||
pname = lib.concatMapStringsSep "-" (package: package.name) sortedPackages; | ||
version = lib.concatMapStringsSep "-" (package: package.revision) sortedPackages; | ||
src = map (package: | ||
if os != null && builtins.hasAttr os package.archives then package.archives.${os} else package.archives.all | ||
) packages; | ||
buildInputs = [ unzip ] ++ buildInputs; | ||
preferLocalBuild = true; | ||
|
||
unpackPhase = '' | ||
buildDir=$PWD | ||
i=0 | ||
for srcArchive in $src; do | ||
extractedZip="extractedzip-$i" | ||
i=$((i+1)) | ||
cd "$buildDir" | ||
mkdir "$extractedZip" | ||
cd "$extractedZip" | ||
unpackFile "$srcArchive" | ||
done | ||
''; | ||
|
||
installPhase = lib.concatStrings (lib.imap0 (i: package: '' | ||
cd $buildDir/extractedzip-${toString i} | ||
# Most Android Zip packages have a root folder, but some don't. We unpack | ||
# the zip file in a folder and we try to discover whether it has a single root | ||
# folder. If this is the case, we adjust the current working folder. | ||
if [ "$(find . -mindepth 1 -maxdepth 1 -type d | wc -l)" -eq 1 ]; then | ||
cd "$(find . -mindepth 1 -maxdepth 1 -type d)" | ||
fi | ||
extractedZip="$PWD" | ||
packageBaseDir=$out/libexec/android-sdk/${package.path} | ||
mkdir -p $packageBaseDir | ||
cd $packageBaseDir | ||
cp -a $extractedZip/* . | ||
${patchesInstructions.${package.name}} | ||
'') packages); | ||
|
||
# We never attempt to strip. This is not required since we're doing binary | ||
# deployments. Moreover, some executables that have been patched with patchelf | ||
# may not work any longer after they have been stripped. | ||
dontStrip = true; | ||
dontPatchELF = true; | ||
dontAutoPatchelf = true; | ||
|
||
meta = { | ||
description = lib.concatMapStringsSep "\n" (package: package.displayName) packages; | ||
} // meta; | ||
} // extraParams) |