From bf7ea83c70b1e0c213194a5306766a306f65e7b3 Mon Sep 17 00:00:00 2001 From: "Antoine R. Dumont (@ardumont)" Date: Thu, 22 Oct 2020 00:50:07 +0200 Subject: [PATCH] mediatomb: Allow users to customize duktape/js script imports With no customization, the default behavior is kept (virtual-layout using the builtin engine with the default import.js provided by gerbera). This allows user to develop and provide their own list of customized duktape/javascript scripts [1] [1] http://docs.gerbera.io/en/latest/scripting.html --- nixos/modules/services/misc/mediatomb.nix | 24 ++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/nixos/modules/services/misc/mediatomb.nix b/nixos/modules/services/misc/mediatomb.nix index a19b73889ce45..58e88b2107324 100644 --- a/nixos/modules/services/misc/mediatomb.nix +++ b/nixos/modules/services/misc/mediatomb.nix @@ -65,6 +65,14 @@ let ''; + virtualLayout = + let toCustomImportScript = import-script-path: "${import-script-path}\n"; + in if ((builtins.length cfg.customImportJS) > 0) then '' + ${concatMapStrings toCustomImportScript cfg.customImportJS} + '' else '' + ${pkg}/share/${name}/js/import.js + ''; + configText = optionalString (! cfg.customCfg) '' @@ -113,9 +121,7 @@ let ${pkg}/share/${name}/js/common.js ${pkg}/share/${name}/js/playlists.js - - ${pkg}/share/${name}/js/import.js - + ${virtualLayout} @@ -335,6 +341,18 @@ in { ]; }; + customImportJS = mkOption { + type = with types; listOf path; + default = []; + description = '' + A list of user customized javascript files to import. If unspecified, + the default, this uses the default builtin engine. + ''; + example = [ + ./import.js + ]; + }; + customCfg = mkOption { type = types.bool; default = false;