about summary refs log tree commit diff
path: root/nixos/modules/services/misc/mesos-slave.nix
blob: d89531f7e909c0ea63560661c8e7469a2d99925f (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.services.mesos.slave;

in {

  options.services.mesos = {
    slave = {
      enable = mkOption {
        description = "Whether to enable the Mesos Slave.";
        default = false;
        type = types.uniq types.bool;
      };

      port = mkOption {
        description = "Mesos Slave port";
        default = 5051;
        type = types.int;
      };

      master = mkOption {
        description = ''
          May be one of:
            zk://host1:port1,host2:port2,.../path
            zk://username:password@host1:port1,host2:port2,.../path
        '';
        type = types.str;
      };

      withHadoop = mkOption {
	description = "Add the HADOOP_HOME to the slave.";
	default = false;
	type = types.bool;
      };

      workDir = mkOption {
        description = "The Mesos work directory.";
        default = "/var/lib/mesos/slave";
        type = types.str;
      };

      extraCmdLineOptions = mkOption {
        description = ''
	  Extra command line options for Mesos Slave.

	  See https://mesos.apache.org/documentation/latest/configuration/
	'';
        default = [ "" ];
        type = types.listOf types.string;
        example = [ "--gc_delay=3days" ];
      };

      logLevel = mkOption {
        description = ''
          The logging level used. Possible values:
            'INFO', 'WARNING', 'ERROR'
        '';
        default = "INFO";
        type = types.str;
      };

    };

  };


  config = mkIf cfg.enable {
    systemd.services.mesos-slave = {
      description = "Mesos Slave";
      wantedBy = [ "multi-user.target" ];
      after = [ "network-interfaces.target" ];
      environment.MESOS_CONTAINERIZERS = "docker,mesos";
      serviceConfig = {
	ExecStart = ''
	  ${pkgs.mesos}/bin/mesos-slave \
	    --port=${toString cfg.port} \
	    --master=${cfg.master} \
	    ${optionalString cfg.withHadoop "--hadoop-home=${pkgs.hadoop}"} \
	    --work_dir=${cfg.workDir} \
	    --logging_level=${cfg.logLevel} \
	    --docker=${pkgs.docker}/libexec/docker/docker \
	    ${toString cfg.extraCmdLineOptions}
	'';
	PermissionsStartOnly = true;
      };
      preStart = ''
	mkdir -m 0700 -p ${cfg.workDir}
      '';
    };
  };

}