diff --git a/pkgs/tools/graphics/waifu2x-converter-cpp/default.nix b/pkgs/tools/graphics/waifu2x-converter-cpp/default.nix index 338d1511dc5c..8d8ae6e71e42 100644 --- a/pkgs/tools/graphics/waifu2x-converter-cpp/default.nix +++ b/pkgs/tools/graphics/waifu2x-converter-cpp/default.nix @@ -1,4 +1,4 @@ -{ cmake, fetchFromGitHub, makeWrapper, opencv3, lib, stdenv, ocl-icd, opencl-headers +{ cmake, fetchFromGitHub, makeWrapper, opencv3, lib, stdenv, ocl-icd, opencl-headers, OpenCL , cudaSupport ? false, cudatoolkit ? null }: @@ -13,13 +13,20 @@ stdenv.mkDerivation rec { sha256 = "0rv8bnyxz89za6gwk9gmdbaf3j7c1j52mip7h81rir288j35m84x"; }; + patches = [ + # Remove the hard-coded compiler on Darwin and use the one in stdenv. + ./waifu2x_darwin_build.diff + ]; + buildInputs = [ - ocl-icd opencv3 opencl-headers - ] ++ lib.optional cudaSupport cudatoolkit; + opencv3 + ] ++ lib.optional cudaSupport cudatoolkit + ++ lib.optional stdenv.isDarwin OpenCL + ++ lib.optionals stdenv.isLinux [ ocl-icd opencl-headers ]; nativeBuildInputs = [ cmake makeWrapper ]; - preFixup = '' + preFixup = lib.optionalString stdenv.isLinux '' wrapProgram $out/bin/waifu2x-converter-cpp --prefix LD_LIBRARY_PATH : "${ocl-icd}/lib" ''; @@ -28,6 +35,6 @@ stdenv.mkDerivation rec { homepage = "https://github.com/DeadSix27/waifu2x-converter-cpp"; license = lib.licenses.mit; maintainers = [ lib.maintainers.xzfc ]; - platforms = lib.platforms.linux; + platforms = lib.platforms.linux ++ lib.platforms.darwin; }; } diff --git a/pkgs/tools/graphics/waifu2x-converter-cpp/waifu2x_darwin_build.diff b/pkgs/tools/graphics/waifu2x-converter-cpp/waifu2x_darwin_build.diff new file mode 100644 index 000000000000..2a6a83c5ee80 --- /dev/null +++ b/pkgs/tools/graphics/waifu2x-converter-cpp/waifu2x_darwin_build.diff @@ -0,0 +1,15 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 8b728b5..dedf8b6 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -71,10 +71,6 @@ message(STATUS "System is: ${CMAKE_SYSTEM_NAME} (${LOCAL_SYS_TYPE})") + + ### Get binary paths for APPLE users + if(APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$") +- set(CMAKE_C_COMPILER "/usr/local/opt/llvm/bin/clang") +- set(CMAKE_CXX_COMPILER "/usr/local/opt/llvm/bin/clang++") +- set(CMAKE_EXE_LINKER_FLAGS "-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib") +- set(CMAKE_SHARED_LINKER_FLAGS "-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) + set(FILE_SYSTEM_LIB "c++fs") + endif() diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 0f5dc92affed..c3feeee643cd 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -9923,7 +9923,9 @@ with pkgs; openssl = openssl_1_0_2; }; - waifu2x-converter-cpp = callPackage ../tools/graphics/waifu2x-converter-cpp { }; + waifu2x-converter-cpp = callPackage ../tools/graphics/waifu2x-converter-cpp { + inherit (darwin.apple_sdk.frameworks) OpenCL; + }; wakatime = pythonPackages.callPackage ../tools/misc/wakatime { };