|
17 | 17 | in
|
18 | 18 |
|
19 | 19 | {
|
20 |
| - # These define the various ways to build the llama.cpp project. |
21 |
| - # Integrate them into your flake.nix configuration by adding this overlay to nixpkgs.overlays. |
22 |
| - overlays.default = import ./.devops/nix/overlay.nix; |
| 20 | + # An overlay can be used to have a more granular control over llama-cpp's |
| 21 | + # dependencies and configuration, than that offered by the `.override` |
| 22 | + # mechanism. Cf. https://nixos.org/manual/nixpkgs/stable/#chap-overlays. |
| 23 | + # |
| 24 | + # E.g. in a flake: |
| 25 | + # ``` |
| 26 | + # { nixpkgs, llama-cpp, ... }: |
| 27 | + # let pkgs = import nixpkgs { |
| 28 | + # overlays = [ (llama-cpp.overlays.default) ]; |
| 29 | + # system = "aarch64-linux"; |
| 30 | + # config.allowUnfree = true; |
| 31 | + # config.cudaSupport = true; |
| 32 | + # config.cudaCapabilities = [ "7.2" ]; |
| 33 | + # config.cudaEnableForwardCompat = false; |
| 34 | + # }; in { |
| 35 | + # packages.aarch64-linux.llamaJetsonXavier = pkgs.llamaPackages.llama-cpp; |
| 36 | + # } |
| 37 | + # ``` |
| 38 | + # |
| 39 | + # Cf. https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-flake.html?highlight=flake#flake-format |
| 40 | + overlays.default = (final: prev: { llamaPackages = final.callPackage .devops/nix/scope.nix { }; }); |
23 | 41 |
|
24 | 42 | # These use the package definition from `./.devops/nix/package.nix`.
|
25 | 43 | # There's one per backend that llama-cpp uses. Add more as needed!
|
26 | 44 | packages = eachSystem (
|
27 | 45 | system:
|
28 | 46 | let
|
29 |
| - defaultConfig = { |
| 47 | + # Avoid re-evaluation for the nixpkgs instance, |
| 48 | + # cf. https://zimbatm.com/notes/1000-instances-of-nixpkgs |
| 49 | + pkgs = nixpkgs.legacyPackages.${system}; |
| 50 | + |
| 51 | + # Ensure dependencies use CUDA consistently (e.g. that openmpi, ucc, |
| 52 | + # and ucx are built with CUDA support) |
| 53 | + pkgsCuda = import nixpkgs { |
30 | 54 | inherit system;
|
31 |
| - overlays = [ self.overlays.default ]; |
32 |
| - }; |
33 |
| - pkgs = import nixpkgs defaultConfig; |
34 | 55 |
|
35 |
| - # Let's not make a big deal about getting the CUDA bits. |
36 |
| - cudaConfig = defaultConfig // { |
37 | 56 | config.cudaSupport = true;
|
38 | 57 | config.allowUnfreePredicate =
|
39 | 58 | p:
|
|
48 | 67 | )
|
49 | 68 | (p.meta.licenses or [ p.meta.license ]);
|
50 | 69 | };
|
51 |
| - pkgsCuda = import nixpkgs cudaConfig; |
52 | 70 |
|
53 |
| - # Let's make sure to turn on ROCm support across the whole package ecosystem. |
54 |
| - rocmConfig = defaultConfig // { |
| 71 | + # Ensure dependencies use ROCm consistently |
| 72 | + pkgsRocm = import nixpkgs { |
| 73 | + inherit system; |
55 | 74 | config.rocmSupport = true;
|
56 | 75 | };
|
57 |
| - pkgsRocm = import nixpkgs rocmConfig; |
58 | 76 | in
|
59 | 77 | {
|
60 |
| - default = pkgs.llama-cpp; |
61 |
| - opencl = pkgs.llama-cpp.override { useOpenCL = true; }; |
62 |
| - cuda = pkgsCuda.llama-cpp; |
63 |
| - rocm = pkgsRocm.llama-cpp; |
| 78 | + default = (pkgs.callPackage .devops/nix/scope.nix { }).llama-cpp; |
| 79 | + opencl = self.packages.${system}.default.override { useOpenCL = true; }; |
| 80 | + cuda = (pkgsCuda.callPackage .devops/nix/scope.nix { }).llama-cpp; |
| 81 | + rocm = (pkgsRocm.callPackage .devops/nix/scope.nix { }).llama-cpp; |
64 | 82 | }
|
65 | 83 | );
|
66 | 84 |
|
|
0 commit comments