So there’s this program mpdas
which I try to run in a systemd service. Here’s the service:
systemd.services.mpdas = {
description = "Music Player Daemon Scrobbler (mpdas)";
bindsTo = ["mpd.service"];
wantedBy = [ "multi-user.target" ];
unitConfig = { RequiresMountsFor = "/var/lib/mpd"; };
serviceConfig = {
# That file's format is configured here:
# https://github.com/hrkfdn/mpdas/tree/master#configuration
ExecStart = "${pkgs.mpdas}/bin/mpdas";
# A little bit more complicated then mpd's prestart script because it
# has to parse the mpd conf file format
ExecStartPre = pkgs.writeScript "mpdas-start-pre" ''
#!${pkgs.runtimeShell}
set -euo pipefail
password=$(${pkgs.gawk}/bin/awk -F'[@"]' '$1 == "password " {print $2}' /var/lib/secrets/mpd.conf)
echo "mpdpassword = $password" > /etc/mpdasrc
cat /var/lib/secrets/mpdas.conf >> /etc/mpdasrc
'';
Type = "simple";
};
};
And it fails with:
May 16 10:35:59 NUX mpdas[825]: terminate called after throwing an instance of 'std::logic_error'
May 16 10:35:59 NUX mpdas[825]: what(): basic_string::_M_construct null not valid
While sudo /nix/store/i58ym4xm7v34c4l7gawg3w8frgrvk75y-mpdas-0.4.5/bin/mpdas
doesn’t fail . Don’t know why.