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 substituteInPlace webapp/graphite/settings.py \
46 --replace-fail \
47 "join(WEBAPP_DIR, 'content')" \
48 "join('$out/webapp', 'content')"
49 ''
50 + lib.optionalString stdenv.hostPlatform.isDarwin ''
51 substituteInPlace webapp/tests/test_dashboard.py \
52 --replace-fail "test_dashboard_email" "_dont_test_dashboard_email"
53 substituteInPlace webapp/tests/test_render.py \
54 --replace-fail "test_render_view" "_dont_test_render_view"
55 '';
56
57 dependencies = [
58 cairocffi
59 django
60 django-tagging
61 gunicorn
62 pyparsing
63 python-memcached
64 pytz
65 six
66 txamqp
67 urllib3
68 whisper
69 ];
70
71 pythonRelaxDeps = [
72 "django"
73 "django-tagging"
74 ];
75
76 env = {
77 # Carbon-s default installation is /opt/graphite. This env variable ensures
78 # carbon is installed as a regular Python module.
79 GRAPHITE_NO_PREFIX = "True";
80
81 REDIS_HOST = "127.0.0.1";
82 };
83
84 nativeCheckInputs = [
85 mock
86 redis
87 rrdtool
88 writableTmpDirAsHomeHook
89 ];
90
91 preCheck =
92 # Start a redis server
93 ''
94 ${pkgs.valkey}/bin/redis-server &
95 REDIS_PID=$!
96 '';
97
98 checkPhase = ''
99 runHook preCheck
100
101 pushd webapp/
102 # avoid confusion with installed module
103 rm -r graphite
104
105 DJANGO_SETTINGS_MODULE=tests.settings ${python.interpreter} manage.py test
106 popd
107
108 runHook postCheck
109 '';
110
111 postCheck = ''
112 kill $REDIS_PID
113 '';
114
115 __darwinAllowLocalNetworking = true;
116
117 pythonImportsCheck = [ "graphite" ];
118
119 passthru.tests = {
120 inherit (nixosTests) graphite;
121 };
122
123 meta = {
124 description = "Enterprise scalable realtime graphing";
125 homepage = "http://graphiteapp.org/";
126 license = lib.licenses.asl20;
127 maintainers = with lib.maintainers; [
128 offline
129 basvandijk
130 ];
131 };
132}