about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorAnders Lundstedt <git@anderslundstedt.se>2019-07-19 22:13:06 +0200
committerAnders Lundstedt <git@anderslundstedt.se>2019-07-21 00:58:20 +0200
commit53841fcea9cbd639dfd30714e48959a9752c5818 (patch)
tree9846d39dd30e27e07a28261760b77f047ede3e9c /nixos
parente6dd87c438ede050a78b7eeb1539be1af03f4479 (diff)
downloadnixlib-53841fcea9cbd639dfd30714e48959a9752c5818.tar
nixlib-53841fcea9cbd639dfd30714e48959a9752c5818.tar.gz
nixlib-53841fcea9cbd639dfd30714e48959a9752c5818.tar.bz2
nixlib-53841fcea9cbd639dfd30714e48959a9752c5818.tar.lz
nixlib-53841fcea9cbd639dfd30714e48959a9752c5818.tar.xz
nixlib-53841fcea9cbd639dfd30714e48959a9752c5818.tar.zst
nixlib-53841fcea9cbd639dfd30714e48959a9752c5818.zip
nixos/spotifyd: init
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/services/audio/spotifyd.nix42
2 files changed, 43 insertions, 0 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index e07fabb348c0..add9483f4a5f 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -198,6 +198,7 @@
   ./services/audio/slimserver.nix
   ./services/audio/snapserver.nix
   ./services/audio/squeezelite.nix
+  ./services/audio/spotifyd.nix
   ./services/audio/ympd.nix
   ./services/backup/automysqlbackup.nix
   ./services/backup/bacula.nix
diff --git a/nixos/modules/services/audio/spotifyd.nix b/nixos/modules/services/audio/spotifyd.nix
new file mode 100644
index 000000000000..e3556b2559c2
--- /dev/null
+++ b/nixos/modules/services/audio/spotifyd.nix
@@ -0,0 +1,42 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+  cfg = config.services.spotifyd;
+  spotifydConf = pkgs.writeText "spotifyd.conf" cfg.config;
+in
+{
+  options = {
+    services.spotifyd = {
+      enable = mkEnableOption "spotifyd, a Spotify playing daemon";
+
+      config = mkOption {
+        default = "";
+        type = types.lines;
+        description = ''
+          Configuration for Spotifyd. For syntax and directives, see
+          https://github.com/Spotifyd/spotifyd#Configuration.
+        '';
+      };
+    };
+  };
+
+  config = mkIf cfg.enable {
+    systemd.services.spotifyd = {
+      wantedBy = [ "multi-user.target" ];
+      after = [ "network-online.target" "sound.target" ];
+      description = "spotifyd, a Spotify playing daemon";
+      serviceConfig = {
+        ExecStart = "${pkgs.spotifyd}/bin/spotifyd --no-daemon --cache_path /var/cache/spotifyd --config ${spotifydConf}";
+        Restart = "always";
+        RestartSec = 12;
+        DynamicUser = true;
+        CacheDirectory = "spotifyd";
+        SupplementaryGroups = ["audio"];
+      };
+    };
+  };
+
+  meta.maintainers = [ maintainers.anderslundstedt ];
+}