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