btrbk: add mainProgram
[NixPkgs.git] / pkgs / by-name / pr / pretalx / package.nix
blob78fdd3f34b6690e469ed5b55117bee7f4696176c
1 { lib
2 , buildNpmPackage
3 , gettext
4 , python3
5 , fetchFromGitHub
6 , plugins ? [ ]
7 , nixosTests
8 }:
10 let
11   python = python3.override {
12     self = python;
13     packageOverrides = final: prev: {
14       django = prev.django_5;
16       django-bootstrap4 = prev.django-bootstrap4.overridePythonAttrs (oldAttrs: rec {
17         version = "3.0.0";
18         src = oldAttrs.src.override {
19           rev = "v${version}";
20           hash = "sha256-a8BopUwZjmvxOzBVqs4fTo0SY8sEEloGUw90daYWfz8=";
21         };
23         propagatedBuildInputs = with final; [
24           beautifulsoup4
25           django
26         ];
28         # fails with some assertions
29         doCheck = false;
30       });
32       django-extensions = prev.django-extensions.overridePythonAttrs {
33         # Compat issues with Django 5.1
34         # https://github.com/django-extensions/django-extensions/issues/1885
35         doCheck = false;
36       };
37     };
38   };
40   version = "2024.3.1";
42   src = fetchFromGitHub {
43     owner = "pretalx";
44     repo = "pretalx";
45     rev = "v${version}";
46     hash = "sha256-y3BsNmLh9M5NgDPURCjCGWYci40hYcQtDVqsu2HqPRU=";
47   };
49   meta = with lib; {
50     description = "Conference planning tool: CfP, scheduling, speaker management";
51     mainProgram = "pretalx-manage";
52     homepage = "https://github.com/pretalx/pretalx";
53     changelog = "https://docs.pretalx.org/changelog/#${version}";
54     license = licenses.asl20;
55     maintainers = with maintainers; [ hexa] ++ teams.c3d2.members;
56     platforms = platforms.linux;
57   };
59   frontend = buildNpmPackage {
60     pname = "pretalx-frontend";
61     inherit version src;
63     sourceRoot = "${src.name}/src/pretalx/frontend/schedule-editor";
65     npmDepsHash = "sha256-i7awRuR7NxhpxN2IZuI01PsN6FjXht7BxTbB1k039HA=";
67     npmBuildScript = "build";
69     inherit meta;
70   };
72 python.pkgs.buildPythonApplication rec {
73   pname = "pretalx";
74   inherit version src;
75   pyproject = true;
77   outputs = [
78     "out"
79     "static"
80   ];
82   postPatch = ''
83     substituteInPlace src/pretalx/common/management/commands/rebuild.py \
84       --replace 'subprocess.check_call(["npm", "run", "build"], cwd=frontend_dir, env=env)' ""
85   '';
87   nativeBuildInputs = [
88     gettext
89   ];
91   build-system = with python.pkgs; [
92     setuptools
93   ];
95   pythonRelaxDeps = [
96     "celery"
97     "css-inline"
98     "cssutils"
99     "defusedxml"
100     "django-compressor"
101     "django-csp"
102     "django-filter"
103     "django-hierarkey"
104     "djangorestframework"
105     "markdown"
106     "pillow"
107     "publicsuffixlist"
108     "python-dateutil"
109     "reportlab"
110     "requests"
111     "rules"
112     "whitenoise"
113   ];
115   dependencies = with python.pkgs; [
116     beautifulsoup4
117     bleach
118     celery
119     css-inline
120     csscompressor
121     cssutils
122     defusedcsv
123     defusedxml
124     django
125     django-bootstrap4
126     django-compressor
127     django-context-decorator
128     django-countries
129     django-csp
130     django-filter
131     django-formset-js-improved
132     django-formtools
133     django-hierarkey
134     django-i18nfield
135     django-libsass
136     django-scopes
137     djangorestframework
138     libsass
139     markdown
140     pillow
141     publicsuffixlist
142     python-dateutil
143     qrcode
144     reportlab
145     requests
146     rules
147     urlman
148     vobject
149     whitenoise
150     zxcvbn
151   ]
152   ++ beautifulsoup4.optional-dependencies.lxml
153   ++ django.optional-dependencies.argon2
154   ++ plugins;
156   optional-dependencies = {
157     postgres = with python.pkgs; [
158       psycopg2
159     ];
160     redis = with python.pkgs; [
161       redis
162     ];
163   };
165   postBuild = ''
166     rm -r ./src/pretalx/frontend/schedule-editor
167     ln -s ${frontend}/lib/node_modules/@pretalx/schedule-editor ./src/pretalx/frontend/schedule-editor
169     # Generate all static files, see https://docs.pretalx.org/administrator/commands.html#python-m-pretalx-rebuild
170     PYTHONPATH=$PYTHONPATH:./src python -m pretalx rebuild
171   '';
173   postInstall = ''
174     mkdir -p $out/bin
175     cp ./src/manage.py $out/bin/pretalx-manage
177     # The processed source files are in the static output, except for fonts, which are duplicated.
178     # See <https://github.com/pretalx/pretalx/issues/1585> for more details.
179     find $out/${python.sitePackages}/pretalx/static \
180       -mindepth 1 \
181       -not -path "$out/${python.sitePackages}/pretalx/static/fonts*" \
182       -delete
184     # Copy generated static files into dedicated output
185     mkdir -p $static
186     cp -r ./src/static.dist/** $static/
188     # Copy frontend files
189     ln -s ${frontend}/lib/node_modules/@pretalx/schedule-editor/dist/* $static
190   '';
192   preCheck = ''
193     export PRETALX_CONFIG_FILE="$src/src/tests/ci_sqlite.cfg"
194     cd src
195   '';
197   nativeCheckInputs = with python.pkgs; [
198     faker
199     freezegun
200     jsonschema
201     pytest-cov-stub
202     pytest-django
203     pytest-mock
204     pytest-xdist
205     pytestCheckHook
206     responses
207   ] ++ lib.flatten (lib.attrValues optional-dependencies);
209   disabledTests = [
210     # tries to run npm run i18n:extract
211     "test_common_custom_makemessages_does_not_blow_up"
212     # Expected to perform X queries or less but Y were done
213     "test_can_see_schedule"
214     "test_schedule_export_public"
215     "test_schedule_frab_json_export"
216     "test_schedule_frab_xcal_export"
217     "test_schedule_frab_xml_export"
218     "test_schedule_frab_xml_export_control_char"
219     "test_schedule_page_text_list"
220     "test_schedule_page_text_table"
221     "test_schedule_page_text_wrong_format"
222     "test_versioned_schedule_page"
223     # Test is racy
224     "test_can_reset_password_by_email"
225   ];
227   passthru = {
228     inherit python;
229     tests = {
230       inherit (nixosTests) pretalx;
231     };
232     plugins = lib.recurseIntoAttrs (
233       lib.packagesFromDirectoryRecursive {
234         inherit (python.pkgs) callPackage;
235         directory = ./plugins;
236       }
237     );
238   };
240   inherit meta;