From 11f226d19dd1524fa4a4c16c8075c69889b05875 Mon Sep 17 00:00:00 2001 From: weriomat Date: Mon, 14 Jul 2025 16:38:04 +0200 Subject: [PATCH] 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). (cherry picked from commit 6b4ce1ee231c408f467b3f3efd6c31533d483c44) --- nixos/modules/services/logging/vector.nix | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/nixos/modules/services/logging/vector.nix b/nixos/modules/services/logging/vector.nix index 5e5d4efd1630..057754c5d0aa 100644 --- a/nixos/modules/services/logging/vector.nix +++ b/nixos/modules/services/logging/vector.nix @@ -6,7 +6,6 @@ }: let cfg = config.services.vector; - in { options.services.vector = { @@ -31,6 +30,14 @@ in ''; }; + 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 = { }; @@ -53,7 +60,7 @@ in let format = pkgs.formats.toml { }; conf = format.generate "vector.toml" cfg.settings; - validateConfig = + validatedConfig = file: pkgs.runCommand "validate-vector-conf" { @@ -65,7 +72,9 @@ in ''; in { - ExecStart = "${lib.getExe cfg.package} --config ${validateConfig conf} --graceful-shutdown-limit-secs ${builtins.toString cfg.gracefulShutdownLimitSecs}"; + 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";