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