aboutsummaryrefslogtreecommitdiff
path: root/modules/private/mpd.nix
blob: c7e24862e00ad4c038187867e8aba9fb67ba6a9f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
{ lib, pkgs, config, myconfig,  ... }:
{
  options.myServices.mpd.enable = lib.mkEnableOption "enable MPD";
  config = lib.mkIf config.myServices.mpd.enable {
    services.duplyBackup.profiles.mpd = {
      rootDir = "/var/lib/mpd";
    };
    secrets.keys = [
      {
        dest = "mpd";
        permissions = "0400";
        text = myconfig.env.mpd.password;
      }
      {
        dest = "mpd-config";
        permissions = "0400";
        user = "mpd";
        group = "mpd";
        text = ''
          password "${myconfig.env.mpd.password}@read,add,control,admin"
        '';
      }
    ];
    networking.firewall.allowedTCPPorts = [ 6600 ];
    users.users.mpd.extraGroups = [ "wwwrun" "keys" ];
    systemd.services.mpd.serviceConfig.RuntimeDirectory = "mpd";
    services.filesWatcher.mpd = {
      restart = true;
      paths = [ "/var/secrets/mpd-config" ];
    };

    services.mpd = {
      enable = true;
      network.listenAddress = "any";
      musicDirectory = myconfig.env.mpd.folder;
      extraConfig = ''
        include "/var/secrets/mpd-config"
        audio_output {
          type            "null"
          name            "No Output"
          mixer_type      "none"
        }
        audio_output {
          type            "httpd"
          name            "OGG"
          encoder         "vorbis"
          bind_to_address "/run/mpd/ogg.sock"
          quality         "5.0"
          format          "44100:16:1"
        }
        audio_output {
          type            "httpd"
          name            "MP3"
          encoder         "lame"
          bind_to_address "/run/mpd/mp3.sock"
          quality         "5.0"
          format          "44100:16:1"
        }


        '';
    };
  };
}