From 29bdb29ab29bc50c90b91de29e982401e8a16328 Mon Sep 17 00:00:00 2001 From: Andreas Fuchs Date: Tue, 28 Apr 2026 11:19:07 -0400 Subject: [PATCH] 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. --- nixos/modules/services/monitoring/vmalert.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/monitoring/vmalert.nix b/nixos/modules/services/monitoring/vmalert.nix index 0baaa039e395..6dc6a6dc6043 100644 --- a/nixos/modules/services/monitoring/vmalert.nix +++ b/nixos/modules/services/monitoring/vmalert.nix @@ -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;