nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at 20.03 45 lines 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 name = package.name + "-" + package.revision; 9 src = if os != null && builtins.hasAttr os package.archives then package.archives.${os} else package.archives.all; 10 buildInputs = [ unzip ] ++ buildInputs; 11 preferLocalBuild = true; 12 13 # Most Android Zip packages have a root folder, but some don't. We unpack 14 # the zip file in a folder and we try to discover whether it has a single root 15 # folder. If this is the case, we adjust the current working folder. 16 unpackPhase = '' 17 mkdir extractedzip 18 cd extractedzip 19 unpackFile "$src" 20 if [ "$(find . -mindepth 1 -maxdepth 1 -type d | wc -l)" -eq 1 ] 21 then 22 cd "$(find . -mindepth 1 -maxdepth 1 -type d)" 23 fi 24 sourceRoot="$PWD" 25 ''; 26 27 installPhase = '' 28 packageBaseDir=$out/libexec/android-sdk/${package.path} 29 mkdir -p $packageBaseDir 30 cd $packageBaseDir 31 cp -av $sourceRoot/* . 32 ${patchInstructions} 33 ''; 34 35 # We never attempt to strip. This is not required since we're doing binary 36 # deployments. Moreover, some executables that have been patched with patchelf 37 # may not work any longer after they have been stripped. 38 dontStrip = true; 39 dontPatchELF = true; 40 dontAutoPatchelf = true; 41 42 meta = { 43 description = package.displayName; 44 } // meta; 45} // extraParams)