65 lines
2.3 KiB
Nix
65 lines
2.3 KiB
Nix
{pkgs, lib, config, ...}:
|
|
with lib;
|
|
let
|
|
mkLauncher = import ../../packages/darwin-launcher.nix { inherit pkgs; };
|
|
vectorLauncher = mkLauncher ''
|
|
exec ${pkgs.clio}/bin/clio \
|
|
--out-path=${config.services.vector.stdoutPath} \
|
|
--err-path=${config.services.vector.stdoutPath} \
|
|
--pid-file=${config.services.vector.pidPath} \
|
|
--paranoid \
|
|
-- \
|
|
${pkgs.vector}/bin/vector \
|
|
--verbose \
|
|
--watch-config \
|
|
--config=/etc/${config.environment.etc."vector.yaml".target}
|
|
'';
|
|
in
|
|
{
|
|
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 = [
|
|
"${vectorLauncher}"
|
|
];
|
|
WatchPaths= [
|
|
"/etc/${config.environment.etc."vector.yaml".target}"
|
|
];
|
|
RunAtLoad = true;
|
|
};
|
|
};
|
|
|
|
environment.etc."newsyslog.d/org.nixos.vector.conf" = mkIf config.services.vector.enable {
|
|
text = ''
|
|
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
|
|
${config.services.vector.stdoutPath} zaphar:staff 644 10 1000 * BJ ${config.services.vector.pidPath} 1
|
|
${config.services.vector.stderrPath} zaphar:staff 644 10 1000 * BJ ${config.services.vector.pidPath} 1
|
|
'';
|
|
};
|
|
};
|
|
}
|