about summary refs log tree commit diff
path: root/pkgs/servers
diff options
context:
space:
mode:
authorpeter woodman <peter@shortbus.org>2022-03-24 12:24:40 -0400
committerGitHub <noreply@github.com>2022-03-24 12:24:40 -0400
commit6af081ad335ae73b41217d2c5b3bdf0acc30aaa5 (patch)
treef97b2b34812c49dd7ed000a37a4456b633fb2e4a /pkgs/servers
parent077f078a01cab74ca1f33520156b281fc9a3ca43 (diff)
prometheus-node-exporter: fix build on darwin (#165546)
Diffstat (limited to 'pkgs/servers')
-rw-r--r--pkgs/servers/monitoring/prometheus/node-exporter.nix12
-rw-r--r--pkgs/servers/monitoring/prometheus/node-exporter/node-exporter-darwin.patch17
2 files changed, 28 insertions, 1 deletions
diff --git a/pkgs/servers/monitoring/prometheus/node-exporter.nix b/pkgs/servers/monitoring/prometheus/node-exporter.nix
index 7d40e919773d1..0da2bb604a0b1 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 0000000000000..8077bbc47511e
--- /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 <CoreFoundation/CFNumber.h>
++#include <CoreFoundation/CFRunLoop.h>
++#include <CoreFoundation/CFString.h>
+ #include <IOKit/ps/IOPowerSources.h>
+ #include <IOKit/ps/IOPSKeys.h>
+-#include <CoreFoundation/CFArray.h>
+ 
+ // values collected from IOKit Power Source APIs
+ // Functions documentation available at