diff options
author | Antoine R. Dumont (@ardumont) <antoine.romain.dumont@gmail.com> | 2020-07-18 10:07:42 +0200 |
---|---|---|
committer | Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org> | 2020-10-08 08:59:48 +0200 |
commit | de838249c7600ea3cdf375f767f6bb51ed72819d (patch) | |
tree | 08a6ebe3f3360fc211cde08e656bee5546fe8caf /nixos/modules/services/misc/mediatomb.nix | |
parent | 96d1844746d1fd67f83901730eb7b8a9d3cb7985 (diff) | |
download | nixpkgs-de838249c7600ea3cdf375f767f6bb51ed72819d.tar nixpkgs-de838249c7600ea3cdf375f767f6bb51ed72819d.tar.gz nixpkgs-de838249c7600ea3cdf375f767f6bb51ed72819d.tar.bz2 nixpkgs-de838249c7600ea3cdf375f767f6bb51ed72819d.tar.lz nixpkgs-de838249c7600ea3cdf375f767f6bb51ed72819d.tar.xz nixpkgs-de838249c7600ea3cdf375f767f6bb51ed72819d.tar.zst nixpkgs-de838249c7600ea3cdf375f767f6bb51ed72819d.zip |
mediatomb/gerbera: Introduce the mediaDirectories option
So users can declare their autoscan directories configuration from nix.
Diffstat (limited to 'nixos/modules/services/misc/mediatomb.nix')
-rw-r--r-- | nixos/modules/services/misc/mediatomb.nix | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/nixos/modules/services/misc/mediatomb.nix b/nixos/modules/services/misc/mediatomb.nix index e56e9d6e4ba..a06f6da7b23 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: "<directory location=\"${d.path}\" mode=\"inotify\" recursive=\"${optionYesNo d.recursive}\" hidden-files=\"${optionYesNo d.hidden-files}\" />\n"; + transcodingConfig = if cfg.transcoding then with pkgs; '' <transcoding enabled="yes"> <mimetype-profile-mappings> @@ -43,6 +66,10 @@ let ''; mtConf = pkgs.writeText "config.xml" '' + <!-- + See http://gerbera.io or read the docs for more + information on creating and using config.xml configration files. + --> <?xml version="1.0" encoding="UTF-8"?> <config version="2" xmlns="http://mediatomb.cc/config/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://mediatomb.cc/config/2 http://mediatomb.cc/config/2.xsd"> <interface>${cfg.interface}</interface> @@ -85,6 +112,9 @@ let </extended-runtime-options> </server> <import hidden-files="no"> + <autoscan use-inotify="auto"> + ${concatMapStrings toMediaDirectory cfg.mediaDirectories} + </autoscan> <scripting script-charset="UTF-8"> <common-script>${pkg}/share/${name}/js/common.js</common-script> <playlist-script>${pkg}/share/${name}/js/playlists.js</playlist-script> @@ -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; |