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