From 28cd59c9570475ad6e4a80eabe795e5744e859c4 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 16 Oct 2023 22:29:09 +0200 Subject: [PATCH] Add Spotify Connect receiver using librespot --- config/hosts/audio/default.nix | 1 + config/hosts/audio/librespot.nix | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 config/hosts/audio/librespot.nix diff --git a/config/hosts/audio/default.nix b/config/hosts/audio/default.nix index 421557a..4bb568f 100644 --- a/config/hosts/audio/default.nix +++ b/config/hosts/audio/default.nix @@ -2,6 +2,7 @@ { imports = [ ./configuration.nix + ./librespot.nix ./networking.nix ./shairport-sync.nix ]; diff --git a/config/hosts/audio/librespot.nix b/config/hosts/audio/librespot.nix new file mode 100644 index 0000000..5709ee9 --- /dev/null +++ b/config/hosts/audio/librespot.nix @@ -0,0 +1,32 @@ +# 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, ... }: + +{ + systemd.services.spotify-connect-receiver = { + enable = true; + description = "Spotify Connect Receiver Using librespot"; + unitConfig = { + Requires = [ "network-online.target" "pipewire.service" ]; + After = [ "network-online.target" "pipewire.service" ]; + }; + serviceConfig = { + ExecStart = "${pkgs.librespot}/bin/librespot --name 'Z9 Hauptraum' --device-type speaker --bitrate 320 --enable-volume-normalisation --disable-audio-cache --disable-credential-cache --quiet"; + User = "librespot"; + Group = "librespot"; + }; + wantedBy = [ "multi-user.target" ]; + }; + + users = { + users.librespot = { + isSystemUser = true; + group = "librespot"; + extraGroups = [ "pipewire" ]; + }; + groups.librespot = { }; + }; +}