|
7 | 7 | flake-utils.lib.eachDefaultSystem (system:
|
8 | 8 | let
|
9 | 9 | inherit (pkgs.stdenv) isAarch32 isAarch64 isDarwin;
|
10 |
| - osSpecific = with pkgs; [ openmpi ] ++ |
| 10 | + buildInputs = with pkgs; [ openmpi ]; |
| 11 | + osSpecific = with pkgs; buildInputs ++ |
11 | 12 | (
|
12 | 13 | if isAarch64 && isDarwin then
|
13 | 14 | with pkgs.darwin.apple_sdk_11_0.frameworks; [
|
|
29 | 30 | nativeBuildInputs = with pkgs; [ cmake pkgconfig ];
|
30 | 31 | llama-python =
|
31 | 32 | pkgs.python3.withPackages (ps: with ps; [ numpy sentencepiece ]);
|
| 33 | + postPatch = '' |
| 34 | + substituteInPlace ./ggml-metal.m \ |
| 35 | + --replace '[bundle pathForResource:@"ggml-metal" ofType:@"metal"];' "@\"$out/bin/ggml-metal.metal\";" |
| 36 | + substituteInPlace ./*.py --replace '/usr/bin/env python' '${llama-python}/bin/python' |
| 37 | + ''; |
| 38 | + postInstall = '' |
| 39 | + mv $out/bin/main $out/bin/llama |
| 40 | + mv $out/bin/server $out/bin/llama-server |
| 41 | + ''; |
| 42 | + cmakeFlags = [ "-DLLAMA_BUILD_SERVER=ON" "-DLLAMA_MPI=ON" "-DBUILD_SHARED_LIBS=ON" "-DCMAKE_SKIP_BUILD_RPATH=ON" ]; |
32 | 43 | in {
|
33 | 44 | packages.default = pkgs.stdenv.mkDerivation {
|
34 | 45 | name = "llama.cpp";
|
35 | 46 | src = ./.;
|
36 |
| - postPatch = '' |
37 |
| - substituteInPlace ./ggml-metal.m \ |
38 |
| - --replace '[bundle pathForResource:@"ggml-metal" ofType:@"metal"];' "@\"$out/bin/ggml-metal.metal\";" |
39 |
| - substituteInPlace ./*.py --replace '/usr/bin/env python' '${llama-python}/bin/python' |
40 |
| - ''; |
| 47 | + postPatch = postPatch; |
41 | 48 | nativeBuildInputs = nativeBuildInputs;
|
42 | 49 | buildInputs = osSpecific;
|
43 |
| - cmakeFlags = [ "-DLLAMA_BUILD_SERVER=ON" "-DLLAMA_MPI=ON" "-DBUILD_SHARED_LIBS=ON" "-DCMAKE_SKIP_BUILD_RPATH=ON" ] |
| 50 | + cmakeFlags = cmakeFlags |
44 | 51 | ++ (if isAarch64 && isDarwin then [
|
45 | 52 | "-DCMAKE_C_FLAGS=-D__ARM_FEATURE_DOTPROD=1"
|
46 | 53 | "-DLLAMA_METAL=ON"
|
47 | 54 | ] else [
|
48 | 55 | "-DLLAMA_BLAS=ON"
|
49 | 56 | "-DLLAMA_BLAS_VENDOR=OpenBLAS"
|
50 | 57 | ]);
|
51 |
| - postInstall = '' |
52 |
| - mv $out/bin/main $out/bin/llama |
53 |
| - mv $out/bin/server $out/bin/llama-server |
54 |
| - ''; |
| 58 | + postInstall = postInstall; |
| 59 | + meta.mainProgram = "llama"; |
| 60 | + }; |
| 61 | + packages.opencl = pkgs.stdenv.mkDerivation { |
| 62 | + name = "llama.cpp"; |
| 63 | + src = ./.; |
| 64 | + postPatch = postPatch; |
| 65 | + nativeBuildInputs = nativeBuildInputs; |
| 66 | + buildInputs = with pkgs; buildInputs ++ [ clblast ]; |
| 67 | + cmakeFlags = cmakeFlags ++ [ |
| 68 | + "-DLLAMA_CLBLAST=ON" |
| 69 | + ]; |
| 70 | + postInstall = postInstall; |
55 | 71 | meta.mainProgram = "llama";
|
56 | 72 | };
|
57 | 73 | apps.llama-server = {
|
|
0 commit comments