diff --git a/pkgs/os-specific/darwin/apple-sdk-11.0/apple_sdk.nix b/pkgs/os-specific/darwin/apple-sdk-11.0/apple_sdk.nix index 839548ae8ffd0..1860e150ca1ae 100644 --- a/pkgs/os-specific/darwin/apple-sdk-11.0/apple_sdk.nix +++ b/pkgs/os-specific/darwin/apple-sdk-11.0/apple_sdk.nix @@ -160,40 +160,96 @@ in rec { }; }; - overrides = super: { - CoreFoundation = lib.overrideDerivation super.CoreFoundation (drv: { - setupHook = ./cf-setup-hook.sh; - }); - - # This framework doesn't exist in newer SDKs (somewhere around 10.13), but - # there are references to it in nixpkgs. - QuickTime = throw "QuickTime framework not available"; - - # Seems to be appropriate given https://developer.apple.com/forums/thread/666686 - JavaVM = super.JavaNativeFoundation; - - CoreVideo = lib.overrideDerivation super.CoreVideo (drv: { - installPhase = drv.installPhase + '' - # When used as a module, complains about a missing import for - # Darwin.C.stdint. Apparently fixed in later SDKs. - awk -i inplace '/CFBase.h/ { print "#include " } { print }' \ - $out/Library/Frameworks/CoreVideo.framework/Headers/CVBase.h - ''; - }); - }; - - bareFrameworks = ( - lib.mapAttrs framework (import ./frameworks.nix { + frameworks = let + # Dependency map created by gen-frameworks.py. + generatedDeps = import ./frameworks.nix { inherit frameworks libs; + }; + + # Additional dependencies that are not picked up by gen-frameworks.py. + # Some of these are simply private frameworks the generator does not see. + extraDeps = with libs; with frameworks; let inherit (pkgs.darwin.apple_sdk_11_0) libnetwork; libobjc = pkgs.darwin.apple_sdk_11_0.objc4; - }) - ) // ( - lib.mapAttrs privateFramework (import ./private-frameworks.nix { - inherit frameworks; - libobjc = pkgs.darwin.apple_sdk_11_0.objc4; - }) - ); + in { + # Below this comment are entries migrated from before the generator was + # added. If, for a given framework, you are able to reverify the extra + # deps are really necessary on top of the generator deps, move it above + # this comment (and maybe document your findings). + AVFoundation = { inherit ApplicationServices AVFCapture AVFCore; }; + Accelerate = { inherit CoreWLAN IOBluetooth; }; + AddressBook = { inherit AddressBookCore ContactsPersistence libobjc; }; + AppKit = { inherit AudioToolbox AudioUnit UIFoundation; }; + AudioToolbox = { inherit AudioToolboxCore; }; + AudioUnit = { inherit Carbon CoreAudio; }; + Carbon = { inherit IOKit QuartzCore libobjc; }; + CoreAudio = { inherit IOKit; }; + CoreFoundation = { inherit libobjc; }; + CoreGraphics = { inherit SystemConfiguration; }; + CoreMIDIServer = { inherit CoreMIDI; }; + CoreMedia = { inherit ApplicationServices AudioToolbox AudioUnit; }; + CoreServices = { inherit CoreAudio NetFS ServiceManagement; }; + CoreWLAN = { inherit SecurityFoundation; }; + DiscRecording = { inherit IOKit libobjc; }; + Foundation = { inherit SystemConfiguration libobjc; }; + GameKit = { inherit GameCenterFoundation GameCenterUI GameCenterUICore ReplayKit; }; + ICADevices = { inherit Carbon libobjc; }; + IOBluetooth = { inherit CoreBluetooth; }; + JavaScriptCore = { inherit libobjc; }; + Kernel = { inherit IOKit; }; + LinkPresentation = { inherit URLFormatting; }; + MediaToolbox = { inherit AudioUnit; }; + MetricKit = { inherit SignpostMetrics; }; + Network = { inherit libnetwork; }; + PCSC = { inherit CoreData; }; + PassKit = { inherit PassKitCore; }; + QTKit = { inherit CoreMedia CoreMediaIO MediaToolbox VideoToolbox; }; + Quartz = { inherit QTKit; }; + QuartzCore = { inherit ApplicationServices CoreImage CoreVideo Metal OpenCL libobjc; }; + Security = { inherit IOKit libDER; }; + TWAIN = { inherit Carbon; }; + VideoDecodeAcceleration = { inherit CoreVideo; }; + WebKit = { inherit ApplicationServices Carbon libobjc; }; + }; - frameworks = bareFrameworks // overrides bareFrameworks; + # Overrides for framework derivations. + overrides = super: { + CoreFoundation = lib.overrideDerivation super.CoreFoundation (drv: { + setupHook = ./cf-setup-hook.sh; + }); + + # This framework doesn't exist in newer SDKs (somewhere around 10.13), but + # there are references to it in nixpkgs. + QuickTime = throw "QuickTime framework not available"; + + # Seems to be appropriate given https://developer.apple.com/forums/thread/666686 + JavaVM = super.JavaNativeFoundation; + + CoreVideo = lib.overrideDerivation super.CoreVideo (drv: { + installPhase = drv.installPhase + '' + # When used as a module, complains about a missing import for + # Darwin.C.stdint. Apparently fixed in later SDKs. + awk -i inplace '/CFBase.h/ { print "#include " } { print }' \ + $out/Library/Frameworks/CoreVideo.framework/Headers/CVBase.h + ''; + }); + }; + + # Merge extraDeps into generatedDeps. + deps = generatedDeps // ( + lib.mapAttrs + (name: deps: generatedDeps.${name} // deps) + extraDeps + ); + + # Create derivations, and add private frameworks. + bareFrameworks = (lib.mapAttrs framework deps) // ( + lib.mapAttrs privateFramework (import ./private-frameworks.nix { + inherit frameworks; + libobjc = pkgs.darwin.apple_sdk_11_0.objc4; + }) + ); + in + # Apply derivation overrides. + bareFrameworks // overrides bareFrameworks; } diff --git a/pkgs/os-specific/darwin/apple-sdk-11.0/default.nix b/pkgs/os-specific/darwin/apple-sdk-11.0/default.nix index 8c9e16a6ca9a9..1133cca002a8b 100644 --- a/pkgs/os-specific/darwin/apple-sdk-11.0/default.nix +++ b/pkgs/os-specific/darwin/apple-sdk-11.0/default.nix @@ -31,10 +31,7 @@ let }; installPhase = '' - cd Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk - - mkdir $out - cp -r System usr $out/ + mv Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk $out ''; }; @@ -49,10 +46,7 @@ let }; installPhase = '' - cd Library/Developer/CommandLineTools - - mkdir $out - cp -r Library usr $out/ + mv Library/Developer/CommandLineTools $out ''; }; diff --git a/pkgs/os-specific/darwin/apple-sdk-11.0/frameworks.nix b/pkgs/os-specific/darwin/apple-sdk-11.0/frameworks.nix index 59cbc2b1063a1..fa6945f76718f 100644 --- a/pkgs/os-specific/darwin/apple-sdk-11.0/frameworks.nix +++ b/pkgs/os-specific/darwin/apple-sdk-11.0/frameworks.nix @@ -1,193 +1,196 @@ -{ frameworks, libs, libobjc, libnetwork }: with frameworks; with libs; +# This file is generated by gen-frameworks.nix. +# Do not edit, put overrides in apple_sdk.nix instead. +{ libs, frameworks }: with libs; with frameworks; { AGL = { inherit Carbon OpenGL; }; - AVFoundation = { inherit ApplicationServices AVFCapture AVFCore CoreGraphics simd UniformTypeIdentifiers; }; - AVKit = {}; - Accelerate = { inherit CoreWLAN IOBluetooth; }; - Accessibility = {}; - Accounts = {}; - AdSupport = {}; - AddressBook = { inherit AddressBookCore Carbon ContactsPersistence libobjc; }; - AppKit = { inherit ApplicationServices AudioToolbox AudioUnit Foundation QuartzCore UIFoundation; }; - AppTrackingTransparency = {}; + AVFoundation = { inherit AudioToolbox CoreAudio CoreAudioTypes CoreFoundation CoreGraphics CoreImage CoreMIDI CoreMedia CoreVideo Foundation IOKit ImageIO MediaToolbox Metal QuartzCore UniformTypeIdentifiers simd; }; + AVKit = { inherit AVFoundation AppKit Cocoa Foundation; }; + Accelerate = { inherit CoreFoundation CoreGraphics CoreVideo Foundation IOKit Metal; }; + Accessibility = { inherit CoreGraphics Foundation; }; + Accounts = { inherit Foundation; }; + AdServices = { inherit Foundation; }; + AdSupport = { inherit Foundation; }; + AddressBook = { inherit Carbon Cocoa CoreFoundation Foundation; }; + AppKit = { inherit ApplicationServices CloudKit CoreData CoreFoundation CoreGraphics CoreImage CoreLocation Foundation IOKit Metal OpenGL QuartzCore; }; + AppTrackingTransparency = { inherit Foundation; }; AppleScriptKit = {}; - AppleScriptObjC = {}; - ApplicationServices = { inherit ColorSync CoreGraphics CoreServices CoreText ImageIO; }; - AudioToolbox = { inherit AudioToolboxCore CoreAudio CoreMIDI; }; - AudioUnit = { inherit AudioToolbox Carbon CoreAudio; }; - AudioVideoBridging = { inherit Foundation; }; - AuthenticationServices = {}; - AutomaticAssessmentConfiguration = {}; - Automator = {}; - BackgroundTasks = {}; - BusinessChat = {}; - CFNetwork = {}; + AppleScriptObjC = { inherit Foundation; }; + ApplicationServices = { inherit ColorSync CoreFoundation CoreGraphics CoreServices CoreText ImageIO; }; + AudioToolbox = { inherit Carbon CoreAudio CoreAudioTypes CoreFoundation CoreMIDI Foundation; }; + AudioUnit = { inherit AudioToolbox; }; + AudioVideoBridging = { inherit Foundation IOKit; }; + AuthenticationServices = { inherit AppKit Foundation; }; + AutomaticAssessmentConfiguration = { inherit Foundation; }; + Automator = { inherit AppKit Cocoa Foundation OSAKit; }; + BackgroundTasks = { inherit Foundation; }; + BusinessChat = { inherit Cocoa Foundation; }; + CFNetwork = { inherit CoreFoundation; }; CalendarStore = {}; - CallKit = {}; - Carbon = { inherit ApplicationServices CoreServices Foundation IOKit QuartzCore Security libobjc; }; - ClassKit = {}; - CloudKit = { inherit CoreLocation; }; - Cocoa = { inherit AppKit CoreData; }; - Collaboration = {}; - ColorSync = {}; + CallKit = { inherit CoreFoundation CoreGraphics Foundation IOKit; }; + Carbon = { inherit ApplicationServices CoreServices Foundation Security; }; + ClassKit = { inherit CoreGraphics Foundation; }; + CloudKit = { inherit CoreFoundation CoreGraphics CoreLocation Foundation IOKit; }; + Cocoa = { inherit AppKit CoreData Foundation; }; + Collaboration = { inherit AppKit CoreServices Foundation; }; + ColorSync = { inherit CoreFoundation; }; Combine = {}; - Contacts = {}; - ContactsUI = {}; - CoreAudio = { inherit IOKit CoreAudioTypes; }; - CoreAudioKit = { inherit AudioUnit; }; - CoreAudioTypes = {}; - CoreBluetooth = {}; - CoreData = { inherit CloudKit; }; + Contacts = { inherit CoreFoundation CoreGraphics Foundation IOKit; }; + ContactsUI = { inherit AppKit; }; + CoreAudio = { inherit CoreAudioTypes CoreFoundation; }; + CoreAudioKit = { inherit AppKit AudioUnit Cocoa Foundation; }; + CoreAudioTypes = { inherit CoreFoundation; }; + CoreBluetooth = { inherit Foundation; }; + CoreData = { inherit CloudKit Combine CoreFoundation CoreGraphics CoreLocation Foundation IOKit; }; CoreDisplay = {}; - CoreFoundation = { inherit libobjc; }; - CoreGraphics = { inherit Accelerate IOKit IOSurface SystemConfiguration; }; - CoreHaptics = {}; - CoreImage = {}; - CoreLocation = {}; - CoreMIDI = {}; - CoreMIDIServer = { inherit CoreMIDI; }; - CoreML = {}; - CoreMedia = { inherit ApplicationServices AudioToolbox AudioUnit CoreAudio CoreGraphics CoreVideo; }; - CoreMediaIO = { inherit CoreMedia; }; - CoreMotion = {}; - CoreServices = { inherit CFNetwork CoreAudio CoreData CoreFoundation DiskArbitration NetFS OpenDirectory Security ServiceManagement; }; - CoreSpotlight = {}; + CoreFoundation = {}; + CoreGraphics = { inherit CoreFoundation IOKit; }; + CoreHaptics = { inherit Foundation; }; + CoreImage = { inherit ApplicationServices CoreFoundation CoreGraphics CoreVideo Foundation IOKit IOSurface ImageIO Metal OpenGL; }; + CoreLocation = { inherit CoreFoundation CoreGraphics Foundation IOKit; }; + CoreMIDI = { inherit CoreFoundation CoreGraphics Foundation IOKit; }; + CoreMIDIServer = {}; + CoreML = { inherit CoreFoundation CoreGraphics CoreVideo Foundation IOKit ImageIO Metal; }; + CoreMedia = { inherit CoreAudio CoreAudioTypes CoreFoundation CoreGraphics CoreVideo Foundation IOKit Metal; }; + CoreMediaIO = { inherit CoreFoundation CoreMedia; }; + CoreMotion = { inherit Foundation; }; + CoreServices = { inherit CFNetwork CoreFoundation DiskArbitration Security; }; + CoreSpotlight = { inherit Foundation UniformTypeIdentifiers; }; CoreTelephony = {}; - CoreText = { inherit CoreGraphics; }; - CoreVideo = { inherit ApplicationServices CoreGraphics IOSurface OpenGL; }; - CoreWLAN = { inherit SecurityFoundation; }; - CryptoKit = {}; - CryptoTokenKit = {}; - DVDPlayback = {}; - DeveloperToolsSupport = {}; - DeviceCheck = {}; - DirectoryService = {}; - DiscRecording = { inherit CoreServices IOKit libobjc; }; - DiscRecordingUI = {}; - DiskArbitration = { inherit IOKit; }; + CoreText = { inherit CoreFoundation CoreGraphics; }; + CoreVideo = { inherit ApplicationServices CoreFoundation CoreGraphics IOSurface Metal OpenGL; }; + CoreWLAN = { inherit Foundation IOKit; }; + CryptoKit = { inherit CoreFoundation CoreGraphics Foundation IOKit LocalAuthentication Security; }; + CryptoTokenKit = { inherit CoreFoundation CoreGraphics Foundation IOKit Security; }; + DVDPlayback = { inherit ApplicationServices CoreFoundation Security; }; + DeveloperToolsSupport = { inherit Foundation; }; + DeviceCheck = { inherit Foundation; }; + DirectoryService = { inherit CoreFoundation; }; + DiscRecording = { inherit CoreServices Foundation; }; + DiscRecordingUI = { inherit Carbon Cocoa DiscRecording; }; + DiskArbitration = { inherit CoreFoundation IOKit; }; DriverKit = {}; - EventKit = {}; - ExceptionHandling = {}; - ExecutionPolicy = {}; - ExternalAccessory = {}; - FWAUserLib = {}; - FileProvider = {}; - FileProviderUI = {}; - FinderSync = {}; - ForceFeedback = { inherit IOKit; }; - Foundation = { inherit ApplicationServices CoreFoundation Security SystemConfiguration Combine libobjc; }; - GLKit = {}; + EventKit = { inherit CoreGraphics CoreLocation Foundation; }; + ExceptionHandling = { inherit Foundation; }; + ExecutionPolicy = { inherit Foundation; }; + ExternalAccessory = { inherit Foundation; }; + FWAUserLib = { inherit IOKit; }; + FileProvider = { inherit CoreGraphics Foundation; }; + FileProviderUI = { inherit AppKit FileProvider Foundation; }; + FinderSync = { inherit AppKit Foundation; }; + ForceFeedback = { inherit CoreFoundation IOKit; }; + Foundation = { inherit ApplicationServices Combine CoreFoundation CoreGraphics CoreServices IOKit Security; }; + GLKit = { inherit AppKit CloudKit CoreData CoreFoundation CoreGraphics CoreImage CoreLocation Foundation IOKit Metal ModelIO OpenGL QuartzCore simd; }; GLUT = { inherit OpenGL; }; - GSS = {}; - GameController = {}; - GameKit = { inherit Cocoa Foundation GameCenterFoundation GameCenterUI GameCenterUICore GameController GameplayKit Metal MetalKit ModelIO ReplayKit SceneKit SpriteKit; }; - GameplayKit = {}; - HIDDriverKit = {}; + GSS = { inherit CoreFoundation; }; + GameController = { inherit AppKit Foundation IOKit; }; + GameKit = { inherit AppKit Cocoa Contacts CoreGraphics Foundation GameController GameplayKit Metal MetalKit ModelIO SceneKit SpriteKit simd; }; + GameplayKit = { inherit AppKit CloudKit CoreData CoreFoundation CoreGraphics CoreImage CoreLocation Foundation GLKit IOKit Metal ModelIO QuartzCore SceneKit SpriteKit simd; }; + HIDDriverKit = { inherit IOKit USBDriverKit; }; Hypervisor = {}; - ICADevices = { inherit Carbon IOBluetooth libobjc; }; - IMServicePlugIn = {}; - IOBluetooth = { inherit CoreBluetooth IOKit; }; - IOBluetoothUI = { inherit IOBluetooth; }; - IOKit = {}; - IOSurface = { inherit IOKit; }; - IOUSBHost = {}; - IdentityLookup = {}; - ImageCaptureCore = {}; - ImageIO = { inherit CoreGraphics; }; - InputMethodKit = { inherit Carbon; }; + ICADevices = { inherit CoreFoundation CoreGraphics CoreServices IOBluetooth; }; + IMServicePlugIn = { inherit Foundation; }; + IOBluetooth = { inherit CoreAudio CoreFoundation CoreServices Foundation IOKit; }; + IOBluetoothUI = { inherit Cocoa IOBluetooth; }; + IOKit = { inherit CoreFoundation; }; + IOSurface = { inherit CoreFoundation Foundation IOKit; }; + IOUSBHost = { inherit Foundation IOKit; }; + IdentityLookup = { inherit Foundation; }; + ImageCaptureCore = { inherit Cocoa CoreGraphics Foundation; }; + ImageIO = { inherit CoreFoundation CoreGraphics; }; + InputMethodKit = { inherit Carbon Cocoa Foundation; }; InstallerPlugins = {}; InstantMessage = {}; - Intents = {}; - JavaNativeFoundation = {}; - JavaRuntimeSupport = {}; - JavaScriptCore = { inherit libobjc; }; + Intents = { inherit CoreFoundation CoreGraphics CoreLocation Foundation IOKit; }; + JavaNativeFoundation = { inherit Foundation; }; + JavaRuntimeSupport = { inherit ApplicationServices Cocoa Foundation QuartzCore; }; + JavaScriptCore = { inherit CoreFoundation CoreGraphics Foundation; }; Kerberos = {}; - Kernel = { inherit IOKit; }; - KernelManagement = {}; + Kernel = {}; + KernelManagement = { inherit Foundation; }; LDAP = {}; - LatentSemanticMapping = { inherit Carbon; }; - LinkPresentation = { inherit URLFormatting; }; - LocalAuthentication = {}; - MLCompute = {}; - MapKit = {}; - MediaAccessibility = { inherit CoreGraphics CoreText QuartzCore; }; - MediaLibrary = {}; - MediaPlayer = {}; - MediaToolbox = { inherit AudioToolbox AudioUnit CoreMedia; }; + LatentSemanticMapping = { inherit Carbon CoreFoundation; }; + LinkPresentation = { inherit AppKit Foundation; }; + LocalAuthentication = { inherit Foundation; }; + MLCompute = { inherit CoreFoundation CoreGraphics Foundation IOKit Metal; }; + MapKit = { inherit AppKit CloudKit CoreData CoreFoundation CoreGraphics CoreImage CoreLocation Foundation IOKit Metal QuartzCore; }; + MediaAccessibility = { inherit CoreFoundation CoreGraphics CoreText QuartzCore; }; + MediaLibrary = { inherit Foundation; }; + MediaPlayer = { inherit AVFoundation CoreGraphics Foundation; }; + MediaToolbox = { inherit AudioToolbox CoreFoundation CoreMedia; }; Message = {}; - Metal = {}; - MetalKit = { inherit Metal ModelIO; }; - MetalPerformanceShaders = {}; - MetalPerformanceShadersGraph = {}; - MetricKit = { inherit SignpostMetrics; }; - ModelIO = {}; - MultipeerConnectivity = {}; - NaturalLanguage = {}; - NearbyInteraction = {}; - NetFS = {}; - Network = { inherit libnetwork; }; - NetworkExtension = { inherit Network; }; + Metal = { inherit CoreFoundation CoreGraphics Foundation IOKit IOSurface; }; + MetalKit = { inherit AppKit CloudKit CoreData CoreFoundation CoreGraphics CoreImage CoreLocation Foundation IOKit Metal ModelIO QuartzCore simd; }; + MetalPerformanceShaders = { inherit CoreGraphics Foundation Metal simd; }; + MetalPerformanceShadersGraph = { inherit Foundation MetalPerformanceShaders; }; + MetricKit = { inherit CoreFoundation CoreGraphics Foundation IOKit; }; + ModelIO = { inherit CoreFoundation CoreGraphics Foundation IOKit simd; }; + MultipeerConnectivity = { inherit Cocoa Foundation; }; + NaturalLanguage = { inherit CoreFoundation CoreGraphics Foundation IOKit; }; + NearbyInteraction = { inherit CoreFoundation CoreGraphics Foundation IOKit simd; }; + NetFS = { inherit CoreFoundation; }; + Network = { inherit CoreFoundation Foundation Security; }; + NetworkExtension = { inherit Foundation Network Security; }; NetworkingDriverKit = {}; - NotificationCenter = {}; - OSAKit = { inherit Carbon; }; - OSLog = {}; + NotificationCenter = { inherit AppKit Foundation; }; + OSAKit = { inherit Carbon Cocoa; }; + OSLog = { inherit CoreFoundation CoreGraphics Foundation IOKit; }; OpenAL = {}; - OpenCL = { inherit IOSurface OpenGL; }; - OpenDirectory = {}; + OpenCL = { inherit OpenGL; }; + OpenDirectory = { inherit CoreFoundation Foundation; }; OpenGL = {}; - PCIDriverKit = {}; - PCSC = { inherit CoreData; }; - PDFKit = {}; - ParavirtualizedGraphics = {}; - PassKit = { inherit PassKitCore; }; - PencilKit = {}; - Photos = {}; - PhotosUI = {}; - PreferencePanes = {}; - PushKit = {}; - Python = {}; - QTKit = { inherit CoreMedia CoreMediaIO MediaToolbox VideoToolbox; }; - Quartz = { inherit QTKit QuartzCore QuickLook PDFKit; }; - QuartzCore = { inherit ApplicationServices CoreImage CoreVideo Metal OpenCL libobjc; }; - QuickLook = { inherit ApplicationServices; }; - QuickLookThumbnailing = {}; - RealityKit = {}; - ReplayKit = {}; + PCIDriverKit = { inherit IOKit; }; + PCSC = {}; + PDFKit = { inherit AppKit Cocoa; }; + ParavirtualizedGraphics = { inherit AppKit CoreVideo Foundation IOSurface Metal; }; + PassKit = { inherit AppKit Contacts CoreGraphics Foundation; }; + PencilKit = { inherit AppKit CloudKit Cocoa CoreData CoreFoundation CoreGraphics CoreImage CoreLocation Foundation IOKit Metal QuartzCore; }; + Photos = { inherit AVFoundation CoreAudio CoreFoundation CoreGraphics CoreImage CoreLocation CoreMIDI CoreMedia Foundation IOKit ImageIO Metal QuartzCore UniformTypeIdentifiers simd; }; + PhotosUI = { inherit AppKit Foundation MapKit Photos; }; + PreferencePanes = { inherit Cocoa; }; + PushKit = { inherit Foundation; }; + Python = { inherit Carbon; }; + QTKit = {}; + Quartz = { inherit AppKit ApplicationServices Cocoa Foundation ImageCaptureCore OpenGL PDFKit QuartzCore QuickLook; }; + QuartzCore = { inherit CoreFoundation CoreGraphics CoreImage CoreVideo Foundation IOKit Metal OpenGL; }; + QuickLook = { inherit ApplicationServices CoreFoundation; }; + QuickLookThumbnailing = { inherit CoreGraphics Foundation UniformTypeIdentifiers; }; + RealityKit = { inherit AVFoundation AppKit AudioToolbox CloudKit Combine CoreAudio CoreData CoreFoundation CoreGraphics CoreImage CoreLocation CoreMIDI CoreText Foundation IOKit Metal MultipeerConnectivity QuartzCore simd; }; + ReplayKit = { inherit AVFoundation AppKit Foundation; }; Ruby = {}; - SafariServices = {}; - SceneKit = {}; - ScreenSaver = {}; - ScreenTime = {}; - ScriptingBridge = {}; - Security = { inherit IOKit libDER; }; - SecurityFoundation = { inherit Security; }; - SecurityInterface = { inherit Security SecurityFoundation; }; - SensorKit = {}; - ServiceManagement = { inherit Security; }; - Social = {}; - SoundAnalysis = {}; - Speech = {}; - SpriteKit = {}; - StoreKit = {}; - SwiftUI = { inherit AppKit DeveloperToolsSupport UniformTypeIdentifiers; }; + SafariServices = { inherit AppKit CloudKit CoreData CoreFoundation CoreGraphics CoreImage CoreLocation Foundation IOKit Metal QuartzCore; }; + SceneKit = { inherit AppKit CloudKit CoreData CoreFoundation CoreGraphics CoreImage CoreLocation Foundation GLKit IOKit Metal ModelIO QuartzCore simd; }; + ScreenSaver = { inherit AppKit Foundation; }; + ScreenTime = { inherit AppKit Foundation; }; + ScriptingBridge = { inherit ApplicationServices CoreServices Foundation; }; + Security = { inherit CoreFoundation; }; + SecurityFoundation = { inherit Foundation Security; }; + SecurityInterface = { inherit AppKit Cocoa Security SecurityFoundation; }; + SensorKit = { inherit CoreFoundation CoreLocation Foundation; }; + ServiceManagement = { inherit CoreFoundation Security; }; + Social = { inherit AppKit Foundation; }; + SoundAnalysis = { inherit AVFoundation CoreML CoreMedia Foundation; }; + Speech = { inherit AVFoundation CoreAudio CoreFoundation CoreGraphics CoreImage CoreMIDI CoreMedia Foundation IOKit Metal QuartzCore UniformTypeIdentifiers simd; }; + SpriteKit = { inherit AppKit CloudKit Cocoa CoreData CoreFoundation CoreGraphics CoreImage CoreLocation Foundation GLKit IOKit Metal ModelIO QuartzCore simd; }; + StoreKit = { inherit AppKit CoreGraphics Foundation; }; + SwiftUI = { inherit AppKit CloudKit Combine CoreData CoreFoundation CoreGraphics CoreImage CoreLocation DeveloperToolsSupport Foundation IOKit Metal QuartzCore UniformTypeIdentifiers; }; SyncServices = {}; System = {}; - SystemConfiguration = { inherit Security; }; - SystemExtensions = {}; - TWAIN = { inherit Carbon; }; + SystemConfiguration = { inherit CoreFoundation Security; }; + SystemExtensions = { inherit Foundation; }; + TWAIN = {}; Tcl = {}; Tk = {}; - USBDriverKit = {}; - UniformTypeIdentifiers = {}; - UserNotifications = {}; - UserNotificationsUI = {}; - VideoDecodeAcceleration = { inherit CoreVideo; }; - VideoSubscriberAccount = {}; - VideoToolbox = { inherit CoreMedia CoreVideo; }; - Virtualization = {}; - Vision = {}; - WebKit = { inherit ApplicationServices Carbon JavaScriptCore OpenGL libobjc; }; - WidgetKit = {}; - iTunesLibrary = {}; + USBDriverKit = { inherit IOKit; }; + UniformTypeIdentifiers = { inherit CoreFoundation CoreGraphics Foundation IOKit; }; + UserNotifications = { inherit Foundation; }; + UserNotificationsUI = { inherit AppKit; }; + VideoDecodeAcceleration = {}; + VideoSubscriberAccount = { inherit Foundation; }; + VideoToolbox = { inherit CoreFoundation CoreGraphics CoreMedia CoreVideo; }; + Virtualization = { inherit CoreFoundation CoreGraphics Foundation IOKit; }; + Vision = { inherit CoreAudio CoreFoundation CoreGraphics CoreML CoreMedia CoreVideo Foundation IOKit ImageIO Metal simd; }; + WebKit = { inherit AppKit CloudKit CoreData CoreFoundation CoreGraphics CoreImage CoreLocation Foundation IOKit JavaScriptCore Metal OpenGL QuartzCore; }; + WidgetKit = { inherit Combine CoreFoundation CoreGraphics CoreVideo Foundation IOKit Intents Metal SwiftUI; }; + iTunesLibrary = { inherit Foundation; }; vmnet = {}; } diff --git a/pkgs/os-specific/darwin/gen-frameworks.py b/pkgs/os-specific/darwin/gen-frameworks.py new file mode 100755 index 0000000000000..ec2a6c7c16ecd --- /dev/null +++ b/pkgs/os-specific/darwin/gen-frameworks.py @@ -0,0 +1,147 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i python -p python3 swiftPackages.swift-unwrapped + +""" +Generate a frameworks.nix for a macOS SDK. + +You may point this tool at an Xcode bundled SDK, but more ideal is using the +SDK from Nixpkgs. For example: + +SDK_PATH="$(nix-build --no-link -A darwin.apple_sdk_11_0.MacOSX-SDK)" +./gen-frameworks.py "$SDK_PATH" > ./new-frameworks.nix +""" + +import json +import os +import subprocess +import sys + +ALLOWED_LIBS = ["simd"] + +HEADER = """\ +# This file is generated by gen-frameworks.nix. +# Do not edit, put overrides in apple_sdk.nix instead. +{ libs, frameworks }: with libs; with frameworks; +{ +""" + +FOOTER = """\ +} +""" + + +def eprint(*args): + print(*args, file=sys.stderr) + + +def name_from_ident(ident): + return ident.get("swift", ident.get("clang")) + + +def scan_sdk(sdk): + # Find frameworks by scanning the SDK frameworks directory. + frameworks = [ + framework.removesuffix(".framework") + for framework in os.listdir(f"{sdk}/System/Library/Frameworks") + if not framework.startswith("_") + ] + frameworks.sort() + + # Determine the longest name for padding output. + width = len(max(frameworks, key=len)) + + output = HEADER + + for framework in frameworks: + deps = [] + + # Use Swift to scan dependencies, because a module may have both Clang + # and Swift parts. Using Clang only imports the Clang module, whereas + # using Swift will usually import both Clang + Swift overlay. + # + # TODO: The above is an assumption. Not sure if it's possible a Swift + # module completely shadows a Clang module. (Seems unlikely) + # + # TODO: Handle "module 'Foobar' is incompatible with feature 'swift'" + # + # If there were a similar Clang invocation for scanning, we could fix + # the above todos, but that doesn't appear to exist. + eprint(f"# scanning {framework}") + result = subprocess.run( + [ + "swiftc", + "-scan-dependencies", + # We provide a source snippet via stdin. + "-", + # Use the provided SDK. + "-sdk", + sdk, + # This search path is normally added automatically by the + # compiler based on the SDK, but we have a patch in place that + # removes that for SDKs in /nix/store, because our xcbuild stub + # SDK doesn't have the directory. + # (swift-prevent-sdk-dirs-warning.patch) + "-I", + f"{sdk}/usr/lib/swift", + # For some reason, 'lib/swift/shims' from both the SDK and + # Swift compiler are picked up, causing redefinition errors. + # This eliminates the latter. + "-resource-dir", + f"{sdk}/usr/lib/swift", + ], + input=f"import {framework}".encode(), + stdout=subprocess.PIPE, + ) + if result.returncode != 0: + eprint(f"# Scanning {framework} failed (exit code {result.returncode})") + result.stdout = b"" + + # Parse JSON output. + if len(result.stdout) != 0: + data = json.loads(result.stdout) + + # Entries in the modules list come in pairs. The first is an + # identifier (`{ swift: "foobar" }` or `{ clang: "foobar" }`), and + # the second metadata for that module. Here we look for the pair + # that matches the framework we're scanning (and ignore the rest). + modules = data["modules"] + for i in range(0, len(modules), 2): + ident, meta = modules[i : i + 2] + + # NOTE: We may match twice, for a Swift module _and_ for a + # Clang module. So matching here doesn't break from the loop, + # and deps is appended to. + if name_from_ident(ident) == framework: + dep_idents = meta["directDependencies"] + deps += [name_from_ident(ident) for ident in dep_idents] + # List unfiltered deps in progress output. + eprint(ident, "->", dep_idents) + + # Filter out modules that are not separate derivations. + # Also filter out duplicates (when a Swift overlay imports the Clang module) + allowed = frameworks + ALLOWED_LIBS + deps = set([dep for dep in deps if dep in allowed]) + + # Filter out self-references. (Swift overlay importing Clang module.) + if framework in deps: + deps.remove(framework) + + # Generate a Nix attribute line. + if len(deps) != 0: + deps = list(deps) + deps.sort() + deps = " ".join(deps) + output += f" {framework.ljust(width)} = {{ inherit {deps}; }};\n" + else: + output += f" {framework.ljust(width)} = {{}};\n" + + output += FOOTER + sys.stdout.write(output) + + +if __name__ == "__main__": + if len(sys.argv) != 2: + eprint(f"Usage: {sys.argv[0]} ") + sys.exit(64) + + scan_sdk(sys.argv[1])