52 lines
1.7 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.err.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}"
"--paranoid"
"--"
"${pkgs.vector}/bin/vector"
"--verbose"
"--watch-config"
"--config=/etc/${config.environment.etc."vector.yaml".target}"
];
WatchPaths= [
"/etc/${config.environment.etc."vector.yaml".target}"
];
KeepAlive = true;
RunAtLoad = true;
};
};
};
}