From 0a8ae58334dc21e7c3464d0dfa2bdde734d64d8c Mon Sep 17 00:00:00 2001 From: Jeltz Date: Sat, 22 Feb 2025 10:58:56 +0100 Subject: [PATCH] indico: wip: main pkg is almost working Signed-off-by: Jeltz --- pkgs/indico/default.nix | 92 +++++++++++++++++++++++++---- pkgs/indico/force_map_version.patch | 15 +++++ 2 files changed, 97 insertions(+), 10 deletions(-) create mode 100644 pkgs/indico/force_map_version.patch diff --git a/pkgs/indico/default.nix b/pkgs/indico/default.nix index d00560e..a80b249 100644 --- a/pkgs/indico/default.nix +++ b/pkgs/indico/default.nix @@ -3,6 +3,17 @@ fetchFromGitHub, fetchPypi, python3, + nodejs, + callPackage, + fetchNpmDeps, + npmHooks, + stdenv, + substituteAll, + prefetch-npm-deps, + pkg-config, + pixman, + cairo, + pango, }: let @@ -34,8 +45,12 @@ let sqlalchemy = super.sqlalchemy_1_4; wtforms-dateutil = self.callPackage ../wtforms-dateutil { }; wtforms-sqlalchemy = self.callPackage ../wtforms-sqlalchemy { }; + flask-url-map-serializer = self.callPackage ../flask-url-map-serializer { }; }; }; + # TODO PR + qTipUpstreamUrl = "git+https://indico@github.com/indico/qTip2.git#8951e5538a5c0833021b2d2b5d8a587a2c24faae"; + qTipLocalUrl = "git+https://github.com/federez-tba/qTip2.git#8d1d579c0aac94333e390f19aa0489c57bf74cf7"; in python.pkgs.buildPythonApplication rec { pname = "indico"; @@ -51,25 +66,83 @@ python.pkgs.buildPythonApplication rec { hash = "sha256-OX5tqeIjd7Lb5XfvFFKcYb9Dbf5Z9QLXlVTepTpeOMU="; }; - build-system = with python.pkgs; [ - hatchling - hatch-requirements-txt + INDICO_NO_GIT = "true"; + INDICO_MAP_VERSION = src.outputHash; + + # TODO bin/maintenance/build-{wheel,assets}.py + build-system = [ + python.pkgs.hatchling + python.pkgs.hatch-requirements-txt + python.pkgs.babel + python.pkgs.flask-url-map-serializer + nodejs + npmHooks.npmConfigHook + # Used by the npm dependency "canvas" + pkg-config ]; + buildInputs = [ + # Used by the npm dependency "canvas" + pixman + cairo + pango + ]; + + npmDeps = fetchNpmDeps { + inherit src patches postPatch; + pname = "${pname}-${version}-npm-deps"; + hash = "sha256-OeeA2NyRnhlQuSryTmqsLcNNkXde0Vnk21pHddV3aco="; + }; + + # FIXME *why* is it required? + makeCacheWritable = true; + + npmFlags = [ "--verbose" ]; + patches = [ ./remove_marshmallow_enum.patch + ./force_map_version.patch ]; postPatch = '' + # Seems fixed (the dependency is gone in master) + substituteInPlace requirements.in \ + --replace-fail "hiredis<3" "" # See JoshData/python-email-validator#90 substituteInPlace requirements.in \ - --replace "email-validator<1.3.0" "email-validator!=1.3.0" + --replace-fail "email-validator<1.3.0" "email-validator!=1.3.0" # Botocore doesn't seem to be used anymore - substituteInPlace requirements.in --replace "urllib3<2" "urllib3" + substituteInPlace requirements.in \ + --replace-fail "urllib3<2" "urllib3" # Seems fixed - substituteInPlace requirements.in --replace "pydyf<0.10" "pydyf" + substituteInPlace requirements.in \ + --replace-fail "pydyf<0.10" "pydyf" # Remove transitive dependencies and unnecessary version pins cp requirements.in requirements.txt + cp requirements.dev.in requirements.dev.txt + # Nix's pyproject format builds a wheel, but the custom hook + # is configured only for sdists (TODO figure out why) + substituteInPlace pyproject.toml \ + --replace-fail "tool.hatch.build.targets.sdist.hooks.custom" \ + "tool.hatch.build.hooks.custom" \ + --replace-fail "babel==2.16.0" "babel" \ + --replace-fail "hatchling==1.25.0" "hatchling" + substituteInPlace package.json \ + --replace-fail ${qTipUpstreamUrl} ${qTipLocalUrl} + substituteInPlace package-lock.json \ + --replace-fail ${qTipUpstreamUrl} ${qTipLocalUrl} + # Make the WSGI module importable by Gunicorn + # (TODO is there a way to use Gunicorn with a path?) + mv indico/web/indico.wsgi indico/web/wsgi.py + # TODO TODO ./bin/maintenance/build-assets.py + ''; + + # TODO build-assets.py + # build_urls_map.py tries to import indico.web.flask.app + # which has not been installed yet at this stage + preBuild = '' + ls -lah + PYTHONPATH="$(pwd):$PYTHONPATH" ${lib.getExe python} bin/maintenance/build-assets.py indico --clean ''; dependencies = @@ -102,7 +175,6 @@ python.pkgs.buildPythonApplication rec { flask-wtf flask google-auth - hiredis html2text icalendar indico-fonts @@ -161,9 +233,9 @@ python.pkgs.buildPythonApplication rec { ++ sentry-sdk_1.optional-dependencies.pure_eval ++ wtforms.optional-dependencies.email; - passthru = { - inherit python; - }; + # passthru = { + # inherit python; + # }; meta = { description = "Full-featured conferency lifecycle management and meeting/lecture scheduling tool"; diff --git a/pkgs/indico/force_map_version.patch b/pkgs/indico/force_map_version.patch new file mode 100644 index 0000000..f8c44ca --- /dev/null +++ b/pkgs/indico/force_map_version.patch @@ -0,0 +1,15 @@ +diff --git a/bin/maintenance/dump_url_map.py b/bin/maintenance/dump_url_map.py +index 050b671c46..cf56a20f72 100644 +--- a/bin/maintenance/dump_url_map.py ++++ b/bin/maintenance/dump_url_map.py +@@ -19,7 +19,9 @@ def get_map_version(): + # whenever something changed + h = hashlib.md5() + h.update(os.getcwd().encode()) +- if not os.environ.get('INDICO_NO_GIT'): ++ if (version := os.environ.get("INDICO_MAP_VERSION")): ++ h.update(version.encode()) ++ elif not os.environ.get('INDICO_NO_GIT'): + h.update(subprocess.check_output(['git', 'describe', '--always'])) + h.update(subprocess.check_output(['git', 'status'])) + h.update(subprocess.check_output(['git', 'diff']))