nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 python3,
4 fetchFromGitHub,
5 gettext,
6 pango,
7 harfbuzz,
8 librsvg,
9 gdk-pixbuf,
10 glib,
11 gobject-introspection,
12 askalono,
13 borgbackup,
14 writeText,
15 nixosTests,
16}:
17
18let
19 python = python3.override {
20 packageOverrides = final: prev: {
21 django = prev.django_5;
22 };
23 };
24in
25python.pkgs.buildPythonApplication rec {
26 pname = "weblate";
27 version = "5.15.2";
28
29 pyproject = true;
30
31 outputs = [
32 "out"
33 "static"
34 ];
35
36 src = fetchFromGitHub {
37 owner = "WeblateOrg";
38 repo = "weblate";
39 tag = "weblate-${version}";
40 hash = "sha256-qNv3aaPyQ/bOrPbK7u9vtq8R1MFqXLJzvLUZfVgjMK0=";
41 };
42
43 build-system = with python.pkgs; [ setuptools ];
44
45 nativeBuildInputs = [ gettext ];
46
47 # Build static files into a separate output
48 postBuild =
49 let
50 staticSettings = writeText "static_settings.py" ''
51 DEBUG = False
52 STATIC_ROOT = os.environ["static"]
53 COMPRESS_OFFLINE = True
54 # So we don't need postgres dependencies
55 DATABASES = {}
56 '';
57 in
58 ''
59 mkdir $static
60 cat weblate/settings_example.py ${staticSettings} > weblate/settings_static.py
61 export DJANGO_SETTINGS_MODULE="weblate.settings_static"
62 ${python.pythonOnBuildForHost.interpreter} manage.py compilemessages
63 ${python.pythonOnBuildForHost.interpreter} manage.py collectstatic --no-input
64 ${python.pythonOnBuildForHost.interpreter} manage.py compress
65 '';
66
67 pythonRelaxDeps = [
68 "certifi"
69 "urllib3"
70 ];
71
72 dependencies =
73 with python.pkgs;
74 [
75 aeidon
76 ahocorasick-rs
77 altcha
78 (toPythonModule (borgbackup.override { python3 = python; }))
79 celery
80 certifi
81 charset-normalizer
82 confusable-homoglyphs
83 crispy-bootstrap3
84 crispy-bootstrap5
85 cryptography
86 cssselect
87 cython
88 cyrtranslit
89 dateparser
90 diff-match-patch
91 disposable-email-domains
92 django-appconf
93 django-celery-beat
94 django-compressor
95 django-cors-headers
96 django-crispy-forms
97 django-filter
98 django-redis
99 django-otp
100 django-otp-webauthn
101 django
102 djangorestframework-csv
103 djangorestframework
104 docutils
105 drf-spectacular
106 drf-standardized-errors
107 fedora-messaging
108 filelock
109 fluent-syntax
110 gitpython
111 hiredis
112 html2text
113 iniparse
114 jsonschema
115 lxml
116 mistletoe
117 nh3
118 openpyxl
119 packaging
120 phply
121 pillow
122 pyaskalono
123 pycairo
124 pygments
125 pygobject3
126 pyicumessageformat
127 pyparsing
128 python-dateutil
129 qrcode
130 rapidfuzz
131 redis
132 requests
133 ruamel-yaml
134 sentry-sdk
135 siphashc
136 social-auth-app-django
137 social-auth-core
138 tesserocr
139 translate-toolkit
140 translation-finder
141 unidecode
142 urllib3
143 user-agents
144 weblate-language-data
145 weblate-schemas
146 ]
147 ++ django.optional-dependencies.argon2
148 ++ celery.optional-dependencies.redis
149 ++ drf-spectacular.optional-dependencies.sidecar
150 ++ drf-standardized-errors.optional-dependencies.openapi
151 ++ translate-toolkit.optional-dependencies.toml
152 ++ urllib3.optional-dependencies.brotli
153 ++ urllib3.optional-dependencies.zstd;
154
155 optional-dependencies = {
156 postgres = with python.pkgs; [ psycopg ];
157 };
158
159 # We don't just use wrapGAppsNoGuiHook because we need to expose GI_TYPELIB_PATH
160 GI_TYPELIB_PATH = lib.makeSearchPathOutput "out" "lib/girepository-1.0" [
161 pango
162 harfbuzz
163 librsvg
164 gdk-pixbuf
165 glib
166 gobject-introspection
167 ];
168 makeWrapperArgs = [ "--set GI_TYPELIB_PATH \"$GI_TYPELIB_PATH\"" ];
169
170 passthru = {
171 inherit python;
172 # We need to expose this so weblate can work outside of calling its bin output
173 inherit GI_TYPELIB_PATH;
174 tests = {
175 inherit (nixosTests) weblate;
176 };
177 };
178
179 meta = {
180 description = "Web based translation tool with tight version control integration";
181 homepage = "https://weblate.org/";
182 changelog = "https://github.com/WeblateOrg/weblate/releases/tag/${src.tag}";
183 license = with lib.licenses; [
184 gpl3Plus
185 mit
186 ];
187 platforms = lib.platforms.linux;
188 maintainers = with lib.maintainers; [ erictapen ];
189 mainProgram = "weblate";
190 };
191}