feat(hass): setup a working SpotifyPlus
All checks were successful
Discord / discord commits (push) Has been skipped
All checks were successful
Discord / discord commits (push) Has been skipped
This commit is contained in:
parent
b25ff8dd9a
commit
b3f2dab52b
4 changed files with 50 additions and 39 deletions
|
@ -36,6 +36,7 @@ in {
|
|||
|
||||
extraComponents = [
|
||||
"mpd"
|
||||
"sonos"
|
||||
|
||||
# BT components
|
||||
"ibeacon"
|
||||
|
|
|
@ -48,7 +48,9 @@
|
|||
enable = true;
|
||||
|
||||
extraComponents = [
|
||||
"androidtv_remote"
|
||||
"caldav"
|
||||
"cast"
|
||||
"holiday"
|
||||
"isal"
|
||||
"met"
|
||||
|
|
|
@ -3,7 +3,10 @@
|
|||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
}: let
|
||||
inherit (lib) getExe;
|
||||
inherit (config.vars) mainUser;
|
||||
in {
|
||||
hardware.bluetooth = {
|
||||
enable = true;
|
||||
powerOnBoot = true;
|
||||
|
@ -19,10 +22,17 @@
|
|||
};
|
||||
};
|
||||
|
||||
# Have pulseaudio.service itself start at boot but after bluetooth
|
||||
# Have pulseaudio and spotifyd start at boot but after bluetooth
|
||||
# so bluetooth accepts sound connections from the start.
|
||||
systemd.user.services.pulseaudio.after = ["bluetooth.service"];
|
||||
systemd.user.targets.default.wants = ["pulseaudio.service"];
|
||||
users.users.${mainUser}.linger = true;
|
||||
systemd.user.services = {
|
||||
pulseaudio.after = ["bluetooth.service"];
|
||||
spotifyd.after = ["pulseaudio.service"];
|
||||
};
|
||||
systemd.user.targets.default.wants = [
|
||||
"pulseaudio.service"
|
||||
"spotifyd.service"
|
||||
];
|
||||
|
||||
# Allow pulseaudio to be managed by MPD
|
||||
hardware.pulseaudio = {
|
||||
|
@ -58,40 +68,38 @@
|
|||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
spotifyd = {
|
||||
enable = true;
|
||||
home-manager.users.${mainUser}.services.spotifyd = {
|
||||
enable = true;
|
||||
|
||||
settings.global = let
|
||||
cacheDir = "/etc/spotifyd";
|
||||
in {
|
||||
device_name = config.networking.hostName + " connect";
|
||||
device_type = "speaker";
|
||||
package = pkgs.spotifyd.override {
|
||||
withMpris = false;
|
||||
withKeyring = false;
|
||||
};
|
||||
|
||||
zeroconf_port = 33798;
|
||||
cache_path = cacheDir;
|
||||
username_cmd = "${lib.getExe pkgs.jq} -r .username ${cacheDir}/credentials.json";
|
||||
settings.global = {
|
||||
device_name = config.networking.hostName + " connect";
|
||||
device_type = "speaker";
|
||||
|
||||
autoplay = false;
|
||||
backend = "pulseaudio";
|
||||
bitrate = 320;
|
||||
no_audio_cache = true;
|
||||
volume_normalisation = false;
|
||||
};
|
||||
zeroconf_port = 33798;
|
||||
|
||||
autoplay = false;
|
||||
backend = "pulseaudio";
|
||||
bitrate = 320;
|
||||
no_audio_cache = true;
|
||||
volume_normalisation = false;
|
||||
};
|
||||
};
|
||||
|
||||
environment.etc."spotifyd/credentials.json" = {
|
||||
source = config.sops.secrets.spotifyd.path;
|
||||
};
|
||||
|
||||
nixpkgs.overlays = [
|
||||
(final: prev: {
|
||||
# FIXME: remove this if https://github.com/NixOS/nixpkgs/pull/342913 is merged
|
||||
spotifyd = prev.spotifyd.override {
|
||||
withMpris = false;
|
||||
withKeyring = false;
|
||||
};
|
||||
})
|
||||
];
|
||||
systemd.services.home-assistant.preStart = let
|
||||
WorkingDirectory = "/var/lib/hass";
|
||||
creds = config.sops.secrets.spotifyd.path;
|
||||
in
|
||||
getExe (pkgs.writeShellApplication {
|
||||
name = "spotify-plus-creds";
|
||||
text = ''
|
||||
cp -f ${creds} ${WorkingDirectory}/.storage/SpotifyWebApiPython_librespot_credentials.json
|
||||
'';
|
||||
});
|
||||
}
|
||||
|
|
12
flake.lock
generated
12
flake.lock
generated
|
@ -1872,11 +1872,11 @@
|
|||
"spotifyplus-src": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1727276581,
|
||||
"narHash": "sha256-6fMuJ5g0SbHqm84fYoOuP2zJ6/c7rLAC6ltpGR2eOHo=",
|
||||
"lastModified": 1727556884,
|
||||
"narHash": "sha256-HBGGB9MtQlOzQxN39bUzWl9+iElAc6HJHeisfGqaLLE=",
|
||||
"owner": "thlucas1",
|
||||
"repo": "homeassistantcomponent_spotifyplus",
|
||||
"rev": "dbc279fd3466b5aebc82dea3c49f9ad175c83985",
|
||||
"rev": "f017285d88405749a0c21da14dff7dae6e46f39c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -1888,11 +1888,11 @@
|
|||
"spotifywebapi-src": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1727382400,
|
||||
"narHash": "sha256-meoiGg2CbAjvjIM7L0OW19Y2w9q4+or+JjhTXdLLebM=",
|
||||
"lastModified": 1727551631,
|
||||
"narHash": "sha256-Dj9cQ/Zm9Th0QnQV+2Q/+8sc3LwywAAIMPv8ZKOkr7M=",
|
||||
"owner": "thlucas1",
|
||||
"repo": "SpotifyWebApiPython",
|
||||
"rev": "092a1cf17dae9a9c7f62b5dc3616fe807115636f",
|
||||
"rev": "9f5ea3dcadc531dfdbf6b6f9ecea58e3b3094494",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
Loading…
Add table
Reference in a new issue