feat: implement nixos-exporter

Prometheus exporter for NixOS-specific metrics including:
- Generation collector: count, current, booted, age, config mismatch
- Flake collector: input age, input info, revision behind

Includes NixOS module, flake packaging, and documentation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-06 22:50:14 +01:00
commit f637da487c
14 changed files with 1345 additions and 0 deletions

53
flake.nix Normal file
View File

@@ -0,0 +1,53 @@
{
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;
in
{
packages = forAllSystems (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
default = pkgs.buildGoModule {
pname = "nixos-exporter";
version = "0.1.0";
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; };
};
}