diff options
author | Antoine R. Dumont (@ardumont) <antoine.romain.dumont@gmail.com> | 2020-07-18 20:58:30 +0200 |
---|---|---|
committer | Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org> | 2020-10-08 08:59:48 +0200 |
commit | fcb38d67738bec95e5116321f86d7ce7e6f5ed3e (patch) | |
tree | 56fc82303e45672a81eb8452d753b72e87277743 /nixos/modules/services/misc/mediatomb.nix | |
parent | de838249c7600ea3cdf375f767f6bb51ed72819d (diff) | |
download | nixpkgs-fcb38d67738bec95e5116321f86d7ce7e6f5ed3e.tar nixpkgs-fcb38d67738bec95e5116321f86d7ce7e6f5ed3e.tar.gz nixpkgs-fcb38d67738bec95e5116321f86d7ce7e6f5ed3e.tar.bz2 nixpkgs-fcb38d67738bec95e5116321f86d7ce7e6f5ed3e.tar.lz nixpkgs-fcb38d67738bec95e5116321f86d7ce7e6f5ed3e.tar.xz nixpkgs-fcb38d67738bec95e5116321f86d7ce7e6f5ed3e.tar.zst nixpkgs-fcb38d67738bec95e5116321f86d7ce7e6f5ed3e.zip |
mediatomb/gerbera: Make the actual configuration generation lazy
Also use verbose flag in cli command to make the intent clearer.
Diffstat (limited to 'nixos/modules/services/misc/mediatomb.nix')
-rw-r--r-- | nixos/modules/services/misc/mediatomb.nix | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/nixos/modules/services/misc/mediatomb.nix b/nixos/modules/services/misc/mediatomb.nix index a06f6da7b23..9d73a64be91 100644 --- a/nixos/modules/services/misc/mediatomb.nix +++ b/nixos/modules/services/misc/mediatomb.nix @@ -65,11 +65,7 @@ let </transcoding> ''; - mtConf = pkgs.writeText "config.xml" '' - <!-- - See http://gerbera.io or read the docs for more - information on creating and using config.xml configration files. - --> + configText = optionalString (! cfg.customCfg) '' <?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> @@ -330,12 +326,15 @@ in { ###### implementation - config = mkIf cfg.enable { - systemd.services."${name}"= { + config = let binaryCommand = "${pkg}/bin/${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"; after = [ "network.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}"; }; |