mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-10-06 12:39:54 +03:00
nixos/loki: skip config validation when it's impossible to validate
This is a follow-up to8d7f3c9dbd
andae48735c53
. Running the config validation in the build sandbox is impossible and will fail when using `cfg.configFile` or `-config.expand-env=true`. `cfg.configFile` is a string of a path which is simply not available to the build sandbox. Similarly, one may opt to use `cfg.configuration` with environment variables in combination with `-config.expand-env=true`. The environment variables referenced that way are also not available in the build sandbox. So we skip the validation when it's impossible (`cfg.configFile`) or likely impossible (`-config.expand-env=true`). An alternative approach would be something like nixos/prometheus' `services.prometheus.checkConfig` that takes a boolean and makes toggling the config validation user-facing.
This commit is contained in:
parent
68ead29211
commit
100c1501e1
@ -97,7 +97,12 @@ in {
|
||||
|
||||
serviceConfig = let
|
||||
conf = if cfg.configFile == null
|
||||
then prettyJSON cfg.configuration
|
||||
then
|
||||
# Config validation may fail when using extraFlags = [ "-config.expand-env=true" ].
|
||||
# To work around this, we simply skip it when extraFlags is not empty.
|
||||
if cfg.extraFlags == []
|
||||
then validateConfig (prettyJSON cfg.configuration)
|
||||
else prettyJSON cfg.configuration
|
||||
else cfg.configFile;
|
||||
validateConfig = file:
|
||||
pkgs.runCommand "validate-loki-conf" {
|
||||
@ -108,7 +113,7 @@ in {
|
||||
'';
|
||||
in
|
||||
{
|
||||
ExecStart = "${cfg.package}/bin/loki --config.file=${validateConfig conf} ${escapeShellArgs cfg.extraFlags}";
|
||||
ExecStart = "${cfg.package}/bin/loki --config.file=${conf} ${escapeShellArgs cfg.extraFlags}";
|
||||
User = cfg.user;
|
||||
Restart = "always";
|
||||
PrivateTmp = true;
|
||||
|
Loading…
Reference in New Issue
Block a user