Merge pull request #108981 from doronbehar/nixos/mpd

nixos/mpd: use credentials only if needed
This commit is contained in:
Doron Behar 2021-01-11 09:40:49 +02:00 committed by GitHub
commit 8addce8b60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -40,7 +40,7 @@ let
} }
''} ''}
${credentialsPlaceholder cfg.credentials} ${optionalString (cfg.credentials != []) (credentialsPlaceholder cfg.credentials)}
${cfg.extraConfig} ${cfg.extraConfig}
''; '';
@ -234,9 +234,10 @@ in {
ExecStartPre = pkgs.writeShellScript "mpd-start-pre" '' ExecStartPre = pkgs.writeShellScript "mpd-start-pre" ''
set -euo pipefail set -euo pipefail
install -m 600 ${mpdConf} /run/mpd/mpd.conf install -m 600 ${mpdConf} /run/mpd/mpd.conf
${pkgs.replace}/bin/replace-literal -fe ${ ${optionalString (cfg.credentials != [])
"${pkgs.replace}/bin/replace-literal -fe ${
concatStringsSep " -a " (imap0 (i: c: "\"{{password-${toString i}}}\" \"$(cat ${c.passwordFile})\"") cfg.credentials) concatStringsSep " -a " (imap0 (i: c: "\"{{password-${toString i}}}\" \"$(cat ${c.passwordFile})\"") cfg.credentials)
} /run/mpd/mpd.conf } /run/mpd/mpd.conf"}
''; '';
RuntimeDirectory = "mpd"; RuntimeDirectory = "mpd";
Type = "notify"; Type = "notify";