From 2fe5f594f26db0617eec908262435814673b43b5 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Sun, 26 Jan 2025 22:45:56 +0000 Subject: [PATCH] llama-cpp-python: fix darwin build when Metal device has no name --- .../python-modules/llama-cpp-python/default.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkgs/development/python-modules/llama-cpp-python/default.nix b/pkgs/development/python-modules/llama-cpp-python/default.nix index 1dfd7f9d707a3c..3d7cb90d435512 100644 --- a/pkgs/development/python-modules/llama-cpp-python/default.nix +++ b/pkgs/development/python-modules/llama-cpp-python/default.nix @@ -4,6 +4,7 @@ gcc13Stdenv, buildPythonPackage, fetchFromGitHub, + fetchpatch2, # nativeBuildInputs cmake, @@ -51,6 +52,17 @@ buildPythonPackage rec { }; # src = /home/gaetan/llama-cpp-python; + patches = [ + # fix segfault when running tests due to missing default Metal device + # posted at: https://github.com/ggerganov/llama.cpp/pull/11441 + (fetchpatch2 { + url = "https://github.com/ggerganov/llama.cpp/pull/11441/commits/77860f97db85f1796f04809aaffcda622d0cfff2.patch?full_index=1"; + stripLen = 1; + extraPrefix = "vendor/llama.cpp/"; + hash = "sha256-bI/shVj1DB8DF2TrnEsdvQd23aHDlkGkvesdexH2dKc="; + }) + ]; + dontUseCmakeConfigure = true; SKBUILD_CMAKE_ARGS = lib.strings.concatStringsSep ";" ( lib.optionals cudaSupport [