From a641c717ae4a35500368af8b7f6da7bea0bc4b20 Mon Sep 17 00:00:00 2001 From: Ananth Bhaskararaman Date: Fri, 9 Jan 2026 20:01:09 +0530 Subject: [PATCH 1/4] prometheus-libvirt-exporter: add mainProgram Add mainProgram meta attribute so the exporter NixOS module uses the correct binary path in its systemd service. --- pkgs/by-name/pr/prometheus-libvirt-exporter/package.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/by-name/pr/prometheus-libvirt-exporter/package.nix b/pkgs/by-name/pr/prometheus-libvirt-exporter/package.nix index 2f6862ac6dcd..97d8506cc77c 100644 --- a/pkgs/by-name/pr/prometheus-libvirt-exporter/package.nix +++ b/pkgs/by-name/pr/prometheus-libvirt-exporter/package.nix @@ -30,5 +30,6 @@ buildGoModule (finalAttrs: { homepage = "https://github.com/Tinkoff/libvirt-exporter"; license = lib.licenses.asl20; maintainers = [ ]; + mainProgram = "libvirt-exporter"; }; }) From a517010c3cfb6e6ebfd652b5b3271954cfbd51f7 Mon Sep 17 00:00:00 2001 From: Ananth Bhaskararaman Date: Sat, 4 Apr 2026 00:36:44 +0530 Subject: [PATCH 2/4] nixos/prometheus-exporters: remove unused imports Remove foldl, maintainers, optional, and mkOptionDefault from the inherit list as they are not used. --- nixos/modules/services/monitoring/prometheus/exporters.nix | 4 ---- 1 file changed, 4 deletions(-) diff --git a/nixos/modules/services/monitoring/prometheus/exporters.nix b/nixos/modules/services/monitoring/prometheus/exporters.nix index 0e38fb27508f..2d11e03d07de 100644 --- a/nixos/modules/services/monitoring/prometheus/exporters.nix +++ b/nixos/modules/services/monitoring/prometheus/exporters.nix @@ -10,11 +10,9 @@ let inherit (lib) concatStrings - foldl foldl' genAttrs literalExpression - maintainers mapAttrs mapAttrsToList mkDefault @@ -22,9 +20,7 @@ let mkIf mkMerge mkOption - optional types - mkOptionDefault flip attrNames xor From e50595fdffe853074431d0540affe62c4392697a Mon Sep 17 00:00:00 2001 From: Ananth Bhaskararaman Date: Sat, 4 Apr 2026 00:38:07 +0530 Subject: [PATCH 3/4] nixos/prometheus-libvirt-exporter: fix systemd socket restrictions Allow AF_UNIX, AF_INET, and AF_INET6 address families so the exporter can connect to the libvirt socket and serve HTTP metrics. --- .../services/monitoring/prometheus/exporters/libvirt.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nixos/modules/services/monitoring/prometheus/exporters/libvirt.nix b/nixos/modules/services/monitoring/prometheus/exporters/libvirt.nix index 8a4b5f481022..37b16c331598 100644 --- a/nixos/modules/services/monitoring/prometheus/exporters/libvirt.nix +++ b/nixos/modules/services/monitoring/prometheus/exporters/libvirt.nix @@ -24,6 +24,11 @@ in --web.listen-address ${cfg.listenAddress}:${toString cfg.port} \ --libvirt.uri ${cfg.libvirtUri} ${lib.concatStringsSep " " cfg.extraFlags} ''; + RestrictAddressFamilies = [ + "AF_UNIX" + "AF_INET" + "AF_INET6" + ]; }; }; } From 42b7af82a5c9676a7937e6ce41ca284f6640e122 Mon Sep 17 00:00:00 2001 From: Ananth Bhaskararaman Date: Sat, 4 Apr 2026 00:45:12 +0530 Subject: [PATCH 4/4] nixos/prometheus-libvirt-exporter: add libvirtd group Add the libvirtd group to the exporter's user so it can access the libvirt socket. --- nixos/modules/services/monitoring/prometheus/exporters.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nixos/modules/services/monitoring/prometheus/exporters.nix b/nixos/modules/services/monitoring/prometheus/exporters.nix index 2d11e03d07de..d3298742772c 100644 --- a/nixos/modules/services/monitoring/prometheus/exporters.nix +++ b/nixos/modules/services/monitoring/prometheus/exporters.nix @@ -324,6 +324,7 @@ let description = "Prometheus ${name} exporter service user"; isSystemUser = true; inherit (conf) group; + extraGroups = mkIf (name == "libvirt") [ "libvirtd" ]; } ); users.groups = mkMerge [