about summary refs log tree commit diff
path: root/pkgs/by-name/ll/llama-cpp/package.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/by-name/ll/llama-cpp/package.nix')
-rw-r--r--pkgs/by-name/ll/llama-cpp/package.nix17
1 files changed, 15 insertions, 2 deletions
diff --git a/pkgs/by-name/ll/llama-cpp/package.nix b/pkgs/by-name/ll/llama-cpp/package.nix
index 379673740aeef..637fbc3435cc3 100644
--- a/pkgs/by-name/ll/llama-cpp/package.nix
+++ b/pkgs/by-name/ll/llama-cpp/package.nix
@@ -19,6 +19,8 @@
 , openblas
 , pkg-config
 , metalSupport ? stdenv.isDarwin && stdenv.isAarch64 && !openclSupport
+, patchelf
+, static ? true # if false will build the shared objects as well
 }:
 
 let
@@ -29,13 +31,13 @@ let
 in
 effectiveStdenv.mkDerivation (finalAttrs: {
   pname = "llama-cpp";
-  version = "1848";
+  version = "1892";
 
   src = fetchFromGitHub {
     owner = "ggerganov";
     repo = "llama.cpp";
     rev = "refs/tags/b${finalAttrs.version}";
-    hash = "sha256-KuomiKU9c06Ux/ZcqctFdPQykGtjDzArN+tElPJVQ60=";
+    hash = "sha256-FNyl8bR0rg6cixcqidqzk9rG62+CI/0BNvzHuUkBq1E=";
   };
 
   postPatch = ''
@@ -105,15 +107,26 @@ effectiveStdenv.mkDerivation (finalAttrs: {
   ++ lib.optionals blasSupport [
     "-DLLAMA_BLAS=ON"
     "-DLLAMA_BLAS_VENDOR=OpenBLAS"
+  ]
+  ++ lib.optionals (!static) [
+    (lib.cmakeBool "BUILD_SHARED_LIBS" true)
   ];
 
   installPhase = ''
     runHook preInstall
 
     mkdir -p $out/bin
+    ${lib.optionalString (!static) ''
+      mkdir $out/lib
+      cp libggml_shared.so $out/lib
+      cp libllama.so $out/lib
+    ''}
 
     for f in bin/*; do
       test -x "$f" || continue
+      ${lib.optionalString (!static) ''
+        ${patchelf}/bin/patchelf "$f" --set-rpath "$out/lib"
+      ''}
       cp "$f" $out/bin/llama-cpp-"$(basename "$f")"
     done