summary refs log tree commit diff
path: root/nixos/modules/services/scheduling/chronos.nix
blob: 9a8ed4c09ac1c4827544fa17574d20244a734ede (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
43
44
45
46
47
48
49
50
51
52
53
54
{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.services.chronos;

in {

  ###### interface

  options.services.chronos = {
    enable = mkOption {
      description = "Whether to enable graphite web frontend.";
      default = false;
      type = types.bool;
    };

    httpPort = mkOption {
      description = "Chronos listening port";
      default = 4400;
      type = types.int;
    };

    master = mkOption {
      description = "Chronos mesos master zookeeper address";
      default = "zk://${head cfg.zookeeperHosts}/mesos";
      type = types.str;
    };

    zookeeperHosts = mkOption {
      description = "Chronos mesos zookepper addresses";
      default = [ "localhost:2181" ];
      type = types.listOf types.str;
    };
  };

  ###### implementation

  config = mkIf cfg.enable {
    systemd.services.chronos = {
      description = "Chronos Service";
      wantedBy = [ "multi-user.target" ];
      after = [ "network.target" "zookeeper.service" ];

      serviceConfig = {
        ExecStart = "${pkgs.chronos}/bin/chronos --master ${cfg.master} --zk_hosts ${concatStringsSep "," cfg.zookeeperHosts} --http_port ${toString cfg.httpPort}";
        User = "chronos";
      };
    };

    users.users.chronos.uid = config.ids.uids.chronos;
  };
}