summary refs log tree commit diff
path: root/pkgs/servers/monitoring/prometheus/tor-exporter.nix
blob: 663b532c8fc680a567a2b9a22f8b44bc51bbd3f8 (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
{ lib, fetchFromGitHub, python3Packages, nixosTests }:

python3Packages.buildPythonApplication rec {
  pname = "tor-exporter";
  version = "0.4";

  # Just a single .py file to use as the application's main entry point.
  format = "other";

  src = fetchFromGitHub {
    rev = "v${version}";
    owner = "atx";
    repo = "prometheus-tor_exporter";
    sha256 = "1gzf42z0cgdqijbi9cwpjkqzkvnabaxkkfa5ac5h27r3pxx3q4n0";
  };

  propagatedBuildInputs = with python3Packages; [ prometheus_client stem retrying ];

  installPhase = ''
    mkdir -p $out/share/
    cp prometheus-tor-exporter.py $out/share/
  '';

  fixupPhase = ''
    makeWrapper "${python3Packages.python.interpreter}" "$out/bin/prometheus-tor-exporter" \
          --set PYTHONPATH "$PYTHONPATH" \
          --add-flags "$out/share/prometheus-tor-exporter.py"
  '';

  passthru.tests = { inherit (nixosTests.prometheus-exporters) tor; };

  meta = with lib; {
    description = "Prometheus exporter that exposes metrics from a Tor daemon";
    homepage = "https://github.com/atx/prometheus-tor_exporter";
    license = licenses.mit;
    maintainers = with maintainers; [ delroth ];
    platforms = platforms.unix;
  };
}