···
Configuration for Nomad. See the <link xlink:href="https://www.nomadproject.io/docs/configuration">documentation</link>
70
+
Notes about <literal>data_dir</literal>:
72
+
If <literal>data_dir</literal> is set to a value other than the
73
+
default value of <literal>"/var/lib/nomad"</literal> it is the Nomad
74
+
cluster manager's responsibility to make sure that this directory
75
+
exists and has the appropriate permissions.
77
+
Additionally, if <literal>dropPrivileges</literal> is
78
+
<literal>true</literal> then <literal>data_dir</literal>
79
+
<emphasis>cannot</emphasis> be customized. Setting
80
+
<literal>dropPrivileges</literal> to <literal>true</literal> enables
81
+
the <literal>DynamicUser</literal> feature of systemd which directly
82
+
manages and operates on <literal>StateDirectory</literal>.
example = literalExample ''
···
113
-
DynamicUser = cfg.dropPrivileges;
114
-
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
115
-
ExecStart = "${cfg.package}/bin/nomad agent -config=/etc/nomad.json" +
116
-
concatMapStrings (path: " -config=${path}") cfg.extraSettingsPaths;
117
-
KillMode = "process";
118
-
KillSignal = "SIGINT";
119
-
LimitNOFILE = 65536;
120
-
LimitNPROC = "infinity";
121
-
OOMScoreAdjust = -1000;
122
-
Restart = "on-failure";
124
-
# Agrees with the default `data_dir = "/var/lib/nomad"` in `settings` above.
125
-
StateDirectory = "nomad";
126
-
TasksMax = "infinity";
127
-
User = optionalString cfg.dropPrivileges "nomad";
128
-
} // (optionalAttrs cfg.enableDocker {
129
-
SupplementaryGroups = "docker"; # space-separated string
126
+
serviceConfig = mkMerge [
128
+
DynamicUser = cfg.dropPrivileges;
129
+
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
130
+
ExecStart = "${cfg.package}/bin/nomad agent -config=/etc/nomad.json" +
131
+
concatMapStrings (path: " -config=${path}") cfg.extraSettingsPaths;
132
+
KillMode = "process";
133
+
KillSignal = "SIGINT";
134
+
LimitNOFILE = 65536;
135
+
LimitNPROC = "infinity";
136
+
OOMScoreAdjust = -1000;
137
+
Restart = "on-failure";
139
+
TasksMax = "infinity";
141
+
(mkIf cfg.enableDocker {
142
+
SupplementaryGroups = "docker"; # space-separated string
144
+
(mkIf (cfg.settings.data_dir == "/var/lib/nomad") {
145
+
StateDirectory = "nomad";
StartLimitIntervalSec = 10;
157
+
assertion = cfg.dropPrivileges -> cfg.settings.data_dir == "/var/lib/nomad";
158
+
message = "settings.data_dir must be equal to \"/var/lib/nomad\" if dropPrivileges is true";
# Docker support requires the Docker daemon to be running.
virtualisation.docker.enable = mkIf cfg.enableDocker true;