|
9 | 9 | inherit (pkgs.stdenv) isAarch64 isDarwin;
|
10 | 10 | inherit (pkgs.lib) optionals;
|
11 | 11 | isM1 = isAarch64 && isDarwin;
|
12 |
| - osSpecific = |
13 |
| - if isM1 then with pkgs.darwin.apple_sdk_11_0.frameworks; [ Accelerate MetalKit MetalPerformanceShaders MetalPerformanceShadersGraph ] |
14 |
| - else if isDarwin then with pkgs.darwin.apple_sdk.frameworks; [ Accelerate CoreGraphics CoreVideo ] |
15 |
| - else [ ]; |
16 |
| - pkgs = import nixpkgs { |
17 |
| - inherit system; |
18 |
| - }; |
19 |
| - llama-python = pkgs.python310.withPackages (ps: with ps; [ |
20 |
| - numpy |
21 |
| - sentencepiece |
22 |
| - ]); |
23 |
| - in |
24 |
| - { |
| 12 | + osSpecific = if isM1 then |
| 13 | + with pkgs.darwin.apple_sdk_11_0.frameworks; [ |
| 14 | + Accelerate |
| 15 | + MetalKit |
| 16 | + MetalPerformanceShaders |
| 17 | + MetalPerformanceShadersGraph |
| 18 | + ] |
| 19 | + else if isDarwin then |
| 20 | + with pkgs.darwin.apple_sdk.frameworks; [ |
| 21 | + Accelerate |
| 22 | + CoreGraphics |
| 23 | + CoreVideo |
| 24 | + ] |
| 25 | + else |
| 26 | + [ ]; |
| 27 | + pkgs = import nixpkgs { inherit system; }; |
| 28 | + llama-python = |
| 29 | + pkgs.python310.withPackages (ps: with ps; [ numpy sentencepiece ]); |
| 30 | + in { |
25 | 31 | packages.default = pkgs.stdenv.mkDerivation {
|
26 | 32 | name = "llama.cpp";
|
27 | 33 | src = ./.;
|
28 |
| - postPatch = |
29 |
| - if isM1 then '' |
30 |
| - substituteInPlace ./ggml-metal.m \ |
31 |
| - --replace '[bundle pathForResource:@"ggml-metal" ofType:@"metal"];' "@\"$out/ggml-metal.metal\";" |
32 |
| - '' else ""; |
| 34 | + postPatch = if isM1 then '' |
| 35 | + substituteInPlace ./ggml-metal.m \ |
| 36 | + --replace '[bundle pathForResource:@"ggml-metal" ofType:@"metal"];' "@\"$out/bin/ggml-metal.metal\";" |
| 37 | + '' else |
| 38 | + ""; |
33 | 39 | nativeBuildInputs = with pkgs; [ cmake ];
|
34 | 40 | buildInputs = osSpecific;
|
35 | 41 | cmakeFlags = [ "-DLLAMA_BUILD_SERVER=ON" ] ++ (optionals isM1 [
|
|
62 | 68 | };
|
63 | 69 | apps.default = self.apps.${system}.llama;
|
64 | 70 | devShells.default = pkgs.mkShell {
|
65 |
| - packages = with pkgs; [ |
66 |
| - cmake |
67 |
| - llama-python |
68 |
| - ] ++ osSpecific; |
| 71 | + packages = with pkgs; [ cmake llama-python ] ++ osSpecific; |
69 | 72 | };
|
70 |
| - } |
71 |
| - ); |
| 73 | + }); |
72 | 74 | }
|
0 commit comments