diff --git a/machines/gerd/services/wger/default.nix b/machines/gerd/services/wger/default.nix index cf3e762..0469306 100644 --- a/machines/gerd/services/wger/default.nix +++ b/machines/gerd/services/wger/default.nix @@ -95,6 +95,7 @@ let WGER_SETTINGS[k] = v ''; + settingsFileDir = pkgs.writeTextDir "settings.py" (builtins.readFile settingsFile); in { # main service @@ -103,13 +104,20 @@ in { wantedBy = [ "multi-user.target" ]; after = [ "networking.target" ]; - script = '' + script = let + pythonEnv = pkgs.python3.withPackages (ps: with ps; [ + gunicorn + (pkgs.python3Packages.callPackage ./wgerpkg/default.nix {}) + ]); + in '' # initial setup ${wgerpkgs}/bin/wger migrate-db -s ${settingsFile} || true - ${wgerpkgs}/bin/wger load-fixtures -s ${settingsFile} || true + # TODO: fix at some point + # ${wgerpkgs}/bin/wger load-fixtures -s ${settingsFile} || true # run server - ${wgerpkgs}/bin/wger start -s ${settingsFile} + # ${wgerpkgs}/bin/wger start -s ${settingsFile} + PYTHONPATH="${pythonEnv}/${pkgs.python3.sitePackages}:${settingsFileDir}" ${pythonEnv}/bin/gunicorn wger.wsgi:application --reload --bind 127.0.0.1:${builtins.toString port} ''; serviceConfig = { diff --git a/machines/gerd/services/wger/wgerpkg/default.nix b/machines/gerd/services/wger/wgerpkg/default.nix index bb2438d..1f80708 100644 --- a/machines/gerd/services/wger/wgerpkg/default.nix +++ b/machines/gerd/services/wger/wgerpkg/default.nix @@ -8,7 +8,7 @@ let frontend = callPackage ./frontend.nix {}; -in python3.pkgs.buildPythonApplication rec { +in python3.pkgs.buildPythonPackage rec { pname = "wger"; version = "unstable-2024-12-01"; pyproject = true; @@ -28,6 +28,7 @@ in python3.pkgs.buildPythonApplication rec { ./patches/pyproject.patch ./patches/tasks.patch ./patches/manage.patch + ./patches/exercises-no-gifs.patch ]; # dependencies = with python3.pkgs; [ diff --git a/machines/gerd/services/wger/wgerpkg/patches/exercises-no-gifs.patch b/machines/gerd/services/wger/wgerpkg/patches/exercises-no-gifs.patch new file mode 100644 index 0000000..b1639d1 --- /dev/null +++ b/machines/gerd/services/wger/wgerpkg/patches/exercises-no-gifs.patch @@ -0,0 +1,32 @@ +diff --git a/wger/exercises/api/views.py b/wger/exercises/api/views.py +index d6387bb2b..86bca386b 100644 +--- a/wger/exercises/api/views.py ++++ b/wger/exercises/api/views.py +@@ -374,12 +374,13 @@ def search(request): + image = image_obj.image.url + t = get_thumbnailer(image_obj.image) + thumbnail = None +- try: +- thumbnail = t.get_thumbnail(aliases.get('micro_cropped')).url +- except InvalidImageFormatError as e: +- logger.info(f'InvalidImageFormatError while processing a thumbnail: {e}') +- except OSError as e: +- logger.info(f'OSError while processing a thumbnail: {e}') ++ if not image.lower().endswith(".gif"): ++ try: ++ thumbnail = t.get_thumbnail(aliases.get('micro_cropped')).url ++ except InvalidImageFormatError as e: ++ logger.info(f'InvalidImageFormatError while processing a thumbnail: {e}') ++ except OSError as e: ++ logger.info(f'OSError while processing a thumbnail: {e}') + + result_json = { + 'value': translation.name, +@@ -393,6 +394,7 @@ def search(request): + }, + } + results.append(result_json) ++ + response['suggestions'] = results + return Response(response) +