Merge pull request #118516 from happysalada/fix_vector

This commit is contained in:
Sandro 2021-04-05 02:32:23 +02:00 committed by GitHub
commit 95a5678118
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,7 +3,8 @@
with lib; with lib;
let cfg = config.services.vector; let cfg = config.services.vector;
in { in
{
options.services.vector = { options.services.vector = {
enable = mkEnableOption "Vector"; enable = mkEnableOption "Vector";
@ -37,25 +38,27 @@ in {
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
after = [ "network-online.target" ]; after = [ "network-online.target" ];
requires = [ "network-online.target" ]; requires = [ "network-online.target" ];
serviceConfig = let serviceConfig =
format = pkgs.formats.toml { }; let
conf = format.generate "vector.toml" cfg.settings; format = pkgs.formats.toml { };
validateConfig = file: conf = format.generate "vector.toml" cfg.settings;
pkgs.runCommand "validate-vector-conf" { } '' validateConfig = file:
${pkgs.vector}/bin/vector validate --no-topology --no-environment "${file}" pkgs.runCommand "validate-vector-conf" { } ''
ln -s "${file}" "$out" ${pkgs.vector}/bin/vector validate --no-environment "${file}"
''; ln -s "${file}" "$out"
in { '';
ExecStart = "${pkgs.vector}/bin/vector --config ${validateConfig conf}"; in
User = "vector"; {
Group = "vector"; ExecStart = "${pkgs.vector}/bin/vector --config ${validateConfig conf}";
Restart = "no"; User = "vector";
StateDirectory = "vector"; Group = "vector";
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; Restart = "no";
AmbientCapabilities = "CAP_NET_BIND_SERVICE"; StateDirectory = "vector";
# This group is required for accessing journald. ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
SupplementaryGroups = mkIf cfg.journaldAccess "systemd-journal"; AmbientCapabilities = "CAP_NET_BIND_SERVICE";
}; # This group is required for accessing journald.
SupplementaryGroups = mkIf cfg.journaldAccess "systemd-journal";
};
}; };
}; };
} }