2024-01-14 19:54:32 +02:00
|
|
|
{
|
2024-01-14 23:23:39 +02:00
|
|
|
lib,
|
2024-01-14 19:54:32 +02:00
|
|
|
stdenv,
|
|
|
|
runCommand,
|
|
|
|
makeWrapper,
|
|
|
|
python3Packages,
|
|
|
|
libmaxminddb,
|
|
|
|
dart-sass,
|
2024-01-15 11:57:36 +02:00
|
|
|
gunicornPort ? 8002,
|
2024-01-14 23:23:39 +02:00
|
|
|
database-path ? null,
|
2024-01-15 10:52:46 +02:00
|
|
|
geoip-mmdb,
|
2024-01-14 19:54:32 +02:00
|
|
|
}:
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "e11sync";
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
python3Packages.django_5
|
|
|
|
python3Packages.django-compressor
|
|
|
|
python3Packages.geoip2
|
|
|
|
libmaxminddb
|
|
|
|
];
|
|
|
|
nativeBuildInputs = [makeWrapper];
|
2024-01-15 07:50:38 +02:00
|
|
|
src = ../app;
|
|
|
|
patchPhase = ''patchShebangs --build manage.py'';
|
2024-01-14 22:49:44 +02:00
|
|
|
buildPhase = ''mkdir -p $out'';
|
|
|
|
installPhase = ''
|
2024-01-15 07:50:38 +02:00
|
|
|
cp -r . $out/app
|
2024-01-14 19:54:32 +02:00
|
|
|
makeWrapper ${python3Packages.gunicorn}/bin/gunicorn $out/bin/e11sync-gunicorn \
|
|
|
|
--chdir $out/app \
|
|
|
|
--set-default E11SYNC_HTTP_PORT ${toString gunicornPort} \
|
2024-01-14 23:23:39 +02:00
|
|
|
${lib.optionalString (database-path != null) ''
|
2024-01-14 23:31:23 +02:00
|
|
|
--set E11SYNC_DATABASE_PATH "${database-path}" \
|
|
|
|
''} \
|
2024-01-14 19:54:32 +02:00
|
|
|
--set E11SYNC_DEBUG "" \
|
|
|
|
--set E11SYNC_COMPRESS_OFFLINE 1 \
|
2024-01-15 10:52:46 +02:00
|
|
|
--set GEOIP_PATH "${geoip-mmdb}" \
|
2024-01-14 19:54:32 +02:00
|
|
|
--add-flags --bind=127.0.0.1:\$E11SYNC_HTTP_PORT \
|
|
|
|
--add-flags e11sync.wsgi
|
|
|
|
|
|
|
|
makeWrapper $out/app/manage.py $out/bin/e11sync \
|
2024-01-15 10:52:46 +02:00
|
|
|
--set GEOIP_PATH "${geoip-mmdb}"
|
2024-01-14 19:54:32 +02:00
|
|
|
'';
|
2024-01-14 23:31:23 +02:00
|
|
|
passthru.tests.unit =
|
|
|
|
runCommand "e11sync-test" {
|
2024-01-15 07:50:38 +02:00
|
|
|
src = ../app;
|
2024-01-14 23:31:23 +02:00
|
|
|
buildInputs = [
|
|
|
|
python3Packages.django_5
|
|
|
|
python3Packages.django-compressor
|
|
|
|
python3Packages.geoip2
|
|
|
|
dart-sass
|
|
|
|
];
|
|
|
|
} ''
|
2024-01-14 23:41:19 +02:00
|
|
|
unpackPhase
|
2024-01-15 07:50:38 +02:00
|
|
|
patchShebangs --build app/manage.py
|
2024-01-15 10:52:46 +02:00
|
|
|
export GEOIP_PATH="${geoip-mmdb}"
|
2024-01-14 23:41:19 +02:00
|
|
|
app/manage.py test app
|
|
|
|
mkdir -p $out
|
2024-01-14 23:31:23 +02:00
|
|
|
'';
|
2024-01-14 19:54:32 +02:00
|
|
|
}
|