You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
2.3 KiB
Nix
97 lines
2.3 KiB
Nix
2 years ago
|
{ config
|
||
|
, lib
|
||
|
, pkgs
|
||
|
, ...
|
||
|
}:
|
||
|
let
|
||
1 month ago
|
cfg = config.services.openbao;
|
||
2 years ago
|
settingsFormat = pkgs.formats.json { };
|
||
2 years ago
|
|
||
|
autoAuthMethodModule = lib.types.submodule {
|
||
|
freeformType = lib.types.attrsOf lib.types.unspecified;
|
||
|
|
||
|
options = {
|
||
|
type = lib.mkOption {
|
||
|
type = lib.types.str;
|
||
|
};
|
||
|
|
||
|
config = lib.mkOption {
|
||
|
type = lib.types.attrsOf lib.types.unspecified;
|
||
|
};
|
||
|
};
|
||
|
};
|
||
|
|
||
|
autoAuthModule = lib.types.submodule {
|
||
|
freeformType = lib.types.attrsOf lib.types.unspecified;
|
||
|
|
||
|
options = {
|
||
|
method = lib.mkOption {
|
||
|
type = lib.types.listOf autoAuthMethodModule;
|
||
2 years ago
|
default = [ ];
|
||
2 years ago
|
};
|
||
|
};
|
||
|
};
|
||
|
|
||
|
templateConfigModule = lib.types.submodule {
|
||
|
freeformType = lib.types.attrsOf lib.types.unspecified;
|
||
|
|
||
|
options = {
|
||
|
exit_on_retry_failure = lib.mkOption {
|
||
|
type = lib.types.bool;
|
||
|
default = true;
|
||
|
};
|
||
|
};
|
||
|
};
|
||
|
|
||
|
agentConfigType = lib.types.submodule {
|
||
|
freeformType = lib.types.attrsOf lib.types.unspecified;
|
||
|
|
||
|
options = {
|
||
|
auto_auth = lib.mkOption {
|
||
|
type = autoAuthModule;
|
||
2 years ago
|
default = { };
|
||
2 years ago
|
};
|
||
|
|
||
|
template_config = lib.mkOption {
|
||
|
type = templateConfigModule;
|
||
2 years ago
|
default = { };
|
||
2 years ago
|
};
|
||
|
};
|
||
|
};
|
||
2 years ago
|
in
|
||
|
{
|
||
1 month ago
|
options.services.openbao.agents = lib.mkOption {
|
||
2 years ago
|
default = { };
|
||
1 month ago
|
description = "Instances of openbao agent";
|
||
2 years ago
|
type = lib.types.attrsOf (lib.types.submodule {
|
||
|
options = {
|
||
|
settings = lib.mkOption {
|
||
|
description = "agent configuration";
|
||
|
type = agentConfigType;
|
||
|
};
|
||
|
};
|
||
|
});
|
||
|
};
|
||
|
config = {
|
||
2 years ago
|
systemd.services = lib.mapAttrs'
|
||
|
(name: instanceCfg:
|
||
1 month ago
|
lib.nameValuePair "openbao-agent-${name}" {
|
||
2 years ago
|
after = [ "network.target" ];
|
||
|
wantedBy = [ "multi-user.target" ];
|
||
2 years ago
|
|
||
2 years ago
|
# Services that also have `stopIfChanged = false` might wait for secrets
|
||
|
# while `vault-agent` is still stopped. This for example happens with nginx.service.
|
||
2 years ago
|
|
||
2 years ago
|
stopIfChanged = false;
|
||
|
# Needs getent in PATH
|
||
1 year ago
|
path = [ pkgs.getent ];
|
||
2 years ago
|
serviceConfig = {
|
||
|
Restart = "on-failure";
|
||
1 month ago
|
# TODO: cfg.package
|
||
|
ExecStart = "${lib.getExe pkgs.openbao} agent -config=${settingsFormat.generate "agent.json" instanceCfg.settings}";
|
||
2 years ago
|
};
|
||
|
})
|
||
|
cfg.agents;
|
||
2 years ago
|
};
|
||
|
}
|