about summary refs log tree commit diff
path: root/nixpkgs/pkgs/servers/monitoring/prometheus/php-fpm-exporter.nix
blob: e9ba97d1f3f79a28762a4191e4249484ff883d1d (plain) (blame)
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
{ lib
, buildGoModule
, fetchFromGitHub
, makeWrapper
, installShellFiles
, getent
, nix-update-script
, testers
, prometheus-php-fpm-exporter
}:

buildGoModule rec {
  pname = "php-fpm_exporter";
  version = "2.2.0";

  src = fetchFromGitHub {
    owner = "hipages";
    repo = pname;
    rev = "v${version}";
    hash = "sha256-ggrFnyEdGBoZVh4dHMw+7RUm8nJ1hJXo/fownO3wvzE=";
  };

  vendorHash = "sha256-OK36tHkBtosdfEWFPYMtlbzCkh5cF35NBWYyJrb9fwg= ";

  nativeBuildInputs = [ makeWrapper installShellFiles ];

  ldflags = [
    "-X main.version=${version}"
  ];

  preFixup = ''
    wrapProgram "$out/bin/php-fpm_exporter" \
      --prefix PATH ":" "${lib.makeBinPath [ getent ]}"
  '';

  postInstall = ''
    installShellCompletion --cmd php-fpm_exporter \
      --bash <($out/bin/php-fpm_exporter completion bash) \
      --fish <($out/bin/php-fpm_exporter completion fish) \
      --zsh <($out/bin/php-fpm_exporter completion zsh)
  '';

  passthru = {
    updateScript = nix-update-script { };
    tests = testers.testVersion {
      inherit version;
      package = prometheus-php-fpm-exporter;
      command = "php-fpm_exporter version";
    };
  };

  meta = with lib; {
    homepage = "https://github.com/hipages/php-fpm_exporter";
    description = "A prometheus exporter for PHP-FPM.";
    license = licenses.asl20;
    maintainers = with maintainers; [ gaelreyrol ];
    mainProgram = "php-fpm_exporter";
  };
}