nixpkgs-suyu/pkgs/os-specific/darwin/apple-sdk/default.nix

173 lines
4.8 KiB
Nix
Raw Normal View History

{ stdenv, fetchurl, xar, gzip, cpio, CF, 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 {
version = "10.9";
name = "MacOS_SDK-${version}";
src = fetchurl {
url = "http://swcdn.apple.com/content/downloads/27/02/031-06182/xxog8vxu8i6af781ivf4uhy6yt1lslex34/DevSDK_OSX109.pkg";
sha256 = "16b7aplha5573yl1d44nl2yxzp0w2hafihbyh7930wrcvba69iy4";
};
buildInputs = [ xar gzip cpio ];
phases = [ "unpackPhase" "installPhase" "fixupPhase" ];
unpackPhase = ''
xar -x -f $src
'';
installPhase = ''
start="$(pwd)"
mkdir -p $out
cd $out
cat $start/Payload | gzip -d | cpio -idm
mv usr/* .
rmdir usr
mv System/* .
rmdir System
cd Library/Frameworks/QuartzCore.framework/Versions/A/Headers
for file in CI*.h; do
rm $file
ln -s ../Frameworks/CoreImage.framework/Versions/A/Headers/$file
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" ];
# 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")"
if [ -z "$current" ]; then
current=A
fi
2015-06-21 00:29:42 +02:00
mkdir -p "$dest"
pushd "$dest" >/dev/null
cp -R "${sdk}/Library/Frameworks/$path/Versions/$current/Headers" .
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
pushd "${sdk}/Library/Frameworks/$path/Versions/$current" >/dev/null
local children=$(echo Frameworks/*.framework)
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;
# Not going to bother being more precise than this...
2015-07-01 01:11:04 +02:00
__propagatedImpureHostDeps = (import ./impure-deps.nix).${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; [
OpenGL ApplicationServices Carbon IOKit 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: {
2015-10-16 05:49:29 +02:00
CoreText = stdenv.lib.overrideDerivation super.CoreText (drv: {
propagatedNativeBuildInputs = drv.propagatedNativeBuildInputs ++ [ pkgs.darwin.cf-private ];
});
2015-10-01 02:13:56 +02:00
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"
'';
});
};
bareFrameworks = stdenv.lib.mapAttrs framework (import ./frameworks.nix { inherit frameworks libs CF; });
frameworks = bareFrameworks // overrides bareFrameworks;
inherit sdk;
2015-06-21 00:29:42 +02:00
}