Files
nixpkgs/pkgs/development/mobile/xcodeenv/simulate-app.nix
T
Silvan Mosberger 4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build https://github.com/infinisil/treewide-nixpkgs-reformat-script/archive/a08b3a4d199c6124ac5b36a889d9099b4383463f.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00

66 lines
1.6 KiB
Nix

{
stdenv,
lib,
composeXcodeWrapper,
}:
{
name,
app ? null,
bundleId ? null,
...
}@args:
assert app != null -> bundleId != null;
let
xcodewrapperArgs = builtins.intersectAttrs (builtins.functionArgs composeXcodeWrapper) args;
xcodewrapper = composeXcodeWrapper xcodewrapperArgs;
in
stdenv.mkDerivation {
name = lib.replaceStrings [ " " ] [ "" ] name;
buildCommand = ''
mkdir -p $out/bin
cat > $out/bin/run-test-simulator << "EOF"
#! ${stdenv.shell} -e
if [ "$1" = "" ]
then
# Show the user the possibile UDIDs and let him pick one, if none is provided as a command-line parameter
xcrun simctl list
echo "Please provide a UDID of a simulator:"
read udid
else
# If a parameter has been provided, consider that a device UDID and use that
udid="$1"
fi
# Open the simulator instance
open -a "$(readlink "${xcodewrapper}/bin/Simulator")" --args -CurrentDeviceUDID $udid
${lib.optionalString (app != null) ''
# Copy the app and restore the write permissions
appTmpDir=$(mktemp -d -t appTmpDir)
cp -r "$(echo ${app}/*.app)" "$appTmpDir"
chmod -R 755 "$(echo $appTmpDir/*.app)"
# Wait for the simulator to start
echo "Press enter when the simulator is started..."
read
# Install the app
xcrun simctl install "$udid" "$(echo $appTmpDir/*.app)"
# Remove the app tempdir
rm -Rf $appTmpDir
# Launch the app in the simulator
xcrun simctl launch $udid "${bundleId}"
EOF
chmod +x $out/bin/run-test-simulator
''}
'';
}