diff --git a/ops/nixos/lib/common.nix b/ops/nixos/lib/common.nix index fe69ead189..ae5c78c1dd 100644 --- a/ops/nixos/lib/common.nix +++ b/ops/nixos/lib/common.nix @@ -193,13 +193,19 @@ in text = '' test -d /run/prometheus-textfile-exports || mkdir /run/prometheus-textfile-exports my_version_string="$(cat "$systemConfig/nixos-version")" - echo "nixos_running_system{version=\"$my_version_string\"} 1" > /run/prometheus-textfile-exports/running_system.prom + my_hash_string="$(readlink -f "$systemConfig" | grep -Eo '\b[0-9a-df-np-sv-z]{32}\b')" + echo "nixos_running_system{version=\"$my_version_string\", hash=\"$my_hash_string\"} 1" > /run/prometheus-textfile-exports/running_system.prom + + my_version_string="$(cat "/run/booted-system/nixos-version")" + my_hash_string="$(readlink -f "/run/booted-system" | grep -Eo '\b[0-9a-df-np-sv-z]{32}\b')" + echo "nixos_booted_system{version=\"$my_version_string\", hash=\"$my_hash_string\"} 1" > /run/prometheus-textfile-exports/booted_system.prom ''; }; boot.postBootCommands = lib.mkAfter '' test -d /run/prometheus-textfile-exports || mkdir /run/prometheus-textfile-exports my_version_string="$(cat "/run/booted-system/nixos-version")" - echo "nixos_booted_system{version=\"$my_version_string\"} 1" > /run/prometheus-textfile-exports/booted_system.prom + my_hash_string="$(readlink -f "/run/booted-system" | grep -Eo '\b[0-9a-df-np-sv-z]{32}\b')" + echo "nixos_booted_system{version=\"$my_version_string\", hash=\"$my_hash_string\"} 1" > /run/prometheus-textfile-exports/booted_system.prom ''; system.nixos.tags = lib.mkBefore [