forgejo-lts: 7.0.10 -> 7.0.11
[NixPkgs.git] / pkgs / development / libraries / prometheus-client-c / default.nix
blob4d695eff64085215cc2a358b2cb73e23a2552900
1 { lib, stdenv
2 , fetchFromGitHub
3 , fetchpatch
4 , cmake
5 , libmicrohttpd
6 }:
7 let
8   build =
9     { pname
10     , subdir
11     , buildInputs ? [ ]
12     , description
13     }:
14     stdenv.mkDerivation rec {
15       inherit pname;
16       version = "0.1.1";
18       src = fetchFromGitHub {
19         owner = "digitalocean";
20         repo = "prometheus-client-c";
21         rev = "v${version}";
22         sha256 = "0g69s24xwrv5974acshrhnp6i8rpby8c6bhz15m3d8kpgjw3cm8f";
23       };
25       nativeBuildInputs = [ cmake ];
26       inherit buildInputs;
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       ];
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";
53       preConfigure = ''
54         cd ${subdir}
55       '';
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     };
66 rec {
67   libprom = build {
68     pname = "libprom";
69     subdir = "prom";
70     description = "Prometheus Client in C";
71   };
72   libpromhttp = build {
73     pname = "libpromhttp";
74     subdir = "promhttp";
75     buildInputs = [ libmicrohttpd libprom ];
76     description = "Prometheus HTTP Endpoint in C";
77   };