xcodeenv: allow versions higher than specified
Add `allowHigher` option to let higher versions of Xcode. This is useful when xcodeenv is used for `nix-shell` for developers and their xcode version might be a bit newer than required one. Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
65277def0f
commit
ae08ff7b71
2 changed files with 18 additions and 15 deletions
|
@ -1,10 +1,13 @@
|
||||||
{stdenv}:
|
{ stdenv, lib }:
|
||||||
{version ? "11.1", xcodeBaseDir ? "/Applications/Xcode.app"}:
|
{ version ? "11.1"
|
||||||
|
, allowHigher ? false
|
||||||
|
, xcodeBaseDir ? "/Applications/Xcode.app" }:
|
||||||
|
|
||||||
assert stdenv.isDarwin;
|
assert stdenv.isDarwin;
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "xcode-wrapper-"+version;
|
pname = "xcode-wrapper${lib.optionalString allowHigher "-plus"}";
|
||||||
|
inherit version;
|
||||||
buildCommand = ''
|
buildCommand = ''
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
cd $out/bin
|
cd $out/bin
|
||||||
|
@ -24,9 +27,15 @@ stdenv.mkDerivation {
|
||||||
ln -s "${xcodeBaseDir}/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs"
|
ln -s "${xcodeBaseDir}/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs"
|
||||||
|
|
||||||
# Check if we have the xcodebuild version that we want
|
# Check if we have the xcodebuild version that we want
|
||||||
if [ -z "$($out/bin/xcodebuild -version | grep -x 'Xcode ${version}')" ]
|
currVer=$($out/bin/xcodebuild -version | head -n1)
|
||||||
|
${if allowHigher then ''
|
||||||
|
if [ -z "$(printf '%s\n' "${version}" "$currVer" | sort -V | head -n1)""" != "${version}" ]
|
||||||
|
'' else ''
|
||||||
|
if [ -z "$(echo $currVer | grep -x 'Xcode ${version}')" ]
|
||||||
|
''}
|
||||||
then
|
then
|
||||||
echo "We require xcodebuild version: ${version}"
|
echo "We require xcodebuild version${if allowHigher then " or higher" else ""}: ${version}"
|
||||||
|
echo "Instead what was found: $currVer"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -1,15 +1,9 @@
|
||||||
{ stdenv, lib }:
|
{ callPackage }:
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
composeXcodeWrapper = import ./compose-xcodewrapper.nix {
|
composeXcodeWrapper = callPackage ./compose-xcodewrapper.nix { };
|
||||||
inherit stdenv;
|
|
||||||
};
|
|
||||||
|
|
||||||
buildApp = import ./build-app.nix {
|
buildApp = callPackage ./build-app.nix { inherit composeXcodeWrapper; };
|
||||||
inherit stdenv lib composeXcodeWrapper;
|
|
||||||
};
|
|
||||||
|
|
||||||
simulateApp = import ./simulate-app.nix {
|
simulateApp = callPackage ./simulate-app.nix { inherit composeXcodeWrapper; };
|
||||||
inherit stdenv lib composeXcodeWrapper;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue