diff --git a/nixos/modules/services/web-apps/peertube.nix b/nixos/modules/services/web-apps/peertube.nix index 2a676fd06673..76e95cfe52e0 100644 --- a/nixos/modules/services/web-apps/peertube.nix +++ b/nixos/modules/services/web-apps/peertube.nix @@ -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 {