diff options
Diffstat (limited to 'pkgs/os-specific/darwin')
63 files changed, 1166 insertions, 221 deletions
diff --git a/pkgs/os-specific/darwin/DarwinTools/default.nix b/pkgs/os-specific/darwin/DarwinTools/default.nix index 5badf2434d640..588769c7bfc6a 100644 --- a/pkgs/os-specific/darwin/DarwinTools/default.nix +++ b/pkgs/os-specific/darwin/DarwinTools/default.nix @@ -8,7 +8,11 @@ stdenv.mkDerivation rec { sha256 = "0hh4jl590jv3v830p77r3jcrnpndy7p2b8ajai3ldpnx2913jfhp"; }; - patchPhase = '' + patches = [ + ./sw_vers-CFPriv.patch + ]; + + postPatch = '' substituteInPlace Makefile \ --replace gcc cc ''; diff --git a/pkgs/os-specific/darwin/DarwinTools/sw_vers-CFPriv.patch b/pkgs/os-specific/darwin/DarwinTools/sw_vers-CFPriv.patch new file mode 100644 index 0000000000000..6faeaa75025e6 --- /dev/null +++ b/pkgs/os-specific/darwin/DarwinTools/sw_vers-CFPriv.patch @@ -0,0 +1,19 @@ +--- a/sw_vers.c 2021-04-19 13:06:50.131346864 +0900 ++++ b/sw_vers.c 2021-04-19 13:07:32.481967474 +0900 +@@ -28,7 +28,15 @@ + */ + + #include <CoreFoundation/CoreFoundation.h> +-#include <CoreFoundation/CFPriv.h> ++ ++// Avoid dependency on CoreFoundation/CFPriv, which no longer appears to be ++// part of the upstream sdk. ++ ++CFDictionaryRef _CFCopyServerVersionDictionary(void); ++CFDictionaryRef _CFCopySystemVersionDictionary(void); ++extern CFStringRef _kCFSystemVersionProductNameKey; ++extern CFStringRef _kCFSystemVersionProductVersionKey; ++extern CFStringRef _kCFSystemVersionBuildVersionKey; + + void usage(char *progname) { + fprintf(stderr, "Usage: %s [-productName|-productVersion|-buildVersion]\n", progname); 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 new file mode 100644 index 0000000000000..a4242405b4118 --- /dev/null +++ b/pkgs/os-specific/darwin/apple-sdk-11.0/apple_sdk.nix @@ -0,0 +1,151 @@ +{ lib, stdenvNoCC, buildPackages, fetchurl, xar, cpio, pkgs, python3, pbzx, MacOSX-SDK }: + +# TODO: reorganize to make this just frameworks, and move libs to default.nix + +let + stdenv = stdenvNoCC; + + standardFrameworkPath = name: private: + "/System/Library/${lib.optionalString private "Private"}Frameworks/${name}.framework"; + + mkDepsRewrites = deps: + let + mergeRewrites = x: y: { + prefix = lib.mergeAttrs (x.prefix or {}) (y.prefix or {}); + const = lib.mergeAttrs (x.const or {}) (y.const or {}); + }; + + rewriteArgs = { prefix ? {}, const ? {} }: lib.concatLists ( + (lib.mapAttrsToList (from: to: [ "-p" "${from}:${to}" ]) prefix) ++ + (lib.mapAttrsToList (from: to: [ "-c" "${from}:${to}" ]) const) + ); + + rewrites = depList: lib.fold mergeRewrites {} + (map (dep: dep.tbdRewrites) + (lib.filter (dep: dep ? tbdRewrites) depList)); + in + lib.escapeShellArgs (rewriteArgs (rewrites (builtins.attrValues deps))); + + mkFramework = { name, deps, private ? false }: + let self = stdenv.mkDerivation { + pname = "apple-${lib.optionalString private "private-"}framework-${name}"; + version = MacOSX-SDK.version; + + dontUnpack = true; + + # because we copy files from the system + preferLocalBuild = true; + + disallowedRequisites = [ MacOSX-SDK ]; + + nativeBuildInputs = [ buildPackages.darwin.rewrite-tbd ]; + + installPhase = '' + mkdir -p $out/Library/Frameworks + + cp -r ${MacOSX-SDK}${standardFrameworkPath name private} $out/Library/Frameworks + + # Fix and check tbd re-export references + chmod u+w -R $out + find $out -name '*.tbd' -type f | while read tbd; do + echo "Fixing re-exports in $tbd" + rewrite-tbd \ + -p ${standardFrameworkPath name private}/:$out/Library/Frameworks/${name}.framework/ \ + ${mkDepsRewrites deps} \ + -r ${builtins.storeDir} \ + "$tbd" + done + ''; + + propagatedBuildInputs = builtins.attrValues deps; + + passthru = { + tbdRewrites = { + prefix."${standardFrameworkPath name private}/" = "${self}/Library/Frameworks/${name}.framework/"; + }; + }; + + meta = with lib; { + description = "Apple SDK framework ${name}"; + maintainers = with maintainers; [ copumpkin ]; + platforms = platforms.darwin; + }; + }; + in self; + + framework = name: deps: mkFramework { inherit name deps; private = false; }; + privateFramework = name: deps: mkFramework { inherit name deps; private = true; }; +in rec { + libs = { + xpc = stdenv.mkDerivation { + name = "apple-lib-xpc"; + dontUnpack = true; + + installPhase = '' + mkdir -p $out/include + pushd $out/include >/dev/null + cp -r "${MacOSX-SDK}/usr/include/xpc" $out/include/xpc + cp "${MacOSX-SDK}/usr/include/launch.h" $out/include/launch.h + popd >/dev/null + ''; + }; + + Xplugin = stdenv.mkDerivation { + name = "apple-lib-Xplugin"; + dontUnpack = true; + + propagatedBuildInputs = with frameworks; [ + OpenGL ApplicationServices Carbon IOKit CoreGraphics CoreServices CoreText + ]; + + installPhase = '' + mkdir -p $out/include $out/lib + ln -s "${MacOSX-SDK}/include/Xplugin.h" $out/include/Xplugin.h + cp ${MacOSX-SDK}/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 "${MacOSX-SDK}/include/utmp.h" + ln -s "${MacOSX-SDK}/include/utmpx.h" + popd >/dev/null + ''; + }; + + libDER = stdenv.mkDerivation { + name = "apple-lib-libDER"; + dontUnpack = true; + installPhase = '' + mkdir -p $out/include + cp -r ${MacOSX-SDK}/usr/include/libDER $out/include + ''; + }; + }; + + overrides = super: { + CoreFoundation = lib.overrideDerivation super.CoreFoundation (drv: { + setupHook = ./cf-setup-hook.sh; + }); + }; + + bareFrameworks = ( + lib.mapAttrs framework (import ./frameworks.nix { + inherit frameworks libs; + inherit (pkgs.darwin) libobjc Libsystem; + inherit (pkgs.darwin.apple_sdk) libnetwork; + }) + ) // ( + lib.mapAttrs privateFramework (import ./private-frameworks.nix { + inherit frameworks; + }) + ); + + frameworks = bareFrameworks // overrides bareFrameworks; +} diff --git a/pkgs/os-specific/darwin/apple-sdk-11.0/cf-setup-hook.sh b/pkgs/os-specific/darwin/apple-sdk-11.0/cf-setup-hook.sh new file mode 100644 index 0000000000000..3b08c51d196e4 --- /dev/null +++ b/pkgs/os-specific/darwin/apple-sdk-11.0/cf-setup-hook.sh @@ -0,0 +1,6 @@ +forceLinkCoreFoundationFramework() { + NIX_CFLAGS_COMPILE="-F@out@/Library/Frameworks${NIX_CFLAGS_COMPILE:+ }${NIX_CFLAGS_COMPILE-}" + NIX_LDFLAGS+=" @out@/Library/Frameworks/CoreFoundation.framework/CoreFoundation" +} + +preConfigureHooks+=(forceLinkCoreFoundationFramework) diff --git a/pkgs/os-specific/darwin/apple-sdk-11.0/default.nix b/pkgs/os-specific/darwin/apple-sdk-11.0/default.nix new file mode 100644 index 0000000000000..03a6650d9d989 --- /dev/null +++ b/pkgs/os-specific/darwin/apple-sdk-11.0/default.nix @@ -0,0 +1,58 @@ +{ stdenvNoCC, fetchurl, newScope, pkgs +, xar, cpio, python3, pbzx }: + +let + MacOSX-SDK = stdenvNoCC.mkDerivation rec { + pname = "MacOSX-SDK"; + version = "11.0.0"; + + # https://swscan.apple.com/content/catalogs/others/index-10.16.merged-1.sucatalog + src = fetchurl { + url = "http://swcdn.apple.com/content/downloads/58/37/001-75138-A_59RXKDS8YM/12ksm19hgzscfc7cau3yhecz4vpkps7wbq/CLTools_macOSNMOS_SDK.pkg"; + sha256 = "0n51ba926ckwm62w5c8lk3w5hj4ihk0p5j02321qi75wh824hl8m"; + }; + + dontBuild = true; + darwinDontCodeSign = true; + + nativeBuildInputs = [ cpio pbzx ]; + + outputs = [ "out" ]; + + unpackPhase = '' + pbzx $src | cpio -idm + ''; + + installPhase = '' + cd Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk + + mkdir $out + cp -r System usr $out/ + ''; + + passthru = { + inherit version; + }; + }; + + callPackage = newScope (packages // pkgs.darwin // { inherit MacOSX-SDK; }); + + packages = { + inherit (callPackage ./apple_sdk.nix {}) frameworks libs; + + # TODO: this is nice to be private. is it worth the callPackage above? + # Probably, I don't think that callPackage costs much at all. + inherit MacOSX-SDK; + + Libsystem = callPackage ./libSystem.nix {}; + LibsystemCross = pkgs.darwin.Libsystem; + libcharset = callPackage ./libcharset.nix {}; + libunwind = callPackage ./libunwind.nix {}; + libnetwork = callPackage ./libnetwork.nix {}; + objc4 = callPackage ./libobjc.nix {}; + + # questionable aliases + configd = pkgs.darwin.apple_sdk.frameworks.SystemConfiguration; + IOKit = pkgs.darwin.apple_sdk.frameworks.IOKit; + }; +in packages diff --git a/pkgs/os-specific/darwin/apple-sdk-11.0/frameworks.nix b/pkgs/os-specific/darwin/apple-sdk-11.0/frameworks.nix new file mode 100644 index 0000000000000..c8f8ccc4a0813 --- /dev/null +++ b/pkgs/os-specific/darwin/apple-sdk-11.0/frameworks.nix @@ -0,0 +1,193 @@ +{ frameworks, libs, libobjc, Libsystem, libnetwork }: with frameworks; with libs; +{ + AGL = { inherit Carbon OpenGL; }; + AVFoundation = { inherit ApplicationServices AVFCapture AVFCore CoreGraphics; }; + AVKit = {}; + Accelerate = { inherit CoreWLAN IOBluetooth; }; + Accessibility = {}; + Accounts = {}; + AdSupport = {}; + AddressBook = { inherit AddressBookCore Carbon ContactsPersistence libobjc; }; + AppKit = { inherit ApplicationServices AudioToolbox AudioUnit Foundation QuartzCore UIFoundation; }; + AppTrackingTransparency = {}; + 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 = {}; + CalendarStore = {}; + CallKit = {}; + Carbon = { inherit ApplicationServices CoreServices Foundation IOKit QuartzCore Security libobjc; }; + ClassKit = {}; + CloudKit = { inherit CoreLocation; }; + Cocoa = { inherit AppKit CoreData; }; + Collaboration = {}; + ColorSync = {}; + Combine = {}; + Contacts = {}; + ContactsUI = {}; + CoreAudio = { inherit IOKit CoreAudioTypes; }; + CoreAudioKit = { inherit AudioUnit; }; + CoreAudioTypes = {}; + CoreBluetooth = {}; + CoreData = { inherit CloudKit; }; + 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 = {}; + 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; }; + DriverKit = {}; + EventKit = {}; + ExceptionHandling = {}; + ExecutionPolicy = {}; + ExternalAccessory = {}; + FWAUserLib = {}; + FileProvider = {}; + FileProviderUI = {}; + FinderSync = {}; + ForceFeedback = { inherit IOKit; }; + Foundation = { inherit ApplicationServices CoreFoundation Security SystemConfiguration libobjc; }; + GLKit = {}; + GLUT = { inherit OpenGL; }; + GSS = {}; + GameController = {}; + GameKit = { inherit Cocoa Foundation GameCenterFoundation GameCenterUI GameCenterUICore GameController GameplayKit Metal MetalKit ModelIO ReplayKit SceneKit SpriteKit; }; + GameplayKit = {}; + HIDDriverKit = {}; + Hypervisor = {}; + ICADevices = { inherit Carbon IOBluetooth libobjc; }; + IMServicePlugIn = {}; + IOBluetooth = { inherit CoreBluetooth IOKit; }; + IOBluetoothUI = { inherit IOBluetooth; }; + IOKit = {}; + IOSurface = { inherit IOKit xpc; }; + IOUSBHost = {}; + IdentityLookup = {}; + ImageCaptureCore = {}; + ImageIO = { inherit CoreGraphics; }; + InputMethodKit = { inherit Carbon; }; + InstallerPlugins = {}; + InstantMessage = {}; + Intents = {}; + JavaNativeFoundation = {}; + JavaRuntimeSupport = {}; + JavaScriptCore = { inherit libobjc; }; + Kerberos = {}; + Kernel = { inherit IOKit; }; + KernelManagement = {}; + LDAP = {}; + LatentSemanticMapping = { inherit Carbon; }; + LinkPresentation = { inherit URLFormatting; }; + LocalAuthentication = {}; + MLCompute = {}; + MapKit = {}; + MediaAccessibility = { inherit CoreGraphics CoreText QuartzCore; }; + MediaLibrary = {}; + MediaPlayer = {}; + MediaToolbox = { inherit AudioToolbox AudioUnit CoreMedia; }; + Message = {}; + Metal = {}; + MetalKit = { inherit Metal ModelIO; }; + MetalPerformanceShaders = {}; + MetalPerformanceShadersGraph = {}; + MetricKit = { inherit SignpostMetrics; }; + ModelIO = {}; + MultipeerConnectivity = {}; + NaturalLanguage = {}; + NearbyInteraction = {}; + NetFS = {}; + Network = { inherit libnetwork; }; + NetworkExtension = { inherit Network; }; + NetworkingDriverKit = {}; + NotificationCenter = {}; + OSAKit = { inherit Carbon; }; + OSLog = {}; + OpenAL = {}; + OpenCL = { inherit IOSurface OpenGL; }; + OpenDirectory = {}; + 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 = {}; + 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 = {}; + SyncServices = {}; + System = {}; + SystemConfiguration = { inherit Security; }; + SystemExtensions = {}; + TWAIN = { inherit Carbon; }; + 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 = {}; + vmnet = {}; +} diff --git a/pkgs/os-specific/darwin/apple-sdk-11.0/libSystem.nix b/pkgs/os-specific/darwin/apple-sdk-11.0/libSystem.nix new file mode 100644 index 0000000000000..f04b964f755f4 --- /dev/null +++ b/pkgs/os-specific/darwin/apple-sdk-11.0/libSystem.nix @@ -0,0 +1,78 @@ +{ stdenvNoCC, buildPackages, MacOSX-SDK }: + +stdenvNoCC.mkDerivation { + pname = "libSystem"; + version = MacOSX-SDK.version; + + dontBuild = true; + dontUnpack = true; + + nativeBuildInputs = [ buildPackages.darwin.rewrite-tbd ]; + + includeDirs = [ + "CommonCrypto" "_types" "architecture" "arpa" "atm" "bank" "bsd" "bsm" + "corecrypto" "corpses" "default_pager" "device" "dispatch" "hfs" "i386" + "iokit" "kern" "libkern" "mach" "mach-o" "mach_debug" "machine" "malloc" + "miscfs" "net" "netinet" "netinet6" "netkey" "nfs" "os" "osfmk" "pexpert" + "platform" "protocols" "pthread" "rpc" "rpcsvc" "secure" "security" + "servers" "sys" "uuid" "vfs" "voucher" "xlocale" + ] ++ [ + "arm" "xpc" "arm64" + ]; + + csu = [ + "bundle1.o" "crt0.o" "crt1.10.5.o" "crt1.10.6.o" "crt1.o" "dylib1.10.5.o" + "dylib1.o" "gcrt1.o" "lazydylib1.o" + ]; + + installPhase = '' + mkdir -p $out/{include,lib} + + for dir in $includeDirs; do + from=${MacOSX-SDK}/usr/include/$dir + if [ -e "$from" ]; then + cp -dr $from $out/include + else + echo "Header directory '$from' doesn't exist: skipping" + fi + done + + cp -d \ + ${MacOSX-SDK}/usr/include/*.h \ + $out/include + + rm $out/include/tk*.h $out/include/tcl*.h + + cp -dr \ + ${MacOSX-SDK}/usr/lib/libSystem.* \ + ${MacOSX-SDK}/usr/lib/system \ + $out/lib + + # Extra libraries + for name in c dbm dl info m mx poll proc pthread rpcsvc util gcc_s.1 resolv; do + cp -d \ + ${MacOSX-SDK}/usr/lib/lib$name.tbd \ + ${MacOSX-SDK}/usr/lib/lib$name.*.tbd \ + $out/lib + done + + for f in $csu; do + from=${MacOSX-SDK}/usr/lib/$f + if [ -e "$from" ]; then + cp -d $from $out/lib + else + echo "Csu file '$from' doesn't exist: skipping" + fi + done + + chmod u+w -R $out/lib + find $out -name '*.tbd' -type f | while read tbd; do + rewrite-tbd \ + -c /usr/lib/libsystem.dylib:$out/lib/libsystem.dylib \ + -p /usr/lib/system/:$out/lib/system/ \ + -r ${builtins.storeDir} \ + "$tbd" + done + ''; +} + diff --git a/pkgs/os-specific/darwin/apple-sdk-11.0/libcharset.nix b/pkgs/os-specific/darwin/apple-sdk-11.0/libcharset.nix new file mode 100644 index 0000000000000..bf55037ab6057 --- /dev/null +++ b/pkgs/os-specific/darwin/apple-sdk-11.0/libcharset.nix @@ -0,0 +1,16 @@ +{ stdenvNoCC, buildPackages, MacOSX-SDK }: + +stdenvNoCC.mkDerivation { + pname = "libcharset"; + version = MacOSX-SDK.version; + + dontUnpack = true; + dontBuild = true; + + nativeBuildInputs = [ buildPackages.darwin.checkReexportsHook ]; + + installPhase = '' + mkdir -p $out/{include,lib} + cp ${MacOSX-SDK}/usr/lib/libcharset* $out/lib + ''; +} diff --git a/pkgs/os-specific/darwin/apple-sdk-11.0/libnetwork.nix b/pkgs/os-specific/darwin/apple-sdk-11.0/libnetwork.nix new file mode 100644 index 0000000000000..2e5c0593bf406 --- /dev/null +++ b/pkgs/os-specific/darwin/apple-sdk-11.0/libnetwork.nix @@ -0,0 +1,20 @@ +{ stdenvNoCC, buildPackages, MacOSX-SDK }: + +let self = stdenvNoCC.mkDerivation { + pname = "libnetwork"; + version = MacOSX-SDK.version; + + dontUnpack = true; + dontBuild = true; + + installPhase = '' + mkdir -p $out/lib + cp ${MacOSX-SDK}/usr/lib/libnetwork* $out/lib + ''; + + passthru = { + tbdRewrites = { + const."/usr/lib/libnetwork.dylib" = "${self}/lib/libnetwork.dylib"; + }; + }; +}; in self diff --git a/pkgs/os-specific/darwin/apple-sdk-11.0/libobjc.nix b/pkgs/os-specific/darwin/apple-sdk-11.0/libobjc.nix new file mode 100644 index 0000000000000..63ef2a1c263e0 --- /dev/null +++ b/pkgs/os-specific/darwin/apple-sdk-11.0/libobjc.nix @@ -0,0 +1,21 @@ +{ stdenvNoCC, MacOSX-SDK, libcharset }: + +let self = stdenvNoCC.mkDerivation { + pname = "libobjc"; + version = MacOSX-SDK.version; + + dontUnpack = true; + dontBuild = true; + + installPhase = '' + mkdir -p $out/{include,lib} + cp -r ${MacOSX-SDK}/usr/include/objc $out/include + cp ${MacOSX-SDK}/usr/lib/libobjc* $out/lib + ''; + + passthru = { + tbdRewrites = { + const."/usr/lib/libobjc.A.dylib" = "${self}/lib/libobjc.A.dylib"; + }; + }; +}; in self diff --git a/pkgs/os-specific/darwin/apple-sdk-11.0/libunwind.nix b/pkgs/os-specific/darwin/apple-sdk-11.0/libunwind.nix new file mode 100644 index 0000000000000..885780eba75cd --- /dev/null +++ b/pkgs/os-specific/darwin/apple-sdk-11.0/libunwind.nix @@ -0,0 +1,24 @@ +{ stdenvNoCC, buildPackages, MacOSX-SDK }: + +stdenvNoCC.mkDerivation { + pname = "libunwind"; + version = MacOSX-SDK.version; + + dontUnpack = true; + dontBuild = true; + + nativeBuildInputs = [ buildPackages.darwin.checkReexportsHook ]; + + installPhase = '' + mkdir -p $out/include/mach-o + + cp \ + ${MacOSX-SDK}/usr/include/libunwind.h \ + ${MacOSX-SDK}/usr/include/unwind.h \ + $out/include + + cp \ + ${MacOSX-SDK}/usr/include/mach-o/compact_unwind_encoding.h \ + $out/include/mach-o + ''; +} diff --git a/pkgs/os-specific/darwin/apple-sdk-11.0/private-frameworks.nix b/pkgs/os-specific/darwin/apple-sdk-11.0/private-frameworks.nix new file mode 100644 index 0000000000000..48b373bbd22c5 --- /dev/null +++ b/pkgs/os-specific/darwin/apple-sdk-11.0/private-frameworks.nix @@ -0,0 +1,17 @@ +{ frameworks }: with frameworks; +# generated by hand to avoid exposing all private frameworks +# frameworks here are only the necessary ones used by public frameworks. +{ + AVFCapture = {}; + AVFCore = {}; + AddressBookCore = { inherit ContactsPersistence; }; + AudioToolboxCore = {}; + ContactsPersistence = {}; + UIFoundation = {}; + GameCenterFoundation = {}; + GameCenterUI = {}; + GameCenterUICore = {}; + URLFormatting = {}; + SignpostMetrics = {}; + PassKitCore = {}; +} diff --git a/pkgs/os-specific/darwin/apple-source-releases/CarbonHeaders/default.nix b/pkgs/os-specific/darwin/apple-source-releases/CarbonHeaders/default.nix index b53c5985a21c2..25e1df3773dbf 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/CarbonHeaders/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/CarbonHeaders/default.nix @@ -1,6 +1,6 @@ -{ lib, appleDerivation }: +{ lib, appleDerivation', stdenvNoCC }: -appleDerivation { +appleDerivation' stdenvNoCC { dontBuild = true; installPhase = '' diff --git a/pkgs/os-specific/darwin/apple-source-releases/CommonCrypto/default.nix b/pkgs/os-specific/darwin/apple-source-releases/CommonCrypto/default.nix index 476a77c59d7f8..36013fe307ce4 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/CommonCrypto/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/CommonCrypto/default.nix @@ -1,6 +1,6 @@ -{ lib, appleDerivation }: +{ lib, appleDerivation', stdenvNoCC }: -appleDerivation { +appleDerivation' stdenvNoCC { installPhase = '' mkdir -p $out/include/CommonCrypto cp include/* $out/include/CommonCrypto diff --git a/pkgs/os-specific/darwin/apple-source-releases/Csu/default.nix b/pkgs/os-specific/darwin/apple-source-releases/Csu/default.nix index e3b3179d4a3b2..ac09a282f5121 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/Csu/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/Csu/default.nix @@ -1,13 +1,14 @@ -{ lib, appleDerivation }: +{ lib, appleDerivation', stdenv }: + +appleDerivation' stdenv { -appleDerivation { prePatch = '' substituteInPlace Makefile \ --replace /usr/lib /lib \ --replace /usr/local/lib /lib \ --replace /usr/bin "" \ --replace /bin/ "" \ - --replace "CC = " "CC = cc #" \ + --replace "CC = " "#" \ --replace "SDK_DIR = " "SDK_DIR = . #" \ # Mac OS didn't support rpaths back before 10.5, but we don't care about it. diff --git a/pkgs/os-specific/darwin/apple-source-releases/ICU/default.nix b/pkgs/os-specific/darwin/apple-source-releases/ICU/default.nix index 032b1447463d8..cdebfe6d2f727 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/ICU/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/ICU/default.nix @@ -1,8 +1,20 @@ -{ appleDerivation, python3 }: +{ appleDerivation, lib, stdenv, buildPackages, python3 }: + +let + formatVersionNumeric = version: + let + versionParts = lib.versions.splitVersion version; + major = lib.toInt (lib.elemAt versionParts 0); + minor = lib.toInt (lib.elemAt versionParts 1); + patch = if lib.length versionParts > 2 then lib.toInt (lib.elemAt versionParts 2) else 0; + in toString (major * 10000 + minor * 100 + patch); +in appleDerivation { nativeBuildInputs = [ python3 ]; + depsBuildBuild = lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) [ buildPackages.stdenv.cc ]; + postPatch = '' substituteInPlace makefile \ --replace "/usr/bin/" "" \ @@ -26,6 +38,13 @@ appleDerivation { --replace "&TestMailFilterCSS" "NULL" patchShebangs icuSources + '' + lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) '' + + # This looks like a bug in the makefile. It defines ENV_BUILDHOST to + # propagate the correct value of CC, CXX, etc, but has the following double + # expansion that results in the empty string. + substituteInPlace makefile \ + --replace '$($(ENV_BUILDHOST))' '$(ENV_BUILDHOST)' ''; # APPLE is using makefile to save its default configuration and call ./configure, so we hack makeFlags @@ -40,10 +59,21 @@ appleDerivation { "DATA_INSTALL_DIR=/share/icu/" "DATA_LOOKUP_DIR=$(DSTROOT)$(DATA_INSTALL_DIR)" - + ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ # darwin* platform properties are only defined on darwin # hack to use our lower macos version - "MAC_OS_X_VERSION_MIN_REQUIRED=__MAC_OS_X_VERSION_MIN_REQUIRED" - "OSX_HOST_VERSION_MIN_STRING=$(MACOSX_DEPLOYMENT_TARGET)" + "MAC_OS_X_VERSION_MIN_REQUIRED=${formatVersionNumeric stdenv.hostPlatform.darwinMinVersion}" + "ICU_TARGET_VERSION=-m${stdenv.hostPlatform.darwinPlatform}-version-min=${stdenv.hostPlatform.darwinMinVersion}" + ] + ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ + "CROSS_BUILD=YES" + "BUILD_TYPE=" + "RC_ARCHS=${stdenv.hostPlatform.darwinArch}" + "HOSTCC=cc" + "HOSTCXX=c++" + "CC=${stdenv.cc.targetPrefix}cc" + "CXX=${stdenv.cc.targetPrefix}c++" + "HOSTISYSROOT=" + "OSX_HOST_VERSION_MIN_STRING=${stdenv.buildPlatform.darwinMinVersion}" ]; doCheck = true; diff --git a/pkgs/os-specific/darwin/apple-source-releases/IOKit/default.nix b/pkgs/os-specific/darwin/apple-source-releases/IOKit/default.nix index 0ba61ccb49150..085d223bd04d8 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/IOKit/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/IOKit/default.nix @@ -1,7 +1,7 @@ -{ lib, appleDerivation, IOKitSrcs, xnu, darwin-stubs }: +{ lib, appleDerivation', stdenv, IOKitSrcs, xnu, darwin-stubs }: # Someday it'll make sense to split these out into their own packages, but today is not that day. -appleDerivation { +appleDerivation' stdenv { srcs = lib.attrValues IOKitSrcs; sourceRoot = "."; diff --git a/pkgs/os-specific/darwin/apple-source-releases/Libc/825_40_1.nix b/pkgs/os-specific/darwin/apple-source-releases/Libc/825_40_1.nix index 29aa3d64cb08b..c9202b536583c 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/Libc/825_40_1.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/Libc/825_40_1.nix @@ -1,6 +1,6 @@ -{ appleDerivation, ed, unifdef }: +{ appleDerivation', stdenvNoCC, ed, unifdef }: -appleDerivation { +appleDerivation' stdenvNoCC { nativeBuildInputs = [ ed unifdef ]; installPhase = '' diff --git a/pkgs/os-specific/darwin/apple-source-releases/Libc/default.nix b/pkgs/os-specific/darwin/apple-source-releases/Libc/default.nix index 3554a2e15b074..9bec0b103c9db 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/Libc/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/Libc/default.nix @@ -1,6 +1,6 @@ -{ appleDerivation, ed, unifdef, Libc_old, Libc_10-9 }: +{ appleDerivation', stdenvNoCC, ed, unifdef, Libc_old, Libc_10-9 }: -appleDerivation { +appleDerivation' stdenvNoCC { nativeBuildInputs = [ ed unifdef ]; # TODO: asl.h actually comes from syslog project now diff --git a/pkgs/os-specific/darwin/apple-source-releases/Libinfo/default.nix b/pkgs/os-specific/darwin/apple-source-releases/Libinfo/default.nix index 5481ae74d38d4..789e536b8a7f1 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/Libinfo/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/Libinfo/default.nix @@ -1,6 +1,6 @@ -{ appleDerivation }: +{ appleDerivation', stdenvNoCC }: -appleDerivation { +appleDerivation' stdenvNoCC { installPhase = '' substituteInPlace xcodescripts/install_files.sh \ --replace "/usr/local/" "/" \ diff --git a/pkgs/os-specific/darwin/apple-source-releases/Libm/default.nix b/pkgs/os-specific/darwin/apple-source-releases/Libm/default.nix index df5f6b7b8fd64..6e6712f375e65 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/Libm/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/Libm/default.nix @@ -1,6 +1,6 @@ -{ appleDerivation }: +{ appleDerivation', stdenvNoCC }: -appleDerivation { +appleDerivation' stdenvNoCC { installPhase = '' mkdir -p $out/include diff --git a/pkgs/os-specific/darwin/apple-source-releases/Libnotify/default.nix b/pkgs/os-specific/darwin/apple-source-releases/Libnotify/default.nix index 2ee80d7026463..969e64427c9b9 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/Libnotify/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/Libnotify/default.nix @@ -1,6 +1,6 @@ -{ appleDerivation }: +{ appleDerivation', stdenvNoCC }: -appleDerivation { +appleDerivation' stdenvNoCC { installPhase = '' mkdir -p $out/include cp notify.h $out/include diff --git a/pkgs/os-specific/darwin/apple-source-releases/Libsystem/default.nix b/pkgs/os-specific/darwin/apple-source-releases/Libsystem/default.nix index 2c98dd35e39d9..cb85566b51281 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/Libsystem/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/Libsystem/default.nix @@ -1,9 +1,13 @@ -{ lib, appleDerivation, cpio, xnu, Libc, Libm, libdispatch, cctools, Libinfo +{ lib, stdenv, buildPackages +, appleDerivation', cpio, xnu, Libc, Libm, libdispatch, Libinfo , dyld, Csu, architecture, libclosure, CarbonHeaders, ncurses, CommonCrypto -, copyfile, removefile, libresolv, Libnotify, libplatform, libpthread -, mDNSResponder, launchd, libutil, hfs, darling, darwin-stubs }: +, copyfile, removefile, libresolvHeaders, libresolv, Libnotify, libplatform, libpthread +, mDNSResponder, launchd, libutilHeaders, hfsHeaders, darling, darwin-stubs +, headersOnly ? false +, withLibresolv ? !headersOnly +}: -appleDerivation { +appleDerivation' stdenv { dontBuild = true; dontFixup = true; @@ -21,13 +25,13 @@ appleDerivation { for dep in ${Libc} ${Libm} ${Libinfo} ${dyld} ${architecture} \ ${libclosure} ${CarbonHeaders} ${libdispatch} ${ncurses.dev} \ - ${CommonCrypto} ${copyfile} ${removefile} ${libresolv} \ + ${CommonCrypto} ${copyfile} ${removefile} ${libresolvHeaders} \ ${Libnotify} ${libplatform} ${mDNSResponder} ${launchd} \ - ${libutil} ${libpthread} ${hfs}; do + ${libutilHeaders} ${libpthread} ${hfsHeaders}; do (cd $dep/include && find . -name '*.h' | cpio -pdm $out/include) done - (cd ${cctools.dev}/include/mach-o && find . -name '*.h' | cpio -pdm $out/include/mach-o) + (cd ${buildPackages.darwin.cctools.dev}/include/mach-o && find . -name '*.h' | cpio -pdm $out/include/mach-o) mkdir -p $out/include/os @@ -84,6 +88,7 @@ appleDerivation { #define TARGET_RT_64_BIT 1 #endif /* __TARGETCONDITIONALS__ */ EOF + '' + lib.optionalString (!headersOnly) '' # The startup object files cp ${Csu}/lib/* $out/lib @@ -101,14 +106,15 @@ appleDerivation { for name in c dbm dl info m mx poll proc pthread rpcsvc util gcc_s.10.4 gcc_s.10.5; do ln -s libSystem.tbd $out/lib/lib$name.tbd done + '' + lib.optionalString withLibresolv '' # This probably doesn't belong here, but we want to stay similar to glibc, which includes resolv internally... cp ${libresolv}/lib/libresolv.9.dylib $out/lib/libresolv.9.dylib - resolv_libSystem=$(otool -L "$out/lib/libresolv.9.dylib" | tail -n +3 | grep -o "$NIX_STORE.*-\S*") || true + resolv_libSystem=$(${stdenv.cc.bintools.targetPrefix}otool -L "$out/lib/libresolv.9.dylib" | tail -n +3 | grep -o "$NIX_STORE.*-\S*") || true echo $libs chmod +w $out/lib/libresolv.9.dylib - install_name_tool \ + ${stdenv.cc.bintools.targetPrefix}install_name_tool \ -id $out/lib/libresolv.9.dylib \ -change "$resolv_libSystem" /usr/lib/libSystem.dylib \ $out/lib/libresolv.9.dylib diff --git a/pkgs/os-specific/darwin/apple-source-releases/Security/boot.nix b/pkgs/os-specific/darwin/apple-source-releases/Security/boot.nix index b819057f0c1ad..bb09adce252e1 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/Security/boot.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/Security/boot.nix @@ -1,6 +1,6 @@ -{ appleDerivation, darwin-stubs }: +{ appleDerivation', stdenv, darwin-stubs }: -appleDerivation { +appleDerivation' stdenv { phases = [ "unpackPhase" "installPhase" ]; __propagatedImpureHostDeps = [ diff --git a/pkgs/os-specific/darwin/apple-source-releases/adv_cmds/boot.nix b/pkgs/os-specific/darwin/apple-source-releases/adv_cmds/boot.nix index b4c28e23c142a..2ca2d061591af 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/adv_cmds/boot.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/adv_cmds/boot.nix @@ -1,4 +1,4 @@ -{ lib, appleDerivation, fetchzip, bsdmake, perl, flex, bison +{ lib, stdenv, buildPackages, appleDerivation, fetchzip, bsdmake, perl, flex, bison }: # this derivation sucks @@ -16,6 +16,7 @@ let recentAdvCmds = fetchzip { }; in appleDerivation { + depsBuildBuild = [ buildPackages.stdenv.cc ]; nativeBuildInputs = [ bsdmake perl bison flex ]; buildInputs = [ flex ]; @@ -61,7 +62,7 @@ in appleDerivation { bsdmake -C usr-share-locale.tproj - clang ${recentAdvCmds}/ps/*.c -o ps + ${stdenv.cc.targetPrefix}clang ${recentAdvCmds}/ps/*.c -o ps ''; installPhase = '' diff --git a/pkgs/os-specific/darwin/apple-source-releases/architecture/default.nix b/pkgs/os-specific/darwin/apple-source-releases/architecture/default.nix index 74327bc4c4285..e0e27255b72f4 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/architecture/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/architecture/default.nix @@ -1,6 +1,6 @@ -{ lib, appleDerivation }: +{ lib, appleDerivation', stdenvNoCC }: -appleDerivation { +appleDerivation' stdenvNoCC { dontBuild = true; postPatch = '' diff --git a/pkgs/os-specific/darwin/apple-source-releases/bootstrap_cmds/default.nix b/pkgs/os-specific/darwin/apple-source-releases/bootstrap_cmds/default.nix index 800da92dae9d5..ff98ed88804ce 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/bootstrap_cmds/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/bootstrap_cmds/default.nix @@ -1,4 +1,13 @@ -{ lib, stdenv, appleDerivation, bison, flex }: +{ lib, appleDerivation, stdenv, bison, flex }: + +let + + # Hard to get CC to pull this off without infinite recursion + targetTargetPrefix = lib.optionalString + (with stdenv; hostPlatform != targetPlatform) + (stdenv.targetPlatform.config + "-"); + +in appleDerivation { nativeBuildInputs = [ bison flex ]; @@ -12,7 +21,7 @@ appleDerivation { yacc -d parser.y flex --header-file=lexxer.yy.h -o lexxer.yy.c lexxer.l - cc -std=gnu99 -Os -dead_strip -DMIG_VERSION=\"$pname-$version\" -I. -o migcom *.c + $CC -std=gnu99 -Os -dead_strip -DMIG_VERSION=\"$pname-$version\" -I. -o migcom *.c ''; installPhase = '' @@ -29,6 +38,6 @@ appleDerivation { --replace 'arch=`/usr/bin/arch`' 'arch=${stdenv.targetPlatform.darwinArch}' \ --replace '/usr/bin/' "" \ --replace '/bin/rmdir' "rmdir" \ - --replace 'C=''${MIGCC}' "C=cc" + --replace 'C=''${MIGCC}' "C=${targetTargetPrefix}cc" ''; } diff --git a/pkgs/os-specific/darwin/apple-source-releases/configd/default.nix b/pkgs/os-specific/darwin/apple-source-releases/configd/default.nix index 20168d24dd712..879d3a7b5f79f 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/configd/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/configd/default.nix @@ -1,6 +1,6 @@ -{ stdenv, appleDerivation, launchd, bootstrap_cmds, xnu, ppp, IOKit, eap8021x, Security }: +{ stdenv, appleDerivation', launchd, bootstrap_cmds, xnu, ppp, IOKit, eap8021x, Security }: -appleDerivation { +appleDerivation' stdenv { meta.broken = stdenv.cc.nativeLibc; nativeBuildInputs = [ bootstrap_cmds ]; @@ -127,78 +127,78 @@ appleDerivation { mig -arch x86_64 -header derived/helper.h -user derived/helperUser.c -sheader /dev/null -server /dev/null helper/helper.defs mig -arch x86_64 -header derived/pppcontroller.h -user derived/pppcontrollerUser.c -sheader /dev/null -server /dev/null pppcontroller.defs - cc -I. -Ihelper -Iderived -F. -c SCSchemaDefinitions.c -o SCSchemaDefinitions.o - cc -I. -Ihelper -Iderived -F. -c SCD.c -o SCD.o - cc -I. -Ihelper -Iderived -F. -c SCDKeys.c -o SCDKeys.o - cc -I. -Ihelper -Iderived -F. -c SCDPrivate.c -o SCDPrivate.o - cc -I. -Ihelper -Iderived -F. -c SCDPlugin.c -o SCDPlugin.o - cc -I. -Ihelper -Iderived -F. -c CaptiveNetwork.c -o CaptiveNetwork.o - cc -I. -Ihelper -Iderived -F. -c SCDOpen.c -o SCDOpen.o - cc -I. -Ihelper -Iderived -F. -c SCDList.c -o SCDList.o - cc -I. -Ihelper -Iderived -F. -c SCDAdd.c -o SCDAdd.o - cc -I. -Ihelper -Iderived -F. -c SCDGet.c -o SCDGet.o - cc -I. -Ihelper -Iderived -F. -c SCDSet.c -o SCDSet.o - cc -I. -Ihelper -Iderived -F. -c SCDRemove.c -o SCDRemove.o - cc -I. -Ihelper -Iderived -F. -c SCDNotify.c -o SCDNotify.o - cc -I. -Ihelper -Iderived -F. -c SCDNotifierSetKeys.c -o SCDNotifierSetKeys.o - cc -I. -Ihelper -Iderived -F. -c SCDNotifierAdd.c -o SCDNotifierAdd.o - cc -I. -Ihelper -Iderived -F. -c SCDNotifierRemove.c -o SCDNotifierRemove.o - cc -I. -Ihelper -Iderived -F. -c SCDNotifierGetChanges.c -o SCDNotifierGetChanges.o - cc -I. -Ihelper -Iderived -F. -c SCDNotifierWait.c -o SCDNotifierWait.o - cc -I. -Ihelper -Iderived -F. -c SCDNotifierInformViaCallback.c -o SCDNotifierInformViaCallback.o - cc -I. -Ihelper -Iderived -F. -c SCDNotifierInformViaFD.c -o SCDNotifierInformViaFD.o - cc -I. -Ihelper -Iderived -F. -c SCDNotifierInformViaSignal.c -o SCDNotifierInformViaSignal.o - cc -I. -Ihelper -Iderived -F. -c SCDNotifierCancel.c -o SCDNotifierCancel.o - cc -I. -Ihelper -Iderived -F. -c SCDSnapshot.c -o SCDSnapshot.o - cc -I. -Ihelper -Iderived -F. -c SCP.c -o SCP.o - cc -I. -Ihelper -Iderived -F. -c SCPOpen.c -o SCPOpen.o - cc -I. -Ihelper -Iderived -F. -c SCPLock.c -o SCPLock.o - cc -I. -Ihelper -Iderived -F. -c SCPUnlock.c -o SCPUnlock.o - cc -I. -Ihelper -Iderived -F. -c SCPList.c -o SCPList.o - cc -I. -Ihelper -Iderived -F. -c SCPGet.c -o SCPGet.o - cc -I. -Ihelper -Iderived -F. -c SCPAdd.c -o SCPAdd.o - cc -I. -Ihelper -Iderived -F. -c SCPSet.c -o SCPSet.o - cc -I. -Ihelper -Iderived -F. -c SCPRemove.c -o SCPRemove.o - cc -I. -Ihelper -Iderived -F. -c SCPCommit.c -o SCPCommit.o - cc -I. -Ihelper -Iderived -F. -c SCPApply.c -o SCPApply.o - cc -I. -Ihelper -Iderived -F. -c SCPPath.c -o SCPPath.o - cc -I. -Ihelper -Iderived -F. -c SCDConsoleUser.c -o SCDConsoleUser.o - cc -I. -Ihelper -Iderived -F. -c SCDHostName.c -o SCDHostName.o - cc -I. -Ihelper -Iderived -F. -c SCLocation.c -o SCLocation.o - cc -I. -Ihelper -Iderived -F. -c SCNetwork.c -o SCNetwork.o - cc -I. -Ihelper -Iderived -F. -c derived/pppcontrollerUser.c -o pppcontrollerUser.o - cc -I. -Ihelper -Iderived -F. -c SCNetworkConnection.c -o SCNetworkConnection.o - cc -I. -Ihelper -Iderived -F. -c SCNetworkConnectionPrivate.c -o SCNetworkConnectionPrivate.o - cc -I. -Ihelper -Iderived -I../dnsinfo -F. -c SCNetworkReachability.c -o SCNetworkReachability.o - cc -I. -Ihelper -Iderived -F. -c SCProxies.c -o SCProxies.o - cc -I. -Ihelper -Iderived -F. -c DHCP.c -o DHCP.o - cc -I. -Ihelper -Iderived -F. -c moh.c -o moh.o - cc -I. -Ihelper -Iderived -F. -c DeviceOnHold.c -o DeviceOnHold.o - cc -I. -Ihelper -Iderived -I $HACK -F. -c LinkConfiguration.c -o LinkConfiguration.o - cc -I. -Ihelper -Iderived -F. -c dy_framework.c -o dy_framework.o - cc -I. -Ihelper -Iderived -I $HACK -F. -c VLANConfiguration.c -o VLANConfiguration.o - cc -I. -Ihelper -Iderived -F. -c derived/configUser.c -o configUser.o - cc -I. -Ihelper -Iderived -F. -c SCPreferencesPathKey.c -o SCPreferencesPathKey.o - cc -I. -Ihelper -Iderived -I../dnsinfo -F. -c derived/shared_dns_infoUser.c -o shared_dns_infoUser.o - cc -I. -Ihelper -Iderived -F. -c SCNetworkConfigurationInternal.c -o SCNetworkConfigurationInternal.o - cc -I. -Ihelper -Iderived -F. -c SCNetworkInterface.c -o SCNetworkInterface.o - cc -I. -Ihelper -Iderived -F. -c SCNetworkProtocol.c -o SCNetworkProtocol.o - cc -I. -Ihelper -Iderived -F. -c SCNetworkService.c -o SCNetworkService.o - cc -I. -Ihelper -Iderived -F. -c SCNetworkSet.c -o SCNetworkSet.o - cc -I. -Ihelper -Iderived -I $HACK -F. -c BondConfiguration.c -o BondConfiguration.o - cc -I. -Ihelper -Iderived -I $HACK -F. -c BridgeConfiguration.c -o BridgeConfiguration.o - cc -I. -Ihelper -Iderived -F. -c helper/SCHelper_client.c -o SCHelper_client.o - cc -I. -Ihelper -Iderived -F. -c SCPreferencesKeychainPrivate.c -o SCPreferencesKeychainPrivate.o - cc -I. -Ihelper -Iderived -F. -c SCNetworkSignature.c -o SCNetworkSignature.o - cc -I. -Ihelper -Iderived -F. -c VPNPrivate.c -o VPNPrivate.o - cc -I. -Ihelper -Iderived -F. -c VPNConfiguration.c -o VPNConfiguration.o - cc -I. -Ihelper -Iderived -F. -c VPNTunnel.c -o VPNTunnel.o - cc -I. -Ihelper -Iderived -F. -c derived/helperUser.c -o helperUser.o - cc -I. -Ihelper -Iderived -F. -c reachability/SCNetworkReachabilityServer_client.c -o SCNetworkReachabilityServer_client.o - cc -I. -Ihelper -Iderived -F. -c reachability/rb.c -o rb.o - cc -I. -Ihelper -Iderived -F. -c derived/SystemConfiguration_vers.c -o SystemConfiguration_vers.o - - cc -dynamiclib *.o -install_name $out/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration -dead_strip -framework CoreFoundation -single_module -o SystemConfiguration.framework/SystemConfiguration + $CC -I. -Ihelper -Iderived -F. -c SCSchemaDefinitions.c -o SCSchemaDefinitions.o + $CC -I. -Ihelper -Iderived -F. -c SCD.c -o SCD.o + $CC -I. -Ihelper -Iderived -F. -c SCDKeys.c -o SCDKeys.o + $CC -I. -Ihelper -Iderived -F. -c SCDPrivate.c -o SCDPrivate.o + $CC -I. -Ihelper -Iderived -F. -c SCDPlugin.c -o SCDPlugin.o + $CC -I. -Ihelper -Iderived -F. -c CaptiveNetwork.c -o CaptiveNetwork.o + $CC -I. -Ihelper -Iderived -F. -c SCDOpen.c -o SCDOpen.o + $CC -I. -Ihelper -Iderived -F. -c SCDList.c -o SCDList.o + $CC -I. -Ihelper -Iderived -F. -c SCDAdd.c -o SCDAdd.o + $CC -I. -Ihelper -Iderived -F. -c SCDGet.c -o SCDGet.o + $CC -I. -Ihelper -Iderived -F. -c SCDSet.c -o SCDSet.o + $CC -I. -Ihelper -Iderived -F. -c SCDRemove.c -o SCDRemove.o + $CC -I. -Ihelper -Iderived -F. -c SCDNotify.c -o SCDNotify.o + $CC -I. -Ihelper -Iderived -F. -c SCDNotifierSetKeys.c -o SCDNotifierSetKeys.o + $CC -I. -Ihelper -Iderived -F. -c SCDNotifierAdd.c -o SCDNotifierAdd.o + $CC -I. -Ihelper -Iderived -F. -c SCDNotifierRemove.c -o SCDNotifierRemove.o + $CC -I. -Ihelper -Iderived -F. -c SCDNotifierGetChanges.c -o SCDNotifierGetChanges.o + $CC -I. -Ihelper -Iderived -F. -c SCDNotifierWait.c -o SCDNotifierWait.o + $CC -I. -Ihelper -Iderived -F. -c SCDNotifierInformViaCallback.c -o SCDNotifierInformViaCallback.o + $CC -I. -Ihelper -Iderived -F. -c SCDNotifierInformViaFD.c -o SCDNotifierInformViaFD.o + $CC -I. -Ihelper -Iderived -F. -c SCDNotifierInformViaSignal.c -o SCDNotifierInformViaSignal.o + $CC -I. -Ihelper -Iderived -F. -c SCDNotifierCancel.c -o SCDNotifierCancel.o + $CC -I. -Ihelper -Iderived -F. -c SCDSnapshot.c -o SCDSnapshot.o + $CC -I. -Ihelper -Iderived -F. -c SCP.c -o SCP.o + $CC -I. -Ihelper -Iderived -F. -c SCPOpen.c -o SCPOpen.o + $CC -I. -Ihelper -Iderived -F. -c SCPLock.c -o SCPLock.o + $CC -I. -Ihelper -Iderived -F. -c SCPUnlock.c -o SCPUnlock.o + $CC -I. -Ihelper -Iderived -F. -c SCPList.c -o SCPList.o + $CC -I. -Ihelper -Iderived -F. -c SCPGet.c -o SCPGet.o + $CC -I. -Ihelper -Iderived -F. -c SCPAdd.c -o SCPAdd.o + $CC -I. -Ihelper -Iderived -F. -c SCPSet.c -o SCPSet.o + $CC -I. -Ihelper -Iderived -F. -c SCPRemove.c -o SCPRemove.o + $CC -I. -Ihelper -Iderived -F. -c SCPCommit.c -o SCPCommit.o + $CC -I. -Ihelper -Iderived -F. -c SCPApply.c -o SCPApply.o + $CC -I. -Ihelper -Iderived -F. -c SCPPath.c -o SCPPath.o + $CC -I. -Ihelper -Iderived -F. -c SCDConsoleUser.c -o SCDConsoleUser.o + $CC -I. -Ihelper -Iderived -F. -c SCDHostName.c -o SCDHostName.o + $CC -I. -Ihelper -Iderived -F. -c SCLocation.c -o SCLocation.o + $CC -I. -Ihelper -Iderived -F. -c SCNetwork.c -o SCNetwork.o + $CC -I. -Ihelper -Iderived -F. -c derived/pppcontrollerUser.c -o pppcontrollerUser.o + $CC -I. -Ihelper -Iderived -F. -c SCNetworkConnection.c -o SCNetworkConnection.o + $CC -I. -Ihelper -Iderived -F. -c SCNetworkConnectionPrivate.c -o SCNetworkConnectionPrivate.o + $CC -I. -Ihelper -Iderived -I../dnsinfo -F. -c SCNetworkReachability.c -o SCNetworkReachability.o + $CC -I. -Ihelper -Iderived -F. -c SCProxies.c -o SCProxies.o + $CC -I. -Ihelper -Iderived -F. -c DHCP.c -o DHCP.o + $CC -I. -Ihelper -Iderived -F. -c moh.c -o moh.o + $CC -I. -Ihelper -Iderived -F. -c DeviceOnHold.c -o DeviceOnHold.o + $CC -I. -Ihelper -Iderived -I $HACK -F. -c LinkConfiguration.c -o LinkConfiguration.o + $CC -I. -Ihelper -Iderived -F. -c dy_framework.c -o dy_framework.o + $CC -I. -Ihelper -Iderived -I $HACK -F. -c VLANConfiguration.c -o VLANConfiguration.o + $CC -I. -Ihelper -Iderived -F. -c derived/configUser.c -o configUser.o + $CC -I. -Ihelper -Iderived -F. -c SCPreferencesPathKey.c -o SCPreferencesPathKey.o + $CC -I. -Ihelper -Iderived -I../dnsinfo -F. -c derived/shared_dns_infoUser.c -o shared_dns_infoUser.o + $CC -I. -Ihelper -Iderived -F. -c SCNetworkConfigurationInternal.c -o SCNetworkConfigurationInternal.o + $CC -I. -Ihelper -Iderived -F. -c SCNetworkInterface.c -o SCNetworkInterface.o + $CC -I. -Ihelper -Iderived -F. -c SCNetworkProtocol.c -o SCNetworkProtocol.o + $CC -I. -Ihelper -Iderived -F. -c SCNetworkService.c -o SCNetworkService.o + $CC -I. -Ihelper -Iderived -F. -c SCNetworkSet.c -o SCNetworkSet.o + $CC -I. -Ihelper -Iderived -I $HACK -F. -c BondConfiguration.c -o BondConfiguration.o + $CC -I. -Ihelper -Iderived -I $HACK -F. -c BridgeConfiguration.c -o BridgeConfiguration.o + $CC -I. -Ihelper -Iderived -F. -c helper/SCHelper_client.c -o SCHelper_client.o + $CC -I. -Ihelper -Iderived -F. -c SCPreferencesKeychainPrivate.c -o SCPreferencesKeychainPrivate.o + $CC -I. -Ihelper -Iderived -F. -c SCNetworkSignature.c -o SCNetworkSignature.o + $CC -I. -Ihelper -Iderived -F. -c VPNPrivate.c -o VPNPrivate.o + $CC -I. -Ihelper -Iderived -F. -c VPNConfiguration.c -o VPNConfiguration.o + $CC -I. -Ihelper -Iderived -F. -c VPNTunnel.c -o VPNTunnel.o + $CC -I. -Ihelper -Iderived -F. -c derived/helperUser.c -o helperUser.o + $CC -I. -Ihelper -Iderived -F. -c reachability/SCNetworkReachabilityServer_client.c -o SCNetworkReachabilityServer_client.o + $CC -I. -Ihelper -Iderived -F. -c reachability/rb.c -o rb.o + $CC -I. -Ihelper -Iderived -F. -c derived/SystemConfiguration_vers.c -o SystemConfiguration_vers.o + + $CC -dynamiclib *.o -install_name $out/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration -dead_strip -framework CoreFoundation -single_module -o SystemConfiguration.framework/SystemConfiguration popd >/dev/null ''; diff --git a/pkgs/os-specific/darwin/apple-source-releases/copyfile/default.nix b/pkgs/os-specific/darwin/apple-source-releases/copyfile/default.nix index 7e1dc5309b1d0..5e7f38e84d7d8 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/copyfile/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/copyfile/default.nix @@ -1,6 +1,6 @@ -{ appleDerivation }: +{ appleDerivation', stdenvNoCC }: -appleDerivation { +appleDerivation' stdenvNoCC { dontBuild = true; installPhase = '' mkdir -p $out/include/ diff --git a/pkgs/os-specific/darwin/apple-source-releases/default.nix b/pkgs/os-specific/darwin/apple-source-releases/default.nix index 3e431810f20d9..5e098926d2968 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, stdenvNoCC, fetchurl, fetchzip, pkgs }: +{ lib, stdenv, fetchurl, fetchzip, pkgs }: let # This attrset can in theory be computed automatically, but for that to work nicely we need @@ -154,7 +154,7 @@ let version = versions.${sdkName}.${pname}; in fetchApple' pname version sha256; - appleDerivation' = pname: version: sdkName: sha256: attrs: stdenv.mkDerivation ({ + appleDerivation'' = stdenv: pname: version: sdkName: sha256: attrs: stdenv.mkDerivation ({ inherit pname version; src = if attrs ? srcs then null else (fetchApple' pname version sha256); @@ -223,8 +223,9 @@ let applePackage' = namePath: version: sdkName: sha256: let pname = builtins.head (lib.splitString "/" namePath); - appleDerivation = appleDerivation' pname version sdkName sha256; - callPackage = self.newScope { inherit appleDerivation; }; + appleDerivation' = stdenv: appleDerivation'' stdenv pname version sdkName sha256; + appleDerivation = appleDerivation' stdenv; + callPackage = self.newScope { inherit appleDerivation' appleDerivation; }; in callPackage (./. + "/${namePath}"); applePackage = namePath: sdkName: sha256: let @@ -272,17 +273,16 @@ developerToolsPackages_11_3_1 // macosPackages_11_0_1 // { libplatform = applePackage "libplatform" "osx-10.12.6" "0rh1f5ybvwz8s0nwfar8s0fh7jbgwqcy903cv2x8m15iq1x599yn" {}; libpthread = applePackage "libpthread" "osx-10.12.6" "1j6541rcgjpas1fc77ip5krjgw4bvz6jq7bq7h9q7axb0jv2ns6c" {}; libresolv = applePackage "libresolv" "osx-10.12.6" "077j6ljfh7amqpk2146rr7dsz5vasvr3als830mgv5jzl7l6vz88" {}; - Libsystem = applePackage "Libsystem" "osx-10.12.6" "1082ircc1ggaq3wha218vmfa75jqdaqidsy1bmrc4ckfkbr3bwx2" { - libutil = pkgs.darwin.libutil.override { headersOnly = true; }; - hfs = pkgs.darwin.hfs.override { headersOnly = true; }; - }; + Libsystem = applePackage "Libsystem" "osx-10.12.6" "1082ircc1ggaq3wha218vmfa75jqdaqidsy1bmrc4ckfkbr3bwx2" {}; libutil = applePackage "libutil" "osx-10.12.6" "0lqdxaj82h8yjbjm856jjz9k2d96k0viimi881akfng08xk1246y" {}; libunwind = applePackage "libunwind" "osx-10.12.6" "0miffaa41cv0lzf8az5k1j1ng8jvqvxcr4qrlkf3xyj479arbk1b" {}; mDNSResponder = applePackage "mDNSResponder" "osx-10.12.6" "02ms1p8zlgmprzn65jzr7yaqxykh3zxjcrw0c06aayim6h0dsqfy" {}; objc4 = applePackage "objc4" "osx-10.12.6" "1cj1vhbcs9pkmag2ms8wslagicnq9bxi2qjkszmp3ys7z7ccrbwz" {}; ppp = applePackage "ppp" "osx-10.12.6" "1kcc2nc4x1kf8sz0a23i6nfpvxg381kipi0qdisrp8x9z2gbkxb8" {}; removefile = applePackage "removefile" "osx-10.12.6" "0jzjxbmxgjzhssqd50z7kq9dlwrv5fsdshh57c0f8mdwcs19bsyx" {}; - xnu = applePackage "xnu" "osx-10.12.6" "1sjb0i7qzz840v2h4z3s4jyjisad4r5yyi6sg8pakv3wd81i5fg5" {}; + xnu = applePackage "xnu" "osx-10.12.6" "1sjb0i7qzz840v2h4z3s4jyjisad4r5yyi6sg8pakv3wd81i5fg5" { + python3 = pkgs.buildPackages.buildPackages.python3; # TODO(@Ericson2314) this shouldn't be needed. + }; hfs = applePackage "hfs" "osx-10.12.6" "1mj3xvqpq1mgd80b6kl1s04knqnap7hccr0gz8rjphalq14rbl5g" {}; Librpcsvc = applePackage "Librpcsvc" "osx-10.11.6" "1zwfwcl9irxl1dlnf2b4v30vdybp0p0r6n6g1pd14zbdci1jcg2k" {}; adv_cmds = applePackage "adv_cmds" "osx-10.11.6" "12gbv35i09aij9g90p6b3x2f3ramw43qcb2gjrg8lzkzmwvcyw9q" {}; @@ -297,6 +297,10 @@ developerToolsPackages_11_3_1 // macosPackages_11_0_1 // { top = applePackage "top" "osx-10.11.6" "0i9120rfwapgwdvjbfg0ya143i29s1m8zbddsxh39pdc59xnsg5l" {}; PowerManagement = applePackage "PowerManagement" "osx-10.11.6" "1llimhvp0gjffd47322lnjq7cqwinx0c5z7ikli04ad5srpa68mh" {}; + libutilHeaders = pkgs.darwin.libutil.override { headersOnly = true; }; + hfsHeaders = pkgs.darwin.hfs.override { headersOnly = true; }; + libresolvHeaders= pkgs.darwin.libresolv.override { headersOnly = true; }; + # TODO(matthewbauer): # To be removed, once I figure out how to build a newer Security version. Security = applePackage "Security/boot.nix" "osx-10.9.5" "1nv0dczf67dhk17hscx52izgdcyacgyy12ag0jh6nl5hmfzsn8yy" {}; diff --git a/pkgs/os-specific/darwin/apple-source-releases/developer_cmds/default.nix b/pkgs/os-specific/darwin/apple-source-releases/developer_cmds/default.nix index 77de079e2f0f4..f2c4ec32146f2 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/developer_cmds/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/developer_cmds/default.nix @@ -1,7 +1,7 @@ -{ lib, appleDerivation, xcbuildHook, llvmPackages }: +{ lib, appleDerivation, xcbuildHook, llvmPackages, makeWrapper }: appleDerivation { - nativeBuildInputs = [ xcbuildHook ]; + nativeBuildInputs = [ xcbuildHook makeWrapper ]; patches = [ # The following copied from @@ -11,8 +11,9 @@ appleDerivation { ]; postPatch = '' + makeWrapper ${llvmPackages.clang}/bin/clang $out/bin/clang-cpp --add-flags "--driver-mode=cpp" substituteInPlace rpcgen/rpc_main.c \ - --replace "/usr/bin/cpp" "${llvmPackages.clang-unwrapped}/bin/clang-cpp" + --replace "/usr/bin/cpp" "$out/bin/clang-cpp" ''; # temporary install phase until xcodebuild has "install" support diff --git a/pkgs/os-specific/darwin/apple-source-releases/dyld/default.nix b/pkgs/os-specific/darwin/apple-source-releases/dyld/default.nix index 01d44d22f5ef0..ca3b70cd09264 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/dyld/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/dyld/default.nix @@ -1,6 +1,6 @@ -{ lib, appleDerivation }: +{ lib, appleDerivation', stdenvNoCC }: -appleDerivation { +appleDerivation' stdenvNoCC { installPhase = '' mkdir -p $out/lib $out/include ln -s /usr/lib/dyld $out/lib/dyld diff --git a/pkgs/os-specific/darwin/apple-source-releases/eap8021x/default.nix b/pkgs/os-specific/darwin/apple-source-releases/eap8021x/default.nix index b24d94b9d70d8..f5c47f01d37a9 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/eap8021x/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/eap8021x/default.nix @@ -1,6 +1,6 @@ -{ appleDerivation }: +{ appleDerivation', stdenv }: -appleDerivation { +appleDerivation' stdenv { dontBuild = true; installPhase = '' mkdir -p $out/Library/Frameworks/EAP8021X.framework/Headers diff --git a/pkgs/os-specific/darwin/apple-source-releases/file_cmds/default.nix b/pkgs/os-specific/darwin/apple-source-releases/file_cmds/default.nix index 53f98e2b457e3..981e1370437d6 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/file_cmds/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/file_cmds/default.nix @@ -1,8 +1,8 @@ -{ lib, appleDerivation, xcbuildHook, zlib, bzip2, xz, ncurses, libutil }: +{ lib, appleDerivation, xcbuildHook, zlib, bzip2, xz, ncurses, libutil, Libinfo }: appleDerivation { nativeBuildInputs = [ xcbuildHook ]; - buildInputs = [ zlib bzip2 xz ncurses libutil ]; + buildInputs = [ zlib bzip2 xz ncurses libutil Libinfo ]; # some commands not working: # mtree: _simple.h not found diff --git a/pkgs/os-specific/darwin/apple-source-releases/hfs/default.nix b/pkgs/os-specific/darwin/apple-source-releases/hfs/default.nix index 58bac765a959c..093e8525e5877 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/hfs/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/hfs/default.nix @@ -1,6 +1,6 @@ -{ appleDerivation, lib, headersOnly ? true }: +{ appleDerivation', stdenv, stdenvNoCC, lib, headersOnly ? true }: -appleDerivation { +appleDerivation' (if headersOnly then stdenvNoCC else stdenv) { installPhase = lib.optionalString headersOnly '' mkdir -p $out/include/hfs cp core/*.h $out/include/hfs diff --git a/pkgs/os-specific/darwin/apple-source-releases/launchd/default.nix b/pkgs/os-specific/darwin/apple-source-releases/launchd/default.nix index c882b83d0a384..67e051d56853e 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/launchd/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/launchd/default.nix @@ -1,6 +1,6 @@ -{ appleDerivation }: +{ appleDerivation', stdenvNoCC }: -appleDerivation { +appleDerivation' stdenvNoCC { # No clue why the same file has two different names. Ask Apple! installPhase = '' mkdir -p $out/include/ $out/include/servers diff --git a/pkgs/os-specific/darwin/apple-source-releases/libclosure/default.nix b/pkgs/os-specific/darwin/apple-source-releases/libclosure/default.nix index d42a288208c5b..976658b7e5ddc 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/libclosure/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/libclosure/default.nix @@ -1,6 +1,6 @@ -{ appleDerivation }: +{ appleDerivation', stdenvNoCC }: -appleDerivation { +appleDerivation' stdenvNoCC { installPhase = '' mkdir -p $out/include cp *.h $out/include/ diff --git a/pkgs/os-specific/darwin/apple-source-releases/libdispatch/default.nix b/pkgs/os-specific/darwin/apple-source-releases/libdispatch/default.nix index 3b9d4a34cc63a..e91ee86cde08f 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/libdispatch/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/libdispatch/default.nix @@ -1,6 +1,6 @@ -{ appleDerivation }: +{ appleDerivation', stdenvNoCC }: -appleDerivation { +appleDerivation' stdenvNoCC { dontConfigure = true; dontBuild = true; installPhase = '' diff --git a/pkgs/os-specific/darwin/apple-source-releases/libplatform/default.nix b/pkgs/os-specific/darwin/apple-source-releases/libplatform/default.nix index 9acbcb212e4d8..39c801962692f 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/libplatform/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/libplatform/default.nix @@ -1,6 +1,6 @@ -{ appleDerivation }: +{ appleDerivation', stdenvNoCC }: -appleDerivation { +appleDerivation' stdenvNoCC { installPhase = '' mkdir $out cp -r include $out/include diff --git a/pkgs/os-specific/darwin/apple-source-releases/libpthread/default.nix b/pkgs/os-specific/darwin/apple-source-releases/libpthread/default.nix index 20eccd8205970..3d62270d76c0d 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/libpthread/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/libpthread/default.nix @@ -1,6 +1,6 @@ -{ lib, appleDerivation, libdispatch, xnu }: +{ lib, appleDerivation', stdenvNoCC, libdispatch, xnu }: -appleDerivation { +appleDerivation' stdenvNoCC { propagatedBuildInputs = [ libdispatch xnu ]; installPhase = '' diff --git a/pkgs/os-specific/darwin/apple-source-releases/libresolv/default.nix b/pkgs/os-specific/darwin/apple-source-releases/libresolv/default.nix index f3c7558cfc626..53fc019768dd4 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/libresolv/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/libresolv/default.nix @@ -1,37 +1,39 @@ -{ appleDerivation, Libinfo, configd, mDNSResponder }: +{ lib, appleDerivation', stdenv, stdenvNoCC, Libinfo, configd, mDNSResponder +, headersOnly ? false +}: -appleDerivation { - buildInputs = [ Libinfo configd mDNSResponder ]; +appleDerivation' (if headersOnly then stdenvNoCC else stdenv) { + buildInputs = lib.optionals (!headersOnly) [ Libinfo configd mDNSResponder ]; - buildPhase = '' - cc -I. -c dns_util.c - cc -I. -c dns.c - cc -I. -c dns_async.c - cc -I. -c base64.c - cc -I. -c dst_api.c - cc -I. -c dst_hmac_link.c - cc -I. -c dst_support.c - cc -I. -c ns_date.c - cc -I. -c ns_name.c - cc -I. -c ns_netint.c - cc -I. -c ns_parse.c - cc -I. -c ns_print.c - cc -I. -c ns_samedomain.c - cc -I. -c ns_sign.c - cc -I. -c ns_ttl.c - cc -I. -c ns_verify.c - cc -I. -c res_comp.c - cc -I. -c res_data.c - cc -I. -c res_debug.c - cc -I. -c res_findzonecut.c - cc -I. -c res_init.c - cc -I. -c res_mkquery.c - cc -I. -c res_mkupdate.c - cc -I. -c res_query.c - cc -I. -c res_send.c - cc -I. -c res_sendsigned.c - cc -I. -c res_update.c - cc -dynamiclib -install_name $out/lib/libresolv.9.dylib -current_version 1.0.0 -compatibility_version 1.0.0 -o libresolv.9.dylib *.o + buildPhase = lib.optionalString (!headersOnly) '' + $CC -I. -c dns_util.c + $CC -I. -c dns.c + $CC -I. -c dns_async.c + $CC -I. -c base64.c + $CC -I. -c dst_api.c + $CC -I. -c dst_hmac_link.c + $CC -I. -c dst_support.c + $CC -I. -c ns_date.c + $CC -I. -c ns_name.c + $CC -I. -c ns_netint.c + $CC -I. -c ns_parse.c + $CC -I. -c ns_print.c + $CC -I. -c ns_samedomain.c + $CC -I. -c ns_sign.c + $CC -I. -c ns_ttl.c + $CC -I. -c ns_verify.c + $CC -I. -c res_comp.c + $CC -I. -c res_data.c + $CC -I. -c res_debug.c + $CC -I. -c res_findzonecut.c + $CC -I. -c res_init.c + $CC -I. -c res_mkquery.c + $CC -I. -c res_mkupdate.c + $CC -I. -c res_query.c + $CC -I. -c res_send.c + $CC -I. -c res_sendsigned.c + $CC -I. -c res_update.c + $CC -dynamiclib -install_name $out/lib/libresolv.9.dylib -current_version 1.0.0 -compatibility_version 1.0.0 -o libresolv.9.dylib *.o ''; installPhase = '' @@ -42,6 +44,7 @@ appleDerivation { cp nameser.h $out/include ln -s ../nameser.h $out/include/arpa cp resolv.h $out/include + '' + lib.optionalString (!headersOnly) '' cp libresolv.9.dylib $out/lib ln -s libresolv.9.dylib $out/lib/libresolv.dylib diff --git a/pkgs/os-specific/darwin/apple-source-releases/libutil/default.nix b/pkgs/os-specific/darwin/apple-source-releases/libutil/default.nix index ea9ca75e7e54b..e7c8a6b1113b2 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/libutil/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/libutil/default.nix @@ -1,9 +1,9 @@ -{ lib, appleDerivation, xcbuildHook +{ lib, stdenv, stdenvNoCC, appleDerivation', xcbuildHook # headersOnly is true when building for libSystem , headersOnly ? false }: -appleDerivation { +appleDerivation' (if headersOnly then stdenvNoCC else stdenv) { nativeBuildInputs = lib.optional (!headersOnly) xcbuildHook; prePatch = '' diff --git a/pkgs/os-specific/darwin/apple-source-releases/mDNSResponder/default.nix b/pkgs/os-specific/darwin/apple-source-releases/mDNSResponder/default.nix index f17ed785360d9..64de728805fd3 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/mDNSResponder/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/mDNSResponder/default.nix @@ -1,6 +1,6 @@ -{ appleDerivation }: +{ appleDerivation', stdenvNoCC }: -appleDerivation { +appleDerivation' stdenvNoCC { phases = [ "unpackPhase" "installPhase" ]; installPhase = '' diff --git a/pkgs/os-specific/darwin/apple-source-releases/ppp/default.nix b/pkgs/os-specific/darwin/apple-source-releases/ppp/default.nix index 5668c376130e7..4ced564ffb722 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/ppp/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/ppp/default.nix @@ -1,6 +1,6 @@ -{ appleDerivation }: +{ appleDerivation', stdenv }: -appleDerivation { +appleDerivation' stdenv { dontBuild = true; installPhase = '' mkdir -p $out/include/ppp diff --git a/pkgs/os-specific/darwin/apple-source-releases/removefile/default.nix b/pkgs/os-specific/darwin/apple-source-releases/removefile/default.nix index 0b2c1c9c7dcc3..611f445e1ec94 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/removefile/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/removefile/default.nix @@ -1,6 +1,6 @@ -{ appleDerivation }: +{ appleDerivation', stdenvNoCC }: -appleDerivation { +appleDerivation' stdenvNoCC { installPhase = '' mkdir -p $out/include/ cp removefile.h checkint.h $out/include/ diff --git a/pkgs/os-specific/darwin/apple-source-releases/shell_cmds/default.nix b/pkgs/os-specific/darwin/apple-source-releases/shell_cmds/default.nix index e2e13a168f04c..a8352285c78e0 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/shell_cmds/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/shell_cmds/default.nix @@ -1,7 +1,7 @@ -{ lib, appleDerivation, xcbuildHook }: +{ lib, appleDerivation, xcbuildHook, launchd }: appleDerivation { - nativeBuildInputs = [ xcbuildHook ]; + nativeBuildInputs = [ xcbuildHook launchd ]; patchPhase = '' # NOTE: these hashes must be recalculated for each version change diff --git a/pkgs/os-specific/darwin/apple-source-releases/system_cmds/default.nix b/pkgs/os-specific/darwin/apple-source-releases/system_cmds/default.nix index 34d093b7cc002..d42d142ef6ee7 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/system_cmds/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/system_cmds/default.nix @@ -1,5 +1,5 @@ { stdenv, appleDerivation, lib -, Librpcsvc, apple_sdk, pam, CF, openbsm }: +, libutil, Librpcsvc, apple_sdk, pam, CF, openbsm }: appleDerivation { # xcbuild fails with: @@ -7,7 +7,7 @@ appleDerivation { # see issue facebook/xcbuild#188 # buildInputs = [ xcbuild ]; - buildInputs = [ Librpcsvc apple_sdk.frameworks.OpenDirectory pam CF + buildInputs = [ libutil Librpcsvc apple_sdk.frameworks.OpenDirectory pam CF apple_sdk.frameworks.IOKit openbsm ]; # NIX_CFLAGS_COMPILE = lib.optionalString hostPlatform.isi686 "-D__i386__" # + lib.optionalString hostPlatform.isx86_64 "-D__x86_64__" @@ -35,6 +35,11 @@ appleDerivation { --replace bsm/audit_session.h bsm/audit.h substituteInPlace login.tproj/login_audit.c \ --replace bsm/audit_session.h bsm/audit.h + '' + lib.optionalString stdenv.isAarch64 '' + substituteInPlace sysctl.tproj/sysctl.c \ + --replace "GPROF_STATE" "0" + substituteInPlace login.tproj/login.c \ + --replace "defined(__arm__)" "defined(__arm__) || defined(__arm64__)" ''; buildPhase = '' diff --git a/pkgs/os-specific/darwin/apple-source-releases/xnu/default.nix b/pkgs/os-specific/darwin/apple-source-releases/xnu/default.nix index 9892814468e9b..90f572d3940d6 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/xnu/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/xnu/default.nix @@ -1,8 +1,12 @@ -{ appleDerivation, lib, bootstrap_cmds, bison, flex +{ appleDerivation', lib, stdenv, stdenvNoCC, buildPackages +, bootstrap_cmds, bison, flex , gnum4, unifdef, perl, python3 -, headersOnly ? true }: +, headersOnly ? true +}: + +appleDerivation' (if headersOnly then stdenvNoCC else stdenv) ({ + depsBuildBuild = [ buildPackages.stdenv.cc ]; -appleDerivation ({ nativeBuildInputs = [ bootstrap_cmds bison flex gnum4 unifdef perl python3 ]; patches = [ ./python3.patch ]; @@ -44,16 +48,16 @@ appleDerivation ({ PLATFORM = "MacOSX"; SDKVERSION = "10.11"; - CC = "cc"; - CXX = "c++"; + CC = "${stdenv.cc.targetPrefix or ""}cc"; + CXX = "${stdenv.cc.targetPrefix or ""}c++"; MIG = "mig"; MIGCOM = "migcom"; - STRIP = "strip"; - NM = "nm"; + STRIP = "${stdenv.cc.bintools.targetPrefix or ""}strip"; + NM = "${stdenv.cc.bintools.targetPrefix or ""}nm"; UNIFDEF = "unifdef"; DSYMUTIL = "dsymutil"; HOST_OS_VERSION = "10.10"; - HOST_CC = "cc"; + HOST_CC = "${buildPackages.stdenv.cc.targetPrefix or ""}cc"; HOST_FLEX = "flex"; HOST_BISON = "bison"; HOST_GM4 = "m4"; diff --git a/pkgs/os-specific/darwin/binutils/default.nix b/pkgs/os-specific/darwin/binutils/default.nix index 29ae1871ddb14..5dc57f43e4ab2 100644 --- a/pkgs/os-specific/darwin/binutils/default.nix +++ b/pkgs/os-specific/darwin/binutils/default.nix @@ -9,6 +9,7 @@ let cmds = [ "ar" "ranlib" "as" "install_name_tool" "ld" "strip" "otool" "lipo" "nm" "strings" "size" + "codesign_allocate" ]; in diff --git a/pkgs/os-specific/darwin/cctools/port.nix b/pkgs/os-specific/darwin/cctools/port.nix index 50e0a2eb3fbfc..bace6f0689d9e 100644 --- a/pkgs/os-specific/darwin/cctools/port.nix +++ b/pkgs/os-specific/darwin/cctools/port.nix @@ -1,6 +1,6 @@ { lib, stdenv, fetchFromGitHub, autoconf, automake, libtool, autoreconfHook , installShellFiles -, libcxxabi, libuuid +, libuuid , libobjc ? null, maloader ? null , enableTapiSupport ? true, libtapi }: @@ -32,7 +32,7 @@ stdenv.mkDerivation { nativeBuildInputs = [ autoconf automake libtool autoreconfHook installShellFiles ]; buildInputs = [ libuuid ] - ++ lib.optionals stdenv.isDarwin [ libcxxabi libobjc ] + ++ lib.optionals stdenv.isDarwin [ libobjc ] ++ lib.optional enableTapiSupport libtapi; patches = [ ./ld-ignore-rpath-link.patch ./ld-rpath-nonfinal.patch ]; diff --git a/pkgs/os-specific/darwin/darwin-stubs/default.nix b/pkgs/os-specific/darwin/darwin-stubs/default.nix index aa946eb5bf0a2..6e3439455cce5 100644 --- a/pkgs/os-specific/darwin/darwin-stubs/default.nix +++ b/pkgs/os-specific/darwin/darwin-stubs/default.nix @@ -1,6 +1,6 @@ -{ stdenv, fetchurl }: +{ stdenvNoCC, fetchurl }: -stdenv.mkDerivation { +stdenvNoCC.mkDerivation { pname = "darwin-stubs"; version = "10.12"; diff --git a/pkgs/os-specific/darwin/libtapi/default.nix b/pkgs/os-specific/darwin/libtapi/default.nix index 8c83b4ae1e699..da07107409736 100644 --- a/pkgs/os-specific/darwin/libtapi/default.nix +++ b/pkgs/os-specific/darwin/libtapi/default.nix @@ -1,6 +1,6 @@ -{ lib, stdenv, fetchFromGitHub, cmake, python3, ncurses }: +{ lib, stdenv, fetchFromGitHub, pkgsBuildBuild, cmake, python3, ncurses }: -stdenv.mkDerivation rec { +stdenv.mkDerivation { pname = "libtapi"; version = "1100.0.11"; # determined by looking at VERSION.txt @@ -13,13 +13,43 @@ stdenv.mkDerivation rec { sourceRoot = "source/src/llvm"; + # Backported from newer llvm, fixes configure error when cross compiling. + # Also means we don't have to manually fix the result with install_name_tool. + patches = [ + ./disable-rpath.patch + ] ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) [ + # TODO: make unconditional and rebuild the world + # TODO: send upstream + ./native-clang-tblgen.patch + ]; + nativeBuildInputs = [ cmake python3 ]; # ncurses is required here to avoid a reference to bootstrap-tools, which is # not allowed for the stdenv. buildInputs = [ ncurses ]; - cmakeFlags = [ "-DLLVM_INCLUDE_TESTS=OFF" ]; + cmakeFlags = [ "-DLLVM_INCLUDE_TESTS=OFF" ] + ++ lib.optional (stdenv.buildPlatform != stdenv.hostPlatform) [ + "-DCMAKE_CROSSCOMPILING=True" + # This package could probably have a llvm_6 llvm-tblgen and clang-tblgen + # provided to reduce some building. This package seems intended to + # include all of its dependencies, including enough of LLVM to build the + # required tablegens. + ( + let + nativeCC = pkgsBuildBuild.stdenv.cc; + nativeBintools = nativeCC.bintools.bintools; + nativeToolchainFlags = [ + "-DCMAKE_C_COMPILER=${nativeCC}/bin/${nativeCC.targetPrefix}cc" + "-DCMAKE_CXX_COMPILER=${nativeCC}/bin/${nativeCC.targetPrefix}c++" + "-DCMAKE_AR=${nativeBintools}/bin/${nativeBintools.targetPrefix}ar" + "-DCMAKE_STRIP=${nativeBintools}/bin/${nativeBintools.targetPrefix}strip" + "-DCMAKE_RANLIB=${nativeBintools}/bin/${nativeBintools.targetPrefix}ranlib" + ]; + in "-DCROSS_TOOLCHAIN_FLAGS_NATIVE:list=${lib.concatStringsSep ";" nativeToolchainFlags}" + ) + ]; # fixes: fatal error: 'clang/Basic/Diagnostic.h' file not found # adapted from upstream @@ -35,10 +65,6 @@ stdenv.mkDerivation rec { installTargets = [ "install-libtapi" "install-tapi-headers" "install-tapi" ]; - postInstall = lib.optionalString stdenv.isDarwin '' - install_name_tool -id $out/lib/libtapi.dylib $out/lib/libtapi.dylib - ''; - meta = with lib; { description = "Replaces the Mach-O Dynamic Library Stub files in Apple's SDKs to reduce the size"; homepage = "https://github.com/tpoechtrager/apple-libtapi"; diff --git a/pkgs/os-specific/darwin/libtapi/disable-rpath.patch b/pkgs/os-specific/darwin/libtapi/disable-rpath.patch new file mode 100644 index 0000000000000..87c0cf3330de6 --- /dev/null +++ b/pkgs/os-specific/darwin/libtapi/disable-rpath.patch @@ -0,0 +1,14 @@ +diff --git a/src/llvm/cmake/modules/AddLLVM.cmake b/src/llvm/cmake/modules/AddLLVM.cmake +index a53016eb0..b65e608a4 100644 +--- a/cmake/modules/AddLLVM.cmake ++++ b/cmake/modules/AddLLVM.cmake +@@ -1683,8 +1683,7 @@ function(llvm_setup_rpath name) + endif() + + if (APPLE) +- set(_install_name_dir INSTALL_NAME_DIR "@rpath") +- set(_install_rpath "@loader_path/../lib" ${extra_libdir}) ++ set(_install_name_dir) + elseif(UNIX) + set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir}) + if(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)") diff --git a/pkgs/os-specific/darwin/libtapi/native-clang-tblgen.patch b/pkgs/os-specific/darwin/libtapi/native-clang-tblgen.patch new file mode 100644 index 0000000000000..9b715766a122e --- /dev/null +++ b/pkgs/os-specific/darwin/libtapi/native-clang-tblgen.patch @@ -0,0 +1,21 @@ +diffprojects/libtapi/CMakeLists.txt b/src/llvm/projects/libtapi/CMakeLists.txt +index 8ee6d8138..8277be147 100644 +--- a/projects/libtapi/CMakeLists.txt ++++ b/projects/libtapi/CMakeLists.txt +@@ -193,7 +193,15 @@ if (NOT DEFINED CLANG_VERSION) + set(CLANG_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}") + endif () + if (NOT DEFINED CLANG_TABLEGEN_EXE) +- set(CLANG_TABLEGEN_EXE "${LLVM_TOOLS_BINARY_DIR}/clang-tblgen") ++ if(LLVM_USE_HOST_TOOLS) ++ if (NOT CMAKE_CONFIGURATION_TYPES) ++ set(CLANG_TABLEGEN_EXE "${LLVM_NATIVE_BUILD}/bin/clang-tblgen") ++ else() ++ set(CLANG_TABLEGEN_EXE "${LLVM_NATIVE_BUILD}/Release/bin/clang-tblgen") ++ endif() ++ else() ++ set(CLANG_TABLEGEN_EXE "${LLVM_TOOLS_BINARY_DIR}/clang-tblgen") ++ endif () + endif () + + # Include must go first. diff --git a/pkgs/os-specific/darwin/apple-sdk/print-reexports/default.nix b/pkgs/os-specific/darwin/print-reexports/default.nix index a548d8da753f5..740bcb48ef595 100644 --- a/pkgs/os-specific/darwin/apple-sdk/print-reexports/default.nix +++ b/pkgs/os-specific/darwin/print-reexports/default.nix @@ -7,11 +7,11 @@ stdenv.mkDerivation { buildInputs = [ libyaml ]; buildPhase = '' - $CC -lyaml -o $name main.c + $CC -lyaml -o print-reexports main.c ''; installPhase = '' mkdir -p $out/bin - mv $name $out/bin + mv print-reexports $out/bin ''; } diff --git a/pkgs/os-specific/darwin/apple-sdk/print-reexports/main.c b/pkgs/os-specific/darwin/print-reexports/main.c index df46e3f18e897..e6ff527da9668 100644 --- a/pkgs/os-specific/darwin/apple-sdk/print-reexports/main.c +++ b/pkgs/os-specific/darwin/print-reexports/main.c @@ -21,6 +21,10 @@ #include <sys/errno.h> #include <yaml.h> +#define LOG(str, ...) fprintf(stderr, "%s", str) + +#define LOGF(...) fprintf(stderr, __VA_ARGS__) + 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"); @@ -35,12 +39,12 @@ static yaml_node_t *get_mapping_entry(yaml_document_t *document, yaml_node_t *ma 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); + LOGF("key (%d) is null\n", pair->key); return NULL; } if (key->type != YAML_SCALAR_NODE) { - fprintf(stderr, "get_mapping_entry: key is not a scalar\n"); + LOG("get_mapping_entry: key is not a scalar\n"); return NULL; } @@ -54,18 +58,17 @@ static yaml_node_t *get_mapping_entry(yaml_document_t *document, yaml_node_t *ma return NULL; } -static int emit_reexports(yaml_document_t *document) { +static int emit_reexports_v2(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; + return 1; } if (exports->type != YAML_SEQUENCE_NODE) { - fprintf(stderr, "emit_reexports, value is not a sequence\n"); + LOG("value is not a sequence\n"); return 0; } @@ -82,6 +85,11 @@ static int emit_reexports(yaml_document_t *document) { continue; } + if (reexports->type != YAML_SEQUENCE_NODE) { + LOG("re-exports is not a sequence\n"); + return 0; + } + for ( yaml_node_item_t *reexport = reexports->data.sequence.items.start; reexport < reexports->data.sequence.items.top; @@ -90,7 +98,58 @@ static int emit_reexports(yaml_document_t *document) { yaml_node_t *val = yaml_document_get_node(document, *reexport); if (val->type != YAML_SCALAR_NODE) { - fprintf(stderr, "item is not a scalar\n"); + LOG("item is not a scalar\n"); + return 0; + } + + fwrite(val->data.scalar.value, val->data.scalar.length, 1, stdout); + putchar('\n'); + } + } + + return 1; +} + +static int emit_reexports_v4(yaml_document_t *document) { + yaml_node_t *root = yaml_document_get_root_node(document); + yaml_node_t *reexports = get_mapping_entry(document, root, "reexported-libraries"); + + if (!reexports) { + return 1; + } + + if (reexports->type != YAML_SEQUENCE_NODE) { + LOG("value is not a sequence\n"); + return 0; + } + + for ( + yaml_node_item_t *entry = reexports->data.sequence.items.start; + entry < reexports->data.sequence.items.top; + ++entry + ) { + yaml_node_t *entry_node = yaml_document_get_node(document, *entry); + + yaml_node_t *libs = get_mapping_entry(document, entry_node, "libraries"); + + if (!libs) { + continue; + } + + if (libs->type != YAML_SEQUENCE_NODE) { + LOG("libraries is not a sequence\n"); + return 0; + } + + for ( + yaml_node_item_t *lib = libs->data.sequence.items.start; + lib < libs->data.sequence.items.top; + ++lib + ) { + yaml_node_t *val = yaml_document_get_node(document, *lib); + + if (val->type != YAML_SCALAR_NODE) { + LOG("item is not a scalar\n"); return 0; } @@ -135,7 +194,13 @@ int main(int argc, char **argv) { goto err_yaml; } - emit_reexports(&yaml_document); + // Try both, only fail if one reports an error. A lack of re-exports is not + // considered an error. + int ok = 1; + ok = ok && emit_reexports_v2(&yaml_document); + ok = ok && emit_reexports_v4(&yaml_document); + + result = !ok; err_yaml: yaml_parser_delete(&yaml_parser); diff --git a/pkgs/os-specific/darwin/print-reexports/setup-hook.sh b/pkgs/os-specific/darwin/print-reexports/setup-hook.sh new file mode 100644 index 0000000000000..9efb00aeb4dc4 --- /dev/null +++ b/pkgs/os-specific/darwin/print-reexports/setup-hook.sh @@ -0,0 +1,19 @@ +fixupOutputHooks+=('checkTbdReexports') + +checkTbdReexports() { + local dir="$1" + + while IFS= read -r -d $'\0' tbd; do + echo "checkTbdRexports: checking re-exports in $tbd" + while read -r 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 < <(print-reexports "$tbd") + done < <(find $prefix -type f -name '*.tbd' -print0) +} diff --git a/pkgs/os-specific/darwin/rewrite-tbd/default.nix b/pkgs/os-specific/darwin/rewrite-tbd/default.nix new file mode 100644 index 0000000000000..f41b81b3bc90f --- /dev/null +++ b/pkgs/os-specific/darwin/rewrite-tbd/default.nix @@ -0,0 +1,16 @@ +{ stdenv, fetchFromGitHub, cmake, pkg-config, libyaml }: + +stdenv.mkDerivation { + pname = "rewrite-tbd"; + version = "20201114"; + + src = fetchFromGitHub { + owner = "thefloweringash"; + repo = "rewrite-tbd"; + rev = "988f29c6ccbca9b883966225263d8d78676da6a3"; + sha256 = "08sk91zwj6n9x2ymwid2k7y0rwv5b7p6h1b25ipx1dv0i43p6v1a"; + }; + + nativeBuildInputs = [ cmake pkg-config ]; + buildInputs = [ libyaml ]; +} diff --git a/pkgs/os-specific/darwin/signing-utils/auto-sign-hook.sh b/pkgs/os-specific/darwin/signing-utils/auto-sign-hook.sh new file mode 100644 index 0000000000000..430aba8cdc7eb --- /dev/null +++ b/pkgs/os-specific/darwin/signing-utils/auto-sign-hook.sh @@ -0,0 +1,20 @@ +fixupOutputHooks+=('signDarwinBinariesIn $prefix') + +# Uses signingUtils, see definition of autoSignDarwinBinariesHook in +# darwin-packages.nix + +signDarwinBinariesIn() { + local dir="$1" + + if [ ! -d "$dir" ]; then + return 0 + fi + + if [ "${darwinDontCodeSign:-}" ]; then + return 0 + fi + + while IFS= read -r -d $'\0' f; do + signIfRequired "$f" + done < <(find "$dir" -type f -print0) +} diff --git a/pkgs/os-specific/darwin/signing-utils/default.nix b/pkgs/os-specific/darwin/signing-utils/default.nix new file mode 100644 index 0000000000000..035ac59b725ae --- /dev/null +++ b/pkgs/os-specific/darwin/signing-utils/default.nix @@ -0,0 +1,24 @@ +{ stdenvNoCC +, sigtool +, cctools +}: + +let + stdenv = stdenvNoCC; +in + +stdenv.mkDerivation { + name = "signing-utils"; + + dontUnpack = true; + dontConfigure = true; + dontBuild = true; + + installPhase = '' + substituteAll ${./utils.sh} $out + ''; + + # Substituted variables + inherit sigtool; + codesignAllocate = "${cctools}/bin/${cctools.targetPrefix}codesign_allocate"; +} diff --git a/pkgs/os-specific/darwin/signing-utils/utils.sh b/pkgs/os-specific/darwin/signing-utils/utils.sh new file mode 100644 index 0000000000000..6d23a461fc995 --- /dev/null +++ b/pkgs/os-specific/darwin/signing-utils/utils.sh @@ -0,0 +1,43 @@ +# Work around for some odd behaviour where we can't codesign a file +# in-place if it has been called before. This happens for example if +# you try to fix-up a binary using strip/install_name_tool, after it +# had been used previous. The solution is to copy the binary (with +# the corrupted signature from strip/install_name_tool) to some +# location, sign it there and move it back into place. +# +# This does not appear to happen with the codesign tool that ships +# with recent macOS BigSur installs on M1 arm64 machines. However it +# had also been happening with the tools that shipped with the DTKs. +sign() { + local tmpdir + tmpdir=$(mktemp -d) + + # $1 is the file + + cp "$1" "$tmpdir" + CODESIGN_ALLOCATE=@codesignAllocate@ \ + @sigtool@/bin/codesign -f -s - "$tmpdir/$(basename "$1")" + mv "$tmpdir/$(basename "$1")" "$1" + rmdir "$tmpdir" +} + +checkRequiresSignature() { + local file=$1 + local rc=0 + + @sigtool@/bin/sigtool --file "$file" check-requires-signature || rc=$? + + if [ "$rc" -eq 0 ] || [ "$rc" -eq 1 ]; then + return "$rc" + fi + + echo "Unexpected exit status from sigtool: $rc" + exit 1 +} + +signIfRequired() { + local file=$1 + if checkRequiresSignature "$file"; then + sign "$file" + fi +} diff --git a/pkgs/os-specific/darwin/sigtool/default.nix b/pkgs/os-specific/darwin/sigtool/default.nix new file mode 100644 index 0000000000000..933ef784879f6 --- /dev/null +++ b/pkgs/os-specific/darwin/sigtool/default.nix @@ -0,0 +1,24 @@ +{ lib, stdenv, fetchFromGitHub, pkg-config, cmake, makeWrapper, openssl }: + +stdenv.mkDerivation { + name = "sigtool"; + + src = fetchFromGitHub { + owner = "thefloweringash"; + repo = "sigtool"; + rev = "4a3719b42dc91c3f513df94048851cc98e7c7fcf"; + sha256 = "04ra1cx7k1sdbkj5yrvl0s3l333vpir8rnm8k1dh2zy1w0a6hpqa"; + }; + + nativeBuildInputs = [ pkg-config makeWrapper ]; + buildInputs = [ openssl ]; + + installFlags = [ "PREFIX=$(out)" ]; + + # Upstream (me) asserts the driver script is optional. + postInstall = '' + substitute $NIX_BUILD_TOP/$sourceRoot/codesign.sh $out/bin/codesign \ + --replace sigtool "$out/bin/sigtool" + chmod a+x $out/bin/codesign + ''; +} diff --git a/pkgs/os-specific/darwin/xcode/sdk-pkgs.nix b/pkgs/os-specific/darwin/xcode/sdk-pkgs.nix index ab934d7eaaafe..0512d9dd46a17 100644 --- a/pkgs/os-specific/darwin/xcode/sdk-pkgs.nix +++ b/pkgs/os-specific/darwin/xcode/sdk-pkgs.nix @@ -41,6 +41,7 @@ rec { mv cc-cflags.tmp $out/nix-support/cc-cflags echo "-target ${targetPlatform.config}" >> $out/nix-support/cc-cflags echo "-isystem ${sdk}/usr/include${lib.optionalString (lib.versionAtLeast "10" sdk.version) " -isystem ${sdk}/usr/include/c++/4.2.1/ -stdlib=libstdc++"}" >> $out/nix-support/cc-cflags + ${lib.optionalString (lib.versionAtLeast sdk.version "14") "echo -isystem ${xcode}/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1 >> $out/nix-support/cc-cflags"} ''; }) // { inherit sdk; |