diff --git a/pkgs/servers/monitoring/prometheus/node-exporter.nix b/pkgs/servers/monitoring/prometheus/node-exporter.nix index 7d40e919773d..0da2bb604a0b 100644 --- a/pkgs/servers/monitoring/prometheus/node-exporter.nix +++ b/pkgs/servers/monitoring/prometheus/node-exporter.nix @@ -1,4 +1,7 @@ -{ lib, buildGoModule, fetchFromGitHub, nixosTests }: +{ lib, stdenv, buildGoModule, fetchFromGitHub, nixosTests + # darwin + , CoreFoundation, IOKit +}: buildGoModule rec { pname = "node_exporter"; @@ -17,6 +20,13 @@ buildGoModule rec { # FIXME: tests fail due to read-only nix store doCheck = false; + buildInputs = lib.optionals stdenv.isDarwin [ CoreFoundation IOKit ]; + # upstream currently doesn't work with the version of the macOS SDK + # we're building against in nix-darwin without a patch. + # this patch has been submitted upstream at https://github.com/prometheus/node_exporter/pull/2327 + # and only needs to be carried until it lands in a new release. + patches = lib.optionals stdenv.isDarwin [ ./node-exporter/node-exporter-darwin.patch ]; + excludedPackages = [ "docs/node-mixin" ]; ldflags = [ diff --git a/pkgs/servers/monitoring/prometheus/node-exporter/node-exporter-darwin.patch b/pkgs/servers/monitoring/prometheus/node-exporter/node-exporter-darwin.patch new file mode 100644 index 000000000000..8077bbc47511 --- /dev/null +++ b/pkgs/servers/monitoring/prometheus/node-exporter/node-exporter-darwin.patch @@ -0,0 +1,17 @@ +diff --git a/collector/powersupplyclass_darwin.go b/collector/powersupplyclass_darwin.go +index a070f64..01d7f18 100644 +--- a/collector/powersupplyclass_darwin.go ++++ b/collector/powersupplyclass_darwin.go +@@ -18,9 +18,11 @@ package collector + + /* + #cgo LDFLAGS: -framework IOKit -framework CoreFoundation ++#include ++#include ++#include + #include + #include +-#include + + // values collected from IOKit Power Source APIs + // Functions documentation available at diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 03811e56a0b2..63fe1960ff9f 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -22000,7 +22000,9 @@ with pkgs; prometheus-nextcloud-exporter = callPackage ../servers/monitoring/prometheus/nextcloud-exporter.nix { }; prometheus-nginx-exporter = callPackage ../servers/monitoring/prometheus/nginx-exporter.nix { }; prometheus-nginxlog-exporter = callPackage ../servers/monitoring/prometheus/nginxlog-exporter.nix { }; - prometheus-node-exporter = callPackage ../servers/monitoring/prometheus/node-exporter.nix { }; + prometheus-node-exporter = callPackage ../servers/monitoring/prometheus/node-exporter.nix { + inherit (darwin.apple_sdk.frameworks) CoreFoundation IOKit; + }; prometheus-openldap-exporter = callPackage ../servers/monitoring/prometheus/openldap-exporter.nix { }; prometheus-openvpn-exporter = callPackage ../servers/monitoring/prometheus/openvpn-exporter.nix { }; prometheus-pihole-exporter = callPackage ../servers/monitoring/prometheus/pihole-exporter.nix { };