about summary refs log tree commit diff
path: root/pkgs/by-name/ko
diff options
context:
space:
mode:
authorDontEatOreo2024-07-11 23:45:34 +0300
committerDontEatOreo2024-07-11 23:45:34 +0300
commit4a10d41b5d72bb900e94f57d3ec27529aa38bc54 (patch)
treea99a27a182ee969de93d163e031b5f20f0d8b80a /pkgs/by-name/ko
parent734c0294c3ac1beea9326bf14cdf9e5eecbe40de (diff)
koboldcpp: add postPatch for Darwin
- Add `postPatch` deleting an unused argument for Darwin
Diffstat (limited to 'pkgs/by-name/ko')
-rw-r--r--pkgs/by-name/ko/koboldcpp/package.nix17
1 files changed, 14 insertions, 3 deletions
diff --git a/pkgs/by-name/ko/koboldcpp/package.nix b/pkgs/by-name/ko/koboldcpp/package.nix
index 1975feafe919..decf34d27694 100644
--- a/pkgs/by-name/ko/koboldcpp/package.nix
+++ b/pkgs/by-name/ko/koboldcpp/package.nix
@@ -36,9 +36,11 @@
   # You can find list of x86_64 options here: https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
   # For ARM here: https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html
   # If you set "march" to "native", specify "mtune" as well; otherwise, it will be set to "generic". (credit to: https://lemire.me/blog/2018/07/25/it-is-more-complicated-than-i-thought-mtune-march-in-gcc/)
-  # For example, if you have an AMD Ryzen CPU, you will set "march" to "x86-64" and "mtune" to "znver2"
   march ? "",
+  # Apple Silicon Chips (M1, M2, M3 and so on DO NOT use mtune)
+  # For example, if you have an AMD Ryzen CPU, you will set "mtune" to "znver2"
   mtune ? "",
+  mcpu ? "",
 }:
 
 let
@@ -114,8 +116,11 @@ effectiveStdenv.mkDerivation (finalAttrs: {
 
   env.NIX_LDFLAGS = lib.concatStringsSep " " (finalAttrs.darwinLdFlags ++ finalAttrs.metalLdFlags);
 
-  env.NIX_CFLAGS_COMPILE =
-    lib.optionalString (march != "") "-march=${march}" + lib.optionalString (mtune != "") "-mtune=${mtune}";
+  env.NIX_CFLAGS_COMPILE = lib.concatStringsSep " " [
+    (lib.optionalString (march != "") "-march=${march}")
+    (lib.optionalString (mtune != "") "-mtune=${mtune}")
+    (lib.optionalString (mcpu != "") "-mcpu=${mcpu}")
+  ];
 
   makeFlags = [
     (makeBool "LLAMA_OPENBLAS" openblasSupport)
@@ -143,6 +148,12 @@ effectiveStdenv.mkDerivation (finalAttrs: {
     runHook postInstall
   '';
 
+  # Remove an unused argument, mainly intended for Darwin to reduce warnings
+  postPatch = ''
+    substituteInPlace Makefile \
+      --replace-warn " -s " " "
+  '';
+
   postFixup = ''
     wrapPythonProgramsIn "$out/bin" "$pythonPath"
     makeWrapper "$out/bin/koboldcpp.unwrapped" "$out/bin/koboldcpp" \