@@ -0,0 +1,42 @@
1+{ config, lib, pkgs, ... }:
2+
3+with lib;
4+
5+let
6+ cfg = config.services.spotifyd;
7+ spotifydConf = pkgs.writeText "spotifyd.conf" cfg.config;
8+in
9+{
10+ options = {
11+ services.spotifyd = {
12+ enable = mkEnableOption "spotifyd, a Spotify playing daemon";
13+
14+ config = mkOption {
15+ default = "";
16+ type = types.lines;
17+ description = ''
18+ Configuration for Spotifyd. For syntax and directives, see
19+ https://github.com/Spotifyd/spotifyd#Configuration.
20+ '';
21+ };
22+ };
23+ };
24+
25+ config = mkIf cfg.enable {
26+ systemd.services.spotifyd = {
27+ wantedBy = [ "multi-user.target" ];
28+ after = [ "network-online.target" "sound.target" ];
29+ description = "spotifyd, a Spotify playing daemon";
30+ serviceConfig = {
31+ ExecStart = "${pkgs.spotifyd}/bin/spotifyd --no-daemon --cache_path /var/cache/spotifyd --config ${spotifydConf}";
32+ Restart = "always";
33+ RestartSec = 12;
34+ DynamicUser = true;
35+ CacheDirectory = "spotifyd";
36+ SupplementaryGroups = ["audio"];
37+ };
38+ };
39+ };
40+
41+ meta.maintainers = [ maintainers.anderslundstedt ];
42+}