{ # MPD on the server: plays ~/media/music into an Opus HTTP stream, no local speakers. # music. = audio stream, mpd. = MPD protocol (via `cloudflared access tcp` on clients). # Password: ~/.config/mpd/password (same file on every device, chmod 600). den.aspects.services.mpd = { 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; inherit user; credentials = [{ passwordFile = "${home}/.config/mpd/password"; permissions = [ "read" "add" "control" "admin" ]; }]; settings = { music_directory = "${home}/media/music"; decoder = [ { plugin = "ffmpeg"; enabled = "yes"; } { plugin = "opus"; enabled = "no"; } ]; 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"; }]; }; }; }; }; }