diff --git a/pkgs/by-name/wh/whisper-cpp/package.nix b/pkgs/by-name/wh/whisper-cpp/package.nix index e54b0c4f5bd8..699e1cab4199 100644 --- a/pkgs/by-name/wh/whisper-cpp/package.nix +++ b/pkgs/by-name/wh/whisper-cpp/package.nix @@ -8,6 +8,7 @@ SDL2, wget, which, + ffmpeg, autoAddDriverRunpath, makeWrapper, nix-update-script, @@ -29,10 +30,13 @@ vulkan-loader, withSDL ? true, + + withFFmpegSupport ? false, }: assert metalSupport -> stdenv.hostPlatform.isDarwin; assert coreMLSupport -> stdenv.hostPlatform.isDarwin; +assert withFFmpegSupport -> stdenv.hostPlatform.isLinux; let # It's necessary to consistently use backendStdenv when building with CUDA support, @@ -108,6 +112,7 @@ effectiveStdenv.mkDerivation (finalAttrs: { buildInputs = optional withSDL SDL2 + ++ optional withFFmpegSupport ffmpeg ++ optionals cudaSupport cudaBuildInputs ++ optionals rocmSupport rocmBuildInputs ++ optionals vulkanSupport vulkanBuildInputs; @@ -122,6 +127,9 @@ effectiveStdenv.mkDerivation (finalAttrs: { (cmakeBool "GGML_NATIVE" false) (cmakeBool "BUILD_SHARED_LIBS" (!effectiveStdenv.hostPlatform.isStatic)) ] + ++ optionals effectiveStdenv.hostPlatform.isLinux [ + (cmakeBool "WHISPER_FFMPEG" withFFmpegSupport) + ] ++ optionals (effectiveStdenv.hostPlatform.isx86 && !effectiveStdenv.hostPlatform.isStatic) [ (cmakeBool "GGML_BACKEND_DL" true) (cmakeBool "GGML_CPU_ALL_VARIANTS" true) @@ -156,6 +164,10 @@ effectiveStdenv.mkDerivation (finalAttrs: { wrapProgram "$out/bin/whisper-cpp-download-ggml-model" \ --prefix PATH : ${lib.makeBinPath [ wget ]} + '' + + lib.optionalString withFFmpegSupport '' + wrapProgram "$out/bin/whisper-server" \ + --prefix PATH : ${lib.makeBinPath [ ffmpeg ]} ''; requiredSystemFeatures = optionals rocmSupport [ "big-parallel" ]; # rocmSupport multiplies build time by the number of GPU targets, which takes arround 30 minutes on a 16-cores system to build