···1-{stdenv, unzip}:
2-{package, os ? null, buildInputs ? [], patchInstructions ? "", meta ? {}, ...}@args:
3-4-let
5- extraParams = removeAttrs args [ "package" "os" "buildInputs" "patchInstructions" ];
6-in
7-stdenv.mkDerivation ({
8- pname = package.name;
9- version = package.revision;
10- src = if os != null && builtins.hasAttr os package.archives then package.archives.${os} else package.archives.all;
11- buildInputs = [ unzip ] ++ buildInputs;
12- preferLocalBuild = true;
13-14- # Most Android Zip packages have a root folder, but some don't. We unpack
15- # the zip file in a folder and we try to discover whether it has a single root
16- # folder. If this is the case, we adjust the current working folder.
17- unpackPhase = ''
18- mkdir extractedzip
19- cd extractedzip
20- unpackFile "$src"
21- if [ "$(find . -mindepth 1 -maxdepth 1 -type d | wc -l)" -eq 1 ]
22- then
23- cd "$(find . -mindepth 1 -maxdepth 1 -type d)"
24- fi
25- sourceRoot="$PWD"
26- '';
27-28- installPhase = ''
29- packageBaseDir=$out/libexec/android-sdk/${package.path}
30- mkdir -p $packageBaseDir
31- cd $packageBaseDir
32- cp -a $sourceRoot/* .
33- ${patchInstructions}
34- '';
35-36- # We never attempt to strip. This is not required since we're doing binary
37- # deployments. Moreover, some executables that have been patched with patchelf
38- # may not work any longer after they have been stripped.
39- dontStrip = true;
40- dontPatchELF = true;
41- dontAutoPatchelf = true;
42-43- meta = {
44- description = package.displayName;
45- } // meta;
46-} // extraParams)
···1+{stdenv, lib, unzip, mkLicenses}:
2+{packages, os ? null, nativeBuildInputs ? [], buildInputs ? [], patchesInstructions ? {}, meta ? {}, ...}@args:
3+4+let
5+ extraParams = removeAttrs args [ "packages" "os" "buildInputs" "nativeBuildInputs" "patchesInstructions" ];
6+ sortedPackages = builtins.sort (x: y: builtins.lessThan x.name y.name) packages;
7+in
8+stdenv.mkDerivation ({
9+ inherit buildInputs;
10+ pname = lib.concatMapStringsSep "-" (package: package.name) sortedPackages;
11+ version = lib.concatMapStringsSep "-" (package: package.revision) sortedPackages;
12+ src = map (package:
13+ if os != null && builtins.hasAttr os package.archives then package.archives.${os} else package.archives.all
14+ ) packages;
15+ nativeBuildInputs = [ unzip ] ++ nativeBuildInputs;
16+ preferLocalBuild = true;
17+18+ unpackPhase = ''
19+ buildDir=$PWD
20+ i=0
21+ for srcArchive in $src; do
22+ extractedZip="extractedzip-$i"
23+ i=$((i+1))
24+ cd "$buildDir"
25+ mkdir "$extractedZip"
26+ cd "$extractedZip"
27+ unpackFile "$srcArchive"
28+ done
29+ '';
30+31+ installPhase = lib.concatStrings (lib.imap0 (i: package: ''
32+ cd $buildDir/extractedzip-${toString i}
33+34+ # Most Android Zip packages have a root folder, but some don't. We unpack
35+ # the zip file in a folder and we try to discover whether it has a single root
36+ # folder. If this is the case, we adjust the current working folder.
37+ if [ "$(find . -mindepth 1 -maxdepth 1 -type d | wc -l)" -eq 1 ]; then
38+ cd "$(find . -mindepth 1 -maxdepth 1 -type d)"
39+ fi
40+ extractedZip="$PWD"
41+42+ packageBaseDir=$out/libexec/android-sdk/${package.path}
43+ mkdir -p $packageBaseDir
44+ cd $packageBaseDir
45+ cp -a $extractedZip/* .
46+ ${patchesInstructions.${package.name}}
47+ '') packages);
48+49+ # Some executables that have been patched with patchelf may not work any longer after they have been stripped.
50+ dontStrip = true;
51+ dontPatchELF = true;
52+ dontAutoPatchelf = true;
53+54+ meta = {
55+ description = lib.concatMapStringsSep "\n" (package: package.displayName) packages;
56+ } // meta;
57+} // extraParams)