mirror of
https://github.com/kmein/niveum
synced 2026-03-16 18:21:07 +01:00
fix(mpd): integrate di.fm secret into playlist
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
mukkeMountPoint = "/mnt/mukke";
|
mukkeMountPoint = "/mnt/mukke";
|
||||||
|
|
||||||
streams = import ../../lib/streams.nix {
|
streams = import ../../lib/streams.nix {
|
||||||
di-fm-key = ""; # TODO lib.strings.fileContents <secrets/di.fm/key>;
|
di-fm-key = "%DI_FM_KEY%"; # TODO lib.strings.fileContents <secrets/di.fm/key>;
|
||||||
};
|
};
|
||||||
multi-room-audio-port = 8000;
|
multi-room-audio-port = 8000;
|
||||||
in {
|
in {
|
||||||
@@ -61,6 +61,17 @@ in {
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
systemd.tmpfiles.rules = [
|
||||||
|
(tmpfilesConfig {
|
||||||
|
type = "L+";
|
||||||
|
mode = "0644";
|
||||||
|
user = "mpd";
|
||||||
|
group = "mpd";
|
||||||
|
path = "${config.services.mpd.musicDirectory}/mukke";
|
||||||
|
argument = mukkeMountPoint;
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
environment.systemPackages = [pkgs.mpc_cli];
|
environment.systemPackages = [pkgs.mpc_cli];
|
||||||
|
|
||||||
networking.firewall = let
|
networking.firewall = let
|
||||||
@@ -82,41 +93,44 @@ in {
|
|||||||
extraStopCommands = firewall.removeRules rules;
|
extraStopCommands = firewall.removeRules rules;
|
||||||
};
|
};
|
||||||
|
|
||||||
# to reset:
|
systemd.services.mpd-playlists = {
|
||||||
# ssh zaatar 'rm /var/lib/mpd/playlists/*.m3u && systemd-tmpfiles --create'
|
before = ["mpd.service"];
|
||||||
systemd.tmpfiles.rules = let
|
wantedBy = ["mpd.service"];
|
||||||
tags = lib.lists.unique (lib.concatMap ({tags ? [], ...}: tags) streams);
|
script = let
|
||||||
tagStreams = tag: lib.filter ({tags ? [], ...}: lib.elem tag tags) streams;
|
tags = lib.lists.unique (lib.concatMap ({tags ? [], ...}: tags) streams);
|
||||||
makePlaylist = name: streams: pkgs.writeText "${name}.m3u" (lib.concatMapStringsSep "\n" (lib.getAttr "stream") streams);
|
tagStreams = tag: lib.filter ({tags ? [], ...}: lib.elem tag tags) streams;
|
||||||
in
|
makePlaylist = name: streams: pkgs.writeText "${name}.m3u" (lib.concatMapStringsSep "\n" (lib.getAttr "stream") streams);
|
||||||
map (tag:
|
playlistDirectory = pkgs.linkFarm "playlists" (
|
||||||
tmpfilesConfig {
|
[
|
||||||
type = "L+";
|
{
|
||||||
path = "/var/lib/mpd/playlists/${tag}.m3u";
|
name = "all.m3u";
|
||||||
mode = "0644";
|
path = makePlaylist "all" streams;
|
||||||
user = "mpd";
|
}
|
||||||
group = "mpd";
|
]
|
||||||
argument = makePlaylist tag (tagStreams tag);
|
++ map (tag: {
|
||||||
})
|
name = "${tag}.m3u";
|
||||||
tags
|
path = makePlaylist tag (tagStreams tag);
|
||||||
++ [
|
})
|
||||||
(tmpfilesConfig {
|
tags
|
||||||
type = "L+";
|
);
|
||||||
mode = "0644";
|
playlistDirectoryPath = "/var/lib/mpd/playlists";
|
||||||
user = "mpd";
|
in ''
|
||||||
group = "mpd";
|
export DI_FM_KEY="$(cat "$CREDENTIALS_DIRECTORY/di-fm-key")"
|
||||||
path = "/var/lib/mpd/playlists/all.m3u";
|
|
||||||
argument = makePlaylist "all" streams;
|
rm -rf ${playlistDirectoryPath}
|
||||||
})
|
mkdir ${playlistDirectoryPath}
|
||||||
(tmpfilesConfig {
|
|
||||||
type = "L+";
|
for m3u in $(ls ${playlistDirectory})
|
||||||
mode = "0644";
|
do
|
||||||
user = "mpd";
|
${pkgs.gnused}/bin/sed s/%DI_FM_KEY%/"$DI_FM_KEY"/g ${playlistDirectory}/"$m3u" > ${playlistDirectoryPath}/"$(basename "$m3u")"
|
||||||
group = "mpd";
|
done
|
||||||
path = "${config.services.mpd.musicDirectory}/mukke";
|
'';
|
||||||
argument = mukkeMountPoint;
|
serviceConfig = {
|
||||||
})
|
LoadCredential = [
|
||||||
];
|
"di-fm-key:${config.age.secrets.di-fm-key.path}"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
services.ympd = {
|
services.ympd = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user