vmalert: Fail if encountering missing rule paths

Previously, when using toString for interpolating paths, the build process wouldn't attempt to copy the given path into the store; that would then result in hard-to-debug errors when running the vmalert service (it launches, but treats the missing as a non-issue, so you run with no alerting).

Instead, use string interpolation to resolve the file from the given path. This properly fails the build if a missing file is referenced.
This commit is contained in:
Andreas Fuchs
2026-04-28 11:23:27 -04:00
parent 315fc655f1
commit 29bdb29ab2
@@ -25,14 +25,16 @@ let
in
attrsOf (either valueType (listOf valueType));
mkCliVal = value: if isPath value then "${value}" else toString value;
mkLine =
key: value:
if value == true then
"-${key}"
else if isList value then
concatMapStringsSep " " (v: "-${key}=${escapeShellArg (toString v)}") value
concatMapStringsSep " " (v: "-${key}=${escapeShellArg (mkCliVal v)}") value
else
"-${key}=${escapeShellArg (toString value)}";
"-${key}=${escapeShellArg (mkCliVal value)}";
vmalertName = name: "vmalert" + lib.optionalString (name != "") ("-" + name);
enabledInstances = lib.filterAttrs (name: conf: conf.enable) config.services.vmalert.instances;