From 4ee1354ae6ae144d43f60e062387450f56eb3e82 Mon Sep 17 00:00:00 2001 From: June Stepp Date: Tue, 15 Jul 2025 17:23:13 -0500 Subject: [PATCH] nixos/peertube: only include whisper when transcription is enabled `whisper-ctranslate2` has a large closure size with unique dependencies. --- nixos/modules/services/web-apps/peertube.nix | 35 ++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) 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 {