mediatomb/gerbera: Make the actual configuration generation lazy

Also use verbose flag in cli command to make the intent clearer.
This commit is contained in:
Antoine R. Dumont (@ardumont) 2020-07-18 20:58:30 +02:00 committed by Antoine R. Dumont (@ardumont)
parent de838249c7
commit fcb38d6773
No known key found for this signature in database
GPG Key ID: 52E2E9840D10C3B8

View File

@ -65,11 +65,7 @@ let
</transcoding> </transcoding>
''; '';
mtConf = pkgs.writeText "config.xml" '' configText = optionalString (! cfg.customCfg) ''
<!--
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"?> <?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"> <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> <interface>${cfg.interface}</interface>
@ -330,12 +326,15 @@ in {
###### implementation ###### implementation
config = mkIf cfg.enable { config = let binaryCommand = "${pkg}/bin/${name}";
systemd.services."${name}"= { interfaceFlag = optionalString ( cfg.interface != "") "--interface ${cfg.interface}";
configFlag = optionalString (! cfg.customCfg) "--config ${pkgs.writeText "config.xml" configText}";
in mkIf cfg.enable {
systemd.services.mediatomb = {
description = "${cfg.serverName} media Server"; description = "${cfg.serverName} media Server";
after = [ "network.target" ]; after = [ "network.target" ];
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
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.ExecStart = "${binaryCommand} --port ${toString cfg.port} ${interfaceFlag} ${configFlag} --home ${cfg.dataDir}";
serviceConfig.User = "${cfg.user}"; serviceConfig.User = "${cfg.user}";
}; };