Skip to content

Commit fdd1860

Browse files
authored
flake : fix ggml-metal.metal path and run nixfmt (#1974)
1 parent c943d82 commit fdd1860

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

flake.nix

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,33 @@
99
inherit (pkgs.stdenv) isAarch64 isDarwin;
1010
inherit (pkgs.lib) optionals;
1111
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 {
2531
packages.default = pkgs.stdenv.mkDerivation {
2632
name = "llama.cpp";
2733
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+
"";
3339
nativeBuildInputs = with pkgs; [ cmake ];
3440
buildInputs = osSpecific;
3541
cmakeFlags = [ "-DLLAMA_BUILD_SERVER=ON" ] ++ (optionals isM1 [
@@ -62,11 +68,7 @@
6268
};
6369
apps.default = self.apps.${system}.llama;
6470
devShells.default = pkgs.mkShell {
65-
packages = with pkgs; [
66-
cmake
67-
llama-python
68-
] ++ osSpecific;
71+
packages = with pkgs; [ cmake llama-python ] ++ osSpecific;
6972
};
70-
}
71-
);
73+
});
7274
}

0 commit comments

Comments
 (0)