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 44 additions and 33 deletions
|
@ -36,6 +36,7 @@ in {
|
||||||
|
|
||||||
extraComponents = [
|
extraComponents = [
|
||||||
"mpd"
|
"mpd"
|
||||||
|
"sonos"
|
||||||
|
|
||||||
# BT components
|
# BT components
|
||||||
"ibeacon"
|
"ibeacon"
|
||||||
|
|
|
@ -48,7 +48,9 @@
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
extraComponents = [
|
extraComponents = [
|
||||||
|
"androidtv_remote"
|
||||||
"caldav"
|
"caldav"
|
||||||
|
"cast"
|
||||||
"holiday"
|
"holiday"
|
||||||
"isal"
|
"isal"
|
||||||
"met"
|
"met"
|
||||||
|
|
|
@ -3,7 +3,10 @@
|
||||||
lib,
|
lib,
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}: {
|
}: let
|
||||||
|
inherit (lib) getExe;
|
||||||
|
inherit (config.vars) mainUser;
|
||||||
|
in {
|
||||||
hardware.bluetooth = {
|
hardware.bluetooth = {
|
||||||
enable = true;
|
enable = true;
|
||||||
powerOnBoot = 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.
|
# so bluetooth accepts sound connections from the start.
|
||||||
systemd.user.services.pulseaudio.after = ["bluetooth.service"];
|
users.users.${mainUser}.linger = true;
|
||||||
systemd.user.targets.default.wants = ["pulseaudio.service"];
|
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
|
# Allow pulseaudio to be managed by MPD
|
||||||
hardware.pulseaudio = {
|
hardware.pulseaudio = {
|
||||||
|
@ -58,19 +68,21 @@
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
spotifyd = {
|
home-manager.users.${mainUser}.services.spotifyd = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
settings.global = let
|
package = pkgs.spotifyd.override {
|
||||||
cacheDir = "/etc/spotifyd";
|
withMpris = false;
|
||||||
in {
|
withKeyring = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
settings.global = {
|
||||||
device_name = config.networking.hostName + " connect";
|
device_name = config.networking.hostName + " connect";
|
||||||
device_type = "speaker";
|
device_type = "speaker";
|
||||||
|
|
||||||
zeroconf_port = 33798;
|
zeroconf_port = 33798;
|
||||||
cache_path = cacheDir;
|
|
||||||
username_cmd = "${lib.getExe pkgs.jq} -r .username ${cacheDir}/credentials.json";
|
|
||||||
|
|
||||||
autoplay = false;
|
autoplay = false;
|
||||||
backend = "pulseaudio";
|
backend = "pulseaudio";
|
||||||
|
@ -79,19 +91,15 @@
|
||||||
volume_normalisation = false;
|
volume_normalisation = false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
environment.etc."spotifyd/credentials.json" = {
|
systemd.services.home-assistant.preStart = let
|
||||||
source = config.sops.secrets.spotifyd.path;
|
WorkingDirectory = "/var/lib/hass";
|
||||||
};
|
creds = config.sops.secrets.spotifyd.path;
|
||||||
|
in
|
||||||
nixpkgs.overlays = [
|
getExe (pkgs.writeShellApplication {
|
||||||
(final: prev: {
|
name = "spotify-plus-creds";
|
||||||
# FIXME: remove this if https://github.com/NixOS/nixpkgs/pull/342913 is merged
|
text = ''
|
||||||
spotifyd = prev.spotifyd.override {
|
cp -f ${creds} ${WorkingDirectory}/.storage/SpotifyWebApiPython_librespot_credentials.json
|
||||||
withMpris = false;
|
'';
|
||||||
withKeyring = false;
|
});
|
||||||
};
|
|
||||||
})
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
BIN
flake.lock
BIN
flake.lock
Binary file not shown.
Loading…
Reference in a new issue