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>2022-04-19 19:47:37 -0400
committerRandy Eckenrode <randy@largeandhighquality.com>2022-05-23 01:03:34 -0400
commit5603dff93c56f0dcc7f3ad2367ac60c0b8f721f8 (patch)
tree58defc442c639cdf549b2b650cf99a7f845bd50c /pkgs/tools/graphics/vulkan-tools/default.nix
parent71ceba177ffd922c82191560c7878ac587f06253 (diff)
downloadnixpkgs-5603dff93c56f0dcc7f3ad2367ac60c0b8f721f8.tar
nixpkgs-5603dff93c56f0dcc7f3ad2367ac60c0b8f721f8.tar.gz
nixpkgs-5603dff93c56f0dcc7f3ad2367ac60c0b8f721f8.tar.bz2
nixpkgs-5603dff93c56f0dcc7f3ad2367ac60c0b8f721f8.tar.lz
nixpkgs-5603dff93c56f0dcc7f3ad2367ac60c0b8f721f8.tar.xz
nixpkgs-5603dff93c56f0dcc7f3ad2367ac60c0b8f721f8.tar.zst
nixpkgs-5603dff93c56f0dcc7f3ad2367ac60c0b8f721f8.zip
vulkan-tools: enable support for Darwin
Diffstat (limited to 'pkgs/tools/graphics/vulkan-tools/default.nix')
-rw-r--r--pkgs/tools/graphics/vulkan-tools/default.nix37
1 files changed, 34 insertions, 3 deletions
diff --git a/pkgs/tools/graphics/vulkan-tools/default.nix b/pkgs/tools/graphics/vulkan-tools/default.nix
index 9cc83e19769..6ff9bd833ea 100644
--- a/pkgs/tools/graphics/vulkan-tools/default.nix
+++ b/pkgs/tools/graphics/vulkan-tools/default.nix
@@ -14,6 +14,9 @@
 , vulkan-loader
 , wayland
 , wayland-protocols
+, moltenvk
+, AppKit
+, Cocoa
 }:
 
 stdenv.mkDerivation rec {
@@ -38,20 +41,45 @@ stdenv.mkDerivation rec {
 
   buildInputs = [
     glslang
+    vulkan-headers
+    vulkan-loader
+  ] ++ lib.optionals (!stdenv.isDarwin) [
     libffi
     libX11
     libXau
     libxcb
     libXdmcp
     libXrandr
-    vulkan-headers
-    vulkan-loader
     wayland
     wayland-protocols
+  ] ++ lib.optionals stdenv.isDarwin [
+    moltenvk
+    moltenvk.dev
+    AppKit
+    Cocoa
   ];
 
   libraryPath = lib.strings.makeLibraryPath [ vulkan-loader ];
 
+  patches = [
+    # 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"))
+  '';
+
   dontPatchELF = true;
 
   cmakeFlags = [
@@ -62,6 +90,9 @@ stdenv.mkDerivation rec {
     "-DPKG_CONFIG_EXECUTABLE=${pkg-config}/bin/pkg-config"
     # Hide dev warnings that are useless for packaging
     "-Wno-dev"
+  ] ++ lib.optionals stdenv.isDarwin [
+    "-DMOLTENVK_REPO_ROOT=${moltenvk}/share/vulkan/icd.d"
+    "-DIBTOOL=/usr/bin/ibtool"
   ];
 
   meta = with lib; {
@@ -72,7 +103,7 @@ stdenv.mkDerivation rec {
       use of the Vulkan API.
     '';
     homepage    = "https://github.com/KhronosGroup/Vulkan-Tools";
-    platforms   = platforms.linux;
+    platforms   = platforms.unix;
     license     = licenses.asl20;
     maintainers = [ maintainers.ralith ];
   };