]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - nixops/modules/mpd/default.nix
Move diaspora to new secrets
[perso/Immae/Config/Nix.git] / nixops / modules / mpd / default.nix
index d59a34cd0b5048858e6e025d1b2ffcbcca6b47b8..2cf37adfe6b9be5fd8e840495daaf32c0d6ab4bd 100644 (file)
@@ -1,20 +1,34 @@
 { lib, pkgs, config, myconfig, mylibs, ... }:
 {
   config = {
+    nixpkgs.overlays = [ (self: super: rec {
+      mpd = (self.callPackage ./mpd.nix {}).mpd;
+    }) ];
     deployment.keys = {
       mpd = {
         permissions = "0400";
         text = myconfig.env.mpd.password;
       };
+      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 "/run/keys/mpd-config"
         audio_output {
           type            "null"
           name            "No Output"
@@ -24,8 +38,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"
         }
@@ -33,8 +46,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"
         }