Commit 4ee1354a authored by June Stepp's avatar June Stepp Committed by Kerstin
Browse files

nixos/peertube: only include whisper when transcription is enabled

`whisper-ctranslate2` has a large closure size with unique dependencies.
parent 17c8f3e3
Loading
Loading
Loading
Loading
+33 −2
Original line number Diff line number Diff line
@@ -165,7 +165,39 @@ in
    };

    settings = lib.mkOption {
      type = settingsFormat.type;
      type = lib.types.submodule (
        { config, ... }:
        {
          freeformType = settingsFormat.type;
          options = {
            video_transcription = {
              enabled = lib.mkOption {
                type = lib.types.bool;
                default = false;
                description = "Enable automatic transcription of videos.";
              };
              engine_path = lib.mkOption {
                type = with lib.types; either path str;
                default =
                  if config.video_transcription.enabled then
                    lib.getExe pkgs.whisper-ctranslate2
                  else
                    # This will be in the error message when someone enables
                    # transcription manually in the web UI and tries to run a
                    # transcription job.
                    "Set `services.peertube.settings.video_transcription.enabled = true`.";
                defaultText = lib.literalExpression ''
                  if config.services.peertube.settings.video_transcription.enabled then
                    lib.getExe pkgs.whisper-ctranslate2
                  else
                    "Set `services.peertube.settings.video_transcription.enabled = true`."
                '';
                description = "Custom engine path for local transcription.";
              };
            };
          };
        }
      );
      example = lib.literalExpression ''
        {
          listen = {
@@ -424,7 +456,6 @@ in
        };
        video_transcription = {
          engine = lib.mkDefault "whisper-ctranslate2";
          engine_path = lib.mkDefault (lib.getExe pkgs.whisper-ctranslate2);
        };
      }
      (lib.mkIf cfg.redis.enableUnixSocket {