2020-11-19 00:13:47 +00:00
|
|
|
{ stdenv, fetchurl, xar, cpio, pkgs, python3, pbzx, lib, darwin-stubs, print-reexports }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
# sadly needs to be exported because security_tool needs it
|
|
|
|
sdk = stdenv.mkDerivation rec {
|
|
|
|
pname = "MacOS_SDK";
|
2021-02-05 17:12:51 +00:00
|
|
|
version = "10.12";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# This URL comes from https://swscan.apple.com/content/catalogs/others/index-10.12.merged-1.sucatalog, which we found by:
|
|
|
|
# 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
|
|
|
|
src = fetchurl {
|
|
|
|
url = "http://swcdn.apple.com/content/downloads/33/36/041-90419-A_7JJ4H9ZHO2/xs88ob5wjz6riz7g6764twblnvksusg4ps/DevSDK_OSX1012.pkg";
|
|
|
|
sha256 = "13xq34sb7383b37hwy076gnhf96prpk1b4087p87xnwswxbrisih";
|
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ xar cpio python3 pbzx ];
|
|
|
|
|
|
|
|
outputs = [ "out" "dev" "man" ];
|
|
|
|
|
|
|
|
unpackPhase = ''
|
|
|
|
xar -x -f $src
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
start="$(pwd)"
|
|
|
|
mkdir -p $out
|
|
|
|
cd $out
|
|
|
|
pbzx -n $start/Payload | cpio -idm
|
|
|
|
|
|
|
|
mv usr/* .
|
|
|
|
rmdir usr
|
|
|
|
|
|
|
|
mv System/* .
|
|
|
|
rmdir System
|
|
|
|
|
|
|
|
pushd lib
|
2020-11-19 00:13:47 +00: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
|
2020-04-24 23:36:52 +00:00
|
|
|
popd
|
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Apple SDK ${version}";
|
|
|
|
maintainers = with maintainers; [ copumpkin ];
|
|
|
|
platforms = platforms.darwin;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-11-19 00:13:47 +00: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;
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
framework = name: deps: stdenv.mkDerivation {
|
|
|
|
name = "apple-framework-${name}";
|
|
|
|
|
|
|
|
dontUnpack = true;
|
|
|
|
|
|
|
|
# because we copy files from the system
|
|
|
|
preferLocalBuild = true;
|
|
|
|
|
|
|
|
disallowedRequisites = [ sdk ];
|
|
|
|
|
2020-11-19 00:13:47 +00:00
|
|
|
nativeBuildInputs = [ print-reexports ];
|
|
|
|
|
|
|
|
extraTBDFiles = [];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
installPhase = ''
|
|
|
|
linkFramework() {
|
|
|
|
local path="$1"
|
|
|
|
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
|
|
|
|
local name="$(basename "$path" .framework)"
|
|
|
|
local current="$(readlink "/System/Library/Frameworks/$nested_path/Versions/Current")"
|
|
|
|
if [ -z "$current" ]; then
|
|
|
|
current=A
|
|
|
|
fi
|
|
|
|
|
2020-11-19 00:13:47 +00:00
|
|
|
local dest="$out/Library/Frameworks/$path"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-11-19 00:13:47 +00:00
|
|
|
mkdir -p "$dest/Versions/$current"
|
|
|
|
pushd "$dest/Versions/$current" >/dev/null
|
2020-04-24 23:36:52 +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" .
|
|
|
|
elif [ -d "${sdk.out}/Library/Frameworks/$name.framework/Versions/$current/Headers" ]; then
|
|
|
|
current="$(readlink "/System/Library/Frameworks/$name.framework/Versions/Current")"
|
|
|
|
cp -R "${sdk.out}/Library/Frameworks/$name.framework/Versions/$current/Headers" .
|
|
|
|
fi
|
2020-11-19 00:13:47 +00:00
|
|
|
|
|
|
|
local tbd_source=${darwin-stubs}/System/Library/Frameworks/$nested_path/Versions/$current
|
|
|
|
if [ "${name}" != "Kernel" ]; then
|
|
|
|
# The Kernel.framework has headers but no actual library component.
|
|
|
|
cp -v $tbd_source/*.tbd .
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d "$tbd_source/Libraries" ]; then
|
|
|
|
mkdir Libraries
|
|
|
|
cp -v $tbd_source/Libraries/*.tbd Libraries/
|
|
|
|
fi
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
ln -s -L "/System/Library/Frameworks/$nested_path/Versions/$current/Resources"
|
|
|
|
|
|
|
|
if [ -f "/System/Library/Frameworks/$nested_path/module.map" ]; then
|
|
|
|
ln -s "/System/Library/Frameworks/$nested_path/module.map"
|
|
|
|
fi
|
|
|
|
|
|
|
|
pushd "${sdk.out}/Library/Frameworks/$nested_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
|
|
|
|
|
2020-11-19 00:13:47 +00:00
|
|
|
pushd ../.. >/dev/null
|
|
|
|
ln -s "$current" Versions/Current
|
|
|
|
ln -s Versions/Current/* .
|
|
|
|
popd >/dev/null
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
popd >/dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
linkFramework "${name}.framework"
|
2020-11-19 00:13:47 +00: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
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2020-11-19 00:13:47 +00:00
|
|
|
propagatedBuildInputs = builtins.attrValues deps;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# don't use pure CF for dylibs that depend on frameworks
|
|
|
|
setupHook = ./framework-setup-hook.sh;
|
|
|
|
|
|
|
|
# Not going to be more specific than this for now
|
2021-02-05 17:12:51 +00:00
|
|
|
__propagatedImpureHostDeps = lib.optionals (name != "Kernel") [
|
2020-04-24 23:36:52 +00:00
|
|
|
# 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}"
|
|
|
|
];
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Apple SDK framework ${name}";
|
|
|
|
maintainers = with maintainers; [ copumpkin ];
|
|
|
|
platforms = platforms.darwin;
|
|
|
|
};
|
|
|
|
};
|
2020-11-19 00:13:47 +00: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
|
2021-05-20 23:08:51 +00:00
|
|
|
|
|
|
|
cd $out/Library/Frameworks/${name}.framework
|
|
|
|
|
|
|
|
versions=(./Versions/*)
|
|
|
|
if [ "''${#versions[@]}" != 1 ]; then
|
|
|
|
echo "Unable to determine current version of framework ${name}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
current=$(basename ''${versions[0]})
|
|
|
|
|
|
|
|
chmod u+w -R .
|
|
|
|
ln -s "$current" Versions/Current
|
|
|
|
ln -s Versions/Current/* .
|
|
|
|
|
2020-11-19 00:13:47 +00:00
|
|
|
# NOTE there's no re-export checking here, this is probably wrong
|
|
|
|
'';
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
in rec {
|
|
|
|
libs = {
|
|
|
|
xpc = stdenv.mkDerivation {
|
|
|
|
name = "apple-lib-xpc";
|
|
|
|
dontUnpack = true;
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/include
|
|
|
|
pushd $out/include >/dev/null
|
|
|
|
cp -r "${lib.getDev sdk}/include/xpc" $out/include/xpc
|
|
|
|
cp "${lib.getDev sdk}/include/launch.h" $out/include/launch.h
|
|
|
|
popd >/dev/null
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
Xplugin = stdenv.mkDerivation {
|
|
|
|
name = "apple-lib-Xplugin";
|
|
|
|
dontUnpack = true;
|
|
|
|
|
|
|
|
# Not enough
|
|
|
|
__propagatedImpureHostDeps = [ "/usr/lib/libXplugin.1.dylib" ];
|
|
|
|
|
|
|
|
propagatedBuildInputs = with frameworks; [
|
|
|
|
OpenGL ApplicationServices Carbon IOKit CoreGraphics CoreServices CoreText
|
|
|
|
];
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/include $out/lib
|
|
|
|
ln -s "${lib.getDev sdk}/include/Xplugin.h" $out/include/Xplugin.h
|
2020-11-19 00:13:47 +00:00
|
|
|
cp ${darwin-stubs}/usr/lib/libXplugin.1.tbd $out/lib
|
|
|
|
ln -s libXplugin.1.tbd $out/lib/libXplugin.tbd
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
utmp = stdenv.mkDerivation {
|
|
|
|
name = "apple-lib-utmp";
|
|
|
|
dontUnpack = true;
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/include
|
|
|
|
pushd $out/include >/dev/null
|
|
|
|
ln -s "${lib.getDev sdk}/include/utmp.h"
|
|
|
|
ln -s "${lib.getDev sdk}/include/utmpx.h"
|
|
|
|
popd >/dev/null
|
|
|
|
'';
|
|
|
|
};
|
2021-03-23 19:22:30 +00:00
|
|
|
|
|
|
|
sandbox = stdenv.mkDerivation {
|
|
|
|
name = "apple-lib-sandbox";
|
|
|
|
dontUnpack = true;
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/include $out/lib
|
|
|
|
ln -s "${lib.getDev sdk}/include/sandbox.h" $out/include/sandbox.h
|
|
|
|
cp "${darwin-stubs}/usr/lib/libsandbox.1.tbd" $out/lib
|
|
|
|
ln -s libsandbox.1.tbd $out/lib/libsandbox.tbd
|
|
|
|
'';
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
overrides = super: {
|
2021-02-05 17:12:51 +00:00
|
|
|
AppKit = lib.overrideDerivation super.AppKit (drv: {
|
2021-12-06 16:07:01 +00:00
|
|
|
__propagatedImpureHostDeps = drv.__propagatedImpureHostDeps or [] ++ [
|
2020-04-24 23:36:52 +00:00
|
|
|
"/System/Library/PrivateFrameworks/"
|
|
|
|
];
|
|
|
|
});
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
Carbon = lib.overrideDerivation super.Carbon (drv: {
|
2020-11-19 00:13:47 +00:00
|
|
|
extraTBDFiles = [ "Versions/A/Frameworks/HTMLRendering.framework/Versions/A/HTMLRendering.tbd" ];
|
|
|
|
});
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
CoreFoundation = lib.overrideDerivation super.CoreFoundation (drv: {
|
2020-04-24 23:36:52 +00:00
|
|
|
setupHook = ./cf-setup-hook.sh;
|
|
|
|
});
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
CoreMedia = lib.overrideDerivation super.CoreMedia (drv: {
|
2021-12-06 16:07:01 +00:00
|
|
|
__propagatedImpureHostDeps = drv.__propagatedImpureHostDeps or [] ++ [
|
2020-04-24 23:36:52 +00:00
|
|
|
"/System/Library/Frameworks/CoreImage.framework"
|
|
|
|
];
|
|
|
|
});
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
CoreMIDI = lib.overrideDerivation super.CoreMIDI (drv: {
|
2021-12-06 16:07:01 +00:00
|
|
|
__propagatedImpureHostDeps = drv.__propagatedImpureHostDeps or [] ++ [
|
2020-04-24 23:36:52 +00:00
|
|
|
"/System/Library/PrivateFrameworks/"
|
|
|
|
];
|
|
|
|
setupHook = ./private-frameworks-setup-hook.sh;
|
|
|
|
});
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
IMServicePlugIn = lib.overrideDerivation super.IMServicePlugIn (drv: {
|
2020-11-19 00:13:47 +00:00
|
|
|
extraTBDFiles = [ "Versions/A/Frameworks/IMServicePlugInSupport.framework/Versions/A/IMServicePlugInSupport.tbd" ];
|
|
|
|
});
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
Security = lib.overrideDerivation super.Security (drv: {
|
2020-04-24 23:36:52 +00:00
|
|
|
setupHook = ./security-setup-hook.sh;
|
|
|
|
});
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
QuartzCore = lib.overrideDerivation super.QuartzCore (drv: {
|
2020-04-24 23:36:52 +00:00
|
|
|
installPhase = drv.installPhase + ''
|
|
|
|
f="$out/Library/Frameworks/QuartzCore.framework/Headers/CoreImage.h"
|
|
|
|
substituteInPlace "$f" \
|
|
|
|
--replace "QuartzCore/../Frameworks/CoreImage.framework/Headers" "CoreImage"
|
|
|
|
'';
|
|
|
|
});
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
MetalKit = lib.overrideDerivation super.MetalKit (drv: {
|
2020-04-24 23:36:52 +00:00
|
|
|
installPhase = drv.installPhase + ''
|
|
|
|
mkdir -p $out/include/simd
|
|
|
|
cp ${lib.getDev sdk}/include/simd/*.h $out/include/simd/
|
|
|
|
'';
|
|
|
|
});
|
2020-11-19 00:13:47 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
WebKit = lib.overrideDerivation super.WebKit (drv: {
|
2020-11-19 00:13:47 +00:00
|
|
|
extraTBDFiles = [
|
|
|
|
"Versions/A/Frameworks/WebCore.framework/Versions/A/WebCore.tbd"
|
|
|
|
"Versions/A/Frameworks/WebKitLegacy.framework/Versions/A/WebKitLegacy.tbd"
|
|
|
|
];
|
|
|
|
});
|
2023-01-11 07:51:40 +00:00
|
|
|
} // lib.genAttrs [
|
|
|
|
"ContactsPersistence"
|
|
|
|
"CoreSymbolication"
|
|
|
|
"DebugSymbols"
|
|
|
|
"GameCenter"
|
|
|
|
"MultitouchSupport"
|
|
|
|
"SkyLight"
|
|
|
|
"UIFoundation"
|
|
|
|
]
|
|
|
|
(x: tbdOnlyFramework x {});
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
bareFrameworks = lib.mapAttrs framework (import ./frameworks.nix {
|
2020-04-24 23:36:52 +00:00
|
|
|
inherit frameworks libs;
|
|
|
|
inherit (pkgs.darwin) libobjc;
|
|
|
|
});
|
|
|
|
|
|
|
|
frameworks = bareFrameworks // overrides bareFrameworks;
|
|
|
|
|
|
|
|
inherit sdk;
|
|
|
|
}
|