|
24 | 24 | useMetalKit ? stdenv.isAarch64 && stdenv.isDarwin && !useOpenCL,
|
25 | 25 | useOpenCL ? false,
|
26 | 26 | useRocm ? config.rocmSupport,
|
| 27 | + llamaVersion ? "0.0.0", # Arbitrary version, substituted by the flake |
27 | 28 | }@inputs:
|
28 | 29 |
|
29 | 30 | let
|
30 | 31 | inherit (lib)
|
31 | 32 | cmakeBool
|
32 | 33 | cmakeFeature
|
33 | 34 | optionals
|
| 35 | + strings |
34 | 36 | versionOlder
|
35 | 37 | ;
|
36 | 38 |
|
|
39 | 41 | stdenv = throw "Use effectiveStdenv instead";
|
40 | 42 | effectiveStdenv = if useCuda then cudaPackages.backendStdenv else inputs.stdenv;
|
41 | 43 |
|
42 |
| - # Give a little description difference between the flavors. |
| 44 | + suffices = |
| 45 | + lib.optionals useOpenCL [ "OpenCL" ] |
| 46 | + ++ lib.optionals useCuda [ "CUDA" ] |
| 47 | + ++ lib.optionals useRocm [ "ROCm" ] |
| 48 | + ++ lib.optionals useMetalKit [ "MetalKit" ] |
| 49 | + ++ lib.optionals useBlas [ "BLAS" ]; |
| 50 | + |
| 51 | + pnameSuffix = |
| 52 | + strings.optionalString (suffices != [ ]) |
| 53 | + "-${strings.concatMapStringsSep "-" strings.toLower suffices}"; |
43 | 54 | descriptionSuffix =
|
44 |
| - if useOpenCL then |
45 |
| - " (OpenCL accelerated)" |
46 |
| - else if useCuda then |
47 |
| - " (CUDA accelerated)" |
48 |
| - else if useRocm then |
49 |
| - " (ROCm accelerated)" |
50 |
| - else if useMetalKit then |
51 |
| - " (MetalKit accelerated)" |
52 |
| - else |
53 |
| - ""; |
| 55 | + strings.optionalString (suffices != [ ]) |
| 56 | + ", accelerated with ${strings.concatStringsSep ", " suffices}"; |
54 | 57 |
|
55 | 58 | # TODO: package the Python in this repository in a Nix-like way.
|
56 | 59 | # It'd be nice to migrate to buildPythonPackage, as well as ensure this repo
|
|
99 | 102 |
|
100 | 103 | effectiveStdenv.mkDerivation (
|
101 | 104 | finalAttrs: {
|
102 |
| - name = "llama.cpp"; |
| 105 | + pname = "llama-cpp${pnameSuffix}"; |
| 106 | + version = llamaVersion; |
| 107 | + |
103 | 108 | src = ../../.;
|
104 | 109 |
|
105 | 110 | postPatch = ''
|
@@ -171,14 +176,14 @@ effectiveStdenv.mkDerivation (
|
171 | 176 | ;
|
172 | 177 |
|
173 | 178 | shell = mkShell {
|
174 |
| - name = "default${descriptionSuffix}"; |
| 179 | + name = "shell-${finalAttrs.finalPackage.name}"; |
175 | 180 | description = "contains numpy and sentencepiece";
|
176 | 181 | buildInputs = [ llama-python ];
|
177 | 182 | inputsFrom = [ finalAttrs.finalPackage ];
|
178 | 183 | };
|
179 | 184 |
|
180 | 185 | shell-extra = mkShell {
|
181 |
| - name = "extra${descriptionSuffix}"; |
| 186 | + name = "shell-extra-${finalAttrs.finalPackage.name}"; |
182 | 187 | description = "contains numpy, sentencepiece, torchWithoutCuda, and transformers";
|
183 | 188 | buildInputs = [ llama-python-extra ];
|
184 | 189 | inputsFrom = [ finalAttrs.finalPackage ];
|
|
0 commit comments