Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ stdenv, lib }: 2{ version ? "11.1" 3, allowHigher ? false 4, xcodeBaseDir ? "/Applications/Xcode.app" }: 5 6assert stdenv.isDarwin; 7 8stdenv.mkDerivation { 9 pname = "xcode-wrapper${lib.optionalString allowHigher "-plus"}"; 10 inherit version; 11 # Fails in sandbox. Use `--option sandbox relaxed` or `--option sandbox false`. 12 __noChroot = true; 13 buildCommand = '' 14 mkdir -p $out/bin 15 cd $out/bin 16 ln -s /usr/bin/xcode-select 17 ln -s /usr/bin/security 18 ln -s /usr/bin/codesign 19 ln -s /usr/bin/xcrun 20 ln -s /usr/bin/plutil 21 ln -s /usr/bin/clang 22 ln -s /usr/bin/lipo 23 ln -s /usr/bin/file 24 ln -s /usr/bin/rev 25 ln -s "${xcodeBaseDir}/Contents/Developer/usr/bin/xcodebuild" 26 ln -s "${xcodeBaseDir}/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator" 27 28 cd .. 29 ln -s "${xcodeBaseDir}/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs" 30 31 # Check if we have the xcodebuild version that we want 32 currVer=$($out/bin/xcodebuild -version | head -n1) 33 ${if allowHigher then '' 34 if [ -z "$(printf '%s\n' "${version}" "$currVer" | sort -V | head -n1)""" != "${version}" ] 35 '' else '' 36 if [ -z "$(echo $currVer | grep -x 'Xcode ${version}')" ] 37 ''} 38 then 39 echo "We require xcodebuild version${if allowHigher then " or higher" else ""}: ${version}" 40 echo "Instead what was found: $currVer" 41 exit 1 42 fi 43 ''; 44}