at 23.05-pre 1.5 kB view raw
1{stdenv, unzip}: 2{package, os ? null, buildInputs ? [], patchInstructions ? "", meta ? {}, ...}@args: 3 4let 5 extraParams = removeAttrs args [ "package" "os" "buildInputs" "patchInstructions" ]; 6in 7stdenv.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)