diff --git a/roles/spotifyd/default.nix b/roles/spotifyd/default.nix index e3e056f..a91dc8e 100644 --- a/roles/spotifyd/default.nix +++ b/roles/spotifyd/default.nix @@ -4,6 +4,16 @@ with lib; let cfg = config.roles.spotifyd; + spotifyd = pkgs.spotifyd.override { withMpris = true; withPulseAudio = true; }; + spotifydConf = pkgs.writeText "spotifyd-config" '' + [global] + backend = "pulseaudio" + bitrate = 320 + use_mpris = false + zeroconf_port = 5354 + autoplay = false + device_type = "${cfg.deviceType}" + ''; in { options.roles.spotifyd = { @@ -16,27 +26,19 @@ in config = mkIf cfg.enable { roles.audio.enable = true; - hardware.pulseaudio.enable = true; - hardware.pulseaudio.extraConfig = '' - unload-module module-native-protocol-unix - load-module module-native-protocol-unix auth-anonymous=1 - ''; - hardware.pulseaudio.systemWide = true; - services.spotifyd = { + systemd.user.services.spotifyd = { enable = true; - settings = { - global = { - use_mpris = false; - backend = "pulseaudio"; - bitrate = 320; - cache_path = ""; - zeroconf_port = 5354; - autoplay = false; - device_type = cfg.deviceType; - }; + wantedBy = [ "default.target" ]; + after = [ "network-online.target" "sound.target" ]; + description = "spotifyd, a Spotify playing daemon"; + serviceConfig = { + ExecStart = "${spotifyd}/bin/spotifyd --no-daemon --cache-path=\${HOME}/.cache/spotifyd --config-path=${spotifydConf}"; + Restart = "always"; + RestartSec = 12; }; }; + users.users."kodi".linger = true; networking.firewall.allowedTCPPorts = [ 5354