helm/modules/audio/spotify.nix

38 lines
1.3 KiB
Nix
Raw Normal View History

2019-12-03 21:10:51 -08:00
{ config, lib, pkgs, ... }:
{
2019-12-13 00:06:01 -08:00
# services.spotifyd doesn't work so we'll have to roll our own spotifyd +
# spotify-tui solution. I can't get the dbus interface doesn't work, though,
# so we have to wait for spotify-tui to implement CLI command for controlling
# spotify playback (see https://github.com/Rigellute/spotify-tui/issues/147)
# or for spotifyd to get fixed.
2019-12-03 21:10:51 -08:00
environment.systemPackages = with pkgs; [
2019-12-13 00:06:01 -08:00
unstable.spotifyd
2019-12-03 21:10:51 -08:00
(writeScriptBin "spt" ''
#!${stdenv.shell}
2019-12-13 00:06:01 -08:00
if ! systemctl --user is-active spotifyd >/dev/null; then
systemctl --user start spotifyd
2019-12-03 21:10:51 -08:00
fi
${unstable.spotify-tui}/bin/spt
'')
# spotify-tui is fine for selecting and playing music, but incomplete. We
2019-12-13 00:06:01 -08:00
# occasionally still need the official client for more sophisticated search
# and the "made for you" playlists.
2019-12-03 21:10:51 -08:00
spotify
];
2019-12-13 00:06:01 -08:00
systemd.user.services.spotifyd.serviceConfig =
let spotifydConf = pkgs.writeText "spotifyd.conf" ''
[global]
username = accounts@v0.io
password_cmd = ${pkgs.pass}/bin/pass www/spotify.com | head -n1
backend = pulseaudio
'';
in {
ExecStart = "${pkgs.unstable.spotifyd}/bin/spotifyd --no-daemon --cache-path /tmp/spotifyd --config-path ${spotifydConf}";
Restart = "always";
RestartSec = 6;
};
2019-12-03 21:10:51 -08:00
}