summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/graphite-web/default.nix
blob: 19bf7f0fb368d64b55d3c15b53ec6334f6422ba8 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
{
  lib,
  stdenv,
  pkgs,
  buildPythonPackage,
  fetchFromGitHub,

  # dependencies
  cairocffi,
  django,
  django-tagging,
  gunicorn,
  pyparsing,
  python-memcached,
  pytz,
  six,
  txamqp,
  urllib3,
  whisper,

  # tests
  mock,
  redis,
  rrdtool,
  writableTmpDirAsHomeHook,
  python,

  # passthru
  nixosTests,
}:

buildPythonPackage {
  pname = "graphite-web";
  version = "1.1.10-unstable-2025-02-24";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "graphite-project";
    repo = "graphite-web";
    rev = "49c28e2015d605ad9ec93524f7076dd924a4731a";
    hash = "sha256-TxsQPhnI5WhQvKKkDEYZ8xnyg/qf+N9Icej6d6A0jC0=";
  };

  postPatch = ''
    substituteInPlace webapp/graphite/settings.py \
      --replace-fail \
        "join(WEBAPP_DIR, 'content')" \
        "join('$out/webapp', 'content')"
  ''
  + lib.optionalString stdenv.hostPlatform.isDarwin ''
    substituteInPlace webapp/tests/test_dashboard.py \
      --replace-fail "test_dashboard_email" "_dont_test_dashboard_email"
    substituteInPlace webapp/tests/test_render.py \
      --replace-fail "test_render_view" "_dont_test_render_view"
  '';

  dependencies = [
    cairocffi
    django
    django-tagging
    gunicorn
    pyparsing
    python-memcached
    pytz
    six
    txamqp
    urllib3
    whisper
  ];

  pythonRelaxDeps = [
    "django"
    "django-tagging"
  ];

  env = {
    # Carbon-s default installation is /opt/graphite. This env variable ensures
    # carbon is installed as a regular Python module.
    GRAPHITE_NO_PREFIX = "True";

    REDIS_HOST = "127.0.0.1";
  };

  nativeCheckInputs = [
    mock
    redis
    rrdtool
    writableTmpDirAsHomeHook
  ];

  preCheck =
    # Start a redis server
    ''
      ${pkgs.valkey}/bin/redis-server &
      REDIS_PID=$!
    '';

  checkPhase = ''
    runHook preCheck

    pushd webapp/
    # avoid confusion with installed module
    rm -r graphite

    DJANGO_SETTINGS_MODULE=tests.settings ${python.interpreter} manage.py test
    popd

    runHook postCheck
  '';

  postCheck = ''
    kill $REDIS_PID
  '';

  __darwinAllowLocalNetworking = true;

  pythonImportsCheck = [ "graphite" ];

  passthru.tests = {
    inherit (nixosTests) graphite;
  };

  meta = {
    description = "Enterprise scalable realtime graphing";
    homepage = "http://graphiteapp.org/";
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [
      offline
      basvandijk
    ];
  };
}