diff options
Diffstat (limited to 'nixpkgs/pkgs/os-specific/darwin/apple-sdk')
9 files changed, 932 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/os-specific/darwin/apple-sdk/cf-setup-hook.sh b/nixpkgs/pkgs/os-specific/darwin/apple-sdk/cf-setup-hook.sh new file mode 100644 index 000000000000..bbf9625e6557 --- /dev/null +++ b/nixpkgs/pkgs/os-specific/darwin/apple-sdk/cf-setup-hook.sh @@ -0,0 +1,9 @@ +linkSystemCoreFoundationFramework() { + NIX_CFLAGS_COMPILE="-F@out@/Library/Frameworks${NIX_CFLAGS_COMPILE:+ }${NIX_CFLAGS_COMPILE-}" + # gross! many symbols (such as _OBJC_CLASS_$_NSArray) are defined in system CF, but not + # in the opensource release + # if the package needs private headers, we assume they also want to link with system CF + NIX_LDFLAGS+=" @out@/Library/Frameworks/CoreFoundation.framework/CoreFoundation" +} + +preConfigureHooks+=(linkSystemCoreFoundationFramework) diff --git a/nixpkgs/pkgs/os-specific/darwin/apple-sdk/default.nix b/nixpkgs/pkgs/os-specific/darwin/apple-sdk/default.nix new file mode 100644 index 000000000000..8a814e9558de --- /dev/null +++ b/nixpkgs/pkgs/os-specific/darwin/apple-sdk/default.nix @@ -0,0 +1,313 @@ +{ stdenv, fetchurl, xar, cpio, pkgs, python3, pbzx, lib, darwin-stubs, print-reexports }: + +let + # sadly needs to be exported because security_tool needs it + sdk = stdenv.mkDerivation rec { + pname = "MacOS_SDK"; + version = "10.12"; + + # 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 + 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 + popd + ''; + + meta = with lib; { + description = "Apple SDK ${version}"; + maintainers = with maintainers; [ copumpkin ]; + platforms = platforms.darwin; + }; + }; + + 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; + + framework = name: deps: stdenv.mkDerivation { + name = "apple-framework-${name}"; + + dontUnpack = true; + + # because we copy files from the system + preferLocalBuild = true; + + disallowedRequisites = [ sdk ]; + + nativeBuildInputs = [ print-reexports ]; + + extraTBDFiles = []; + + 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 + + local dest="$out/Library/Frameworks/$path" + + mkdir -p "$dest/Versions/$current" + pushd "$dest/Versions/$current" >/dev/null + + 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 + + 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 + + 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 + + pushd ../.. >/dev/null + ln -s "$current" Versions/Current + ln -s Versions/Current/* . + popd >/dev/null + + popd >/dev/null + } + + linkFramework "${name}.framework" + + # 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 + ''; + + propagatedBuildInputs = builtins.attrValues deps; + + # 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 + __propagatedImpureHostDeps = 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}" + ]; + + meta = with lib; { + description = "Apple SDK framework ${name}"; + maintainers = with maintainers; [ copumpkin ]; + platforms = platforms.darwin; + }; + }; + + 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 + ''; + }; +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 + cp ${darwin-stubs}/usr/lib/libXplugin.1.tbd $out/lib + ln -s libXplugin.1.tbd $out/lib/libXplugin.tbd + ''; + }; + + 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 + ''; + }; + }; + + overrides = super: { + AppKit = lib.overrideDerivation super.AppKit (drv: { + __propagatedImpureHostDeps = drv.__propagatedImpureHostDeps ++ [ + "/System/Library/PrivateFrameworks/" + ]; + }); + + Carbon = lib.overrideDerivation super.Carbon (drv: { + extraTBDFiles = [ "Versions/A/Frameworks/HTMLRendering.framework/Versions/A/HTMLRendering.tbd" ]; + }); + + CoreFoundation = lib.overrideDerivation super.CoreFoundation (drv: { + setupHook = ./cf-setup-hook.sh; + }); + + CoreMedia = lib.overrideDerivation super.CoreMedia (drv: { + __propagatedImpureHostDeps = drv.__propagatedImpureHostDeps ++ [ + "/System/Library/Frameworks/CoreImage.framework" + ]; + }); + + CoreMIDI = lib.overrideDerivation super.CoreMIDI (drv: { + __propagatedImpureHostDeps = drv.__propagatedImpureHostDeps ++ [ + "/System/Library/PrivateFrameworks/" + ]; + setupHook = ./private-frameworks-setup-hook.sh; + }); + + IMServicePlugIn = lib.overrideDerivation super.IMServicePlugIn (drv: { + extraTBDFiles = [ "Versions/A/Frameworks/IMServicePlugInSupport.framework/Versions/A/IMServicePlugInSupport.tbd" ]; + }); + + Security = lib.overrideDerivation super.Security (drv: { + setupHook = ./security-setup-hook.sh; + }); + + QuartzCore = 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" + ''; + }); + + MetalKit = lib.overrideDerivation super.MetalKit (drv: { + installPhase = drv.installPhase + '' + mkdir -p $out/include/simd + cp ${lib.getDev sdk}/include/simd/*.h $out/include/simd/ + ''; + }); + + WebKit = 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 {}); + + bareFrameworks = lib.mapAttrs framework (import ./frameworks.nix { + inherit frameworks libs; + inherit (pkgs.darwin) libobjc; + }); + + frameworks = bareFrameworks // overrides bareFrameworks; + + inherit sdk; +} diff --git a/nixpkgs/pkgs/os-specific/darwin/apple-sdk/framework-setup-hook.sh b/nixpkgs/pkgs/os-specific/darwin/apple-sdk/framework-setup-hook.sh new file mode 100644 index 000000000000..b0d5915fc1fc --- /dev/null +++ b/nixpkgs/pkgs/os-specific/darwin/apple-sdk/framework-setup-hook.sh @@ -0,0 +1,42 @@ +# On macOS, frameworks are linked to the system CoreFoundation but +# dynamic libraries built with nix use a pure version of CF this +# causes segfaults for binaries that depend on it at runtime. This +# can be solved in two ways. +# 1. Rewrite references to the pure CF using this setup hook, this +# works for the simple case but this can still cause problems if other +# dependencies (eg. python) use the pure CF. +# 2. Create a wrapper for the binary that sets DYLD_FRAMEWORK_PATH to +# /System/Library/Frameworks. This will make everything load the +# system's CoreFoundation framework while still keeping the +# dependencies pure for other packages. + +fixupOutputHooks+=('fixDarwinFrameworksIn $prefix') + +fixDarwinFrameworks() { + local systemPrefix='/System/Library/Frameworks' + + for fn in "$@"; do + if [ -L "$fn" ]; then continue; fi + echo "$fn: fixing dylib" + + for framework in $(otool -L "$fn" | awk '/CoreFoundation\.framework/ {print $1}'); do + install_name_tool -change "$framework" "$systemPrefix/CoreFoundation.framework/Versions/A/CoreFoundation" "$fn" >&2 + done + done +} + +fixDarwinFrameworksIn() { + local dir="$1" + fixDarwinFrameworks $(find "$dir" -name "*.dylib") +} + + +# This configures the stdenv to use /System/Library/Frameworks/CoreFoundation.framework +# instead of the nix version by including the system frameworks path +# as an rpath entry when creating binaries. + +useSystemCoreFoundationFramework () { + export NIX_COREFOUNDATION_RPATH=/System/Library/Frameworks +} + +addEnvHooks "$hostOffset" useSystemCoreFoundationFramework diff --git a/nixpkgs/pkgs/os-specific/darwin/apple-sdk/frameworks.nix b/nixpkgs/pkgs/os-specific/darwin/apple-sdk/frameworks.nix new file mode 100644 index 000000000000..d3b00e6a6a68 --- /dev/null +++ b/nixpkgs/pkgs/os-specific/darwin/apple-sdk/frameworks.nix @@ -0,0 +1,129 @@ +# Current as of 10.9 +# Epic weird knot-tying happening here. +# TODO: clean up the process for generating this and include it + +{ frameworks, libs, libobjc, }: + +with frameworks; with libs; { + AGL = { inherit Carbon OpenGL; }; + AVFoundation = { inherit ApplicationServices CoreGraphics CoreMedia MediaToolbox; }; + AVKit = {}; + Accounts = {}; + AddressBook = { inherit libobjc Carbon ContactsPersistence; }; + AppKit = { inherit ApplicationServices AudioToolbox AudioUnit Foundation QuartzCore UIFoundation; }; + AppKitScripting = {}; + AppleScriptKit = {}; + AppleScriptObjC = {}; + AudioToolbox = { inherit CoreAudio CoreMIDI; }; + AudioUnit = { inherit AudioToolbox Carbon CoreAudio; }; + AudioVideoBridging = { inherit Foundation; }; + Automator = {}; + CFNetwork = {}; + CalendarStore = {}; + Cocoa = { inherit AppKit CoreData; }; + Collaboration = {}; + # Impure version of CoreFoundation, this should not be used unless another + # framework includes headers that are not available in the pure version. + CoreFoundation = {}; + CoreAudio = { inherit IOKit; }; + CoreAudioKit = { inherit AudioUnit; }; + CoreData = {}; + CoreGraphics = { inherit Accelerate IOKit IOSurface SystemConfiguration; }; + CoreImage = {}; + CoreLocation = {}; + CoreMIDI = {}; + CoreMIDIServer = { inherit CoreMIDI; }; + CoreMedia = { inherit ApplicationServices AudioToolbox AudioUnit CoreAudio CoreGraphics CoreVideo; }; + CoreMediaIO = { inherit CoreMedia; }; + CoreText = { inherit CoreGraphics; }; + CoreVideo = { inherit ApplicationServices CoreGraphics IOSurface OpenGL; }; + CoreWLAN = { inherit SecurityFoundation; }; + DVDPlayback = {}; + DirectoryService = {}; + DiscRecording = { inherit libobjc CoreServices IOKit; }; + DiscRecordingUI = {}; + DiskArbitration = { inherit IOKit; }; + EventKit = {}; + ExceptionHandling = {}; + FWAUserLib = {}; + ForceFeedback = { inherit IOKit; }; + Foundation = { inherit libobjc CoreFoundation Security ApplicationServices SystemConfiguration; }; + GLKit = {}; + GLUT = { inherit OpenGL; }; + GSS = {}; + GameCenter = {}; + GameController = {}; + GameKit = { inherit Cocoa Foundation GameCenter GameController GameplayKit Metal MetalKit ModelIO SceneKit SpriteKit; }; + GameplayKit = {}; + Hypervisor = {}; + ICADevices = { inherit libobjc Carbon IOBluetooth; }; + IMServicePlugIn = {}; + IOBluetoothUI = { inherit IOBluetooth; }; + IOKit = {}; + IOSurface = { inherit IOKit xpc; }; + ImageCaptureCore = {}; + ImageIO = { inherit CoreGraphics; }; + InputMethodKit = { inherit Carbon; }; + InstallerPlugins = {}; + InstantMessage = {}; + JavaFrameEmbedding = {}; + JavaNativeFoundation = {}; + JavaRuntimeSupport = {}; + JavaScriptCore = { inherit libobjc; }; + Kerberos = {}; + Kernel = { inherit IOKit; }; + LDAP = {}; + LatentSemanticMapping = { inherit Carbon; }; + LocalAuthentication = {}; + MapKit = {}; + MediaAccessibility = { inherit CoreGraphics CoreText QuartzCore; }; + MediaPlayer = {}; + MediaToolbox = { inherit AudioToolbox AudioUnit CoreMedia; }; + Metal = {}; + MetalKit = { inherit ModelIO Metal; }; + ModelIO = {}; + NetFS = {}; + OSAKit = { inherit Carbon; }; + OpenAL = {}; + OpenCL = { inherit IOSurface OpenGL; }; + OpenGL = {}; + PCSC = { inherit CoreData; }; + PreferencePanes = {}; + PubSub = {}; + QTKit = { inherit CoreMediaIO CoreMedia MediaToolbox QuickTime VideoToolbox; }; + QuickLook = { inherit ApplicationServices; }; + SceneKit = {}; + ScreenSaver = {}; + Scripting = {}; + ScriptingBridge = {}; + Security = { inherit IOKit; }; + SecurityFoundation = {}; + SecurityInterface = { inherit Security SecurityFoundation; }; + ServiceManagement = { inherit Security; }; + Social = {}; + SpriteKit = {}; + StoreKit = {}; + SyncServices = {}; + SystemConfiguration = { inherit Security; }; + TWAIN = { inherit Carbon; }; + Tcl = {}; + VideoDecodeAcceleration = { inherit CoreVideo; }; + VideoToolbox = { inherit CoreMedia CoreVideo; }; + WebKit = { inherit libobjc ApplicationServices Carbon JavaScriptCore OpenGL; }; + + # Umbrellas + Accelerate = { inherit CoreWLAN IOBluetooth; }; + ApplicationServices = { inherit CoreGraphics CoreServices CoreText ImageIO; }; + Carbon = { inherit libobjc ApplicationServices CoreServices Foundation IOKit Security QuartzCore; }; + CoreBluetooth = {}; + # TODO: figure out which part of the umbrella depends on CoreFoundation and move it there. + CoreServices = { inherit CFNetwork CoreFoundation CoreAudio CoreData DiskArbitration Security NetFS OpenDirectory ServiceManagement; }; + IOBluetooth = { inherit CoreBluetooth IOKit; }; + JavaVM = {}; + OpenDirectory = {}; + Quartz = { inherit QuartzCore QuickLook QTKit; }; + QuartzCore = { inherit libobjc ApplicationServices CoreVideo OpenCL CoreImage Metal; }; + QuickTime = { inherit ApplicationServices AudioUnit Carbon CoreAudio CoreServices OpenGL QuartzCore; }; + + vmnet = {}; +} diff --git a/nixpkgs/pkgs/os-specific/darwin/apple-sdk/impure-deps.nix b/nixpkgs/pkgs/os-specific/darwin/apple-sdk/impure-deps.nix new file mode 100644 index 000000000000..c111492f2b3d --- /dev/null +++ b/nixpkgs/pkgs/os-specific/darwin/apple-sdk/impure-deps.nix @@ -0,0 +1,256 @@ +rec { + CFNetwork = [ + "/System/Library/Frameworks/CFNetwork.framework" + "/usr/lib/libsqlite3.dylib" + "/usr/lib/libxml2.2.dylib" + ]; + ForceFeedback = [ + "/System/Library/Frameworks/ForceFeedback.framework" + ]; + AGL = [ + "/System/Library/Frameworks/AGL.framework" + ]; + IOKit = [ + "/System/Library/Frameworks/IOKit.framework" + ]; + JavaScriptCore = [ + "/System/Library/Frameworks/JavaScriptCore.framework" + ]; + QuickLook = [ + "/System/Library/Frameworks/QuickLook.framework" + ]; + Quartz = [ + "/System/Library/Frameworks/Quartz.framework" + "/System/Library/PrivateFrameworks/AppleSystemInfo.framework/Versions/A/AppleSystemInfo" + "/System/Library/PrivateFrameworks/CorePDF.framework/Versions/A/CorePDF" + "/usr/lib/libspindump.dylib" + ]; + ImageCaptureCore = [ + "/System/Library/Frameworks/ImageCaptureCore.framework" + ]; + VideoToolbox = [ + "/System/Library/Frameworks/VideoToolbox.framework" + "/System/Library/PrivateFrameworks/AppleVA.framework/Versions/A/AppleVA" + ]; + QuickTime = [ + "/System/Library/Frameworks/QuickTime.framework" + ]; + CoreMedia = [ + "/System/Library/Frameworks/CoreMedia.framework" + ]; + CoreMediaIO = [ + "/System/Library/Frameworks/CoreMediaIO.framework" + "/System/Library/PrivateFrameworks/AppSandbox.framework/Versions/A/AppSandbox" + "/System/Library/PrivateFrameworks/AppContainer.framework/Versions/A/AppContainer" + "/System/Library/PrivateFrameworks/SecCodeWrapper.framework/Versions/A/SecCodeWrapper" + "/System/Library/PrivateFrameworks/XPCService.framework/Versions/A/XPCService" + "/usr/lib/libsandbox.1.dylib" + "/usr/lib/libMatch.1.dylib" + ]; + MediaToolbox = [ + "/System/Library/Frameworks/MediaToolbox.framework" + "/System/Library/PrivateFrameworks/CoreAUC.framework/Versions/A/CoreAUC" + "/System/Library/PrivateFrameworks/NetworkStatistics.framework/Versions/A/NetworkStatistics" + ]; + QTKit = [ + "/System/Library/Frameworks/QTKit.framework" + "/System/Library/PrivateFrameworks/CoreMediaAuthoring.framework/Versions/A/CoreMediaAuthoring" + ]; + OSAKit = [ + "/System/Library/Frameworks/OSAKit.framework" + "/usr/lib/libexslt.0.dylib" + ]; + WebKit = [ + "/System/Library/Frameworks/WebKit.framework" + ]; + DiskArbitration = [ + "/System/Library/Frameworks/DiskArbitration.framework" + ]; + Security = [ + "/System/Library/Frameworks/Security.framework" + "/usr/lib/libbsm.0.dylib" + "/usr/lib/libbz2.1.0.dylib" + "/usr/lib/libpam.2.dylib" + "/usr/lib/libxar.1.dylib" + "/usr/lib/libxml2.2.dylib" + "/usr/lib/libsqlite3.dylib" + ]; + GSS = [ + "/System/Library/Frameworks/GSS.framework" + ]; + Kerberos = [ + "/System/Library/Frameworks/Kerberos.framework" + ]; + CoreServices = [ + "/System/Library/Frameworks/CoreServices.framework" + "/System/Library/PrivateFrameworks/DataDetectorsCore.framework/Versions/A/DataDetectorsCore" + "/System/Library/PrivateFrameworks/TCC.framework/Versions/A/TCC" + "/System/Library/PrivateFrameworks/LanguageModeling.framework/Versions/A/LanguageModeling" + "/usr/lib/libmecabra.dylib" + "/usr/lib/libcmph.dylib" + "/usr/lib/libiconv.2.dylib" + "/usr/lib/libxslt.1.dylib" + ] ++ Foundation; + IOSurface = [ + "/System/Library/Frameworks/IOSurface.framework" + ]; + CoreGraphics = [ + "/System/Library/Frameworks/CoreGraphics.framework" + "/System/Library/PrivateFrameworks/MultitouchSupport.framework/Versions/A/MultitouchSupport" + "/usr/lib/libbsm.0.dylib" + "/usr/lib/libz.1.dylib" + ]; + CoreText = [ + "/System/Library/Frameworks/CoreText.framework" + ]; + ImageIO = [ + "/System/Library/Frameworks/ImageIO.framework" + ]; + ApplicationServices = [ + "/System/Library/Frameworks/ApplicationServices.framework" + "/usr/lib/libcups.2.dylib" + "/usr/lib/libresolv.9.dylib" + ] ++ AudioToolbox; + OpenGL = [ + "/System/Library/Frameworks/OpenGL.framework" + ]; + CoreVideo = [ + "/System/Library/Frameworks/CoreVideo.framework" + ]; + QuartzCore = [ + "/System/Library/Frameworks/QuartzCore.framework" + "/System/Library/PrivateFrameworks/CrashReporterSupport.framework/Versions/A/CrashReporterSupport" + ]; + PCSC = [ + "/System/Library/Frameworks/PCSC.framework" + ]; + AppKit = [ + "/System/Library/Frameworks/AppKit.framework" + "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Apple80211" + "/System/Library/PrivateFrameworks/AppleJPEG.framework/Versions/A/AppleJPEG" + "/System/Library/PrivateFrameworks/AppleVPA.framework/Versions/A/AppleVPA" + "/System/Library/PrivateFrameworks/Backup.framework/Versions/A/Backup" + "/System/Library/PrivateFrameworks/ChunkingLibrary.framework/Versions/A/ChunkingLibrary" + "/System/Library/PrivateFrameworks/CommonAuth.framework/Versions/A/CommonAuth" + "/System/Library/PrivateFrameworks/CoreSymbolication.framework/Versions/A/CoreSymbolication" + "/System/Library/PrivateFrameworks/CoreUI.framework/Versions/A/CoreUI" + "/System/Library/PrivateFrameworks/CoreWiFi.framework/Versions/A/CoreWiFi" + "/System/Library/PrivateFrameworks/CrashReporterSupport.framework/Versions/A/CrashReporterSupport" + "/System/Library/PrivateFrameworks/DataDetectorsCore.framework/Versions/A/DataDetectorsCore" + "/System/Library/PrivateFrameworks/DebugSymbols.framework/Versions/A/DebugSymbols" + "/System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv" + "/System/Library/PrivateFrameworks/FaceCore.framework/Versions/A/FaceCore" + "/System/Library/PrivateFrameworks/GenerationalStorage.framework/Versions/A/GenerationalStorage" + "/System/Library/PrivateFrameworks/Heimdal.framework/Heimdal" + "/System/Library/PrivateFrameworks/Heimdal.framework/Versions/Current" + "/System/Library/PrivateFrameworks/Heimdal.framework/Versions/A/Heimdal" + "/System/Library/PrivateFrameworks/IconServices.framework/Versions/A/IconServices" + "/System/Library/PrivateFrameworks/LanguageModeling.framework/Versions/A/LanguageModeling" + "/System/Library/PrivateFrameworks/MultitouchSupport.framework/Versions/A/MultitouchSupport" + "/System/Library/PrivateFrameworks/NetAuth.framework/Versions/A/NetAuth" + "/System/Library/PrivateFrameworks/PerformanceAnalysis.framework/Versions/A/PerformanceAnalysis" + "/System/Library/PrivateFrameworks/RemoteViewServices.framework/Versions/A/RemoteViewServices" + "/System/Library/PrivateFrameworks/Sharing.framework/Versions/A/Sharing" + "/System/Library/PrivateFrameworks/SpeechRecognitionCore.framework/Versions/A/SpeechRecognitionCore" + "/System/Library/PrivateFrameworks/Symbolication.framework/Versions/A/Symbolication" + "/System/Library/PrivateFrameworks/TCC.framework/Versions/A/TCC" + "/System/Library/PrivateFrameworks/UIFoundation.framework/Versions/A/UIFoundation" + "/System/Library/PrivateFrameworks/login.framework/Versions/A/Frameworks/loginsupport.framework/Versions/A/loginsupport" + "/usr/lib/libCRFSuite.dylib" + "/usr/lib/libOpenScriptingUtil.dylib" + "/usr/lib/libarchive.2.dylib" + "/usr/lib/libbsm.0.dylib" + "/usr/lib/libbz2.1.0.dylib" + "/usr/lib/libc++.1.dylib" + "/usr/lib/libc++abi.dylib" + "/usr/lib/libcmph.dylib" + "/usr/lib/libcups.2.dylib" + "/usr/lib/libextension.dylib" + "/usr/lib/libheimdal-asn1.dylib" + "/usr/lib/libiconv.2.dylib" + "/usr/lib/libicucore.A.dylib" + "/usr/lib/liblangid.dylib" + "/usr/lib/liblzma.5.dylib" + "/usr/lib/libmecabra.dylib" + "/usr/lib/libpam.2.dylib" + "/usr/lib/libresolv.9.dylib" + "/usr/lib/libsqlite3.dylib" + "/usr/lib/libxar.1.dylib" + "/usr/lib/libxml2.2.dylib" + "/usr/lib/libxslt.1.dylib" + "/usr/lib/libz.1.dylib" + ]; + Foundation = [ + "/System/Library/Frameworks/Foundation.framework" + "/usr/lib/libextension.dylib" + "/usr/lib/libarchive.2.dylib" + "/usr/lib/liblzma.5.dylib" + "/usr/lib/liblangid.dylib" + "/usr/lib/libCRFSuite.dylib" + ]; + CoreData = [ + "/System/Library/Frameworks/CoreData.framework" + ]; + Cocoa = [ + "/System/Library/Frameworks/Cocoa.framework" + "/System/Library/PrivateFrameworks/UIFoundation.framework/Versions/A/UIFoundation" + "/System/Library/PrivateFrameworks/UIFoundation.framework/Versions/A" + ]; + Carbon = [ + "/System/Library/Frameworks/Carbon.framework" + "/System/Library/PrivateFrameworks/CoreUI.framework/Versions/A/CoreUI" + "/System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv" + "/System/Library/PrivateFrameworks/IconServices.framework/Versions/A/IconServices" + "/System/Library/PrivateFrameworks/ChunkingLibrary.framework/Versions/A/ChunkingLibrary" + "/System/Library/PrivateFrameworks/Sharing.framework/Versions/A/Sharing" + "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Apple80211" + "/System/Library/PrivateFrameworks/GenerationalStorage.framework/Versions/A/GenerationalStorage" + ]; + CoreAudio = [ + "/System/Library/Frameworks/CoreAudio.framework" + ]; + AudioUnit = [ + "/System/Library/Frameworks/AudioUnit.framework" + ]; + CoreMIDI = [ + "/System/Library/Frameworks/CoreMIDI.framework" + ]; + AudioToolbox = [ + "/System/Library/Frameworks/AudioToolbox.framework" + ]; + SystemConfiguration = [ + "/System/Library/Frameworks/SystemConfiguration.framework" + ]; + NetFS = [ + "/System/Library/Frameworks/NetFS.framework" + "/System/Library/PrivateFrameworks/NetAuth.framework/Versions/A/NetAuth" + "/System/Library/PrivateFrameworks/login.framework/Versions/A/Frameworks/loginsupport.framework/Versions/A/loginsupport" + ]; + Accelerate = [ + "/System/Library/Frameworks/Accelerate.framework" + ]; + OpenDirectory = [ + "/System/Library/Frameworks/OpenDirectory.framework" + ]; + ServiceManagement = [ + "/System/Library/Frameworks/ServiceManagement.framework" + ]; + OpenCL = [ + "/System/Library/Frameworks/OpenCL.framework" + ]; + CoreWLAN = [ + "/System/Library/Frameworks/CoreWLAN.framework" + ]; + IOBluetooth = [ + "/System/Library/Frameworks/IOBluetooth.framework" + ] ++ AudioUnit ++ CoreBluetooth; + CoreBluetooth = [ + "/System/Library/Frameworks/CoreBluetooth.framework" + ]; + SecurityFoundation = [ + "/System/Library/Frameworks/SecurityFoundation.framework" + ]; + Kernel = [ + "/System/Library/Frameworks/Kernel.framework" + ]; +} diff --git a/nixpkgs/pkgs/os-specific/darwin/apple-sdk/print-reexports/default.nix b/nixpkgs/pkgs/os-specific/darwin/apple-sdk/print-reexports/default.nix new file mode 100644 index 000000000000..a548d8da753f --- /dev/null +++ b/nixpkgs/pkgs/os-specific/darwin/apple-sdk/print-reexports/default.nix @@ -0,0 +1,17 @@ +{ lib, stdenv, libyaml }: + +stdenv.mkDerivation { + name = "print-reexports"; + src = lib.sourceFilesBySuffices ./. [".c"]; + + buildInputs = [ libyaml ]; + + buildPhase = '' + $CC -lyaml -o $name main.c + ''; + + installPhase = '' + mkdir -p $out/bin + mv $name $out/bin + ''; +} diff --git a/nixpkgs/pkgs/os-specific/darwin/apple-sdk/print-reexports/main.c b/nixpkgs/pkgs/os-specific/darwin/apple-sdk/print-reexports/main.c new file mode 100644 index 000000000000..df46e3f18e89 --- /dev/null +++ b/nixpkgs/pkgs/os-specific/darwin/apple-sdk/print-reexports/main.c @@ -0,0 +1,148 @@ +/** + * Display the list of re-exported libraries from a TAPI v2 .tbd file, one per + * line on stdout. + * + * TAPI files are the equivalent of library files for the purposes of linking. + * Like dylib files, they may re-export other libraries. In upstream usage + * these refer to the absolute paths of dylibs, and are resolved to .tbd files + * in combination with the syslibroot option. In nixpkgs, the .tbd files refer + * directly to other .tbd files without a syslibroot. Note that each .tbd file + * contains an install name, so the re-exported path does not affect the final + * result. + * + * In nixpkgs each framework is a distinct store path and some frameworks + * re-export other frameworks. The re-exported names are rewritten to refer to + * the store paths of dependencies via textual substitution. This utility is + * used to emit every file that is listed as a re-exported library, which + * allows the framework builder to verify their existence. + */ + +#include <stdio.h> +#include <sys/errno.h> +#include <yaml.h> + +static yaml_node_t *get_mapping_entry(yaml_document_t *document, yaml_node_t *mapping, const char *name) { + if (!mapping) { + fprintf(stderr, "get_mapping_entry: mapping is null\n"); + return NULL; + } + + for ( + yaml_node_pair_t *pair = mapping->data.mapping.pairs.start; + pair < mapping->data.mapping.pairs.top; + ++pair + ) { + yaml_node_t *key = yaml_document_get_node(document, pair->key); + + if (!key) { + fprintf(stderr, "get_mapping_entry: key (%i) is null\n", pair->key); + return NULL; + } + + if (key->type != YAML_SCALAR_NODE) { + fprintf(stderr, "get_mapping_entry: key is not a scalar\n"); + return NULL; + } + + if (strncmp((const char *)key->data.scalar.value, name, key->data.scalar.length) != 0) { + continue; + } + + return yaml_document_get_node(document, pair->value); + } + + return NULL; +} + +static int emit_reexports(yaml_document_t *document) { + yaml_node_t *root = yaml_document_get_root_node(document); + + yaml_node_t *exports = get_mapping_entry(document, root, "exports"); + + if (!exports) { + fprintf(stderr, "emit_reexports: no exports found\n"); + return 0; + } + + if (exports->type != YAML_SEQUENCE_NODE) { + fprintf(stderr, "emit_reexports, value is not a sequence\n"); + return 0; + } + + for ( + yaml_node_item_t *export = exports->data.sequence.items.start; + export < exports->data.sequence.items.top; + ++export + ) { + yaml_node_t *export_node = yaml_document_get_node(document, *export); + + yaml_node_t *reexports = get_mapping_entry(document, export_node, "re-exports"); + + if (!reexports) { + continue; + } + + for ( + yaml_node_item_t *reexport = reexports->data.sequence.items.start; + reexport < reexports->data.sequence.items.top; + ++reexport + ) { + yaml_node_t *val = yaml_document_get_node(document, *reexport); + + if (val->type != YAML_SCALAR_NODE) { + fprintf(stderr, "item is not a scalar\n"); + return 0; + } + + fwrite(val->data.scalar.value, val->data.scalar.length, 1, stdout); + putchar('\n'); + } + } + + return 1; +} + +int main(int argc, char **argv) { + int result = 0; + + if (argc != 2) { + fprintf(stderr, "Invalid usage\n"); + result = 2; + goto done; + } + + FILE *f = fopen(argv[1], "r"); + if (!f) { + perror("opening input file"); + result = errno; + goto done; + } + + yaml_parser_t yaml_parser; + if (!yaml_parser_initialize(&yaml_parser)) { + fprintf(stderr, "Failed to initialize yaml parser\n"); + result = 1; + goto err_file; + } + + yaml_parser_set_input_file(&yaml_parser, f); + + yaml_document_t yaml_document; + + if(!yaml_parser_load(&yaml_parser, &yaml_document)) { + fprintf(stderr, "Failed to load yaml file\n"); + result = 1; + goto err_yaml; + } + + emit_reexports(&yaml_document); + +err_yaml: + yaml_parser_delete(&yaml_parser); + +err_file: + fclose(f); + +done: + return result; +} diff --git a/nixpkgs/pkgs/os-specific/darwin/apple-sdk/private-frameworks-setup-hook.sh b/nixpkgs/pkgs/os-specific/darwin/apple-sdk/private-frameworks-setup-hook.sh new file mode 100644 index 000000000000..a351c39de130 --- /dev/null +++ b/nixpkgs/pkgs/os-specific/darwin/apple-sdk/private-frameworks-setup-hook.sh @@ -0,0 +1,8 @@ +addPrivateFrameworks() { + flag="-F/System/Library/PrivateFrameworks" + if [[ "${NIX_CFLAGS_COMPILE-}" != *$flag* ]]; then + NIX_CFLAGS_COMPILE+=" $flag" + fi +} + +addEnvHooks "$hostOffset" addPrivateFrameworks diff --git a/nixpkgs/pkgs/os-specific/darwin/apple-sdk/security-setup-hook.sh b/nixpkgs/pkgs/os-specific/darwin/apple-sdk/security-setup-hook.sh new file mode 100644 index 000000000000..35cea773f98b --- /dev/null +++ b/nixpkgs/pkgs/os-specific/darwin/apple-sdk/security-setup-hook.sh @@ -0,0 +1,10 @@ +noDeprecatedDeclarations() { + # Security.framework has about 2000 deprecated constants, all of which the user will be + # warned about at compilation time + flag="-Wno-deprecated-declarations" + if [[ "${NIX_CFLAGS_COMPILE-}" != *$flag* ]]; then + NIX_CFLAGS_COMPILE+=" $flag" + fi +} + +addEnvHooks "$hostOffset" noDeprecatedDeclarations |