mirror of
https://github.com/kmein/niveum
synced 2026-03-20 12:01:06 +01:00
home-assistant: remove playlists
This commit is contained in:
@@ -1,10 +1,6 @@
|
|||||||
{config, pkgs, lib, ...}: let
|
{config, pkgs, lib, ...}: let
|
||||||
port = 8123;
|
port = 8123;
|
||||||
volumeName = "home-assistant";
|
volumeName = "home-assistant";
|
||||||
streams = import ../../lib/streams.nix {
|
|
||||||
di-fm-key = "%DI_FM_KEY%"; # TODO lib.strings.fileContents <secrets/di.fm/key>;
|
|
||||||
};
|
|
||||||
playlistDirectoryPath = "/var/lib/mpd/playlists";
|
|
||||||
in {
|
in {
|
||||||
networking.firewall.allowedTCPPorts = [port];
|
networking.firewall.allowedTCPPorts = [port];
|
||||||
|
|
||||||
@@ -31,46 +27,6 @@ in {
|
|||||||
di-fm-key.file = ../../secrets/di-fm-key.age;
|
di-fm-key.file = ../../secrets/di-fm-key.age;
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services.mpd-playlists = {
|
|
||||||
before = ["podman-homeassistant.service"];
|
|
||||||
wantedBy = ["podman-homeassistant.service"];
|
|
||||||
script = let
|
|
||||||
tags = lib.lists.unique (lib.concatMap ({tags ? [], ...}: tags) streams);
|
|
||||||
tagStreams = tag: lib.filter ({tags ? [], ...}: lib.elem tag tags) streams;
|
|
||||||
makePlaylist = name: streams: pkgs.writeText "${name}.m3u" (lib.concatMapStringsSep "\n" (lib.getAttr "stream") streams);
|
|
||||||
playlistDirectory = pkgs.linkFarm "playlists" (
|
|
||||||
[
|
|
||||||
{
|
|
||||||
name = "all.m3u";
|
|
||||||
path = makePlaylist "all" streams;
|
|
||||||
}
|
|
||||||
]
|
|
||||||
++ map (tag: {
|
|
||||||
name = "${tag}.m3u";
|
|
||||||
path = makePlaylist tag (tagStreams tag);
|
|
||||||
})
|
|
||||||
tags
|
|
||||||
);
|
|
||||||
in ''
|
|
||||||
mkdir -p ${playlistDirectoryPath}
|
|
||||||
|
|
||||||
export DI_FM_KEY="$(cat "$CREDENTIALS_DIRECTORY/di-fm-key")"
|
|
||||||
|
|
||||||
rm -rf ${playlistDirectoryPath}
|
|
||||||
mkdir ${playlistDirectoryPath}
|
|
||||||
|
|
||||||
for m3u in $(ls ${playlistDirectory})
|
|
||||||
do
|
|
||||||
${pkgs.gnused}/bin/sed s/%DI_FM_KEY%/"$DI_FM_KEY"/g ${playlistDirectory}/"$m3u" > ${playlistDirectoryPath}/"$(basename "$m3u")"
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
serviceConfig = {
|
|
||||||
LoadCredential = [
|
|
||||||
"di-fm-key:${config.age.secrets.di-fm-key.path}"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
hardware.bluetooth.enable = true;
|
hardware.bluetooth.enable = true;
|
||||||
|
|
||||||
systemd.services.update-containers = {
|
systemd.services.update-containers = {
|
||||||
@@ -112,7 +68,6 @@ in {
|
|||||||
containers.homeassistant = {
|
containers.homeassistant = {
|
||||||
volumes = [
|
volumes = [
|
||||||
"${volumeName}:/config"
|
"${volumeName}:/config"
|
||||||
"${playlistDirectoryPath}:/media"
|
|
||||||
"/run/dbus:/run/dbus:ro"
|
"/run/dbus:/run/dbus:ro"
|
||||||
];
|
];
|
||||||
# needed for bluetooth
|
# needed for bluetooth
|
||||||
|
|||||||
Reference in New Issue
Block a user