btrbk: add mainProgram
[NixPkgs.git] / pkgs / by-name / we / weblate / package.nix
blobec952498d21562ef80fc9fb4e17a6cc7908521ec
2   lib,
3   python3,
4   fetchFromGitHub,
5   pango,
6   harfbuzz,
7   librsvg,
8   gdk-pixbuf,
9   glib,
10   borgbackup,
11   writeText,
12   nixosTests,
15 let
16   python = python3.override {
17     packageOverrides = final: prev: {
18       django = prev.django_5.overridePythonAttrs (old: {
19         dependencies = old.dependencies ++ prev.django_5.optional-dependencies.argon2;
20       });
21       sentry-sdk = prev.sentry-sdk_2;
22       djangorestframework = prev.djangorestframework.overridePythonAttrs (old: {
23         # https://github.com/encode/django-rest-framework/discussions/9342
24         disabledTests = (old.disabledTests or [ ]) ++ [ "test_invalid_inputs" ];
25       });
26     };
27   };
29 python.pkgs.buildPythonApplication rec {
30   pname = "weblate";
31   version = "5.7.2";
33   pyproject = true;
35   outputs = [
36     "out"
37     "static"
38   ];
40   src = fetchFromGitHub {
41     owner = "WeblateOrg";
42     repo = "weblate";
43     rev = "refs/tags/weblate-${version}";
44     hash = "sha256-cIwCNYXbg7l6z9OAkMAGJ783QI/nCOyrhLPURDcDv+Y=";
45   };
47   pythonRelaxDeps = [
48     # https://github.com/WeblateOrg/weblate/commit/9695f912b0d24ae999d9442bb49719b4bb552696
49     "qrcode"
50     # https://github.com/WeblateOrg/weblate/commit/1cf2a423b20fcd2dde18a43277311334e38208e7
51     "rapidfuzz"
52     # https://github.com/WeblateOrg/weblate/commit/3e34566fd7c151e1983586586bd7651cefe79585
53     "redis"
54   ];
56   patches = [
57     # FIXME This shouldn't be necessary and probably has to do with some dependency mismatch.
58     ./cache.lock.patch
59   ];
61   build-system = with python.pkgs; [ setuptools ];
63   # Build static files into a separate output
64   postBuild =
65     let
66       staticSettings = writeText "static_settings.py" ''
67         DEBUG = False
68         STATIC_ROOT = os.environ["static"]
69         COMPRESS_OFFLINE = True
70         # So we don't need postgres dependencies
71         DATABASES = {}
72       '';
73     in
74     ''
75       mkdir $static
76       cat weblate/settings_example.py ${staticSettings} > weblate/settings_static.py
77       export DJANGO_SETTINGS_MODULE="weblate.settings_static"
78       ${python.pythonOnBuildForHost.interpreter} manage.py collectstatic --no-input
79       ${python.pythonOnBuildForHost.interpreter} manage.py compress
80     '';
82   dependencies =
83     with python.pkgs;
84     [
85       aeidon
86       ahocorasick-rs
87       (toPythonModule (borgbackup.override { python3 = python; }))
88       celery
89       certifi
90       charset-normalizer
91       django-crispy-bootstrap3
92       cryptography
93       cssselect
94       cython
95       cyrtranslit
96       diff-match-patch
97       django-appconf
98       django-celery-beat
99       django-compressor
100       django-cors-headers
101       django-crispy-forms
102       django-filter
103       django-redis
104       django-otp
105       django-otp-webauthn
106       django
107       djangorestframework
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       pycairo
123       pygments
124       pygobject3
125       pyicumessageformat
126       pyparsing
127       python-dateutil
128       python-redis-lock
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       user-agents
142       weblate-language-data
143       weblate-schemas
144     ]
145     ++ python-redis-lock.optional-dependencies.django
146     ++ celery.optional-dependencies.redis;
148   optional-dependencies = {
149     postgres = with python.pkgs; [ psycopg ];
150   };
152   # We don't just use wrapGAppsNoGuiHook because we need to expose GI_TYPELIB_PATH
153   GI_TYPELIB_PATH = lib.makeSearchPathOutput "out" "lib/girepository-1.0" [
154     pango
155     harfbuzz
156     librsvg
157     gdk-pixbuf
158     glib
159   ];
160   makeWrapperArgs = [ "--set GI_TYPELIB_PATH \"$GI_TYPELIB_PATH\"" ];
162   passthru = {
163     inherit python;
164     # We need to expose this so weblate can work outside of calling its bin output
165     inherit GI_TYPELIB_PATH;
166     tests = {
167       inherit (nixosTests) weblate;
168     };
169   };
171   meta = with lib; {
172     description = "Web based translation tool with tight version control integration";
173     homepage = "https://weblate.org/";
174     license = with licenses; [
175       gpl3Plus
176       mit
177     ];
178     platforms = platforms.linux;
179     maintainers = with maintainers; [ erictapen ];
180   };