From 3ccb633f85a6d1e7931e47206a85773ed9a67383 Mon Sep 17 00:00:00 2001 From: Bernardo Meurer Date: Wed, 4 Aug 2021 10:20:36 -0700 Subject: [PATCH] nixos/hqplayerd: use package-provided config file instead of blank --- nixos/modules/services/audio/hqplayerd.nix | 28 ++++++++-------------- 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/nixos/modules/services/audio/hqplayerd.nix b/nixos/modules/services/audio/hqplayerd.nix index b4d8468a2375..7d221e5b6dea 100644 --- a/nixos/modules/services/audio/hqplayerd.nix +++ b/nixos/modules/services/audio/hqplayerd.nix @@ -115,25 +115,17 @@ in unitConfig.ConditionPathExists = [ configDir stateDir ]; - preStart = - let - blankCfg = pkgs.writeText "hqplayerd.xml" '' - - - - ''; - in - '' - cp -r "${pkg}/var/lib/hqplayer/web" "${stateDir}" - chmod -R u+wX "${stateDir}/web" + preStart = '' + cp -r "${pkg}/var/lib/hqplayer/web" "${stateDir}" + chmod -R u+wX "${stateDir}/web" - if [ ! -f "${configDir}/hqplayerd.xml" ]; then - echo "creating blank config file" - install -m 0644 "${blankCfg}" "${configDir}/hqplayerd.xml" - fi - '' + optionalString (cfg.auth.username != null && cfg.auth.password != null) '' - ${pkg}/bin/hqplayerd -s ${cfg.auth.username} ${cfg.auth.password} - ''; + if [ ! -f "${configDir}/hqplayerd.xml" ]; then + echo "creating initial config file" + install -m 0644 "${pkg}/etc/hqplayer/hqplayerd.xml" "${configDir}/hqplayerd.xml" + fi + '' + optionalString (cfg.auth.username != null && cfg.auth.password != null) '' + ${pkg}/bin/hqplayerd -s ${cfg.auth.username} ${cfg.auth.password} + ''; serviceConfig = { ExecStart = "${pkg}/bin/hqplayerd";