at 24.11-pre 78 lines 2.3 kB view raw
1{ lib, stdenv 2, fetchFromGitHub 3, fetchpatch 4, cmake 5, libmicrohttpd 6}: 7let 8 build = 9 { pname 10 , subdir 11 , buildInputs ? [ ] 12 , description 13 }: 14 stdenv.mkDerivation rec { 15 inherit pname; 16 version = "0.1.1"; 17 18 src = fetchFromGitHub { 19 owner = "digitalocean"; 20 repo = "prometheus-client-c"; 21 rev = "v${version}"; 22 sha256 = "0g69s24xwrv5974acshrhnp6i8rpby8c6bhz15m3d8kpgjw3cm8f"; 23 }; 24 25 nativeBuildInputs = [ cmake ]; 26 inherit buildInputs; 27 28 # These patches will be in 0.1.2 29 patches = [ 30 # Required so CMAKE_INSTALL_PREFIX is honored, otherwise it 31 # installs headers in /usr/include (absolute) 32 ( 33 fetchpatch { 34 url = "https://github.com/digitalocean/prometheus-client-c/commit/5fcedeb506b7d47dd7bab35797f2c3f23db6fe10.patch"; 35 sha256 = "10hzg8v5jcgxz224kdq0nha9vs78wz098b0ys7gig2iwgrg018fy"; 36 } 37 ) 38 ( 39 fetchpatch { 40 url = "https://github.com/digitalocean/prometheus-client-c/commit/0c15e7e45ad0c3726593591fdd7d8f2fde845fe3.patch"; 41 sha256 = "06899v1xz3lpsdxww4p3q7pv8nrymnibncdc472056znr5fidlp0"; 42 } 43 ) 44 ]; 45 46 # Workaround build failure on -fno-common toolchains like upstream 47 # gcc-10. Otherwise build fails as: 48 # ld: CMakeFiles/prom.dir/src/prom_process_stat.c.o:(.bss+0x0): multiple definition of 49 # `prom_process_start_time_seconds'; CMakeFiles/prom.dir/src/prom_collector.c.o:(.bss+0x0): first defined here 50 # Should be fixed in 1.2.0 and later: https://github.com/digitalocean/prometheus-client-c/pull/25 51 env.NIX_CFLAGS_COMPILE = "-fcommon"; 52 53 preConfigure = '' 54 cd ${subdir} 55 ''; 56 57 meta = { 58 homepage = "https://github.com/digitalocean/prometheus-client-c/"; 59 inherit description; 60 platforms = lib.platforms.unix; 61 license = lib.licenses.asl20; 62 maintainers = [ lib.maintainers.cfsmp3 ]; 63 }; 64 }; 65in 66rec { 67 libprom = build { 68 pname = "libprom"; 69 subdir = "prom"; 70 description = "A Prometheus Client in C"; 71 }; 72 libpromhttp = build { 73 pname = "libpromhttp"; 74 subdir = "promhttp"; 75 buildInputs = [ libmicrohttpd libprom ]; 76 description = "A Prometheus HTTP Endpoint in C"; 77 }; 78}