Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{stdenv, lib, composeXcodeWrapper}: 2{name, app ? null, bundleId ? null, ...}@args: 3 4assert app != null -> bundleId != null; 5 6let 7 xcodewrapperArgs = builtins.intersectAttrs (builtins.functionArgs composeXcodeWrapper) args; 8 9 xcodewrapper = composeXcodeWrapper xcodewrapperArgs; 10in 11stdenv.mkDerivation { 12 name = lib.replaceStrings [" "] [""] name; 13 buildCommand = '' 14 mkdir -p $out/bin 15 cat > $out/bin/run-test-simulator << "EOF" 16 #! ${stdenv.shell} -e 17 18 if [ "$1" = "" ] 19 then 20 # Show the user the possibile UDIDs and let him pick one, if none is provided as a command-line parameter 21 xcrun simctl list 22 23 echo "Please provide a UDID of a simulator:" 24 read udid 25 else 26 # If a parameter has been provided, consider that a device UDID and use that 27 udid="$1" 28 fi 29 30 # Open the simulator instance 31 open -a "$(readlink "${xcodewrapper}/bin/Simulator")" --args -CurrentDeviceUDID $udid 32 33 ${lib.optionalString (app != null) '' 34 # Copy the app and restore the write permissions 35 appTmpDir=$(mktemp -d -t appTmpDir) 36 cp -r "$(echo ${app}/*.app)" "$appTmpDir" 37 chmod -R 755 "$(echo $appTmpDir/*.app)" 38 39 # Wait for the simulator to start 40 echo "Press enter when the simulator is started..." 41 read 42 43 # Install the app 44 xcrun simctl install "$udid" "$(echo $appTmpDir/*.app)" 45 46 # Remove the app tempdir 47 rm -Rf $appTmpDir 48 49 # Launch the app in the simulator 50 xcrun simctl launch $udid "${bundleId}" 51 EOF 52 53 chmod +x $out/bin/run-test-simulator 54 ''} 55 ''; 56}