about summary refs log tree commit diff
path: root/pkgs/development/libraries/openimagedenoise/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/libraries/openimagedenoise/default.nix')
-rw-r--r--pkgs/development/libraries/openimagedenoise/default.nix28
1 files changed, 24 insertions, 4 deletions
diff --git a/pkgs/development/libraries/openimagedenoise/default.nix b/pkgs/development/libraries/openimagedenoise/default.nix
index e2d9b66004ed6..ad68505ad609f 100644
--- a/pkgs/development/libraries/openimagedenoise/default.nix
+++ b/pkgs/development/libraries/openimagedenoise/default.nix
@@ -3,34 +3,54 @@
   config,
   cudaPackages,
   cudaSupport ? config.cudaSupport,
+  darwin,
   fetchzip,
   ispc,
   lib,
   python3,
   stdenv,
   tbb,
+  xcodebuild,
 }:
 
-stdenv.mkDerivation rec {
+let
+  stdenv' = if stdenv.isDarwin then darwin.apple_sdk_11_0.stdenv else stdenv;
+in
+stdenv'.mkDerivation (finalAttrs: {
   pname = "openimagedenoise";
   version = "2.2.2";
 
   # The release tarballs include pretrained weights, which would otherwise need to be fetched with git-lfs
   src = fetchzip {
-    url = "https://github.com/OpenImageDenoise/oidn/releases/download/v${version}/oidn-${version}.src.tar.gz";
+    url = "https://github.com/OpenImageDenoise/oidn/releases/download/v${finalAttrs.version}/oidn-${finalAttrs.version}.src.tar.gz";
     sha256 = "sha256-ZIrs4oEb+PzdMh2x2BUFXKyu/HBlFb3CJX24ciEHy3Q=";
   };
 
   patches = lib.optional cudaSupport ./cuda.patch;
 
+  postPatch =
+    ''
+      substituteInPlace devices/metal/CMakeLists.txt \
+        --replace-fail "AppleClang" "Clang"
+    '';
+
   nativeBuildInputs = [
     cmake
     python3
     ispc
-  ] ++ lib.optional cudaSupport cudaPackages.cuda_nvcc;
+  ] ++ lib.optional cudaSupport cudaPackages.cuda_nvcc
+    ++ lib.optionals stdenv.isDarwin [ xcodebuild ];
 
   buildInputs =
     [ tbb ]
+    ++ lib.optionals stdenv.isDarwin (
+      with darwin.apple_sdk_11_0.frameworks;
+      [
+        Accelerate
+        MetalKit
+        MetalPerformanceShadersGraph
+      ]
+    )
     ++ lib.optionals cudaSupport [
       cudaPackages.cuda_cudart
       cudaPackages.cuda_cccl
@@ -50,4 +70,4 @@ stdenv.mkDerivation rec {
     platforms = platforms.unix;
     changelog = "https://github.com/OpenImageDenoise/oidn/blob/v${version}/CHANGELOG.md";
   };
-}
+})