summary refs log tree commit diff
path: root/pkgs/tools/graphics/vulkan-tools/default.nix
diff options
context:
space:
mode:
authorRandy Eckenrode <randy@largeandhighquality.com>2023-10-25 15:41:00 -0400
committerRandy Eckenrode <randy@largeandhighquality.com>2023-10-25 16:10:37 -0400
commit3a319a512eb398c143477e404f212ca5b847f4a9 (patch)
tree07e0e3f8b82c905770b23dcffa478f8cc232943e /pkgs/tools/graphics/vulkan-tools/default.nix
parentbe44f2d9dbff9cd9daa645481526a94ae872a9b1 (diff)
downloadnixpkgs-3a319a512eb398c143477e404f212ca5b847f4a9.tar
nixpkgs-3a319a512eb398c143477e404f212ca5b847f4a9.tar.gz
nixpkgs-3a319a512eb398c143477e404f212ca5b847f4a9.tar.bz2
nixpkgs-3a319a512eb398c143477e404f212ca5b847f4a9.tar.lz
nixpkgs-3a319a512eb398c143477e404f212ca5b847f4a9.tar.xz
nixpkgs-3a319a512eb398c143477e404f212ca5b847f4a9.tar.zst
nixpkgs-3a319a512eb398c143477e404f212ca5b847f4a9.zip
vulkan-tools: fix build on Darwin
* Disable the cube demo, which requires `ibtool`;
* Modify it to find the MoltenVK ICD in the correct location;
* Modify CMakeLists.txt to install `vulkaninfo` to $out/bin; and
* Reenable Hydra platforms for Darwin.
Diffstat (limited to 'pkgs/tools/graphics/vulkan-tools/default.nix')
-rw-r--r--pkgs/tools/graphics/vulkan-tools/default.nix34
1 files changed, 13 insertions, 21 deletions
diff --git a/pkgs/tools/graphics/vulkan-tools/default.nix b/pkgs/tools/graphics/vulkan-tools/default.nix
index 1f5ec9231a8..e148f51d868 100644
--- a/pkgs/tools/graphics/vulkan-tools/default.nix
+++ b/pkgs/tools/graphics/vulkan-tools/default.nix
@@ -57,27 +57,19 @@ stdenv.mkDerivation rec {
     Cocoa
   ];
 
-  libraryPath = lib.strings.makeLibraryPath [ vulkan-loader ];
-
-  patches = lib.optionals stdenv.isDarwin [
-    # Vulkan-Tools expects to find the MoltenVK ICD and `libMoltenVK.dylib` in its source repo.
-    # Patch it to use the already-built binaries and ICD in nixpkgs.
-    ./use-nix-moltenvk.patch
-  ];
-
-  # vkcube.app and vkcubepp.app require `ibtool`, but the version in `xib2nib` is not capable of
-  # building these apps. Build them using `ibtool` from Xcode, but don’t allow any other binaries
-  # into the sandbox. Note that the CLT are not supported because `ibtool` requires Xcode.
-  sandboxProfile = lib.optionalString stdenv.isDarwin ''
-    (allow process-exec
-      (literal "/usr/bin/ibtool")
-      (regex "/Xcode.app/Contents/Developer/usr/bin/ibtool")
-      (regex "/Xcode.app/Contents/Developer/usr/bin/xcodebuild"))
-    (allow file-read*)
-    (deny file-read* (subpath "/usr/local") (with no-log))
-    (allow file-write* (subpath "/private/var/folders"))
+  postPatch = lib.optionalString stdenv.isDarwin ''
+    # Modify mac_common.cmake to find the ICD where nixpkgs puts it.
+    substituteInPlace mac_common.cmake \
+      --replace MoltenVK/icd/MoltenVK_icd.json MoltenVK_icd.json
+    # Remove the unconditional check for `ibtool` since the cube demo that needs it won’t be built.
+    sed -e '/#.*Interface Builder/,/^endif()/d' -i mac_common.cmake
+    # Install `vulkaninfo` to $out/bin even on Darwin.
+    substituteInPlace vulkaninfo/CMakeLists.txt \
+      --replace 'install(TARGETS vulkaninfo RUNTIME DESTINATION "vulkaninfo")' 'install(TARGETS vulkaninfo)'
   '';
 
+  libraryPath = lib.strings.makeLibraryPath [ vulkan-loader ];
+
   dontPatchELF = true;
 
   cmakeFlags = [
@@ -91,7 +83,8 @@ stdenv.mkDerivation rec {
     "-Wno-dev"
   ] ++ lib.optionals stdenv.isDarwin [
     "-DMOLTENVK_REPO_ROOT=${moltenvk}/share/vulkan/icd.d"
-    "-DIBTOOL=/usr/bin/ibtool"
+    # Don’t build the cube demo because it requires `ibtool`, which is not available in nixpkgs.
+    "-DBUILD_CUBE=OFF"
   ];
 
   meta = with lib; {
@@ -102,7 +95,6 @@ stdenv.mkDerivation rec {
       use of the Vulkan API.
     '';
     homepage    = "https://github.com/KhronosGroup/Vulkan-Tools";
-    hydraPlatforms = [ "x86_64-linux" "i686-linux" ];
     platforms   = platforms.unix;
     license     = licenses.asl20;
     maintainers = [ maintainers.ralith ];