nixos/vector: add option to disable the configuration validation

Currently, during built time the configuration gets checked by vector.
This can be a problem if [environment
variables](https://vector.dev/docs/reference/environment_variables/) are
interpolated into the configuration. In this case the validation can be
disabled. This came up in trying to find a solution for
[#377889](https://github.com/NixOS/nixpkgs/issues/377889).

weriomat 6b4ce1ee 9fab35aa

Changed files
+12 -3
nixos
modules
services
logging
+12 -3
nixos/modules/services/logging/vector.nix
···
}:
let
cfg = config.services.vector;
-
in
{
options.services.vector = {
···
'';
};
settings = lib.mkOption {
type = (pkgs.formats.json { }).type;
default = { };
···
let
format = pkgs.formats.toml { };
conf = format.generate "vector.toml" cfg.settings;
-
validateConfig =
file:
pkgs.runCommand "validate-vector-conf"
{
···
'';
in
{
-
ExecStart = "${lib.getExe cfg.package} --config ${validateConfig conf} --graceful-shutdown-limit-secs ${builtins.toString cfg.gracefulShutdownLimitSecs}";
DynamicUser = true;
Restart = "always";
StateDirectory = "vector";
···
}:
let
cfg = config.services.vector;
in
{
options.services.vector = {
···
'';
};
+
validateConfig = lib.mkOption {
+
type = lib.types.bool;
+
default = true;
+
description = ''
+
Enable the checking of the vector config during build time. This should be disabled when interpolating environment variables.
+
'';
+
};
+
settings = lib.mkOption {
type = (pkgs.formats.json { }).type;
default = { };
···
let
format = pkgs.formats.toml { };
conf = format.generate "vector.toml" cfg.settings;
+
validatedConfig =
file:
pkgs.runCommand "validate-vector-conf"
{
···
'';
in
{
+
ExecStart = "${lib.getExe cfg.package} --config ${
+
if cfg.validateConfig then (validatedConfig conf) else conf
+
} --graceful-shutdown-limit-secs ${builtins.toString cfg.gracefulShutdownLimitSecs}";
DynamicUser = true;
Restart = "always";
StateDirectory = "vector";