From de838249c7600ea3cdf375f767f6bb51ed72819d Mon Sep 17 00:00:00 2001 From: "Antoine R. Dumont (@ardumont)" Date: Sat, 18 Jul 2020 10:07:42 +0200 Subject: [PATCH] mediatomb/gerbera: Introduce the mediaDirectories option So users can declare their autoscan directories configuration from nix. --- nixos/modules/services/misc/mediatomb.nix | 42 +++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/nixos/modules/services/misc/mediatomb.nix b/nixos/modules/services/misc/mediatomb.nix index e56e9d6e4ba1..a06f6da7b234 100644 --- a/nixos/modules/services/misc/mediatomb.nix +++ b/nixos/modules/services/misc/mediatomb.nix @@ -9,6 +9,29 @@ let name = cfg.package.pname; pkg = cfg.package; optionYesNo = option: if option then "yes" else "no"; + # configuration on media directory + mediaDirectory = { + options = { + path = mkOption { + type = types.str; + description = '' + Absolute directory path to the media directory to index. + ''; + }; + recursive = mkOption { + type = types.bool; + default = false; + description = "Whether the indexation must take place recursively or not."; + }; + hidden-files = mkOption { + type = types.bool; + default = true; + description = "Whether to index the hidden files or not."; + }; + }; + }; + toMediaDirectory = d: "\n"; + transcodingConfig = if cfg.transcoding then with pkgs; '' @@ -43,6 +66,10 @@ let ''; mtConf = pkgs.writeText "config.xml" '' + ${cfg.interface} @@ -85,6 +112,9 @@ let + + ${concatMapStrings toMediaDirectory cfg.mediaDirectories} + ${pkg}/share/${name}/js/common.js ${pkg}/share/${name}/js/playlists.js @@ -272,6 +302,18 @@ in { ''; }; + mediaDirectories = mkOption { + type = with types; listOf (submodule mediaDirectory); + default = {}; + description = '' + Declare media directories to index. + ''; + example = [ + { path = "/data/pictures"; recursive = false; hidden-files = false; } + { path = "/data/audio"; recursive = true; hidden-files = false; } + ]; + }; + customCfg = mkOption { type = types.bool; default = false;