LostRuins / koboldcpp

Run GGUF models easily with a KoboldAI UI. One File. Zero Install.
https://github.com/lostruins/koboldcpp
GNU Affero General Public License v3.0
5.14k stars 353 forks source link

Adding nix flake support #411

Closed hakan-demirli closed 1 year ago

hakan-demirli commented 1 year ago

Nix offers a reproducible build environment. I have compiled koboldcpp on Ubuntu and Arch before. It was always a chore especially when I had CUDA version dependencies conflicting with other projects. So, I wonder if you can add flake.nix to streamline the build process?

This is the flake I am using to install all dependencies. I have successfully compiled the project on both Ubuntu, Nixos and Arch. Nix claims it should also work on Mac and WSL2 but I haven't tested.

{
  description = "Kobold cpp flake.";
  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

  outputs = { self, nixpkgs }:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs {
        inherit system;
        config.allowUnfree = true;
        config.cudaSupport = true;
        config.cudaVersion = "12";
      };
    in
    {
      devShells.${system}.default = pkgs.mkShell {
        buildInputs = with pkgs; [
          pkgs.bashInteractive

          (python311.withPackages (ps: with ps; [ tkinter ]))

          cudaPackages.cudnn
          cudaPackages.cudatoolkit
          cudaPackages.cuda_nvcc
          pkgs.cudaPackages.libcublas
          pkgs.clblast
          pkgs.openblas
          pkgs.clblast
        ];

        shellHook = ''
          export LD_LIBRARY_PATH="${pkgs.linuxPackages.nvidia_x11}/lib"
        '';
      };
    };
}
hakan-demirli commented 1 year ago

I accidentally opened the same issue twice. This one is redundant. Real one #410 .