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>
60 lines
1.8 KiB
Nix
60 lines
1.8 KiB
Nix
{
|
|
description = "Prometheus exporter for NixOS-specific metrics";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
|
};
|
|
|
|
outputs = { self, nixpkgs }:
|
|
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:
|
|
let
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
in
|
|
{
|
|
default = pkgs.buildGoModule {
|
|
pname = "nixos-exporter";
|
|
inherit version;
|
|
src = ./.;
|
|
vendorHash = "sha256-NnvB20rORPS5QF5enbb5KpWaKZ70ybSgfd7wjk21/Cg=";
|
|
|
|
meta = with pkgs.lib; {
|
|
description = "Prometheus exporter for NixOS-specific metrics";
|
|
homepage = "https://git.t-juice.club/torjus/nixos-exporter";
|
|
license = licenses.mit;
|
|
maintainers = [ ];
|
|
platforms = platforms.linux;
|
|
};
|
|
};
|
|
});
|
|
|
|
devShells = forAllSystems (system:
|
|
let
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
in
|
|
{
|
|
default = pkgs.mkShell {
|
|
buildInputs = with pkgs; [
|
|
go
|
|
gopls
|
|
golangci-lint
|
|
govulncheck
|
|
delve
|
|
];
|
|
};
|
|
});
|
|
|
|
nixosModules.default = import ./module.nix { inherit self; };
|
|
};
|
|
}
|