]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - systems/eldiron/mpd.nix
Migrate to borg backup
[perso/Immae/Config/Nix.git] / systems / eldiron / mpd.nix
CommitLineData
ab8f306d 1{ lib, pkgs, config, ... }:
e229e6f2 2{
8415083e
IB
3 options.myServices.mpd.enable = lib.mkEnableOption "enable MPD";
4 config = lib.mkIf config.myServices.mpd.enable {
4c4652aa
IB
5 secrets.keys = {
6 "mpd" = {
914dd76c 7 permissions = "0400";
ab8f306d 8 text = config.myEnv.mpd.password;
4c4652aa
IB
9 };
10 "mpd-config" = {
65e64925
IB
11 permissions = "0400";
12 user = "mpd";
13 group = "mpd";
14 text = ''
ab8f306d 15 password "${config.myEnv.mpd.password}@read,add,control,admin"
65e64925 16 '';
4c4652aa
IB
17 };
18 };
e229e6f2 19 networking.firewall.allowedTCPPorts = [ 6600 ];
65e64925 20 users.users.mpd.extraGroups = [ "wwwrun" "keys" ];
81b9ff89 21 systemd.services.mpd.serviceConfig.RuntimeDirectory = "mpd";
17f6eae9
IB
22 services.filesWatcher.mpd = {
23 restart = true;
da30ae4f 24 paths = [ config.secrets.fullPaths."mpd-config" ];
17f6eae9
IB
25 };
26
e229e6f2
IB
27 services.mpd = {
28 enable = true;
29 network.listenAddress = "any";
ab8f306d 30 musicDirectory = config.myEnv.mpd.folder;
e229e6f2 31 extraConfig = ''
da30ae4f 32 include "${config.secrets.fullPaths."mpd-config"}"
e229e6f2
IB
33 audio_output {
34 type "null"
35 name "No Output"
36 mixer_type "none"
37 }
38 audio_output {
39 type "httpd"
40 name "OGG"
41 encoder "vorbis"
9df76627 42 bind_to_address "/run/mpd/ogg.sock"
e229e6f2
IB
43 quality "5.0"
44 format "44100:16:1"
45 }
46 audio_output {
47 type "httpd"
48 name "MP3"
49 encoder "lame"
9df76627 50 bind_to_address "/run/mpd/mp3.sock"
e229e6f2
IB
51 quality "5.0"
52 format "44100:16:1"
53 }
54
55
56 '';
57 };
58 };
59}
60