mpd: server stream + remote clients over tunnel

This commit is contained in:
4DBug committed 2026-10-18 10:37:45 -05:00
1 parent 73a0527a33
commit 0ff70fc78c
3 files changed
+93 -35

No files matched your search

+32 -30
View File
@@ -1,41 +1,43 @@
{
# MPD on the server: plays ~/Music into an Opus HTTP stream, no local speakers.
# music.<domain> = audio stream, mpd.<domain> = MPD protocol (via `cloudflared access tcp` on clients).
# Password: ~/.config/mpd/password (same file on every device, chmod 600).
den.aspects.services.mpd = {
homeManager = {
services.mpd-mpris.enable = true;
};
tunnel = [
{ subdomain = "music"; port = 8000; }
{ subdomain = "mpd"; port = 6600; scheme = "tcp"; }
];
nixos = { host, config, ... }: let user = host.owner; home = config.users.users.${user}.home; in {
services = {
mpd = {
enable = true;
services.mpd = {
enable = true;
inherit user;
settings = {
music_directory = "${home}/Music";
credentials = [{
passwordFile = "${home}/.config/mpd/password";
permissions = [ "read" "add" "control" "admin" ];
}];
decoder = [
{
plugin = "ffmpeg";
enabled = "yes";
}
{
plugin = "opus";
enabled = "no";
}
];
settings = {
music_directory = "${home}/Music";
audio_output = [{
type = "pipewire";
name = "PipeWire Sound Server";
}];
};
decoder = [
{ plugin = "ffmpeg"; enabled = "yes"; }
{ plugin = "opus"; enabled = "no"; }
];
inherit user;
};
};
systemd.services = {
mpd.environment = {
XDG_RUNTIME_DIR = "/run/user/1000";
audio_output = [{
type = "httpd";
name = "stream";
encoder = "opus";
bitrate = "128000";
format = "48000:16:2";
bind_to_address = "127.0.0.1";
port = "8000";
always_on = "yes";
tags = "yes";
max_clients = "0";
}];
};
};
};