2019-02-07 02:13:51 +01:00
|
|
|
{ stdenv, fetchurl, xar, cpio, pkgs, python, pbzx, lib }:
|
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 {
|
2019-02-07 02:13:51 +01:00
|
|
|
version = "10.12";
|
2019-08-15 14:41:18 +02:00
|
|
|
pname = "MacOS_SDK";
|
2015-06-21 00:29:42 +02:00
|
|
|
|
2019-02-07 02:13:51 +01:00
|
|
|
# This URL comes from https://swscan.apple.com/content/catalogs/others/index-10.12.merged-1.sucatalog, which we found by:
|
2017-03-15 03:36:21 +01:00
|
|
|
# 1. Google: site:swscan.apple.com and look for a name that seems appropriate for your version
|
|
|
|
# 2. In the resulting file, search for a file called DevSDK ending in .pkg
|
|
|
|
# 3. ???
|
|
|
|
# 4. Profit
|
2015-06-21 00:29:42 +02:00
|
|
|
src = fetchurl {
|
2019-02-07 02:13:51 +01:00
|
|
|
url = "http://swcdn.apple.com/content/downloads/28/09/091-29862/pafhn2u002b9slnrxzy9p86rpedycnjhb5/DevSDK_OSX1012.pkg";
|
|
|
|
sha256 = "1sggc70rypqwcjwr7ciavw8sczwll16cwqxdxrbw7r2qvy3b0nhx";
|
2015-06-21 00:29:42 +02:00
|
|
|
};
|
|
|
|
|
2019-02-07 02:13:51 +01:00
|
|
|
buildInputs = [ xar cpio python pbzx ];
|
2015-06-21 00:29:42 +02:00
|
|
|
|
|
|
|
phases = [ "unpackPhase" "installPhase" "fixupPhase" ];
|
2018-06-09 05:57:36 +02:00
|
|
|
outputs = [ "out" "dev" "man" ];
|
2015-06-21 00:29:42 +02:00
|
|
|
|
|
|
|
unpackPhase = ''
|
|
|
|
xar -x -f $src
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
start="$(pwd)"
|
|
|
|
mkdir -p $out
|
|
|
|
cd $out
|
2019-02-07 02:13:51 +01:00
|
|
|
pbzx -n $start/Payload | 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
|
|
|
'';
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2018-07-04 21:08:35 +02:00
|
|
|
disallowedRequisites = [ sdk ];
|
|
|
|
|
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
|
2019-03-10 02:13:00 +01:00
|
|
|
local isChild=0
|
2016-03-11 21:11:02 +01:00
|
|
|
|
2018-06-09 05:57:36 +02:00
|
|
|
if [ -d "${sdk.out}/Library/Frameworks/$path/Versions/$current/Headers" ]; then
|
2016-03-11 21:11:02 +01:00
|
|
|
isChild=1
|
2018-06-09 05:57:36 +02:00
|
|
|
cp -R "${sdk.out}/Library/Frameworks/$path/Versions/$current/Headers" .
|
2019-03-10 02:13:00 +01:00
|
|
|
elif [ -d "${sdk.out}/Library/Frameworks/$name.framework/Versions/$current/Headers" ]; then
|
2016-03-11 21:11:02 +01:00
|
|
|
current="$(readlink "/System/Library/Frameworks/$name.framework/Versions/Current")"
|
2018-06-09 05:57:36 +02:00
|
|
|
cp -R "${sdk.out}/Library/Frameworks/$name.framework/Versions/$current/Headers" .
|
2016-03-11 21:11:02 +01:00
|
|
|
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
|
2018-06-09 05:57:36 +02:00
|
|
|
pushd "${sdk.out}/Library/Frameworks/$path/Versions/$current" >/dev/null
|
2016-03-11 21:11:02 +01:00
|
|
|
else
|
2018-06-09 05:57:36 +02:00
|
|
|
pushd "${sdk.out}/Library/Frameworks/$name.framework/Versions/$current" >/dev/null
|
2016-03-11 21:11:02 +01:00
|
|
|
fi
|
2015-06-21 00:29:42 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2017-03-15 03:36:21 +01:00
|
|
|
|
2015-06-21 00:29:42 +02:00
|
|
|
linkFramework "${name}.framework"
|
|
|
|
'';
|
|
|
|
|
|
|
|
propagatedBuildInputs = deps;
|
|
|
|
|
2017-03-07 22:10:07 +01:00
|
|
|
# don't use pure CF for dylibs that depend on frameworks
|
2017-07-22 13:31:48 +02:00
|
|
|
setupHook = ./framework-setup-hook.sh;
|
2017-03-07 22:10:07 +01:00
|
|
|
|
2017-10-31 12:58:08 +01:00
|
|
|
# Not going to be more specific than this for now
|
|
|
|
__propagatedImpureHostDeps = stdenv.lib.optionals (name != "Kernel") [
|
|
|
|
# The setup-hook ensures that everyone uses the impure CoreFoundation who uses these SDK frameworks, so let's expose it
|
|
|
|
"/System/Library/Frameworks/CoreFoundation.framework"
|
|
|
|
"/System/Library/Frameworks/${name}.framework"
|
|
|
|
"/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
|
2018-07-02 23:49:59 +02:00
|
|
|
cp -r "${lib.getDev sdk}/include/xpc" $out/include/xpc
|
|
|
|
cp "${lib.getDev sdk}/include/launch.h" $out/include/launch.h
|
2015-06-21 00:29:42 +02:00
|
|
|
popd >/dev/null
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
Xplugin = stdenv.mkDerivation {
|
|
|
|
name = "apple-lib-Xplugin";
|
|
|
|
phases = [ "installPhase" "fixupPhase" ];
|
|
|
|
|
|
|
|
# Not enough
|
|
|
|
__propagatedImpureHostDeps = [ "/usr/lib/libXplugin.1.dylib" ];
|
|
|
|
|
|
|
|
propagatedBuildInputs = with frameworks; [
|
2019-06-17 23:12:07 +02:00
|
|
|
OpenGL ApplicationServices Carbon IOKit CoreGraphics CoreServices CoreText
|
2015-06-21 00:29:42 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/include $out/lib
|
2018-06-09 05:57:36 +02:00
|
|
|
ln -s "${lib.getDev sdk}/include/Xplugin.h" $out/include/Xplugin.h
|
2015-06-21 00:29:42 +02:00
|
|
|
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
|
2018-06-09 05:57:36 +02:00
|
|
|
ln -s "${lib.getDev sdk}/include/utmp.h"
|
|
|
|
ln -s "${lib.getDev sdk}/include/utmpx.h"
|
2015-06-21 00:29:42 +02:00
|
|
|
popd >/dev/null
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2015-10-01 02:13:56 +02:00
|
|
|
overrides = super: {
|
2017-10-31 11:20:18 +01:00
|
|
|
AppKit = stdenv.lib.overrideDerivation super.AppKit (drv: {
|
|
|
|
__propagatedImpureHostDeps = drv.__propagatedImpureHostDeps ++ [
|
|
|
|
"/System/Library/PrivateFrameworks/"
|
|
|
|
];
|
2015-10-01 02:13:56 +02:00
|
|
|
});
|
2015-10-28 20:14:42 +01:00
|
|
|
|
2019-06-17 23:09:06 +02:00
|
|
|
CoreFoundation = stdenv.lib.overrideDerivation super.CoreFoundation (drv: {
|
|
|
|
setupHook = ./cf-setup-hook.sh;
|
|
|
|
});
|
|
|
|
|
2017-10-31 11:20:18 +01:00
|
|
|
CoreMedia = stdenv.lib.overrideDerivation super.CoreMedia (drv: {
|
|
|
|
__propagatedImpureHostDeps = drv.__propagatedImpureHostDeps ++ [
|
|
|
|
"/System/Library/Frameworks/CoreImage.framework"
|
|
|
|
];
|
2015-11-13 03:59:17 +01:00
|
|
|
});
|
|
|
|
|
2018-03-17 13:58:41 +01:00
|
|
|
CoreMIDI = stdenv.lib.overrideDerivation super.CoreMIDI (drv: {
|
|
|
|
__propagatedImpureHostDeps = drv.__propagatedImpureHostDeps ++ [
|
|
|
|
"/System/Library/PrivateFrameworks/"
|
|
|
|
];
|
|
|
|
setupHook = ./private-frameworks-setup-hook.sh;
|
|
|
|
});
|
|
|
|
|
2015-10-28 20:14:42 +01:00
|
|
|
Security = stdenv.lib.overrideDerivation super.Security (drv: {
|
|
|
|
setupHook = ./security-setup-hook.sh;
|
|
|
|
});
|
2017-10-31 11:20:18 +01: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"
|
|
|
|
'';
|
|
|
|
});
|
2019-06-24 00:28:36 +02:00
|
|
|
|
|
|
|
MetalKit = stdenv.lib.overrideDerivation super.MetalKit (drv: {
|
|
|
|
installPhase = drv.installPhase + ''
|
|
|
|
mkdir -p $out/include/simd
|
|
|
|
cp ${lib.getDev sdk}/include/simd/*.h $out/include/simd/
|
|
|
|
'';
|
|
|
|
});
|
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;
|
2019-06-17 23:09:06 +02:00
|
|
|
inherit (pkgs.darwin) libobjc;
|
2015-10-28 20:14:42 +01:00
|
|
|
});
|
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
|
|
|
}
|