summaryrefslogtreecommitdiff
path: root/modules/services/mopidy.nix
blob: b1a71512d8e49125d44161d8451225dd426031cc (plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
{ config, lib, pkgs, ... }:

with lib;

let

  cfg = config.services.mopidy;

in

{
  options = {
    services.mopidy = {

      enable = mkOption {
        type = types.bool;
        default = false;
        description = "Whether to enable the Mopidy Daemon.";
      };

      package = mkOption {
        type = types.path;
        default = pkgs.mopidy;
        description = "This option specifies the mopidy package to use.";
      };

      mediakeys = {
        enable = mkOption {
          type = types.bool;
          default = false;
          description = "Whether to enable the Mopidy OSX Media Keys support daemon.";
        };
        package = mkOption {
          type = types.path;
          default = pkgs.pythonPackages.osxmpdkeys;
          description = "This option specifies the mediakeys package to use.";
        };
      };

    };
  };

  config = mkMerge [
    (mkIf cfg.enable {
      launchd.user.agents.mopidy = {
        serviceConfig.Program = "${cfg.package}/bin/mopidy";
        serviceConfig.RunAtLoad = true;
        serviceConfig.KeepAlive = true;
      };
    })
    (mkIf cfg.mediakeys.enable {
      launchd.user.agents.mopidymediakeys = {
        serviceConfig.Program = "${cfg.package}/bin/mpdkeys";
        serviceConfig.RunAtLoad = true;
        serviceConfig.KeepAlive = true;
      };
    })
  ];
}