mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-19 08:36:41 +01:00
mediatomb: make service compatible with the gerbera fork
The duplication of the interface xml tag is needed for the daemon to respect the setting.
This commit is contained in:
parent
420f89ceb2
commit
3bb5cc6849
1 changed files with 47 additions and 31 deletions
|
@ -6,37 +6,42 @@ let
|
|||
|
||||
gid = config.ids.gids.mediatomb;
|
||||
cfg = config.services.mediatomb;
|
||||
name = cfg.package.pname;
|
||||
pkg = cfg.package;
|
||||
optionYesNo = option: if option then "yes" else "no";
|
||||
|
||||
mtConf = pkgs.writeText "config.xml" ''
|
||||
<?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>
|
||||
<server>
|
||||
<ui enabled="yes" show-tooltips="yes">
|
||||
<accounts enabled="no" session-timeout="30">
|
||||
<account user="mediatomb" password="mediatomb"/>
|
||||
<account user="${name}" password="${name}"/>
|
||||
</accounts>
|
||||
</ui>
|
||||
<name>${cfg.serverName}</name>
|
||||
<udn>uuid:${cfg.uuid}</udn>
|
||||
<home>${cfg.dataDir}</home>
|
||||
<webroot>${pkgs.mediatomb}/share/mediatomb/web</webroot>
|
||||
<interface>${cfg.interface}</interface>
|
||||
<webroot>${pkg}/share/${name}/web</webroot>
|
||||
<storage>
|
||||
<sqlite3 enabled="yes">
|
||||
<database-file>mediatomb.db</database-file>
|
||||
<database-file>${name}.db</database-file>
|
||||
</sqlite3>
|
||||
</storage>
|
||||
<protocolInfo extend="${if cfg.ps3Support then "yes" else "no"}"/>
|
||||
${if cfg.dsmSupport then ''
|
||||
<protocolInfo extend="${optionYesNo cfg.ps3Support}"/>
|
||||
${lib.optionalString cfg.dsmSupport ''
|
||||
<custom-http-headers>
|
||||
<add header="X-User-Agent: redsonic"/>
|
||||
</custom-http-headers>
|
||||
|
||||
<manufacturerURL>redsonic.com</manufacturerURL>
|
||||
<modelNumber>105</modelNumber>
|
||||
'' else ""}
|
||||
${if cfg.tg100Support then ''
|
||||
''}
|
||||
${optionalString cfg.tg100Support ''
|
||||
<upnp-string-limit>101</upnp-string-limit>
|
||||
'' else ""}
|
||||
''}
|
||||
<extended-runtime-options>
|
||||
<mark-played-items enabled="yes" suppress-cds-updates="yes">
|
||||
<string mode="prepend">*</string>
|
||||
|
@ -48,10 +53,10 @@ let
|
|||
</server>
|
||||
<import hidden-files="no">
|
||||
<scripting script-charset="UTF-8">
|
||||
<common-script>${pkgs.mediatomb}/share/mediatomb/js/common.js</common-script>
|
||||
<playlist-script>${pkgs.mediatomb}/share/mediatomb/js/playlists.js</playlist-script>
|
||||
<common-script>${pkg}/share/${name}/js/common.js</common-script>
|
||||
<playlist-script>${pkg}/share/${name}/js/playlists.js</playlist-script>
|
||||
<virtual-layout type="builtin">
|
||||
<import-script>${pkgs.mediatomb}/share/mediatomb/js/import.js</import-script>
|
||||
<import-script>${pkg}/share/${name}/js/import.js</import-script>
|
||||
</virtual-layout>
|
||||
</scripting>
|
||||
<mappings>
|
||||
|
@ -75,12 +80,12 @@ let
|
|||
<map from="flv" to="video/x-flv"/>
|
||||
<map from="mkv" to="video/x-matroska"/>
|
||||
<map from="mka" to="audio/x-matroska"/>
|
||||
${if cfg.ps3Support then ''
|
||||
${optionalString cfg.ps3Support ''
|
||||
<map from="avi" to="video/divx"/>
|
||||
'' else ""}
|
||||
${if cfg.dsmSupport then ''
|
||||
''}
|
||||
${optionalString cfg.dsmSupport ''
|
||||
<map from="avi" to="video/avi"/>
|
||||
'' else ""}
|
||||
''}
|
||||
</extension-mimetype>
|
||||
<mimetype-upnpclass>
|
||||
<map from="audio/*" to="object.item.audioItem.musicTrack"/>
|
||||
|
@ -108,10 +113,10 @@ let
|
|||
</mappings>
|
||||
<online-content>
|
||||
<YouTube enabled="no" refresh="28800" update-at-start="no" purge-after="604800" racy-content="exclude" format="mp4" hd="no">
|
||||
<favorites user="mediatomb"/>
|
||||
<favorites user="${name}"/>
|
||||
<standardfeed feed="most_viewed" time-range="today"/>
|
||||
<playlists user="mediatomb"/>
|
||||
<uploads user="mediatomb"/>
|
||||
<playlists user="${name}"/>
|
||||
<uploads user="${name}"/>
|
||||
<standardfeed feed="recently_featured" time-range="today"/>
|
||||
</YouTube>
|
||||
</online-content>
|
||||
|
@ -158,18 +163,27 @@ in {
|
|||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Whether to enable the mediatomb DLNA server.
|
||||
Whether to enable the Gerbera/Mediatomb DLNA server.
|
||||
'';
|
||||
};
|
||||
|
||||
serverName = mkOption {
|
||||
type = types.str;
|
||||
default = "mediatomb";
|
||||
default = "Gerbera (Mediatomb)";
|
||||
description = ''
|
||||
How to identify the server on the network.
|
||||
'';
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
example = literalExample "pkgs.mediatomb";
|
||||
default = pkgs.gerbera;
|
||||
description = ''
|
||||
Underlying package to be used with the module (default: pkgs.gerbera).
|
||||
'';
|
||||
};
|
||||
|
||||
ps3Support = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
|
@ -206,20 +220,20 @@ in {
|
|||
|
||||
dataDir = mkOption {
|
||||
type = types.path;
|
||||
default = "/var/lib/mediatomb";
|
||||
default = "/var/lib/${name}";
|
||||
description = ''
|
||||
The directory where mediatomb stores its state, data, etc.
|
||||
The directory where ${cfg.serverName} stores its state, data, etc.
|
||||
'';
|
||||
};
|
||||
|
||||
user = mkOption {
|
||||
default = "mediatomb";
|
||||
description = "User account under which mediatomb runs.";
|
||||
description = "User account under which ${name} runs.";
|
||||
};
|
||||
|
||||
group = mkOption {
|
||||
default = "mediatomb";
|
||||
description = "Group account under which mediatomb runs.";
|
||||
description = "Group account under which ${name} runs.";
|
||||
};
|
||||
|
||||
port = mkOption {
|
||||
|
@ -247,7 +261,10 @@ in {
|
|||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Allow mediatomb to create and use its own config file inside ${cfg.dataDir}.
|
||||
Allow ${name} to create and use its own config file inside ${cfg.dataDir}.
|
||||
Deactivated by default, the service then runs with the configuration generated from this module.
|
||||
Otherwise, when enabled, no service configuration is generated. Gerbera/Mediatomb then starts using
|
||||
${cfg.dataDir}/config.xml. It's up to the user to make a correct configuration file.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
@ -257,12 +274,11 @@ in {
|
|||
###### implementation
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
systemd.services.mediatomb = {
|
||||
description = "MediaTomb media Server";
|
||||
systemd.services."${name}"= {
|
||||
description = "${cfg.serverName} media Server";
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
path = [ pkgs.mediatomb ];
|
||||
serviceConfig.ExecStart = "${pkgs.mediatomb}/bin/mediatomb -p ${toString cfg.port} ${if cfg.interface!="" then "-e ${cfg.interface}" else ""} ${if cfg.customCfg then "" else "-c ${mtConf}"} -m ${cfg.dataDir}";
|
||||
serviceConfig.ExecStart = "${pkg}/bin/${name} -p ${toString cfg.port} ${if cfg.interface!="" then "-e ${cfg.interface}" else ""} ${if cfg.customCfg then "" else "-c ${mtConf}"} -m ${cfg.dataDir}";
|
||||
serviceConfig.User = "${cfg.user}";
|
||||
};
|
||||
|
||||
|
@ -276,11 +292,11 @@ in {
|
|||
group = cfg.group;
|
||||
home = "${cfg.dataDir}";
|
||||
createHome = true;
|
||||
description = "Mediatomb DLNA Server User";
|
||||
description = "${name} DLNA Server User";
|
||||
};
|
||||
};
|
||||
|
||||
networking.firewall = {
|
||||
networking.firewall.interfaces."${cfg.interface}" = {
|
||||
allowedUDPPorts = [ 1900 cfg.port ];
|
||||
allowedTCPPorts = [ cfg.port ];
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue