feat: add nixos_flake_info metric with current and remote revisions

Add a new info metric that exposes the current system's flake revision
and the latest remote revision as labels. This makes it easier to see
exactly which revision is deployed vs available.

Also adds version constant to Go code and extracts it in flake.nix,
providing a single source of truth for the version.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-07 00:16:19 +01:00
parent e381038537
commit 9c29505814
5 changed files with 32 additions and 9 deletions

View File

@@ -9,6 +9,12 @@
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" ];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
# Extract version from main.go
mainGo = builtins.readFile ./main.go;
lines = builtins.filter (x: builtins.isString x) (builtins.split "\n" mainGo);
versionLine = builtins.head (builtins.filter (line: builtins.match ".*const version = .*" line != null) lines);
version = builtins.head (builtins.match ".*\"([0-9.]+)\".*" versionLine);
in
{
packages = forAllSystems (system:
@@ -18,7 +24,7 @@
{
default = pkgs.buildGoModule {
pname = "nixos-exporter";
version = "0.1.0";
inherit version;
src = ./.;
vendorHash = "sha256-NnvB20rORPS5QF5enbb5KpWaKZ70ybSgfd7wjk21/Cg=";