]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/private/mpd.nix
Use attrs for secrets instead of lists
[perso/Immae/Config/Nix.git] / modules / private / mpd.nix
index 9903bdf0d2ba1dea3701057c740f75a7644610a3..7fa8fe9d09a62b73691729ad7ca8f2f5269f2e23 100644 (file)
@@ -1,31 +1,38 @@
-{ lib, pkgs, config, myconfig,  ... }:
+{ lib, pkgs, config,  ... }:
 {
-  config = {
-    secrets.keys = [
-      {
-        dest = "mpd";
+  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 = {
+      "mpd" = {
         permissions = "0400";
-        text = myconfig.env.mpd.password;
-      }
-      {
-        dest = "mpd-config";
+        text = config.myEnv.mpd.password;
+      };
+      "mpd-config" = {
         permissions = "0400";
         user = "mpd";
         group = "mpd";
         text = ''
-          password "${myconfig.env.mpd.password}@read,add,control,admin"
+          password "${config.myEnv.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 = [ config.secrets.fullPaths."mpd-config" ];
+    };
+
     services.mpd = {
       enable = true;
       network.listenAddress = "any";
-      musicDirectory = myconfig.env.mpd.folder;
+      musicDirectory = config.myEnv.mpd.folder;
       extraConfig = ''
-        include "/var/secrets/mpd-config"
+        include "${config.secrets.fullPaths."mpd-config"}"
         audio_output {
           type            "null"
           name            "No Output"