summary refs log tree commit diff
path: root/nixos/modules/services/audio/spotifyd.nix
blob: a589153248fe90f6293345386b763e960ee0abe3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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
          <link xlink:href="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-path ${spotifydConf}";
        Restart = "always";
        RestartSec = 12;
        DynamicUser = true;
        CacheDirectory = "spotifyd";
        SupplementaryGroups = ["audio"];
      };
    };
  };

  meta.maintainers = [ maintainers.anderslundstedt ];
}