nix-infra/modules/services/audio/librespot.nix
June df365e67f9
audio: fix librespot playback and use avahi for mDNS
Fix librespot playback by building the dev branch and applying the
changes from librespot PR 1528
(https://github.com/librespot-org/librespot/pull/1528) fixing librespot
issue 1527 (https://github.com/librespot-org/librespot/issues/1527).

Also make librespot use Avahi, since shairport-sync already uses that.
2025-08-11 04:18:41 +02:00

42 lines
1.2 KiB
Nix

# Sources for this configuration:
# - https://github.com/librespot-org/librespot
# - https://github.com/librespot-org/librespot/wiki/Options
# - https://github.com/librespot-org/librespot/wiki/Audio-Backends
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.ccchh.services.audio;
in
{
config = mkIf cfg.enable {
systemd.services.spotify-connect-receiver = {
enable = true;
description = "Spotify Connect Receiver Using librespot";
unitConfig = {
Requires = [ "network-online.target" "pipewire.service" "avahi-daemon.service" ];
After = [ "network-online.target" "pipewire.service" "avahi-daemon.service" ];
};
serviceConfig = {
ExecStart = "${pkgs.librespot}/bin/librespot --name '${config.ccchh.services.audio.name}' --device-type speaker --bitrate 320 --enable-volume-normalisation --disable-audio-cache --disable-credential-cache --zeroconf-backend avahi";
User = "librespot";
Group = "librespot";
};
wantedBy = [ "multi-user.target" ];
};
users = {
users.librespot = {
isSystemUser = true;
group = "librespot";
extraGroups = [ "pipewire" "audio" ];
};
groups.librespot = { };
};
};
}