Merge pull request #211559 from GTrunSec/nomad-credential

nixos/nomad: add LoadCredential option

Nick Cao c2de9858 a9d9ac98

Changed files
+14 -1
nixos
modules
services
networking
+14 -1
nixos/modules/services/networking/nomad.nix
···
'';
};
settings = mkOption {
type = format.type;
···
};
in
"${cfg.package}/bin/nomad agent -config=/etc/nomad.json -plugin-dir=${pluginsDir}/bin" +
-
concatMapStrings (path: " -config=${path}") cfg.extraSettingsPaths;
KillMode = "process";
KillSignal = "SIGINT";
LimitNOFILE = 65536;
···
Restart = "on-failure";
RestartSec = 2;
TasksMax = "infinity";
}
(mkIf cfg.enableDocker {
SupplementaryGroups = "docker"; # space-separated string
···
'';
};
+
credentials = mkOption {
+
description = lib.mdDoc ''
+
Credentials envs used to configure nomad secrets.
+
'';
+
type = types.attrsOf types.str;
+
default = { };
+
+
example = {
+
logs_remote_write_password = "/run/keys/nomad_write_password";
+
};
+
};
settings = mkOption {
type = format.type;
···
};
in
"${cfg.package}/bin/nomad agent -config=/etc/nomad.json -plugin-dir=${pluginsDir}/bin" +
+
concatMapStrings (path: " -config=${path}") cfg.extraSettingsPaths +
+
concatMapStrings (key: " -config=\${CREDENTIALS_DIRECTORY}/${key}") (lib.attrNames cfg.credentials);
KillMode = "process";
KillSignal = "SIGINT";
LimitNOFILE = 65536;
···
Restart = "on-failure";
RestartSec = 2;
TasksMax = "infinity";
+
LoadCredential = lib.mapAttrsToList (key: value: "${key}:${value}") cfg.credentials;
}
(mkIf cfg.enableDocker {
SupplementaryGroups = "docker"; # space-separated string