From a4afd525cb9ab90b71977142489ac154a701b7d0 Mon Sep 17 00:00:00 2001 From: Kirill Elagin Date: Sun, 20 Sep 2020 17:38:46 -0400 Subject: [PATCH] prometheus: Unbreak IPv6 listenAddress The format of the listenAddress option was recently changed to separate the address and the port parts. There is now a legacy check that tells users to update to the new format. This legacy check produces a false positive on IPv6 addresses, since they contain colons. Fix the regex to make it not match colons within IPv6 addresses. --- nixos/modules/services/monitoring/prometheus/default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/monitoring/prometheus/default.nix b/nixos/modules/services/monitoring/prometheus/default.nix index d7e06484b69289..bfd4951ef48adc 100644 --- a/nixos/modules/services/monitoring/prometheus/default.nix +++ b/nixos/modules/services/monitoring/prometheus/default.nix @@ -629,7 +629,9 @@ in { config = mkIf cfg.enable { assertions = [ ( let - legacy = builtins.match "(.*):(.*)" cfg.listenAddress; + # Match something with dots (an IPv4 address) or something ending in + # a square bracket (an IPv6 addresses) followed by a port number. + legacy = builtins.match "(.*\\..*|.*]):([[:digit:]]+)" cfg.listenAddress; in { assertion = legacy == null; message = ''