1
Fork 0
e11sync/pkgs/e11sync-backend.nix

70 lines
1.8 KiB
Nix
Raw Normal View History

2024-01-14 19:54:32 +02:00
{
lib,
2024-01-14 19:54:32 +02:00
stdenv,
runCommand,
makeWrapper,
2024-01-16 00:09:47 +02:00
python3,
2024-01-14 19:54:32 +02:00
python3Packages,
libmaxminddb,
dart-sass,
uwsgi,
backendPort ? 8002,
database-path ? null,
geoip-mmdb,
2024-01-14 19:54:32 +02:00
}:
stdenv.mkDerivation {
name = "e11sync";
2024-01-16 00:09:47 +02:00
propagatedBuildInputs = let
pythonEnv = python3.withPackages (ps:
2024-01-16 00:09:47 +02:00
with ps; [
django_5
django-compressor.override
{django = django_5;}
#{django-appconf = django-appconf.override {django = django_5;};}
2024-01-16 00:09:47 +02:00
geoip2
]);
in [
pythonEnv
2024-01-14 19:54:32 +02:00
libmaxminddb
];
nativeBuildInputs = [makeWrapper];
2024-01-15 07:50:38 +02:00
src = ../app;
patchPhase = ''patchShebangs --build manage.py'';
buildPhase = ''mkdir -p $out'';
installPhase = ''
2024-01-15 07:50:38 +02:00
cp -r . $out/app
makeWrapper $out/app/manage.py $out/bin/e11sync \
--set GEOIP_PATH "${geoip-mmdb}"
makeWrapper ${uwsgi}/bin/uwsgi $out/bin/e11sync-backend \
2024-01-14 19:54:32 +02:00
--chdir $out/app \
--set-default E11SYNC_HTTP_PORT ${toString backendPort} \
--add-flags "--plugin ${uwsgi}/lib/uwsgi/python3_plugin.so" \
--add-flags "--http-socket 127.0.0.1:${toString backendPort}" \
--add-flags "--wsgi-file e11sync/wsgi.py" \
--add-flags --master \
${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 \
--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
];
} ''
unpackPhase
2024-01-15 07:50:38 +02:00
patchShebangs --build app/manage.py
export GEOIP_PATH="${geoip-mmdb}"
app/manage.py test app
mkdir -p $out
2024-01-14 23:31:23 +02:00
'';
2024-01-14 19:54:32 +02:00
}