@@ -0,0 +1,58 @@
1+{ config, lib, pkgs, ... }:
2+
3+with lib;
4+
5+let
6+
7+ cfg = config.services.marathon;
8+
9+in {
10+
11+ ###### interface
12+
13+ options.services.marathon = {
14+ enable = mkOption {
15+ description = "Whether to enable the marathon mesos framework.";
16+ default = false;
17+ type = types.uniq types.bool;
18+ };
19+
20+ httpPort = mkOption {
21+ description = "Marathon listening port";
22+ default = 8080;
23+ type = types.int;
24+ };
25+
26+ master = mkOption {
27+ description = "Marathon mesos master zookeeper address";
28+ default = "zk://${head cfg.zookeeperHosts}/mesos";
29+ type = types.str;
30+ };
31+
32+ zookeeperHosts = mkOption {
33+ description = "Marathon mesos zookepper addresses";
34+ default = [ "localhost:2181" ];
35+ type = types.listOf types.str;
36+ };
37+ };
38+
39+ ###### implementation
40+
41+ config = mkIf cfg.enable {
42+ systemd.services.marathon = {
43+ description = "Marathon Service";
44+ wantedBy = [ "multi-user.target" ];
45+ after = [ "network-interfaces.target" "zookeeper.service" "mesos-master.service" "mesos-slave.service" ];
46+
47+ serviceConfig = {
48+ ExecStart = "${pkgs.marathon}/bin/marathon --master ${cfg.master} --zk zk://${head cfg.zookeeperHosts}/marathon";
49+ User = "marathon";
50+ };
51+ };
52+
53+ users.extraUsers.marathon = {
54+ uid = config.ids.uids.marathon;
55+ description = "Marathon mesos framework user";
56+ };
57+ };
58+}