nixpkgs/pkgs/by-name/pr/pretalx/package.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

238 lines
5.6 KiB
Nix
Raw Normal View History

2023-05-14 13:42:04 +00:00
{ lib
, buildNpmPackage
, gettext
2024-07-06 13:32:17 +00:00
, python3
2023-05-14 13:42:04 +00:00
, fetchFromGitHub
2024-06-13 07:36:56 +00:00
, fetchpatch2
2024-05-15 12:10:03 +00:00
, plugins ? [ ]
2023-05-14 13:42:04 +00:00
, nixosTests
}:
let
2024-07-06 13:32:17 +00:00
python = python3.override {
2023-05-14 13:42:04 +00:00
packageOverrides = final: prev: {
django-bootstrap4 = prev.django-bootstrap4.overridePythonAttrs (oldAttrs: rec {
version = "3.0.0";
src = oldAttrs.src.override {
rev = "v${version}";
hash = "sha256-a8BopUwZjmvxOzBVqs4fTo0SY8sEEloGUw90daYWfz8=";
};
propagatedBuildInputs = with final; [
beautifulsoup4
django
];
# fails with some assertions
doCheck = false;
});
};
};
version = "2024.1.0";
2023-05-14 13:42:04 +00:00
src = fetchFromGitHub {
owner = "pretalx";
repo = "pretalx";
rev = "v${version}";
hash = "sha256-rFOlovybaEZnv5wBx6Dv8bVkP1D+CgYAKRXuNb6hLKQ=";
2023-05-14 13:42:04 +00:00
};
meta = with lib; {
description = "Conference planning tool: CfP, scheduling, speaker management";
mainProgram = "pretalx-manage";
2023-05-14 13:42:04 +00:00
homepage = "https://github.com/pretalx/pretalx";
changelog = "https://docs.pretalx.org/en/latest/changelog.html";
2023-05-14 13:42:04 +00:00
license = licenses.asl20;
maintainers = with maintainers; [ hexa] ++ teams.c3d2.members;
2023-05-14 13:42:04 +00:00
platforms = platforms.linux;
};
frontend = buildNpmPackage {
pname = "pretalx-frontend";
inherit version src;
sourceRoot = "${src.name}/src/pretalx/frontend/schedule-editor";
npmDepsHash = "sha256-B9R3Nn4tURNxzeyLDHscqHxYOQK9AcmDnyNq3k5WQQs=";
2023-05-14 13:42:04 +00:00
npmBuildScript = "build";
inherit meta;
};
in
python.pkgs.buildPythonApplication rec {
pname = "pretalx";
inherit version src;
pyproject = true;
outputs = [
"out"
"static"
];
2024-06-13 07:36:56 +00:00
patches = [
(fetchpatch2 {
# Backport support for Djangorestframework 3.15.x
name = "pretalx-drf-3.15.patch";
url = "https://github.com/pretalx/pretalx/commit/43a0416c6968d64ea57720abdb82f482940b11f8.patch";
hash = "sha256-Iw1xVF7j7c712kwIk1SMbQSF0ixMUZr1BJib3KAb2HY=";
})
];
2023-05-14 13:42:04 +00:00
postPatch = ''
substituteInPlace src/pretalx/common/management/commands/rebuild.py \
--replace 'subprocess.check_call(["npm", "run", "build"], cwd=frontend_dir, env=env)' ""
substituteInPlace src/setup.cfg \
--replace "--cov=./ --cov-report=" ""
2023-05-14 13:42:04 +00:00
'';
nativeBuildInputs = [
gettext
] ++ (with python.pkgs; [
setuptools
]);
pythonRelaxDeps = [
2024-05-05 18:52:26 +00:00
"celery"
"css-inline"
"cssutils"
"django-compressor"
"django-csp"
"django-filter"
2024-05-05 18:52:26 +00:00
"django-hierarkey"
2024-06-13 07:36:56 +00:00
"djangorestframework"
2024-05-05 18:52:26 +00:00
"markdown"
"pillow"
"publicsuffixlist"
"python-dateutil"
2024-05-05 18:52:26 +00:00
"reportlab"
2024-06-12 19:31:40 +00:00
"requests"
2024-05-19 00:11:36 +00:00
"rules"
2023-05-14 13:42:04 +00:00
];
propagatedBuildInputs = with python.pkgs; [
beautifulsoup4
bleach
celery
css-inline
csscompressor
cssutils
defusedcsv
django
django-bootstrap4
django-compressor
django-context-decorator
django-countries
django-csp
django-filter
django-formset-js-improved
django-formtools
django-hierarkey
django-i18nfield
django-libsass
django-scopes
djangorestframework
libsass
markdown
pillow
publicsuffixlist
python-dateutil
qrcode
reportlab
requests
rules
urlman
vobject
whitenoise
zxcvbn
2024-05-15 12:10:03 +00:00
] ++ beautifulsoup4.optional-dependencies.lxml ++ plugins;
2023-05-14 13:42:04 +00:00
passthru.optional-dependencies = {
mysql = with python.pkgs; [
mysqlclient
];
postgres = with python.pkgs; [
psycopg2
];
redis = with python.pkgs; [
redis
];
};
postBuild = ''
rm -r ./src/pretalx/frontend/schedule-editor
ln -s ${frontend}/lib/node_modules/@pretalx/schedule-editor ./src/pretalx/frontend/schedule-editor
# Generate all static files, see https://docs.pretalx.org/administrator/commands.html#python-m-pretalx-rebuild
PYTHONPATH=$PYTHONPATH:./src python -m pretalx rebuild
'';
postInstall = ''
mkdir -p $out/bin
cp ./src/manage.py $out/bin/pretalx-manage
# The processed source files are in the static output, except for fonts, which are duplicated.
# See <https://github.com/pretalx/pretalx/issues/1585> for more details.
find $out/${python.sitePackages}/pretalx/static \
-mindepth 1 \
-not -path "$out/${python.sitePackages}/pretalx/static/fonts*" \
-delete
# Copy generated static files into dedicated output
mkdir -p $static
cp -r ./src/static.dist/** $static/
# Copy frontend files
ln -s ${frontend}/lib/node_modules/@pretalx/schedule-editor/dist/* $static
'';
preCheck = ''
export PRETALX_CONFIG_FILE="$src/src/tests/ci_sqlite.cfg"
cd src
'';
nativeCheckInputs = with python.pkgs; [
faker
freezegun
jsonschema
2023-05-14 13:42:04 +00:00
pytest-django
pytest-mock
pytest-xdist
pytestCheckHook
responses
] ++ lib.flatten (builtins.attrValues passthru.optional-dependencies);
disabledTests = [
# tries to run npm run i18n:extract
"test_common_custom_makemessages_does_not_blow_up"
# Expected to perform X queries or less but Y were done
"test_can_see_schedule"
2023-05-14 13:42:04 +00:00
"test_schedule_export_public"
"test_schedule_frab_json_export"
"test_schedule_frab_xcal_export"
2023-05-14 13:42:04 +00:00
"test_schedule_frab_xml_export"
"test_schedule_frab_xml_export_control_char"
"test_schedule_page_text_list"
"test_schedule_page_text_table"
"test_schedule_page_text_wrong_format"
"test_versioned_schedule_page"
2023-05-14 13:42:04 +00:00
];
passthru = {
inherit python;
tests = {
inherit (nixosTests) pretalx;
};
2024-05-15 12:10:03 +00:00
plugins = lib.recurseIntoAttrs (
lib.packagesFromDirectoryRecursive {
inherit (python.pkgs) callPackage;
directory = ./plugins;
}
);
2023-05-14 13:42:04 +00:00
};
inherit meta;
}