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