]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - nixops/modules/mpd/default.nix
Upgrade nextcloud to 16.0
[perso/Immae/Config/Nix.git] / nixops / modules / mpd / default.nix
index 7781b363dba7bbbaaff1b38297047e602c32537a..7c896ca92ed2eacfcb6160e33cd87617aa06b978 100644 (file)
@@ -1,14 +1,33 @@
 { lib, pkgs, config, myconfig, mylibs, ... }:
 {
   config = {
+    mySecrets.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" ];
+    users.users.mpd.extraGroups = [ "wwwrun" "keys" ];
+    system.activationScripts.mpd = ''
+      install -d -m 0755 -o mpd -g mpd /run/mpd
+      '';
     services.mpd = {
       enable = true;
       network.listenAddress = "any";
       musicDirectory = myconfig.env.mpd.folder;
       extraConfig = ''
-        password "${myconfig.env.mpd.password}@read,add,control,admin"
+        include "/var/secrets/mpd-config"
         audio_output {
           type            "null"
           name            "No Output"
@@ -18,8 +37,7 @@
           type            "httpd"
           name            "OGG"
           encoder         "vorbis"
-          port            "${myconfig.env.ports.mpd_ogg}"
-          bind_to_address "127.0.0.1"
+          bind_to_address "/run/mpd/ogg.sock"
           quality         "5.0"
           format          "44100:16:1"
         }
@@ -27,8 +45,7 @@
           type            "httpd"
           name            "MP3"
           encoder         "lame"
-          port            "${myconfig.env.ports.mpd_mp3}"
-          bind_to_address "127.0.0.1"
+          bind_to_address "/run/mpd/mp3.sock"
           quality         "5.0"
           format          "44100:16:1"
         }