From dcfd6141c1195b5e23062a698369594d5831b5d2 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Wed, 1 Jul 2020 13:51:57 +1200 Subject: [PATCH] libpromhttp: init at 0.1.1, build in combination with libprom --- .../development/libraries/libprom/default.nix | 48 ------------- .../libraries/prometheus-client-c/default.nix | 71 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 4 +- 3 files changed, 74 insertions(+), 49 deletions(-) delete mode 100644 pkgs/development/libraries/libprom/default.nix create mode 100644 pkgs/development/libraries/prometheus-client-c/default.nix diff --git a/pkgs/development/libraries/libprom/default.nix b/pkgs/development/libraries/libprom/default.nix deleted file mode 100644 index b0c982fbf6a5..000000000000 --- a/pkgs/development/libraries/libprom/default.nix +++ /dev/null @@ -1,48 +0,0 @@ -{ gccStdenv -, fetchFromGitHub -, fetchpatch -, cmake -}: -let - stdenv = gccStdenv; # Darwin is clang by default and it doesn't work for this. -in -stdenv.mkDerivation rec { - pname = "libprom"; - version = "0.1.1"; - - src = fetchFromGitHub { - owner = "digitalocean"; - repo = "prometheus-client-c"; - rev = "v${version}"; - sha256 = "0g69s24xwrv5974acshrhnp6i8rpby8c6bhz15m3d8kpgjw3cm8f"; - }; - - nativeBuildInputs = [ cmake ]; - doCheck = false; - - patches = [ - # Required so CMAKE_INSTALL_PREFIX is honored, otherwise it - # installs headers in /usr/include (absolute) - (fetchpatch { - url = "https://github.com/digitalocean/prometheus-client-c/commit/5fcedeb506b7d47dd7bab35797f2c3f23db6fe10.patch"; - sha256 = "10hzg8v5jcgxz224kdq0nha9vs78wz098b0ys7gig2iwgrg018fy"; - }) - (fetchpatch { - url = "https://github.com/digitalocean/prometheus-client-c/commit/0c15e7e45ad0c3726593591fdd7d8f2fde845fe3.patch"; - sha256 = "06899v1xz3lpsdxww4p3q7pv8nrymnibncdc472056znr5fidlp0"; - }) - ]; - - preConfigure = '' - cd prom - ''; - - meta = { - homepage = "https://github.com/digitalocean/prometheus-client-c/"; - description = "A Prometheus Client in C"; - platforms = stdenv.lib.platforms.unix; - license = stdenv.lib.licenses.asl20; - maintainers = [ stdenv.lib.maintainers.cfsmp3 ]; - }; - -} diff --git a/pkgs/development/libraries/prometheus-client-c/default.nix b/pkgs/development/libraries/prometheus-client-c/default.nix new file mode 100644 index 000000000000..57f4ef5956f6 --- /dev/null +++ b/pkgs/development/libraries/prometheus-client-c/default.nix @@ -0,0 +1,71 @@ +{ stdenv +, fetchFromGitHub +, fetchpatch +, cmake +, libmicrohttpd +}: +let + build = + { pname + , subdir + , buildInputs ? [ ] + , description + }: + stdenv.mkDerivation rec { + inherit pname; + version = "0.1.1"; + + src = fetchFromGitHub { + owner = "digitalocean"; + repo = "prometheus-client-c"; + rev = "v${version}"; + sha256 = "0g69s24xwrv5974acshrhnp6i8rpby8c6bhz15m3d8kpgjw3cm8f"; + }; + + nativeBuildInputs = [ cmake ]; + inherit buildInputs; + + # These patches will be in 0.1.2 + patches = [ + # Required so CMAKE_INSTALL_PREFIX is honored, otherwise it + # installs headers in /usr/include (absolute) + ( + fetchpatch { + url = "https://github.com/digitalocean/prometheus-client-c/commit/5fcedeb506b7d47dd7bab35797f2c3f23db6fe10.patch"; + sha256 = "10hzg8v5jcgxz224kdq0nha9vs78wz098b0ys7gig2iwgrg018fy"; + } + ) + ( + fetchpatch { + url = "https://github.com/digitalocean/prometheus-client-c/commit/0c15e7e45ad0c3726593591fdd7d8f2fde845fe3.patch"; + sha256 = "06899v1xz3lpsdxww4p3q7pv8nrymnibncdc472056znr5fidlp0"; + } + ) + ]; + + preConfigure = '' + cd ${subdir} + ''; + + meta = { + homepage = "https://github.com/digitalocean/prometheus-client-c/"; + inherit description; + platforms = stdenv.lib.platforms.unix; + license = stdenv.lib.licenses.asl20; + maintainers = [ stdenv.lib.maintainers.cfsmp3 ]; + }; + }; +in +rec { + libprom = build { + pname = "libprom"; + subdir = "prom"; + description = "A Prometheus Client in C"; + }; + libpromhttp = build { + pname = "libpromhttp"; + subdir = "promhttp"; + buildInputs = [ libmicrohttpd libprom ]; + description = "A Prometheus HTTP Endpoint in C"; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 010f5c489e15..04d1d6c794ba 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -13465,7 +13465,9 @@ in libpqxx = callPackage ../development/libraries/libpqxx { }; - libprom = callPackage ../development/libraries/libprom { }; + inherit (callPackages ../development/libraries/prometheus-client-c { + stdenv = gccStdenv; # Required for darwin + }) libprom libpromhttp; libproxy = callPackage ../development/libraries/libproxy { inherit (darwin.apple_sdk.frameworks) SystemConfiguration CoreFoundation JavaScriptCore;