2016-12-20 12:33:27 +01:00
|
|
|
{ stdenv, fetchurl, xar, gzip, cpio, pkgs }:
|
2015-06-21 00:29:42 +02:00
|
|
|
|
|
|
|
let
|
2015-06-22 05:29:33 +02:00
|
|
|
# sadly needs to be exported because security_tool needs it
|
2015-06-21 00:29:42 +02:00
|
|
|
sdk = stdenv.mkDerivation rec {
|
2016-12-20 12:33:27 +01:00
|
|
|
version = "10.9";
|
2015-06-21 00:29:42 +02:00
|
|
|
name = "MacOS_SDK-${version}";
|
|
|
|
|
|
|
|
src = fetchurl {
|
2016-12-20 12:33:27 +01:00
|
|
|
url = "http://swcdn.apple.com/content/downloads/27/02/031-06182/xxog8vxu8i6af781ivf4uhy6yt1lslex34/DevSDK_OSX109.pkg";
|
|
|
|
sha256 = "16b7aplha5573yl1d44nl2yxzp0w2hafihbyh7930wrcvba69iy4";
|
2015-06-21 00:29:42 +02:00
|
|
|
};
|
|
|
|
|
2016-12-20 12:33:27 +01:00
|
|
|
buildInputs = [ xar gzip cpio ];
|
2015-06-21 00:29:42 +02:00
|
|
|
|
|
|
|
phases = [ "unpackPhase" "installPhase" "fixupPhase" ];
|
|
|
|
|
|
|
|
unpackPhase = ''
|
|
|
|
xar -x -f $src
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
start="$(pwd)"
|
|
|
|
mkdir -p $out
|
|
|
|
cd $out
|
2016-12-20 12:33:27 +01:00
|
|
|
cat $start/Payload | gzip -d | cpio -idm
|
2015-06-21 00:29:42 +02:00
|
|
|
|
|
|
|
mv usr/* .
|
|
|
|
rmdir usr
|
|
|
|
|
|
|
|
mv System/* .
|
|
|
|
rmdir System
|
|
|
|
|
2016-11-11 23:29:50 +01:00
|
|
|
pushd lib
|
|
|
|
ln -s -L /usr/lib/libcups*.dylib .
|
|
|
|
popd
|
|
|
|
|
2015-06-21 00:29:42 +02:00
|
|
|
cd Library/Frameworks/QuartzCore.framework/Versions/A/Headers
|
|
|
|
for file in CI*.h; do
|
|
|
|
rm $file
|
2015-10-27 01:12:45 +01:00
|
|
|
ln -s ../Frameworks/CoreImage.framework/Headers/$file
|
2015-06-21 00:29:42 +02:00
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "Apple SDK ${version}";
|
|
|
|
maintainers = with maintainers; [ copumpkin ];
|
|
|
|
platforms = platforms.darwin;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
framework = name: deps: stdenv.mkDerivation {
|
|
|
|
name = "apple-framework-${name}";
|
|
|
|
|
|
|
|
phases = [ "installPhase" "fixupPhase" ];
|
|
|
|
|
2015-10-06 09:11:00 +02:00
|
|
|
# because we copy files from the system
|
|
|
|
preferLocalBuild = true;
|
|
|
|
|
2015-06-21 00:29:42 +02:00
|
|
|
installPhase = ''
|
|
|
|
linkFramework() {
|
|
|
|
local path="$1"
|
|
|
|
local dest="$out/Library/Frameworks/$path"
|
|
|
|
local name="$(basename "$path" .framework)"
|
|
|
|
local current="$(readlink "/System/Library/Frameworks/$path/Versions/Current")"
|
2015-10-26 20:38:57 +01:00
|
|
|
if [ -z "$current" ]; then
|
|
|
|
current=A
|
|
|
|
fi
|
2015-06-21 00:29:42 +02:00
|
|
|
|
|
|
|
mkdir -p "$dest"
|
|
|
|
pushd "$dest" >/dev/null
|
|
|
|
|
2016-03-11 21:11:02 +01:00
|
|
|
# Keep track of if this is a child or a child rescue as with
|
|
|
|
# ApplicationServices in the 10.9 SDK
|
|
|
|
local isChild
|
|
|
|
|
|
|
|
if [ -d "${sdk}/Library/Frameworks/$path/Versions/$current/Headers" ]; then
|
|
|
|
isChild=1
|
|
|
|
cp -R "${sdk}/Library/Frameworks/$path/Versions/$current/Headers" .
|
|
|
|
else
|
|
|
|
isChild=0
|
|
|
|
current="$(readlink "/System/Library/Frameworks/$name.framework/Versions/Current")"
|
|
|
|
cp -R "${sdk}/Library/Frameworks/$name.framework/Versions/$current/Headers" .
|
|
|
|
fi
|
2015-06-21 00:29:42 +02:00
|
|
|
ln -s -L "/System/Library/Frameworks/$path/Versions/$current/$name"
|
|
|
|
ln -s -L "/System/Library/Frameworks/$path/Versions/$current/Resources"
|
|
|
|
|
|
|
|
if [ -f "/System/Library/Frameworks/$path/module.map" ]; then
|
|
|
|
ln -s "/System/Library/Frameworks/$path/module.map"
|
|
|
|
fi
|
|
|
|
|
2016-03-11 21:11:02 +01:00
|
|
|
if [ $isChild -eq 1 ]; then
|
|
|
|
pushd "${sdk}/Library/Frameworks/$path/Versions/$current" >/dev/null
|
|
|
|
else
|
|
|
|
pushd "${sdk}/Library/Frameworks/$name.framework/Versions/$current" >/dev/null
|
|
|
|
fi
|
2015-06-21 00:29:42 +02:00
|
|
|
local children=$(echo Frameworks/*.framework)
|
2016-03-11 21:11:02 +01:00
|
|
|
if [ "$name" == "ApplicationServices" ]; then
|
|
|
|
# Fixing up ApplicationServices which is missing
|
|
|
|
# CoreGraphics in the 10.9 SDK
|
|
|
|
children="$children Frameworks/CoreGraphics.framework"
|
|
|
|
fi
|
2015-06-21 00:29:42 +02:00
|
|
|
popd >/dev/null
|
|
|
|
|
|
|
|
for child in $children; do
|
|
|
|
childpath="$path/Versions/$current/$child"
|
|
|
|
linkFramework "$childpath"
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -d "$dest/Versions/$current" ]; then
|
|
|
|
mv $dest/Versions/$current/* .
|
|
|
|
fi
|
|
|
|
|
|
|
|
popd >/dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
linkFramework "${name}.framework"
|
|
|
|
'';
|
|
|
|
|
|
|
|
propagatedBuildInputs = deps;
|
|
|
|
|
2015-11-13 03:59:17 +01:00
|
|
|
# allows building the symlink tree
|
2015-11-25 19:09:35 +01:00
|
|
|
__impureHostDeps = [ "/System/Library/Frameworks/${name}.framework" ];
|
2015-11-13 03:59:17 +01:00
|
|
|
|
2015-11-22 00:59:43 +01:00
|
|
|
__propagatedImpureHostDeps = stdenv.lib.optional (name != "Kernel") "/System/Library/Frameworks/${name}.framework/${name}";
|
2015-06-21 00:29:42 +02:00
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "Apple SDK framework ${name}";
|
|
|
|
maintainers = with maintainers; [ copumpkin ];
|
|
|
|
platforms = platforms.darwin;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in rec {
|
|
|
|
libs = {
|
|
|
|
xpc = stdenv.mkDerivation {
|
|
|
|
name = "apple-lib-xpc";
|
|
|
|
phases = [ "installPhase" "fixupPhase" ];
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/include
|
|
|
|
pushd $out/include >/dev/null
|
|
|
|
ln -s "${sdk}/include/xpc"
|
|
|
|
popd >/dev/null
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
Xplugin = stdenv.mkDerivation {
|
|
|
|
name = "apple-lib-Xplugin";
|
|
|
|
phases = [ "installPhase" "fixupPhase" ];
|
|
|
|
|
|
|
|
# Not enough
|
|
|
|
__propagatedImpureHostDeps = [ "/usr/lib/libXplugin.1.dylib" ];
|
|
|
|
|
|
|
|
propagatedBuildInputs = with frameworks; [
|
2015-10-28 20:14:42 +01:00
|
|
|
OpenGL ApplicationServices Carbon IOKit pkgs.darwin.CF CoreGraphics CoreServices CoreText
|
2015-06-21 00:29:42 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/include $out/lib
|
|
|
|
ln -s "${sdk}/include/Xplugin.h" $out/include/Xplugin.h
|
|
|
|
ln -s "/usr/lib/libXplugin.1.dylib" $out/lib/libXplugin.dylib
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
utmp = stdenv.mkDerivation {
|
|
|
|
name = "apple-lib-utmp";
|
|
|
|
phases = [ "installPhase" "fixupPhase" ];
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/include
|
|
|
|
pushd $out/include >/dev/null
|
|
|
|
ln -s "${sdk}/include/utmp.h"
|
|
|
|
ln -s "${sdk}/include/utmpx.h"
|
|
|
|
popd >/dev/null
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2015-10-01 02:13:56 +02:00
|
|
|
overrides = super: {
|
|
|
|
QuartzCore = stdenv.lib.overrideDerivation super.QuartzCore (drv: {
|
|
|
|
installPhase = drv.installPhase + ''
|
|
|
|
f="$out/Library/Frameworks/QuartzCore.framework/Headers/CoreImage.h"
|
|
|
|
substituteInPlace "$f" \
|
|
|
|
--replace "QuartzCore/../Frameworks/CoreImage.framework/Headers" "CoreImage"
|
|
|
|
'';
|
|
|
|
});
|
2015-10-28 20:14:42 +01:00
|
|
|
|
2015-11-13 03:59:17 +01:00
|
|
|
CoreServices = stdenv.lib.overrideDerivation super.CoreServices (drv: {
|
2015-11-21 21:06:41 +01:00
|
|
|
__propagatedSandboxProfile = drv.__propagatedSandboxProfile ++ [''
|
2015-11-13 03:59:17 +01:00
|
|
|
(allow mach-lookup (global-name "com.apple.CoreServices.coreservicesd"))
|
|
|
|
''];
|
|
|
|
});
|
|
|
|
|
2015-10-28 20:14:42 +01:00
|
|
|
Security = stdenv.lib.overrideDerivation super.Security (drv: {
|
|
|
|
setupHook = ./security-setup-hook.sh;
|
|
|
|
});
|
2015-10-01 02:13:56 +02:00
|
|
|
};
|
|
|
|
|
2015-10-28 20:14:42 +01:00
|
|
|
bareFrameworks = stdenv.lib.mapAttrs framework (import ./frameworks.nix {
|
|
|
|
inherit frameworks libs;
|
|
|
|
inherit (pkgs.darwin) CF cf-private libobjc;
|
|
|
|
});
|
2015-10-01 02:13:56 +02:00
|
|
|
|
|
|
|
frameworks = bareFrameworks // overrides bareFrameworks;
|
2015-07-08 23:14:27 +02:00
|
|
|
|
2015-11-21 21:06:41 +01:00
|
|
|
inherit sdk;
|
2015-06-21 00:29:42 +02:00
|
|
|
}
|