nixfiles/hosts/hetzner-vm/profiles/mpd.nix

71 lines
1.9 KiB
Nix
Raw Normal View History

{ config, pkgs, lib, tree, ... }:
2022-11-02 12:24:55 +00:00
let
ports = (import ../ports.nix { });
secrets = config.services.secrets.secrets;
2022-11-02 12:24:55 +00:00
in {
2022-01-25 12:15:56 +00:00
environment.systemPackages = with pkgs; [ mpc_cli ];
2022-01-23 10:30:56 +00:00
services.mpd = {
enable = true;
network.listenAddress = "0.0.0.0";
2022-11-02 16:04:43 +00:00
musicDirectory = "https://storage-webdav.owo.monster/music_ro/";
2022-01-23 10:30:56 +00:00
credentials = [{
passwordFile = "${secrets.mpd_control_password.path}";
2022-01-23 10:30:56 +00:00
permissions = [ "read" "add" "control" "admin" ];
}];
extraConfig = ''
host_permissions "127.0.0.1 read,add,control,admin"
2022-02-06 08:29:02 +00:00
samplerate_converter "0"
metadata_to_use "title,artist"
auto_update "yes"
audio_buffer_size "4096"
2022-11-02 11:32:03 +00:00
replaygain "track"
2022-01-23 10:30:56 +00:00
audio_output_format "44100:16:2"
audio_output {
type "httpd"
2022-02-08 11:30:06 +00:00
name "HTTP Opus"
2022-01-23 10:30:56 +00:00
encoder "opus"
2022-11-02 12:24:55 +00:00
port "${toString ports.mpd-opus}"
2022-02-06 08:29:02 +00:00
bitrate "96000"
format "44100:16:2"
2022-01-23 10:30:56 +00:00
always_on "yes"
tags "yes"
2022-02-13 13:57:39 +00:00
signal "music"
packet_loss "5"
2022-01-23 10:30:56 +00:00
}
2022-02-08 11:30:06 +00:00
audio_output {
type "httpd"
name "HTTP FLAC"
encoder "flac"
2022-11-02 12:24:55 +00:00
port "${toString ports.mpd-flac}"
2022-02-08 11:30:06 +00:00
format "44100:16:2"
always_on "yes"
tags "yes"
}
2022-01-23 10:30:56 +00:00
'';
};
services.nginx.virtualHosts."stream.owo.monster" = {
forceSSL = true;
enableACME = true;
locations = {
"/" = {
2022-11-02 12:24:55 +00:00
proxyPass = "http://127.0.0.1:${toString ports.mpd-opus}";
extraConfig = ''
auth_basic "Music Password";
auth_basic_user_file ${secrets.music_stream_passwd.path};
'';
};
2022-02-08 11:30:06 +00:00
"/flac" = {
2022-11-02 12:24:55 +00:00
proxyPass = "http://127.0.0.1:${toString ports.mpd-flac}";
2022-02-08 11:30:06 +00:00
extraConfig = ''
auth_basic "Music Password";
auth_basic_user_file ${secrets.music_stream_passwd.path};
2022-02-08 11:30:06 +00:00
'';
};
};
2022-01-23 10:30:56 +00:00
};
networking.firewall.allowedTCPPorts = [ 6600 ];
2022-02-15 11:04:08 +00:00
}