Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib 2, stdenv 3, fetchFromGitHub 4, SDL2 5, makeWrapper 6, wget 7, Accelerate 8, CoreGraphics 9, CoreVideo 10}: 11 12stdenv.mkDerivation rec { 13 pname = "whisper-cpp"; 14 version = "1.4.0"; 15 16 src = fetchFromGitHub { 17 owner = "ggerganov"; 18 repo = "whisper.cpp"; 19 rev = "refs/tags/v${version}" ; 20 hash = "sha256-176MpooVQrq1dXC62h8Yyyhw6IjCA50tp1J4DQPSePQ="; 21 }; 22 23 # The upstream download script tries to download the models to the 24 # directory of the script, which is not writable due to being 25 # inside the nix store. This patch changes the script to download 26 # the models to the current directory of where it is being run from. 27 patches = [ ./download-models.patch ]; 28 29 nativeBuildInputs = [ makeWrapper ]; 30 31 buildInputs = [ SDL2 ] ++ lib.optionals stdenv.isDarwin [ Accelerate CoreGraphics CoreVideo ]; 32 33 makeFlags = [ "main" "stream" ]; 34 35 installPhase = '' 36 runHook preInstall 37 38 mkdir -p $out/bin 39 cp ./main $out/bin/whisper-cpp 40 cp ./stream $out/bin/whisper-cpp-stream 41 42 cp models/download-ggml-model.sh $out/bin/whisper-cpp-download-ggml-model 43 44 wrapProgram $out/bin/whisper-cpp-download-ggml-model \ 45 --prefix PATH : ${lib.makeBinPath [wget]} 46 47 runHook postInstall 48 ''; 49 50 meta = with lib; { 51 description = "Port of OpenAI's Whisper model in C/C++"; 52 longDescription = '' 53 To download the models as described in the project's readme, you may 54 use the `whisper-cpp-download-ggml-model` binary from this package. 55 ''; 56 homepage = "https://github.com/ggerganov/whisper.cpp"; 57 license = licenses.mit; 58 platforms = platforms.all; 59 maintainers = with maintainers; [ dit7ya hughobrien ]; 60 }; 61}