diff options
author | Sandro <sandro.jaeckel@gmail.com> | 2023-05-22 13:31:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-22 13:31:16 +0200 |
commit | 4aa442cab08366eeec3945a46ffa8e67449649b8 (patch) | |
tree | 90ddb9f091e74d3d131cbbded0f48dc127648b02 | |
parent | 1e71d2aa8891795914e2380803623d3b1523c048 (diff) | |
parent | 137b97e2f619cee1fbb8a624f5ad395a84efcca3 (diff) |
Merge pull request #216466 from boeyms/fix-linuxkit-darwin
-rw-r--r-- | pkgs/development/tools/misc/linuxkit/darwin-os-version.patch | 53 | ||||
-rw-r--r-- | pkgs/development/tools/misc/linuxkit/default.nix | 25 | ||||
-rw-r--r-- | pkgs/development/tools/misc/linuxkit/support-apple-11-sdk.patch | 811 | ||||
-rw-r--r-- | pkgs/top-level/all-packages.nix | 3 |
4 files changed, 889 insertions, 3 deletions
diff --git a/pkgs/development/tools/misc/linuxkit/darwin-os-version.patch b/pkgs/development/tools/misc/linuxkit/darwin-os-version.patch new file mode 100644 index 0000000000000..aaa603e4ead19 --- /dev/null +++ b/pkgs/development/tools/misc/linuxkit/darwin-os-version.patch @@ -0,0 +1,53 @@ +diff --git a/src/cmd/linuxkit/vendor/github.com/Code-Hex/vz/v3/osversion.go b/src/cmd/linuxkit/vendor/github.com/Code-Hex/vz/v3/osversion.go +index d72a7856d..b186d3aff 100644 +--- a/src/cmd/linuxkit/vendor/github.com/Code-Hex/vz/v3/osversion.go ++++ b/src/cmd/linuxkit/vendor/github.com/Code-Hex/vz/v3/osversion.go +@@ -9,6 +9,7 @@ import "C" + import ( + "errors" + "fmt" ++ "os/exec" + "strconv" + "strings" + "sync" +@@ -48,6 +49,40 @@ func fetchMajorMinorVersion() (float64, error) { + if err != nil { + return 0, err + } ++ ++ // For backward compatibility reasons, if code compiled against an SDK ++ // earlier than macOS 11 is run on macOS 11 or later, and then tries to read ++ // value of kern.osproductversion, the OS will return the value "10.16" ++ // instead of the real OS version string. By contrast, the command `sw_vers ++ // -productVersion` will return the real OS version string unless the ++ // environment variable SYSTEM_VERSION_COMPAT is set to 1 or 2, in which ++ // case it will respectively return "10.16" and "15.7" (the latter is for ++ // some iOS compatibility reason). ++ // ++ // The only (currently) sure way to get the real OS version string ++ // regardless of SYSTEM_VERSION_COMPAT or the SDK compiled against is ++ // apparently to parse ++ // /System/Library/CoreServices/.SystemVersionPlatform.plist if it exists, ++ // and /System/Library/CoreServices/SystemVersion.plist otherwise. Doing ++ // so, however, requires parsing XML plist files. ++ // ++ // Given what this library does, it doesn't seem likely that there would be ++ // a good reason to run its code with SYSTEM_VERSION_COMPAT set, so using ++ // `sw_vers` should be adequate until a proper parsing of plist files is ++ // added. ++ // ++ // See https://github.com/ziglang/zig/issues/7569, ++ // https://github.com/ziglang/zig/pull/7714 and ++ // https://eclecticlight.co/2020/08/13/macos-version-numbering-isnt-so-simple/ ++ // for more information. ++ if osver == "10.16" { ++ out, err := exec.Command("sw_vers", "-productVersion").Output() ++ if err != nil { ++ return 0, err ++ } ++ osver = strings.TrimRight(string(out), "\r\n") ++ } ++ + prefix := "v" + majorMinor := strings.TrimPrefix(semver.MajorMinor(prefix+osver), prefix) + version, err := strconv.ParseFloat(majorMinor, 64) diff --git a/pkgs/development/tools/misc/linuxkit/default.nix b/pkgs/development/tools/misc/linuxkit/default.nix index be07f7e9c246a..68a908483d13c 100644 --- a/pkgs/development/tools/misc/linuxkit/default.nix +++ b/pkgs/development/tools/misc/linuxkit/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, buildGoModule, fetchFromGitHub, git, Virtualization, testers, linuxkit }: +{ lib, stdenv, buildGoModule, fetchFromGitHub, git, Cocoa, Virtualization, sigtool, testers, linuxkit }: buildGoModule rec { pname = "linuxkit"; @@ -15,7 +15,17 @@ buildGoModule rec { modRoot = "./src/cmd/linuxkit"; - buildInputs = lib.optionals stdenv.isDarwin [ Virtualization ]; + patches = [ + ./darwin-os-version.patch + ./support-apple-11-sdk.patch + ]; + + # - On macOS, an executable must be signed with the right entitlement(s) to be + # able to use the Virtualization framework at runtime. + # - sigtool is allows us to validly sign such executables with a dummy + # authority. + nativeBuildInputs = lib.optionals stdenv.isDarwin [ sigtool ]; + buildInputs = lib.optionals stdenv.isDarwin [ Cocoa Virtualization ]; ldflags = [ "-s" @@ -25,6 +35,17 @@ buildGoModule rec { nativeCheckInputs = [ git ]; + # - Because this package definition doesn't build using the source's Makefile, + # we must manually call the sign target. + # - The binary stripping that nixpkgs does by default in the + # fixup phase removes such signing and entitlements, so we have to sign + # after stripping. + # - Finally, at the start of the fixup phase, the working directory is + # $sourceRoot/src/cmd/linuxkit, so it's simpler to use the sign target from + # the Makefile in that directory rather than $sourceRoot/Makefile. + postFixup = lib.optionalString stdenv.isDarwin '' + make sign LOCAL_TARGET=$out/bin/linuxkit + ''; passthru.tests.version = testers.testVersion { package = linuxkit; command = "linuxkit version"; diff --git a/pkgs/development/tools/misc/linuxkit/support-apple-11-sdk.patch b/pkgs/development/tools/misc/linuxkit/support-apple-11-sdk.patch new file mode 100644 index 0000000000000..70393977715bb --- /dev/null +++ b/pkgs/development/tools/misc/linuxkit/support-apple-11-sdk.patch @@ -0,0 +1,811 @@ +diff --git a/src/cmd/linuxkit/vendor/github.com/Code-Hex/vz/v3/virtualization_12.m b/src/cmd/linuxkit/vendor/github.com/Code-Hex/vz/v3/virtualization_12.m +index 567172ba2..e2c1ac047 100644 +--- a/src/cmd/linuxkit/vendor/github.com/Code-Hex/vz/v3/virtualization_12.m ++++ b/src/cmd/linuxkit/vendor/github.com/Code-Hex/vz/v3/virtualization_12.m +@@ -8,6 +8,7 @@ + + bool vmCanStop(void *machine, void *queue) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + __block BOOL result; + dispatch_sync((dispatch_queue_t)queue, ^{ +@@ -15,12 +16,13 @@ bool vmCanStop(void *machine, void *queue) + }); + return (bool)result; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + + void stopWithCompletionHandler(void *machine, void *queue, void *completionHandler) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + vm_completion_handler_t handler = makeVMCompletionHandler(completionHandler); + dispatch_sync((dispatch_queue_t)queue, ^{ +@@ -29,7 +31,7 @@ void stopWithCompletionHandler(void *machine, void *queue, void *completionHandl + Block_release(handler); + return; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -38,10 +40,11 @@ void stopWithCompletionHandler(void *machine, void *queue, void *completionHandl + */ + void *newVZGenericPlatformConfiguration() + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + return [[VZGenericPlatformConfiguration alloc] init]; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -51,11 +54,12 @@ void *newVZGenericPlatformConfiguration() + */ + void setDirectorySharingDevicesVZVirtualMachineConfiguration(void *config, void *directorySharingDevices) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + [(VZVirtualMachineConfiguration *)config setDirectorySharingDevices:[(NSMutableArray *)directorySharingDevices copy]]; + return; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -66,11 +70,12 @@ void setDirectorySharingDevicesVZVirtualMachineConfiguration(void *config, void + */ + void setPlatformVZVirtualMachineConfiguration(void *config, void *platform) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + [(VZVirtualMachineConfiguration *)config setPlatform:(VZPlatformConfiguration *)platform]; + return; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -80,11 +85,12 @@ void setPlatformVZVirtualMachineConfiguration(void *config, void *platform) + */ + void setGraphicsDevicesVZVirtualMachineConfiguration(void *config, void *graphicsDevices) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + [(VZVirtualMachineConfiguration *)config setGraphicsDevices:[(NSMutableArray *)graphicsDevices copy]]; + return; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -94,11 +100,12 @@ void setGraphicsDevicesVZVirtualMachineConfiguration(void *config, void *graphic + */ + void setPointingDevicesVZVirtualMachineConfiguration(void *config, void *pointingDevices) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + [(VZVirtualMachineConfiguration *)config setPointingDevices:[(NSMutableArray *)pointingDevices copy]]; + return; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -108,11 +115,12 @@ void setPointingDevicesVZVirtualMachineConfiguration(void *config, void *pointin + */ + void setKeyboardsVZVirtualMachineConfiguration(void *config, void *keyboards) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + [(VZVirtualMachineConfiguration *)config setKeyboards:[(NSMutableArray *)keyboards copy]]; + return; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -122,11 +130,12 @@ void setKeyboardsVZVirtualMachineConfiguration(void *config, void *keyboards) + */ + void setAudioDevicesVZVirtualMachineConfiguration(void *config, void *audioDevices) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + [(VZVirtualMachineConfiguration *)config setAudioDevices:[(NSMutableArray *)audioDevices copy]]; + return; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -136,10 +145,11 @@ void setAudioDevicesVZVirtualMachineConfiguration(void *config, void *audioDevic + */ + void *newVZVirtioSoundDeviceConfiguration() + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + return [[VZVirtioSoundDeviceConfiguration alloc] init]; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -148,11 +158,12 @@ void *newVZVirtioSoundDeviceConfiguration() + */ + void setStreamsVZVirtioSoundDeviceConfiguration(void *audioDeviceConfiguration, void *streams) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + [(VZVirtioSoundDeviceConfiguration *)audioDeviceConfiguration setStreams:[(NSMutableArray *)streams copy]]; + return; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -162,10 +173,11 @@ void setStreamsVZVirtioSoundDeviceConfiguration(void *audioDeviceConfiguration, + */ + void *newVZVirtioSoundDeviceInputStreamConfiguration() + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + return [[VZVirtioSoundDeviceInputStreamConfiguration alloc] init]; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -174,12 +186,13 @@ void *newVZVirtioSoundDeviceInputStreamConfiguration() + */ + void *newVZVirtioSoundDeviceHostInputStreamConfiguration() + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + VZVirtioSoundDeviceInputStreamConfiguration *inputStream = (VZVirtioSoundDeviceInputStreamConfiguration *)newVZVirtioSoundDeviceInputStreamConfiguration(); + [inputStream setSource:[[VZHostAudioInputStreamSource alloc] init]]; + return inputStream; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -189,10 +202,11 @@ void *newVZVirtioSoundDeviceHostInputStreamConfiguration() + */ + void *newVZVirtioSoundDeviceOutputStreamConfiguration() + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + return [[VZVirtioSoundDeviceOutputStreamConfiguration alloc] init]; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -201,12 +215,13 @@ void *newVZVirtioSoundDeviceOutputStreamConfiguration() + */ + void *newVZVirtioSoundDeviceHostOutputStreamConfiguration() + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + VZVirtioSoundDeviceOutputStreamConfiguration *outputStream = (VZVirtioSoundDeviceOutputStreamConfiguration *)newVZVirtioSoundDeviceOutputStreamConfiguration(); + [outputStream setSink:[[VZHostAudioOutputStreamSink alloc] init]]; + return outputStream; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -220,12 +235,13 @@ void *newVZVirtioSoundDeviceHostOutputStreamConfiguration() + */ + void *newVZSharedDirectory(const char *dirPath, bool readOnly) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + NSString *dirPathNSString = [NSString stringWithUTF8String:dirPath]; + NSURL *dirURL = [NSURL fileURLWithPath:dirPathNSString]; + return [[VZSharedDirectory alloc] initWithURL:dirURL readOnly:(BOOL)readOnly]; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -237,10 +253,11 @@ void *newVZSharedDirectory(const char *dirPath, bool readOnly) + */ + void *newVZSingleDirectoryShare(void *sharedDirectory) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + return [[VZSingleDirectoryShare alloc] initWithDirectory:(VZSharedDirectory *)sharedDirectory]; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -252,10 +269,11 @@ void *newVZSingleDirectoryShare(void *sharedDirectory) + */ + void *newVZMultipleDirectoryShare(void *sharedDirectories) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + return [[VZMultipleDirectoryShare alloc] initWithDirectories:(NSDictionary<NSString *, VZSharedDirectory *> *)sharedDirectories]; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -267,6 +285,7 @@ void *newVZMultipleDirectoryShare(void *sharedDirectories) + */ + void *newVZVirtioFileSystemDeviceConfiguration(const char *tag, void **error) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + NSString *tagNSString = [NSString stringWithUTF8String:tag]; + BOOL valid = [VZVirtioFileSystemDeviceConfiguration validateTag:tagNSString error:(NSError *_Nullable *_Nullable)error]; +@@ -275,7 +294,7 @@ void *newVZVirtioFileSystemDeviceConfiguration(const char *tag, void **error) + } + return [[VZVirtioFileSystemDeviceConfiguration alloc] initWithTag:tagNSString]; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -284,11 +303,12 @@ void *newVZVirtioFileSystemDeviceConfiguration(const char *tag, void **error) + */ + void setVZVirtioFileSystemDeviceConfigurationShare(void *config, void *share) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + [(VZVirtioFileSystemDeviceConfiguration *)config setShare:(VZDirectoryShare *)share]; + return; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -298,10 +318,11 @@ void setVZVirtioFileSystemDeviceConfigurationShare(void *config, void *share) + */ + void *newVZUSBScreenCoordinatePointingDeviceConfiguration() + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + return [[VZUSBScreenCoordinatePointingDeviceConfiguration alloc] init]; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -311,10 +332,11 @@ void *newVZUSBScreenCoordinatePointingDeviceConfiguration() + */ + void *newVZUSBKeyboardConfiguration() + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + return [[VZUSBKeyboardConfiguration alloc] init]; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -328,6 +350,7 @@ void sharedApplication() + + void startVirtualMachineWindow(void *machine, double width, double height) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + @autoreleasepool { + AppDelegate *appDelegate = [[[AppDelegate alloc] +@@ -340,5 +363,6 @@ void startVirtualMachineWindow(void *machine, double width, double height) + return; + } + } ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } +diff --git a/src/cmd/linuxkit/vendor/github.com/Code-Hex/vz/v3/virtualization_12_arm64.m b/src/cmd/linuxkit/vendor/github.com/Code-Hex/vz/v3/virtualization_12_arm64.m +index 4fbaf6cb7..452adb747 100644 +--- a/src/cmd/linuxkit/vendor/github.com/Code-Hex/vz/v3/virtualization_12_arm64.m ++++ b/src/cmd/linuxkit/vendor/github.com/Code-Hex/vz/v3/virtualization_12_arm64.m +@@ -30,6 +30,7 @@ + */ + void *newVZMacAuxiliaryStorageWithCreating(const char *storagePath, void *hardwareModel, void **error) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + NSString *storagePathNSString = [NSString stringWithUTF8String:storagePath]; + NSURL *storageURL = [NSURL fileURLWithPath:storagePathNSString]; +@@ -38,7 +39,7 @@ void *newVZMacAuxiliaryStorageWithCreating(const char *storagePath, void *hardwa + options:VZMacAuxiliaryStorageInitializationOptionAllowOverwrite + error:(NSError *_Nullable *_Nullable)error]; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -49,6 +50,7 @@ void *newVZMacAuxiliaryStorageWithCreating(const char *storagePath, void *hardwa + */ + void *newVZMacAuxiliaryStorage(const char *storagePath) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + NSString *storagePathNSString = [NSString stringWithUTF8String:storagePath]; + NSURL *storageURL = [NSURL fileURLWithPath:storagePathNSString]; +@@ -56,7 +58,7 @@ void *newVZMacAuxiliaryStorage(const char *storagePath) + // https://developer.apple.com/documentation/virtualization/vzmacauxiliarystorage?language=objc + return [[VZMacAuxiliaryStorage alloc] initWithContentsOfURL:storageURL]; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -80,10 +82,11 @@ void *newVZMacAuxiliaryStorage(const char *storagePath) + */ + void *newVZMacPlatformConfiguration() + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + return [[VZMacPlatformConfiguration alloc] init]; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -92,17 +95,19 @@ void *newVZMacPlatformConfiguration() + */ + void setHardwareModelVZMacPlatformConfiguration(void *config, void *hardwareModel) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + [(VZMacPlatformConfiguration *)config setHardwareModel:(VZMacHardwareModel *)hardwareModel]; + return; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + + // Store the hardware model to disk so that we can retrieve them for subsequent boots. + void storeHardwareModelDataVZMacPlatformConfiguration(void *config, const char *filePath) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + VZMacPlatformConfiguration *macPlatformConfiguration = (VZMacPlatformConfiguration *)config; + NSString *filePathNSString = [NSString stringWithUTF8String:filePath]; +@@ -110,7 +115,7 @@ void storeHardwareModelDataVZMacPlatformConfiguration(void *config, const char * + [macPlatformConfiguration.hardwareModel.dataRepresentation writeToURL:fileURL atomically:YES]; + return; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -121,17 +126,19 @@ void storeHardwareModelDataVZMacPlatformConfiguration(void *config, const char * + */ + void setMachineIdentifierVZMacPlatformConfiguration(void *config, void *machineIdentifier) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + [(VZMacPlatformConfiguration *)config setMachineIdentifier:(VZMacMachineIdentifier *)machineIdentifier]; + return; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + + // Store the machine identifier to disk so that we can retrieve them for subsequent boots. + void storeMachineIdentifierDataVZMacPlatformConfiguration(void *config, const char *filePath) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + VZMacPlatformConfiguration *macPlatformConfiguration = (VZMacPlatformConfiguration *)config; + NSString *filePathNSString = [NSString stringWithUTF8String:filePath]; +@@ -139,7 +146,7 @@ void storeMachineIdentifierDataVZMacPlatformConfiguration(void *config, const ch + [macPlatformConfiguration.machineIdentifier.dataRepresentation writeToURL:fileURL atomically:YES]; + return; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -151,11 +158,12 @@ void storeMachineIdentifierDataVZMacPlatformConfiguration(void *config, const ch + */ + void setAuxiliaryStorageVZMacPlatformConfiguration(void *config, void *auxiliaryStorage) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + [(VZMacPlatformConfiguration *)config setAuxiliaryStorage:(VZMacAuxiliaryStorage *)auxiliaryStorage]; + return; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -169,10 +177,11 @@ void setAuxiliaryStorageVZMacPlatformConfiguration(void *config, void *auxiliary + */ + void *newVZMacOSBootLoader() + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + return [[VZMacOSBootLoader alloc] init]; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -182,10 +191,11 @@ void *newVZMacOSBootLoader() + */ + void *newVZMacGraphicsDeviceConfiguration() + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + return [[VZMacGraphicsDeviceConfiguration alloc] init]; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -194,11 +204,12 @@ void *newVZMacGraphicsDeviceConfiguration() + */ + void setDisplaysVZMacGraphicsDeviceConfiguration(void *graphicsConfiguration, void *displays) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + [(VZMacGraphicsDeviceConfiguration *)graphicsConfiguration setDisplays:[(NSMutableArray *)displays copy]]; + return; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -210,13 +221,14 @@ void setDisplaysVZMacGraphicsDeviceConfiguration(void *graphicsConfiguration, vo + */ + void *newVZMacGraphicsDisplayConfiguration(NSInteger widthInPixels, NSInteger heightInPixels, NSInteger pixelsPerInch) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + return [[VZMacGraphicsDisplayConfiguration alloc] + initWithWidthInPixels:widthInPixels + heightInPixels:heightInPixels + pixelsPerInch:pixelsPerInch]; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -226,6 +238,7 @@ void *newVZMacGraphicsDisplayConfiguration(NSInteger widthInPixels, NSInteger he + */ + void *newVZMacHardwareModelWithPath(const char *hardwareModelPath) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + VZMacHardwareModel *hardwareModel; + NSString *hardwareModelPathNSString = [NSString stringWithUTF8String:hardwareModelPath]; +@@ -236,12 +249,13 @@ void *newVZMacHardwareModelWithPath(const char *hardwareModelPath) + } + return hardwareModel; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + + void *newVZMacHardwareModelWithBytes(void *hardwareModelBytes, int len) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + VZMacHardwareModel *hardwareModel; + @autoreleasepool { +@@ -250,7 +264,7 @@ void *newVZMacHardwareModelWithBytes(void *hardwareModelBytes, int len) + } + return hardwareModel; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -259,10 +273,11 @@ void *newVZMacHardwareModelWithBytes(void *hardwareModelBytes, int len) + */ + void *newVZMacMachineIdentifier() + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + return [[VZMacMachineIdentifier alloc] init]; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -274,6 +289,7 @@ void *newVZMacMachineIdentifier() + */ + void *newVZMacMachineIdentifierWithPath(const char *machineIdentifierPath) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + VZMacMachineIdentifier *machineIdentifier; + NSString *machineIdentifierPathNSString = [NSString stringWithUTF8String:machineIdentifierPath]; +@@ -284,12 +300,13 @@ void *newVZMacMachineIdentifierWithPath(const char *machineIdentifierPath) + } + return machineIdentifier; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + + void *newVZMacMachineIdentifierWithBytes(void *machineIdentifierBytes, int len) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + VZMacMachineIdentifier *machineIdentifier; + @autoreleasepool { +@@ -298,12 +315,13 @@ void *newVZMacMachineIdentifierWithBytes(void *machineIdentifierBytes, int len) + } + return machineIdentifier; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + + nbyteslice getVZMacMachineIdentifierDataRepresentation(void *machineIdentifierPtr) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + VZMacMachineIdentifier *machineIdentifier = (VZMacMachineIdentifier *)machineIdentifierPtr; + NSData *data = [machineIdentifier dataRepresentation]; +@@ -313,12 +331,13 @@ nbyteslice getVZMacMachineIdentifierDataRepresentation(void *machineIdentifierPt + }; + return ret; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + + VZMacOSRestoreImageStruct convertVZMacOSRestoreImage2Struct(void *restoreImagePtr) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + VZMacOSRestoreImage *restoreImage = (VZMacOSRestoreImage *)restoreImagePtr; + VZMacOSRestoreImageStruct ret; +@@ -329,12 +348,13 @@ VZMacOSRestoreImageStruct convertVZMacOSRestoreImage2Struct(void *restoreImagePt + ret.mostFeaturefulSupportedConfiguration = (void *)CFBridgingRetain([restoreImage mostFeaturefulSupportedConfiguration]); + return ret; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + + void fetchLatestSupportedMacOSRestoreImageWithCompletionHandler(void *cgoHandler) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + [VZMacOSRestoreImage fetchLatestSupportedWithCompletionHandler:^(VZMacOSRestoreImage *restoreImage, NSError *error) { + VZMacOSRestoreImageStruct restoreImageStruct = convertVZMacOSRestoreImage2Struct(restoreImage); +@@ -342,12 +362,13 @@ void fetchLatestSupportedMacOSRestoreImageWithCompletionHandler(void *cgoHandler + }]; + return; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + + void loadMacOSRestoreImageFile(const char *ipswPath, void *cgoHandler) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + NSString *ipswPathNSString = [NSString stringWithUTF8String:ipswPath]; + NSURL *ipswURL = [NSURL fileURLWithPath:ipswPathNSString]; +@@ -358,12 +379,13 @@ void loadMacOSRestoreImageFile(const char *ipswPath, void *cgoHandler) + }]; + return; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + + VZMacOSConfigurationRequirementsStruct convertVZMacOSConfigurationRequirements2Struct(void *requirementsPtr) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + VZMacOSConfigurationRequirements *requirements = (VZMacOSConfigurationRequirements *)requirementsPtr; + VZMacOSConfigurationRequirementsStruct ret; +@@ -373,12 +395,13 @@ VZMacOSConfigurationRequirementsStruct convertVZMacOSConfigurationRequirements2S + ret.hardwareModel = (void *)CFBridgingRetain([requirements hardwareModel]); + return ret; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + + VZMacHardwareModelStruct convertVZMacHardwareModel2Struct(void *hardwareModelPtr) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + VZMacHardwareModel *hardwareModel = (VZMacHardwareModel *)hardwareModelPtr; + VZMacHardwareModelStruct ret; +@@ -391,7 +414,7 @@ VZMacHardwareModelStruct convertVZMacHardwareModel2Struct(void *hardwareModelPtr + ret.dataRepresentation = retByteSlice; + return ret; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -405,6 +428,7 @@ VZMacHardwareModelStruct convertVZMacHardwareModel2Struct(void *hardwareModelPtr + */ + void *newVZMacOSInstaller(void *virtualMachine, void *vmQueue, const char *restoreImageFilePath) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + __block VZMacOSInstaller *ret; + NSString *restoreImageFilePathNSString = [NSString stringWithUTF8String:restoreImageFilePath]; +@@ -414,7 +438,7 @@ void *newVZMacOSInstaller(void *virtualMachine, void *vmQueue, const char *resto + }); + return ret; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -425,6 +449,7 @@ void *newProgressObserverVZMacOSInstaller() + + void installByVZMacOSInstaller(void *installerPtr, void *vmQueue, void *progressObserverPtr, void *completionHandler, void *fractionCompletedHandler) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + VZMacOSInstaller *installer = (VZMacOSInstaller *)installerPtr; + dispatch_sync((dispatch_queue_t)vmQueue, ^{ +@@ -439,12 +464,13 @@ void installByVZMacOSInstaller(void *installerPtr, void *vmQueue, void *progress + }); + return; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + + void cancelInstallVZMacOSInstaller(void *installerPtr) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + VZMacOSInstaller *installer = (VZMacOSInstaller *)installerPtr; + if (installer.progress.cancellable) { +@@ -452,7 +478,7 @@ void cancelInstallVZMacOSInstaller(void *installerPtr) + } + return; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +diff --git a/src/cmd/linuxkit/vendor/github.com/Code-Hex/vz/v3/virtualization_debug.m b/src/cmd/linuxkit/vendor/github.com/Code-Hex/vz/v3/virtualization_debug.m +index 67fe356ae..af81a46b0 100644 +--- a/src/cmd/linuxkit/vendor/github.com/Code-Hex/vz/v3/virtualization_debug.m ++++ b/src/cmd/linuxkit/vendor/github.com/Code-Hex/vz/v3/virtualization_debug.m +@@ -12,10 +12,11 @@ + */ + void *newVZGDBDebugStubConfiguration(uint32_t port) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + return [[_VZGDBDebugStubConfiguration alloc] initWithPort:(NSInteger)port]; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } + +@@ -24,10 +25,11 @@ void *newVZGDBDebugStubConfiguration(uint32_t port) + */ + void setDebugStubVZVirtualMachineConfiguration(void *config, void *debugStub) + { ++#ifdef INCLUDE_TARGET_OSX_12 + if (@available(macOS 12, *)) { + [(VZVirtualMachineConfiguration *)config _setDebugStub:(_VZDebugStubConfiguration *)debugStub]; + return; + } +- ++#endif + RAISE_UNSUPPORTED_MACOS_EXCEPTION(); + } +\ No newline at end of file +diff --git a/src/cmd/linuxkit/vendor/github.com/Code-Hex/vz/v3/virtualization_helper.h b/src/cmd/linuxkit/vendor/github.com/Code-Hex/vz/v3/virtualization_helper.h +index 995b40882..9da0700b9 100644 +--- a/src/cmd/linuxkit/vendor/github.com/Code-Hex/vz/v3/virtualization_helper.h ++++ b/src/cmd/linuxkit/vendor/github.com/Code-Hex/vz/v3/virtualization_helper.h +@@ -18,6 +18,13 @@ NSDictionary *dumpProcessinfo(); + __builtin_unreachable(); \ + } while (0) + ++// for macOS 12 API ++#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 120000 ++#define INCLUDE_TARGET_OSX_12 1 ++#else ++#pragma message("macOS 12 API has been disabled") ++#endif ++ + // for macOS 12.3 API + #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 120300 + #define INCLUDE_TARGET_OSX_12_3 1 +diff --git a/src/cmd/linuxkit/vendor/github.com/Code-Hex/vz/v3/virtualization_view.h b/src/cmd/linuxkit/vendor/github.com/Code-Hex/vz/v3/virtualization_view.h +index ab00b9225..15d306f66 100644 +--- a/src/cmd/linuxkit/vendor/github.com/Code-Hex/vz/v3/virtualization_view.h ++++ b/src/cmd/linuxkit/vendor/github.com/Code-Hex/vz/v3/virtualization_view.h +@@ -23,9 +23,11 @@ + - (instancetype)init; + @end + ++#ifdef INCLUDE_TARGET_OSX_12 + API_AVAILABLE(macos(12.0)) + @interface AppDelegate : NSObject <NSApplicationDelegate, NSWindowDelegate, VZVirtualMachineDelegate> + - (instancetype)initWithVirtualMachine:(VZVirtualMachine *)virtualMachine + windowWidth:(CGFloat)windowWidth + windowHeight:(CGFloat)windowHeight; +-@end +\ No newline at end of file ++@end ++#endif +\ No newline at end of file +diff --git a/src/cmd/linuxkit/vendor/github.com/Code-Hex/vz/v3/virtualization_view.m b/src/cmd/linuxkit/vendor/github.com/Code-Hex/vz/v3/virtualization_view.m +index 9031c44f1..33b20d91b 100644 +--- a/src/cmd/linuxkit/vendor/github.com/Code-Hex/vz/v3/virtualization_view.m ++++ b/src/cmd/linuxkit/vendor/github.com/Code-Hex/vz/v3/virtualization_view.m +@@ -165,6 +165,7 @@ + + @end + ++#ifdef INCLUDE_TARGET_OSX_12 + @implementation AppDelegate { + VZVirtualMachine *_virtualMachine; + VZVirtualMachineView *_virtualMachineView; +@@ -372,3 +373,4 @@ + [aboutPanel makeKeyAndOrderFront:nil]; + } + @end ++#endif diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index e59f55f89d659..517e6f3976010 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -18715,7 +18715,8 @@ with pkgs; libwtk-sdl2 = callPackage ../development/libraries/libwtk-sdl2 { }; linuxkit = callPackage ../development/tools/misc/linuxkit { - inherit (darwin.apple_sdk_11_0.frameworks) Virtualization; + inherit (darwin.apple_sdk_11_0.frameworks) Cocoa Virtualization; + inherit (darwin) sigtool; }; listenbrainz-mpd = callPackage ../applications/audio/listenbrainz-mpd { |