about summary refs log tree commit diff
path: root/pkgs/servers/monitoring/prometheus/xmpp-alerts.nix
blob: f9d9ce499b5f2362f45ef9469bb5ea41b87549a9 (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
60
61
62
63
64
65
66
67
68
69
{ lib
, fetchFromGitHub
, python3Packages
, prometheus-alertmanager
, fetchpatch
, runCommand
, prometheus-xmpp-alerts
}:

python3Packages.buildPythonApplication rec {
  pname = "prometheus-xmpp-alerts";
  version = "0.5.6";

  src = fetchFromGitHub {
    owner = "jelmer";
    repo = pname;
    rev = "v${version}";
    sha256 = "sha256-PwShGS1rbfZCK5OS6Cnn+mduOpWAD4fC69mcGB5GB1c=";
  };

  patches = [
    # Required until https://github.com/jelmer/prometheus-xmpp-alerts/pull/33 is merged
    # and contained in a release
    (fetchpatch {
      name = "Fix-outdated-entrypoint-definiton.patch";
      url = "https://github.com/jelmer/prometheus-xmpp-alerts/commit/c41dd41dbd3c781b874bcf0708f6976e6252b621.patch";
      hash = "sha256-G7fRLSXbkI5EDgGf4n9xSVs54IPD0ev8rTEFffRvLY0=";
    })
  ];

  postPatch = ''
    substituteInPlace setup.cfg \
      --replace "bs4" "beautifulsoup4"
  '';

  propagatedBuildInputs = [
    prometheus-alertmanager
  ] ++ (with python3Packages; [
    aiohttp
    aiohttp-openmetrics
    beautifulsoup4
    jinja2
    slixmpp
    prometheus-client
    pyyaml
  ]);

  nativeCheckInputs = with python3Packages; [
    unittestCheckHook
    pytz
  ];

  pythonImportsCheck = [ "prometheus_xmpp" ];

  passthru.tests = {
    binaryWorks = runCommand "${pname}-binary-test" {} ''
      # Running with --help to avoid it erroring due to a missing config file
      ${prometheus-xmpp-alerts}/bin/prometheus-xmpp-alerts --help | tee $out
      grep "usage: prometheus-xmpp-alerts" $out
    '';
  };

  meta = {
    description = "XMPP Web hook for Prometheus";
    homepage = "https://github.com/jelmer/prometheus-xmpp-alerts";
    maintainers = with lib.maintainers; [ fpletz ];
    license = with lib.licenses; [ asl20 ];
  };
}