47 lines
1.5 KiB
Nix
47 lines
1.5 KiB
Nix
{pkgs, lib, config, ...}:
|
|
with lib;
|
|
{
|
|
options.services.vector = {
|
|
enable = mkEnableOption "Enable the vector agent";
|
|
settings = mkOption {
|
|
description = "Settings for the vector agent";
|
|
default = {
|
|
data_dir = "/var/lib/vector";
|
|
};
|
|
defaultText = "{}";
|
|
};
|
|
stdoutPath = mkOption {
|
|
default = "/var/log/vector.out.log";
|
|
};
|
|
stderrPath = mkOption {
|
|
default = "/var/log/vector.out.log";
|
|
};
|
|
pidPath = mkOption {
|
|
default = "/var/log/vector.pid";
|
|
};
|
|
};
|
|
|
|
config = {
|
|
environment.etc."vector.yaml" = mkIf config.services.vector.enable {
|
|
text = (generators.toYAML {} config.services.vector.settings);
|
|
};
|
|
|
|
launchd.daemons.vector = mkIf config.services.vector.enable {
|
|
serviceConfig = {
|
|
ProgramArguments = [
|
|
"${pkgs.clio}/bin/clio"
|
|
"--out-path=${config.services.vector.stdoutPath}"
|
|
"--err-path=${config.services.vector.stderrPath}"
|
|
"--pid-file=${config.services.vector.pidPath}"
|
|
"--"
|
|
"${pkgs.vector}/bin/vector"
|
|
"--watch-config"
|
|
"--config=/etc/${config.environment.etc."vector.yaml".target}"
|
|
];
|
|
KeepAlive = true;
|
|
RunAtLoad = true;
|
|
};
|
|
};
|
|
};
|
|
}
|