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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
|
{
lib,
python3,
fetchFromGitHub,
gettext,
pango,
harfbuzz,
librsvg,
gdk-pixbuf,
glib,
gobject-introspection,
borgbackup,
writeText,
postgresqlTestHook,
postgresql,
redisTestHook,
fontconfig,
nixosTests,
# runtime inputs
gitSVN,
subversion,
#optional runtime inputs
git-review,
tesseract,
licensee,
mercurial,
openssh,
}:
let
python = python3.override {
self = python;
packageOverrides = _final: prev: {
django = prev.django_6;
pygobject = prev.pygobject3;
};
};
python3Packages = python.pkgs;
GI_TYPELIB_PATH = lib.makeSearchPathOutput "out" "lib/girepository-1.0" [
pango
harfbuzz
librsvg
gdk-pixbuf
glib
gobject-introspection
];
in
python3Packages.buildPythonApplication (finalAttrs: {
pname = "weblate";
version = "2026.6.1";
pyproject = true;
outputs = [
"out"
"static"
];
src = fetchFromGitHub {
owner = "WeblateOrg";
repo = "weblate";
tag = "weblate-${finalAttrs.version}";
hash = "sha256-7dhEkU2sVIjMPPR/0U2sMFXG6bl8s5WDvw8MyZZhqNE=";
};
postPatch = ''
sed -i 's|/bin/true|true|g' weblate/addons/example_pre.py
sed -i 's/"setuptools==.*"/"setuptools"/' pyproject.toml
sed -i 's/"translate-toolkit==.*"/"translate-toolkit"/' pyproject.toml
'';
build-system = with python3Packages; [ setuptools ];
nativeBuildInputs = [ gettext ];
# Build static files into a separate output
postBuild =
let
staticSettings = writeText "static_settings.py" ''
DEBUG = False
STATIC_ROOT = os.environ["static"]
COMPRESS_OFFLINE = True
# So we don't need postgres dependencies
DATABASES = {}
'';
manage = "DJANGO_SETTINGS_MODULE='weblate.settings_static' ${python.pythonOnBuildForHost.interpreter} manage.py";
in
''
mkdir $static
cat weblate/settings_example.py ${staticSettings} > weblate/settings_static.py
${manage} compilemessages
${manage} collectstatic --no-input
${manage} compress
'';
# Upstream pins all dependencies, so their version constraints are mostly meaningless,
# except for a few packages maintained by themselves.
# https://github.com/WeblateOrg/weblate/issues/20003#issuecomment-4691837274
pythonRelaxDeps =
let
# Dependencies owned by Weblate that should always be in the exact version specified
coreDeps = [
"weblate-fonts"
"weblate-schemas"
"weblate-language-data"
"translation-finder"
"translate-toolkit"
];
in
lib.concatMap (
p: if !p ? "pname" || lib.elem p.pname coreDeps then [ ] else [ p.pname ]
) finalAttrs.passthru.dependencies;
dependencies =
with python3Packages;
[
ahocorasick-rs
altcha
argon2-cffi-bindings
argon2-cffi
(toPythonModule (borgbackup.override { python3 = python; }))
celery
certifi
cffi
charset-normalizer
confusable-homoglyphs
crispy-bootstrap5
cryptography
cssselect
cyrtranslit
dateparser
diff-match-patch
disposable-email-domains
django-appconf
django-celery-beat
django-compressor
django-cors-headers
django-crispy-forms
django-filter
django-otp-webauthn
django-otp
django-redis
django
djangorestframework-csv
djangorestframework
docutils
drf-spectacular
drf-standardized-errors
fedora-messaging
filelock
gitpython
hiredis
html2text
jsonschema
lxml
mistletoe
nh3
openpyxl
opentelemetry-exporter-otlp-proto-http
opentelemetry-instrumentation-celery
opentelemetry-instrumentation-django
opentelemetry-instrumentation-psycopg
opentelemetry-instrumentation-redis
opentelemetry-instrumentation-requests
opentelemetry-sdk
packaging
pillow
pyaskalono
pyasn1
pycairo
pygments
pygobject
pyicumessageformat
pyjwt
pyopenssl
pyparsing
python-dateutil
qrcode
rapidfuzz
redis
regex
requests
ruamel-yaml
sentry-sdk
siphashc
social-auth-app-django
social-auth-core
tesserocr
translate-toolkit
translation-finder
twisted
unidecode
urllib3
user-agents
weblate-fonts
weblate-language-data
weblate-schemas
]
++ django.optional-dependencies.argon2
++ celery.optional-dependencies.redis
++ drf-spectacular.optional-dependencies.sidecar
++ drf-standardized-errors.optional-dependencies.openapi
++ translate-toolkit.optional-dependencies.chardet
++ translate-toolkit.optional-dependencies.fluent
++ translate-toolkit.optional-dependencies.ini
++ translate-toolkit.optional-dependencies.markdown
++ translate-toolkit.optional-dependencies.toml
++ translate-toolkit.optional-dependencies.php
++ translate-toolkit.optional-dependencies.rc
++ translate-toolkit.optional-dependencies.subtitles
++ translate-toolkit.optional-dependencies.yaml
++ urllib3.optional-dependencies.brotli
++ urllib3.optional-dependencies.zstd;
# Commented entries are not packaged yet
optional-dependencies = with python3Packages; {
amazon = [ boto3 ];
# gelf = [ logging-gelf ];
# gerrit = [ git-review ];
google = [
google-cloud-storage
google-cloud-translate
];
google-errors = [
google-cloud-error-reporting
];
ldap = [ django-auth-ldap ];
# mercurial = [ mercurial ];
postgres = [ psycopg ];
rollbar = [ rollbar ];
saml = [
python3-saml
xmlsec
];
# saml2idp = [ djangosaml2idp2 ];
sphinx = [ sphinx ];
# wllegal = [ wllegal ];
wsgi = [ granian ];
# zxcvbn = [ django-zxcvbn-password-validator ];
};
# We don't just use wrapGAppsNoGuiHook because we need to expose GI_TYPELIB_PATH
env = {
inherit GI_TYPELIB_PATH;
};
makeWrapperArgs = [ "--set GI_TYPELIB_PATH \"$GI_TYPELIB_PATH\"" ];
nativeCheckInputs =
with python3Packages;
[
pytestCheckHook
postgresqlTestHook
postgresql
redisTestHook
pytest-cov-stub
pytest-django
pytest-xdist
responses
selenium
standardwebhooks
gitSVN
subversion
gettext
fontconfig
borgbackup
#optional
git-review
tesseract
licensee
mercurial
openssh
]
++ social-auth-core.optional-dependencies.saml
++ lib.concatAttrValues finalAttrs.passthru.optional-dependencies;
env = {
CI_DATABASE = "postgresql";
DJANGO_SETTINGS_MODULE = "weblate.settings_test";
# Only needed to make weblate/settings_test.py happy
CI_DB_PORT = "";
CI_DB_PASSWORD = "";
CI_REDIS_HOST = "";
CI_REDIS_PORT = "";
};
# pytest-xdist wants to create an additional database per test group
postgresqlTestUserOptions = "LOGIN SUPERUSER";
postgresqlTestSetupPost = ''
export CI_DB_HOST="$PGHOST"
export CI_DB_USER="$PGUSER"
export CI_DB_NAME="$PGDATABASE"
echo "CACHES[\"avatar\"][\"LOCATION\"] = \"unix://$NIX_BUILD_TOP/run/redis.sock\"" \
>> weblate/settings_test.py
${python.pythonOnBuildForHost.interpreter} manage.py migrate --noinput
${python.pythonOnBuildForHost.interpreter} manage.py check
'';
disabledTests = [
# Tries to download things from GitHub
"test_ocr"
"test_ocr_backend"
];
disabledTestPaths = [
# Probably network access?
"weblate/addons/tests.py::SlackWebhooksAddonsTest::test_component_scopes"
"weblate/addons/tests.py::SlackWebhooksAddonsTest::test_connection_error"
"weblate/addons/tests.py::SlackWebhooksAddonsTest::test_invalid_response"
"weblate/addons/tests.py::SlackWebhooksAddonsTest::test_project_scopes"
"weblate/addons/tests.py::SlackWebhooksAddonsTest::test_site_wide_scope"
"weblate/addons/tests.py::SlackWebhooksAddonsTest::test_translation_added"
"weblate/addons/tests.py::SlackWebhooksAddonsTest::test_announcement"
"weblate/addons/tests.py::SlackWebhooksAddonsTest::test_bulk_changes"
"weblate/addons/tests.py::WebhooksAddonTest::test_announcement"
"weblate/addons/tests.py::WebhooksAddonTest::test_bulk_changes"
"weblate/addons/tests.py::WebhooksAddonTest::test_category_in_payload"
"weblate/addons/tests.py::WebhooksAddonTest::test_component_scopes"
"weblate/addons/tests.py::WebhooksAddonTest::test_connection_error"
"weblate/addons/tests.py::WebhooksAddonTest::test_invalid_response"
"weblate/addons/tests.py::WebhooksAddonTest::test_project_scopes"
"weblate/addons/tests.py::WebhooksAddonTest::test_site_wide_scope"
"weblate/addons/tests.py::WebhooksAddonTest::test_translation_added"
"weblate/addons/tests.py::WebhooksAddonTest::test_webhook_signature"
"weblate/addons/tests.py::WebhooksAddonTest::test_webhook_signature_prefix"
# Tries to resolve DNS
"weblate/api/tests.py::ProjectAPITest::test_install_machinery"
"weblate/addons/tests.py::WebhooksAddonTest::test_form"
# djangosaml2idp2 is not packaged yet
"weblate/utils/tests/test_djangosaml2idp.py"
# Don't understand why
"weblate/trans/tests/test_alert.py::WebsiteAlertSettingTest::test_website_alerts_enabled"
];
passthru = {
inherit python;
# We need to expose this so weblate can work outside of calling its bin output
inherit GI_TYPELIB_PATH;
tests = {
inherit (nixosTests) weblate;
};
};
meta = {
description = "Web based translation tool with tight version control integration";
homepage = "https://weblate.org/";
changelog = "https://github.com/WeblateOrg/weblate/releases/tag/${finalAttrs.src.tag}";
license = with lib.licenses; [
gpl3Plus
mit
];
platforms = lib.platforms.linux;
maintainers = with lib.maintainers; [ erictapen ];
mainProgram = "weblate";
};
})
|