1{
2 lib,
3 stdenv,
4 pkgs,
5 buildPythonPackage,
6 fetchFromGitHub,
7
8 # dependencies
9 cairocffi,
10 django,
11 django-tagging,
12 gunicorn,
13 pyparsing,
14 python-memcached,
15 pytz,
16 six,
17 txamqp,
18 urllib3,
19 whisper,
20
21 # tests
22 mock,
23 redis,
24 rrdtool,
25 writableTmpDirAsHomeHook,
26 python,
27
28 # passthru
29 nixosTests,
30}:
31
32buildPythonPackage {
33 pname = "graphite-web";
34 version = "1.1.10-unstable-2025-02-24";
35 pyproject = true;
36
37 src = fetchFromGitHub {
38 owner = "graphite-project";
39 repo = "graphite-web";
40 rev = "49c28e2015d605ad9ec93524f7076dd924a4731a";
41 hash = "sha256-TxsQPhnI5WhQvKKkDEYZ8xnyg/qf+N9Icej6d6A0jC0=";
42 };
43
44 postPatch =
45 ''
46 substituteInPlace webapp/graphite/settings.py \
47 --replace-fail \
48 "join(WEBAPP_DIR, 'content')" \
49 "join('$out/webapp', 'content')"
50 ''
51 + lib.optionalString stdenv.hostPlatform.isDarwin ''
52 substituteInPlace webapp/tests/test_dashboard.py \
53 --replace-fail "test_dashboard_email" "_dont_test_dashboard_email"
54 substituteInPlace webapp/tests/test_render.py \
55 --replace-fail "test_render_view" "_dont_test_render_view"
56 '';
57
58 dependencies = [
59 cairocffi
60 django
61 django-tagging
62 gunicorn
63 pyparsing
64 python-memcached
65 pytz
66 six
67 txamqp
68 urllib3
69 whisper
70 ];
71
72 pythonRelaxDeps = [
73 "django"
74 "django-tagging"
75 ];
76
77 env = {
78 # Carbon-s default installation is /opt/graphite. This env variable ensures
79 # carbon is installed as a regular Python module.
80 GRAPHITE_NO_PREFIX = "True";
81
82 REDIS_HOST = "127.0.0.1";
83 };
84
85 nativeCheckInputs = [
86 mock
87 redis
88 rrdtool
89 writableTmpDirAsHomeHook
90 ];
91
92 preCheck =
93 # Start a redis server
94 ''
95 ${pkgs.valkey}/bin/redis-server &
96 REDIS_PID=$!
97 '';
98
99 checkPhase = ''
100 runHook preCheck
101
102 pushd webapp/
103 # avoid confusion with installed module
104 rm -r graphite
105
106 DJANGO_SETTINGS_MODULE=tests.settings ${python.interpreter} manage.py test
107 popd
108
109 runHook postCheck
110 '';
111
112 postCheck = ''
113 kill $REDIS_PID
114 '';
115
116 __darwinAllowLocalNetworking = true;
117
118 pythonImportsCheck = [ "graphite" ];
119
120 passthru.tests = {
121 inherit (nixosTests) graphite;
122 };
123
124 meta = {
125 description = "Enterprise scalable realtime graphing";
126 homepage = "http://graphiteapp.org/";
127 license = lib.licenses.asl20;
128 maintainers = with lib.maintainers; [
129 offline
130 basvandijk
131 ];
132 };
133}