summaryrefslogtreecommitdiff
path: root/pkgs/development/libraries/prometheus-client-c/default.nix
blob: d76b47dbeee1c2e4680d42efaf19c2b72f7076d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{
  lib,
  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";
        })
      ];

      # Workaround build failure on -fno-common toolchains like upstream
      # gcc-10. Otherwise build fails as:
      #   ld: CMakeFiles/prom.dir/src/prom_process_stat.c.o:(.bss+0x0): multiple definition of
      #     `prom_process_start_time_seconds'; CMakeFiles/prom.dir/src/prom_collector.c.o:(.bss+0x0): first defined here
      # Should be fixed in 1.2.0 and later: https://github.com/digitalocean/prometheus-client-c/pull/25
      env.NIX_CFLAGS_COMPILE = "-fcommon";

      preConfigure = ''
        cd ${subdir}
      '';

      meta = {
        homepage = "https://github.com/digitalocean/prometheus-client-c/";
        inherit description;
        platforms = lib.platforms.unix;
        license = lib.licenses.asl20;
        maintainers = [ lib.maintainers.cfsmp3 ];
      };
    };
in
{
  libprom = build {
    pname = "libprom";
    subdir = "prom";
    description = "Prometheus Client in C";
  };
}