2020-09-18 09:12:43 +01:00
|
|
|
{ stdenv, fetchurl, xar, cpio, pkgs, python3, pbzx, lib, darwin-stubs, print-reexports }:
|
2015-06-20 23:29:42 +01:00
|
|
|
|
2020-01-13 16:56:02 +00:00
|
|
|
let version = "10.12"; in
|
|
|
|
|
|
|
|
# Ensure appleSdkVersion is up to date.
|
|
|
|
assert stdenv.isDarwin -> stdenv.appleSdkVersion == version;
|
|
|
|
|
2015-06-20 23:29:42 +01:00
|
|
|
let
|
2015-06-22 04:29:33 +01:00
|
|
|
# sadly needs to be exported because security_tool needs it
|
2015-06-20 23:29:42 +01:00
|
|
|
sdk = stdenv.mkDerivation rec {
|
2019-08-15 13:41:18 +01:00
|
|
|
pname = "MacOS_SDK";
|
2020-01-13 16:56:02 +00:00
|
|
|
inherit version;
|
2015-06-20 23:29:42 +01:00
|
|
|
|
2019-02-07 01:13:51 +00: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 02:36:21 +00: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-20 23:29:42 +01:00
|
|
|
src = fetchurl {
|
2019-11-27 19:17:43 +00:00
|
|
|
url = "http://swcdn.apple.com/content/downloads/33/36/041-90419-A_7JJ4H9ZHO2/xs88ob5wjz6riz7g6764twblnvksusg4ps/DevSDK_OSX1012.pkg";
|
|
|
|
sha256 = "13xq34sb7383b37hwy076gnhf96prpk1b4087p87xnwswxbrisih";
|
2015-06-20 23:29:42 +01:00
|
|
|
};
|
|
|
|
|
2020-01-13 09:10:23 +00:00
|
|
|
nativeBuildInputs = [ xar cpio python3 pbzx ];
|
2015-06-20 23:29:42 +01:00
|
|
|
|
2018-06-09 04:57:36 +01:00
|
|
|
outputs = [ "out" "dev" "man" ];
|
2015-06-20 23:29:42 +01:00
|
|
|
|
|
|
|
unpackPhase = ''
|
|
|
|
xar -x -f $src
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
start="$(pwd)"
|
|
|
|
mkdir -p $out
|
|
|
|
cd $out
|
2019-02-07 01:13:51 +00:00
|
|
|
pbzx -n $start/Payload | cpio -idm
|
2015-06-20 23:29:42 +01:00
|
|
|
|
|
|
|
mv usr/* .
|
|
|
|
rmdir usr
|
|
|
|
|
|
|
|
mv System/* .
|
|
|
|
rmdir System
|
|
|
|
|
2016-11-11 22:29:50 +00:00
|
|
|
pushd lib
|
2020-09-18 09:12:43 +01:00
|
|
|
cp ${darwin-stubs}/usr/lib/libcups*.tbd .
|
|
|
|
ln -s libcups.2.tbd libcups.tbd
|
|
|
|
ln -s libcupscgi.1.tbd libcupscgi.tbd
|
|
|
|
ln -s libcupsimage.2.tbd libcupsimage.tbd
|
|
|
|
ln -s libcupsmime.1.tbd libcupsmime.tbd
|
|
|
|
ln -s libcupsppdc.1.tbd libcupsppdc.tbd
|
2016-11-11 22:29:50 +00:00
|
|
|
popd
|
2015-06-20 23:29:42 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "Apple SDK ${version}";
|
|
|
|
maintainers = with maintainers; [ copumpkin ];
|
|
|
|
platforms = platforms.darwin;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-09-18 09:12:43 +01:00
|
|
|
mkFrameworkSubs = name: deps:
|
|
|
|
let
|
|
|
|
deps' = deps // { "${name}" = placeholder "out"; };
|
|
|
|
substArgs = lib.concatMap (x: [ "--subst-var-by" x deps'."${x}" ]) (lib.attrNames deps');
|
|
|
|
in lib.escapeShellArgs substArgs;
|
|
|
|
|
2015-06-20 23:29:42 +01:00
|
|
|
framework = name: deps: stdenv.mkDerivation {
|
|
|
|
name = "apple-framework-${name}";
|
|
|
|
|
2019-11-11 18:26:57 +00:00
|
|
|
dontUnpack = true;
|
2015-06-20 23:29:42 +01:00
|
|
|
|
2015-10-06 08:11:00 +01:00
|
|
|
# because we copy files from the system
|
|
|
|
preferLocalBuild = true;
|
|
|
|
|
2018-07-04 20:08:35 +01:00
|
|
|
disallowedRequisites = [ sdk ];
|
|
|
|
|
2020-09-18 09:12:43 +01:00
|
|
|
nativeBuildInputs = [ print-reexports ];
|
|
|
|
|
|
|
|
extraTBDFiles = [];
|
|
|
|
|
2015-06-20 23:29:42 +01:00
|
|
|
installPhase = ''
|
|
|
|
linkFramework() {
|
|
|
|
local path="$1"
|
2020-01-18 15:43:03 +00:00
|
|
|
local nested_path="$1"
|
|
|
|
if [ "$path" == "JavaNativeFoundation.framework" ]; then
|
|
|
|
local nested_path="JavaVM.framework/Versions/A/Frameworks/JavaNativeFoundation.framework"
|
|
|
|
fi
|
|
|
|
if [ "$path" == "JavaRuntimeSupport.framework" ]; then
|
|
|
|
local nested_path="JavaVM.framework/Versions/A/Frameworks/JavaRuntimeSupport.framework"
|
|
|
|
fi
|
2015-06-20 23:29:42 +01:00
|
|
|
local name="$(basename "$path" .framework)"
|
2020-01-18 15:43:03 +00:00
|
|
|
local current="$(readlink "/System/Library/Frameworks/$nested_path/Versions/Current")"
|
2015-10-26 19:38:57 +00:00
|
|
|
if [ -z "$current" ]; then
|
|
|
|
current=A
|
|
|
|
fi
|
2015-06-20 23:29:42 +01:00
|
|
|
|
2020-09-18 09:12:43 +01:00
|
|
|
local dest="$out/Library/Frameworks/$path"
|
2015-06-20 23:29:42 +01:00
|
|
|
|
2020-09-18 09:12:43 +01:00
|
|
|
mkdir -p "$dest/Versions/$current"
|
|
|
|
pushd "$dest/Versions/$current" >/dev/null
|
2016-03-11 20:11:02 +00:00
|
|
|
|
2020-01-18 15:43:03 +00:00
|
|
|
if [ -d "${sdk.out}/Library/Frameworks/$nested_path/Versions/$current/Headers" ]; then
|
|
|
|
cp -R "${sdk.out}/Library/Frameworks/$nested_path/Versions/$current/Headers" .
|
2019-03-10 01:13:00 +00:00
|
|
|
elif [ -d "${sdk.out}/Library/Frameworks/$name.framework/Versions/$current/Headers" ]; then
|
2016-03-11 20:11:02 +00:00
|
|
|
current="$(readlink "/System/Library/Frameworks/$name.framework/Versions/Current")"
|
2018-06-09 04:57:36 +01:00
|
|
|
cp -R "${sdk.out}/Library/Frameworks/$name.framework/Versions/$current/Headers" .
|
2016-03-11 20:11:02 +00:00
|
|
|
fi
|
2020-09-18 09:12:43 +01:00
|
|
|
|
|
|
|
local tbd_source=${darwin-stubs}/System/Library/Frameworks/$nested_path/Versions/$current
|
|
|
|
if [ "${name}" != "Kernel" ]; then
|
2020-11-12 07:50:06 +00:00
|
|
|
# The Kernel.framework has headers but no actual library component.
|
2020-09-18 09:12:43 +01:00
|
|
|
cp -v $tbd_source/*.tbd .
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d "$tbd_source/Libraries" ]; then
|
|
|
|
mkdir Libraries
|
|
|
|
cp -v $tbd_source/Libraries/*.tbd Libraries/
|
|
|
|
fi
|
|
|
|
|
2020-01-18 15:43:03 +00:00
|
|
|
ln -s -L "/System/Library/Frameworks/$nested_path/Versions/$current/Resources"
|
2015-06-20 23:29:42 +01:00
|
|
|
|
2020-01-18 15:43:03 +00:00
|
|
|
if [ -f "/System/Library/Frameworks/$nested_path/module.map" ]; then
|
|
|
|
ln -s "/System/Library/Frameworks/$nested_path/module.map"
|
2015-06-20 23:29:42 +01:00
|
|
|
fi
|
|
|
|
|
2020-01-18 15:43:03 +00:00
|
|
|
pushd "${sdk.out}/Library/Frameworks/$nested_path/Versions/$current" >/dev/null
|
2015-06-20 23:29:42 +01:00
|
|
|
local children=$(echo Frameworks/*.framework)
|
|
|
|
popd >/dev/null
|
|
|
|
|
|
|
|
for child in $children; do
|
|
|
|
childpath="$path/Versions/$current/$child"
|
|
|
|
linkFramework "$childpath"
|
|
|
|
done
|
|
|
|
|
2020-09-18 09:12:43 +01:00
|
|
|
pushd ../.. >/dev/null
|
|
|
|
ln -s "$current" Versions/Current
|
|
|
|
ln -s Versions/Current/* .
|
|
|
|
popd >/dev/null
|
2015-06-20 23:29:42 +01:00
|
|
|
|
|
|
|
popd >/dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
linkFramework "${name}.framework"
|
2020-09-18 09:12:43 +01:00
|
|
|
|
|
|
|
# linkFramework is recursive, the rest of the processing is not.
|
|
|
|
|
|
|
|
local tbd_source=${darwin-stubs}/System/Library/Frameworks/${name}.framework
|
|
|
|
for tbd in $extraTBDFiles; do
|
|
|
|
local tbd_dest_dir=$out/Library/Frameworks/${name}.framework/$(dirname "$tbd")
|
|
|
|
mkdir -p "$tbd_dest_dir"
|
|
|
|
cp -v "$tbd_source/$tbd" "$tbd_dest_dir"
|
|
|
|
done
|
|
|
|
|
|
|
|
# Fix and check tbd re-export references
|
|
|
|
find $out -name '*.tbd' | while read tbd; do
|
|
|
|
echo "Fixing re-exports in $tbd"
|
|
|
|
substituteInPlace "$tbd" ${mkFrameworkSubs name deps}
|
|
|
|
|
|
|
|
echo "Checking re-exports in $tbd"
|
|
|
|
print-reexports "$tbd" | while read target; do
|
|
|
|
local expected="''${target%.dylib}.tbd"
|
|
|
|
if ! [ -e "$expected" ]; then
|
|
|
|
echo -e "Re-export missing:\n\t$target\n\t(expected $expected)"
|
|
|
|
echo -e "While processing\n\t$tbd"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Re-exported target $target ok"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
2015-06-20 23:29:42 +01:00
|
|
|
'';
|
|
|
|
|
2020-09-18 09:12:43 +01:00
|
|
|
propagatedBuildInputs = builtins.attrValues deps;
|
2015-06-20 23:29:42 +01:00
|
|
|
|
2017-03-07 21:10:07 +00:00
|
|
|
# don't use pure CF for dylibs that depend on frameworks
|
2017-07-22 12:31:48 +01:00
|
|
|
setupHook = ./framework-setup-hook.sh;
|
2017-03-07 21:10:07 +00:00
|
|
|
|
2017-10-31 11:58:08 +00: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-20 23:29:42 +01:00
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "Apple SDK framework ${name}";
|
|
|
|
maintainers = with maintainers; [ copumpkin ];
|
|
|
|
platforms = platforms.darwin;
|
|
|
|
};
|
|
|
|
};
|
2020-09-18 09:12:43 +01:00
|
|
|
|
|
|
|
tbdOnlyFramework = name: { private ? true }: stdenv.mkDerivation {
|
|
|
|
name = "apple-framework-${name}";
|
|
|
|
dontUnpack = true;
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/Library/Frameworks/
|
|
|
|
cp -r ${darwin-stubs}/System/Library/${lib.optionalString private "Private"}Frameworks/${name}.framework \
|
|
|
|
$out/Library/Frameworks
|
|
|
|
# NOTE there's no re-export checking here, this is probably wrong
|
|
|
|
'';
|
|
|
|
};
|
2015-06-20 23:29:42 +01:00
|
|
|
in rec {
|
|
|
|
libs = {
|
|
|
|
xpc = stdenv.mkDerivation {
|
|
|
|
name = "apple-lib-xpc";
|
2019-11-11 18:26:57 +00:00
|
|
|
dontUnpack = true;
|
2015-06-20 23:29:42 +01:00
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/include
|
|
|
|
pushd $out/include >/dev/null
|
2018-07-02 22:49:59 +01:00
|
|
|
cp -r "${lib.getDev sdk}/include/xpc" $out/include/xpc
|
|
|
|
cp "${lib.getDev sdk}/include/launch.h" $out/include/launch.h
|
2015-06-20 23:29:42 +01:00
|
|
|
popd >/dev/null
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
Xplugin = stdenv.mkDerivation {
|
|
|
|
name = "apple-lib-Xplugin";
|
2019-11-11 18:26:57 +00:00
|
|
|
dontUnpack = true;
|
2015-06-20 23:29:42 +01:00
|
|
|
|
|
|
|
# Not enough
|
|
|
|
__propagatedImpureHostDeps = [ "/usr/lib/libXplugin.1.dylib" ];
|
|
|
|
|
|
|
|
propagatedBuildInputs = with frameworks; [
|
2019-06-17 22:12:07 +01:00
|
|
|
OpenGL ApplicationServices Carbon IOKit CoreGraphics CoreServices CoreText
|
2015-06-20 23:29:42 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/include $out/lib
|
2018-06-09 04:57:36 +01:00
|
|
|
ln -s "${lib.getDev sdk}/include/Xplugin.h" $out/include/Xplugin.h
|
2020-09-18 09:12:43 +01:00
|
|
|
cp ${darwin-stubs}/usr/lib/libXplugin.1.tbd $out/lib
|
|
|
|
ln -s libXplugin.1.tbd $out/lib/libXplugin.tbd
|
2015-06-20 23:29:42 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
utmp = stdenv.mkDerivation {
|
|
|
|
name = "apple-lib-utmp";
|
2019-11-11 18:26:57 +00:00
|
|
|
dontUnpack = true;
|
2015-06-20 23:29:42 +01:00
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/include
|
|
|
|
pushd $out/include >/dev/null
|
2018-06-09 04:57:36 +01:00
|
|
|
ln -s "${lib.getDev sdk}/include/utmp.h"
|
|
|
|
ln -s "${lib.getDev sdk}/include/utmpx.h"
|
2015-06-20 23:29:42 +01:00
|
|
|
popd >/dev/null
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2015-10-01 01:13:56 +01:00
|
|
|
overrides = super: {
|
2017-10-31 10:20:18 +00:00
|
|
|
AppKit = stdenv.lib.overrideDerivation super.AppKit (drv: {
|
|
|
|
__propagatedImpureHostDeps = drv.__propagatedImpureHostDeps ++ [
|
|
|
|
"/System/Library/PrivateFrameworks/"
|
|
|
|
];
|
2015-10-01 01:13:56 +01:00
|
|
|
});
|
2015-10-28 19:14:42 +00:00
|
|
|
|
2020-09-18 09:12:43 +01:00
|
|
|
Carbon = stdenv.lib.overrideDerivation super.Carbon (drv: {
|
|
|
|
extraTBDFiles = [ "Versions/A/Frameworks/HTMLRendering.framework/Versions/A/HTMLRendering.tbd" ];
|
|
|
|
});
|
|
|
|
|
2019-06-17 22:09:06 +01:00
|
|
|
CoreFoundation = stdenv.lib.overrideDerivation super.CoreFoundation (drv: {
|
|
|
|
setupHook = ./cf-setup-hook.sh;
|
|
|
|
});
|
|
|
|
|
2017-10-31 10:20:18 +00:00
|
|
|
CoreMedia = stdenv.lib.overrideDerivation super.CoreMedia (drv: {
|
|
|
|
__propagatedImpureHostDeps = drv.__propagatedImpureHostDeps ++ [
|
|
|
|
"/System/Library/Frameworks/CoreImage.framework"
|
|
|
|
];
|
2015-11-13 02:59:17 +00:00
|
|
|
});
|
|
|
|
|
2018-03-17 12:58:41 +00:00
|
|
|
CoreMIDI = stdenv.lib.overrideDerivation super.CoreMIDI (drv: {
|
|
|
|
__propagatedImpureHostDeps = drv.__propagatedImpureHostDeps ++ [
|
|
|
|
"/System/Library/PrivateFrameworks/"
|
|
|
|
];
|
|
|
|
setupHook = ./private-frameworks-setup-hook.sh;
|
|
|
|
});
|
|
|
|
|
2020-09-18 09:12:43 +01:00
|
|
|
IMServicePlugIn = stdenv.lib.overrideDerivation super.IMServicePlugIn (drv: {
|
|
|
|
extraTBDFiles = [ "Versions/A/Frameworks/IMServicePlugInSupport.framework/Versions/A/IMServicePlugInSupport.tbd" ];
|
|
|
|
});
|
|
|
|
|
2015-10-28 19:14:42 +00:00
|
|
|
Security = stdenv.lib.overrideDerivation super.Security (drv: {
|
|
|
|
setupHook = ./security-setup-hook.sh;
|
|
|
|
});
|
2017-10-31 10:20:18 +00: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-23 23:28:36 +01: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/
|
|
|
|
'';
|
|
|
|
});
|
2020-09-18 09:12:43 +01:00
|
|
|
|
|
|
|
WebKit = stdenv.lib.overrideDerivation super.WebKit (drv: {
|
|
|
|
extraTBDFiles = [
|
|
|
|
"Versions/A/Frameworks/WebCore.framework/Versions/A/WebCore.tbd"
|
|
|
|
"Versions/A/Frameworks/WebKitLegacy.framework/Versions/A/WebKitLegacy.tbd"
|
|
|
|
];
|
|
|
|
});
|
|
|
|
} // lib.genAttrs [ "ContactsPersistence" "UIFoundation" "GameCenter" ] (x: tbdOnlyFramework x {});
|
2015-10-01 01:13:56 +01:00
|
|
|
|
2015-10-28 19:14:42 +00:00
|
|
|
bareFrameworks = stdenv.lib.mapAttrs framework (import ./frameworks.nix {
|
|
|
|
inherit frameworks libs;
|
2019-06-17 22:09:06 +01:00
|
|
|
inherit (pkgs.darwin) libobjc;
|
2015-10-28 19:14:42 +00:00
|
|
|
});
|
2015-10-01 01:13:56 +01:00
|
|
|
|
|
|
|
frameworks = bareFrameworks // overrides bareFrameworks;
|
2015-07-08 22:14:27 +01:00
|
|
|
|
2015-11-21 20:06:41 +00:00
|
|
|
inherit sdk;
|
2015-06-20 23:29:42 +01:00
|
|
|
}
|