From b0e2c787ba58b6a1f1955b772040e312aeca4139 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sun, 29 Sep 2024 21:54:14 -0400 Subject: [PATCH 1/6] moltenvk: use xcbuildHook When using structured attrs, xcbuildHook supports schemes with spaces in their names. --- pkgs/os-specific/darwin/moltenvk/default.nix | 36 +++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/pkgs/os-specific/darwin/moltenvk/default.nix b/pkgs/os-specific/darwin/moltenvk/default.nix index 43ede5f950c5..486a6a9b1f2d 100644 --- a/pkgs/os-specific/darwin/moltenvk/default.nix +++ b/pkgs/os-specific/darwin/moltenvk/default.nix @@ -11,7 +11,7 @@ spirv-headers, spirv-tools, vulkan-headers, - xcbuild, + xcbuildHook, AppKit, Foundation, Metal, @@ -28,6 +28,8 @@ stdenv.mkDerivation (finalAttrs: { pname = "MoltenVK"; version = "1.2.9"; + strictDeps = true; + buildInputs = [ AppKit Foundation @@ -42,7 +44,7 @@ stdenv.mkDerivation (finalAttrs: { vulkan-headers ]; - nativeBuildInputs = [ xcbuild ]; + nativeBuildInputs = [ xcbuildHook ]; outputs = [ "out" @@ -117,25 +119,25 @@ stdenv.mkDerivation (finalAttrs: { "-lspirv-cross-reflect" ]; - buildPhase = '' - runHook preBuild - + preBuild = '' NIX_CFLAGS_COMPILE+=" \ -I$NIX_BUILD_TOP/$sourceRoot/build/include \ -I$NIX_BUILD_TOP/$sourceRoot/Common" - - xcodebuild build \ - SYMROOT=$PWD/Products OBJROOT=$PWD/Intermedates \ - -jobs $NIX_BUILD_CORES \ - -configuration Release \ - -project MoltenVKPackaging.xcodeproj \ - -scheme 'MoltenVK Package (macOS only)' \ - -destination generic/platform=macOS \ - -arch ${stdenv.hostPlatform.darwinArch} - - runHook postBuild ''; + xcbuildFlags = [ + "-configuration" + "Release" + "-project" + "MoltenVKPackaging.xcodeproj" + "-scheme" + "MoltenVK Package (macOS only)" + "-destination" + "generic/platform=macOS" + "-arch" + stdenv.hostPlatform.darwinArch + ]; + postBuild = if enableStatic then '' @@ -187,6 +189,8 @@ stdenv.mkDerivation (finalAttrs: { runHook postInstall ''; + __structuredAttrs = true; + passthru.updateScript = gitUpdater { rev-prefix = "v"; ignoredVersions = ".*-(beta|rc).*"; From 0cabb33e1d57069bfd3b16857d57fb24b09ce4a4 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sun, 29 Sep 2024 21:54:14 -0400 Subject: [PATCH 2/6] moltenvk: build with the 14.4 SDK MoltenVK can take advantage of newer Metal features when built with the latest Darwin SDK. --- pkgs/os-specific/darwin/moltenvk/default.nix | 14 ++++---------- pkgs/top-level/darwin-packages.nix | 9 +-------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/pkgs/os-specific/darwin/moltenvk/default.nix b/pkgs/os-specific/darwin/moltenvk/default.nix index 486a6a9b1f2d..808b1b281b69 100644 --- a/pkgs/os-specific/darwin/moltenvk/default.nix +++ b/pkgs/os-specific/darwin/moltenvk/default.nix @@ -3,19 +3,16 @@ stdenv, fetchFromGitHub, gitUpdater, + apple-sdk_14, + darwinMinVersionHook, cereal, libcxx, glslang, - simd, spirv-cross, spirv-headers, spirv-tools, vulkan-headers, xcbuildHook, - AppKit, - Foundation, - Metal, - QuartzCore, enableStatic ? stdenv.hostPlatform.isStatic, # MoltenVK supports using private APIs to implement some Vulkan functionality. # Applications that use private APIs can’t be distributed on the App Store, @@ -31,13 +28,10 @@ stdenv.mkDerivation (finalAttrs: { strictDeps = true; buildInputs = [ - AppKit - Foundation - Metal - QuartzCore + apple-sdk_14 cereal + (darwinMinVersionHook "10.15") glslang - simd spirv-cross spirv-headers spirv-tools diff --git a/pkgs/top-level/darwin-packages.nix b/pkgs/top-level/darwin-packages.nix index f0bdad863e90..eb25ad6a7b53 100644 --- a/pkgs/top-level/darwin-packages.nix +++ b/pkgs/top-level/darwin-packages.nix @@ -172,14 +172,7 @@ impure-cmds // appleSourcePackages // chooseLibs // { lsusb = callPackage ../os-specific/darwin/lsusb { }; - moltenvk = callPackage ../os-specific/darwin/moltenvk { - stdenv = pkgs.overrideSDK stdenv { - darwinMinVersion = "10.15"; - darwinSdkVersion = "12.3"; - }; - inherit (apple_sdk.frameworks) AppKit Foundation Metal QuartzCore; - inherit (apple_sdk.libs) simd; - }; + moltenvk = callPackage ../os-specific/darwin/moltenvk { }; openwith = callPackage ../os-specific/darwin/openwith { }; From 329fa34d6237e3da654707de0d55195ee25b7c8e Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sun, 6 Oct 2024 19:21:32 -0400 Subject: [PATCH 3/6] moltenvk: 1.2.9 -> 1.2.10 https://github.com/KhronosGroup/MoltenVK/releases/tag/v1.2.10 --- pkgs/os-specific/darwin/moltenvk/default.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/darwin/moltenvk/default.nix b/pkgs/os-specific/darwin/moltenvk/default.nix index 808b1b281b69..af16cc07adf3 100644 --- a/pkgs/os-specific/darwin/moltenvk/default.nix +++ b/pkgs/os-specific/darwin/moltenvk/default.nix @@ -23,7 +23,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "MoltenVK"; - version = "1.2.9"; + version = "1.2.10"; strictDeps = true; @@ -50,7 +50,7 @@ stdenv.mkDerivation (finalAttrs: { owner = "KhronosGroup"; repo = "MoltenVK"; rev = "v${finalAttrs.version}"; - hash = "sha256-9k7NMw2M6IqCUQNBekzDaS6VYAOKwPmuCfJkENQ7oiI="; + hash = "sha256-5hc+bnsyc8Am9My2kzsU7fv+1CePCHgxL82Mxz/zJRo="; }; postPatch = '' @@ -91,6 +91,10 @@ stdenv.mkDerivation (finalAttrs: { # Link glslang source because MoltenVK needs non-public headers to build. mkdir -p build/include ln -s "${glslang.src}" "build/include/glslang" + + # MoltenVK should be using SPIRV_CROSS_NAMESPACE instead of hardcoding the namespace. + substituteInPlace MoltenVK/MoltenVK/GPUObjects/MVKDescriptorSet.mm \ + --replace-fail MVK_spirv_cross SPIRV_CROSS_NAMESPACE ''; env.NIX_CFLAGS_COMPILE = toString ( From f9e5f1290d88e94c4004e1d49d418f4f7983c734 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sun, 6 Oct 2024 19:12:56 -0400 Subject: [PATCH 4/6] moltenvk: move to pkgs/by-name --- .../moltenvk/default.nix => by-name/mo/moltenvk/package.nix} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename pkgs/{os-specific/darwin/moltenvk/default.nix => by-name/mo/moltenvk/package.nix} (100%) diff --git a/pkgs/os-specific/darwin/moltenvk/default.nix b/pkgs/by-name/mo/moltenvk/package.nix similarity index 100% rename from pkgs/os-specific/darwin/moltenvk/default.nix rename to pkgs/by-name/mo/moltenvk/package.nix From d8906e4851d8a307726a2a10f12b2962dd545a24 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sun, 6 Oct 2024 19:27:33 -0400 Subject: [PATCH 5/6] treewide: switch to moltenvk from darwin.moltenvk --- pkgs/applications/emulators/wine/default.nix | 2 +- pkgs/by-name/fa/fastfetch/package.nix | 3 ++- pkgs/top-level/all-packages.nix | 8 ++------ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/pkgs/applications/emulators/wine/default.nix b/pkgs/applications/emulators/wine/default.nix index 8c8ebdea5878..8f579c35184f 100644 --- a/pkgs/applications/emulators/wine/default.nix +++ b/pkgs/applications/emulators/wine/default.nix @@ -39,7 +39,7 @@ waylandSupport ? false, x11Support ? false, embedInstallers ? false, # The Mono and Gecko MSI installers - moltenvk ? darwin.moltenvk # Allow users to override MoltenVK easily + moltenvk # Allow users to override MoltenVK easily }: let wine-build = build: release: diff --git a/pkgs/by-name/fa/fastfetch/package.nix b/pkgs/by-name/fa/fastfetch/package.nix index 5d1f54b8261e..bed0d66596a7 100644 --- a/pkgs/by-name/fa/fastfetch/package.nix +++ b/pkgs/by-name/fa/fastfetch/package.nix @@ -19,6 +19,7 @@ libsepol, libxcb, makeBinaryWrapper, + moltenvk, nix-update-script, ocl-icd, opencl-headers, @@ -119,7 +120,7 @@ stdenv'.mkDerivation (finalAttrs: { MediaRemote OpenCL SystemConfiguration - darwin.moltenvk + moltenvk ] ); diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index b6744b93ea24..09cdaa1ece2f 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2672,7 +2672,6 @@ with pkgs; dolphin-emu = qt6Packages.callPackage ../applications/emulators/dolphin-emu { stdenv = if stdenv.hostPlatform.isDarwin then overrideSDK stdenv "11.0" else stdenv; inherit (darwin.apple_sdk_11_0.frameworks) CoreBluetooth ForceFeedback IOBluetooth IOKit OpenGL VideoToolbox; - inherit (darwin) moltenvk; }; dolphin-emu-primehack = qt5.callPackage ../applications/emulators/dolphin-emu/primehack.nix { @@ -23479,9 +23478,8 @@ with pkgs; vulkan-extension-layer = callPackage ../tools/graphics/vulkan-extension-layer { }; vulkan-headers = callPackage ../development/libraries/vulkan-headers { }; - vulkan-loader = callPackage ../development/libraries/vulkan-loader { inherit (darwin) moltenvk; }; + vulkan-loader = callPackage ../development/libraries/vulkan-loader { }; vulkan-tools = callPackage ../tools/graphics/vulkan-tools { - inherit (darwin) moltenvk; inherit (darwin.apple_sdk.frameworks) AppKit Cocoa; }; vulkan-tools-lunarg = callPackage ../tools/graphics/vulkan-tools-lunarg { }; @@ -35148,9 +35146,7 @@ with pkgs; quakespasm = callPackage ../games/quakespasm { inherit (darwin.apple_sdk.frameworks) Cocoa CoreAudio CoreFoundation IOKit OpenGL; }; - vkquake = callPackage ../games/quakespasm/vulkan.nix { - inherit (darwin) moltenvk; - }; + vkquake = callPackage ../games/quakespasm/vulkan.nix { }; ioquake3 = callPackage ../games/quake3/ioquake { }; quake3e = callPackage ../games/quake3/quake3e { }; From 1f0a0ab94d769e66967e098dbb0e589f2ff1d86a Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sun, 6 Oct 2024 17:36:30 -0400 Subject: [PATCH 6/6] darwin.moltenvk: add to darwin-aliases.nix --- pkgs/top-level/darwin-aliases.nix | 4 ++++ pkgs/top-level/darwin-packages.nix | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/top-level/darwin-aliases.nix b/pkgs/top-level/darwin-aliases.nix index e64bb256843d..7773977f5b30 100644 --- a/pkgs/top-level/darwin-aliases.nix +++ b/pkgs/top-level/darwin-aliases.nix @@ -66,6 +66,10 @@ mapAliases ({ libauto = throw "'darwin.libauto' has been removed, as it was broken and unmaintained"; # added 2024-05-10 libiconv = pkgs.libiconv; # 2024-03-27 + ### M ### + + moltenvk = pkgs.moltenvk; # 2024-10-06 + ### O ### opencflite = pkgs.opencflite; # added 2024-05-02 diff --git a/pkgs/top-level/darwin-packages.nix b/pkgs/top-level/darwin-packages.nix index eb25ad6a7b53..546d99ae861d 100644 --- a/pkgs/top-level/darwin-packages.nix +++ b/pkgs/top-level/darwin-packages.nix @@ -172,8 +172,6 @@ impure-cmds // appleSourcePackages // chooseLibs // { lsusb = callPackage ../os-specific/darwin/lsusb { }; - moltenvk = callPackage ../os-specific/darwin/moltenvk { }; - openwith = callPackage ../os-specific/darwin/openwith { }; stubs = pkgs.callPackages ../os-specific/darwin/stubs { };