server-configs/machines/gerd/services/wger/wgerpkg/default.nix
eyjhb 6fedaed0f9
bumped sources
- ssh boot - removed /32, otherwise we got error
  `can't parse IP address "xx.xx.xx.xx/32"`
- wger - cleaned up, because of deprecated errors
2025-04-19 13:05:56 +02:00

175 lines
3.8 KiB
Nix

{
lib
, python
, fetchFromGitHub
, buildPythonPackage
, callPackage
, writeText
, fetchpatch
# build systems
, hatchling
# deps
, bleach
, celery
, django-crispy-bootstrap5
, django
, django-activity-stream ? callPackage ./django-activity-stream.nix {}
, django-axes
, django-compressor
, django-cors-headers
, django-crispy-forms
, django-email-verification ? callPackage ./django-email-verification.nix {}
, django-environ
, django-filter
, django-formtools
, django-prometheus
, django-recaptcha ? callPackage ./django-recaptcha.nix {}
, django-simple-history
, django-sortedm2m ? callPackage ./django-sortedm2m.nix {}
, django-storages
, djangorestframework
, djangorestframework-simplejwt
, drf-spectacular
, easy-thumbnails
, flower
, fontawesomefree
, icalendar
, invoke
, openfoodfacts ? callPackage ./openfoodfacts.nix {}
, pillow
, reportlab
, requests
, tqdm
, tzdata
# extra deps
, redis
, django-redis
, drf-spectacular-sidecar
, django-bootstrap-breadcrumbs ? callPackage ./django-bootstrap-breadcrumbs.nix {}
, psycopg2
}:
let
frontend = callPackage ./frontend.nix {};
in buildPythonPackage rec {
pname = "wger";
version = "2.3";
pyproject = true;
src = fetchFromGitHub {
owner = "wger-project";
repo = "wger";
rev = version;
hash = "sha256-riJyVl0/GwAGkcHVzkJc666owPk1E4ca8DV5qTjEbjk=";
};
build-system = [
hatchling
];
patches = [
./patches/pyproject.patch
./patches/manage.patch
./patches/exercises-no-gifs.patch
# adds support for proxy auth header
(fetchpatch {
url = "https://github.com/wger-project/wger/pull/1859/commits/331b2d5d2d520411a7b75193823bbc175802e547.patch";
sha256 = "sha256-5OuuInEO8e7OuWaI311HeHp5Pl6bZmix6wLDn8bEgR4=";
})
];
# dependencies = with python3.pkgs; [
propagatedBuildInputs = [
bleach
celery
django-crispy-bootstrap5
django
django-activity-stream
django-axes
django-compressor
django-cors-headers
django-crispy-forms
django-email-verification
django-environ
django-filter
django-formtools
django-prometheus
django-recaptcha
django-simple-history
django-sortedm2m
django-storages
djangorestframework
djangorestframework-simplejwt
drf-spectacular
easy-thumbnails
flower
fontawesomefree
icalendar
invoke
openfoodfacts
pillow
reportlab
requests
tqdm
tzdata
# extra??
redis
django-redis
drf-spectacular-sidecar
django-bootstrap-breadcrumbs
psycopg2
];
postPatch = ''
cp manage.py wger/manage.py
'';
# fixup compressed files
postBuild = let
staticSettings = writeText "static_settings.py" ''
import os
DEBUG = False
STATIC_ROOT = os.environ["static"]
COMPRESS_OFFLINE = True
# So we don't need postgres dependencies
DATABASES = {}
'';
in ''
# copy over static yarn things
# cp -a ${frontend}/static/yarn $out/${python.sitePackages}/wger/core/static
cp -a ${frontend}/static/yarn wger/core/static
python3 -m wger create-settings -s $PWD/tmp_settings.py
cat ${staticSettings} >> $PWD/tmp_settings.py
mkdir tmpstatic
pushd tmpstatic
static=. WGER_SETTINGS=../tmp_settings.py python ../manage.py collectstatic --no-input
static=. WGER_SETTINGS=../tmp_settings.py python ../manage.py compress --force
popd
'';
postInstall = ''
rm -rf $out/${python.sitePackages}/wger/core/static
cp -a tmpstatic $out/${python.sitePackages}/wger/core/static
mkdir $out/share
cp -a $out/${python.sitePackages}/wger/core/static $out/share
'';
pythonImportsCheck = [
"wger"
];
meta = {
description = "";
homepage = "https://github.com/wger-project/wger";
license = lib.licenses.agpl3Only;
maintainers = with lib.maintainers; [ eyjhb ];
mainProgram = "wger";
};
}