I recently discovered spotifyd, an open source alternative to the deprecated libspotify. I happened to also have a pi-zero W from a while back, and a pHAT DAC amplifier.
It was a relatively trivial job to set up the pi zero w headless, get audio output to the pHAT DAC, install spotifyd and use it as a spotify connect device connected to my old Cambridge Audio A1.
Install guides:
raspberry pi headless, since I last used this, userconf.txt was added which allows setting up a proper user with a unique password! Bonus security points.
spotifyd, zero-w requires the arm-v6 variant, luckily they build releases for this architecture! Building on the pi-zero could take a while.
tailscale, not strictly necessary, but nice to have
and ufw and unattended-upgrade, just for the additional security and sanity. Note that you must set spotifyd to listen on a fixed port for disovery to work, and allow that port in the firewall! Specifically set
--zeroconf-port <number>
either via command line or in the configuration file, and allow connections withsudo ufw allow <number>
I tried a similar project a few years ago, using MPD and spotify plugin, but at the time it was too unreliable. Thanks to the folks who spent the time creating spotifyd!
I should get a case for the pi some time, at the moment it's just freely sitting on the shelf next to the speakers.