1
Fork 0
e11sync/pkgs/e11sync.nix

62 lines
1.5 KiB
Nix
Raw Normal View History

2024-01-14 19:54:32 +02:00
{
self,
lib,
2024-01-14 19:54:32 +02:00
stdenv,
runCommand,
makeWrapper,
python3,
python3Packages,
libmaxminddb,
dart-sass,
gunicornPort ? 8001,
database-path ? null,
2024-01-14 19:54:32 +02:00
geoip-archive,
}:
stdenv.mkDerivation {
name = "e11sync";
propagatedBuildInputs = [
python3Packages.django_5
python3Packages.django-compressor
python3Packages.geoip2
libmaxminddb
];
nativeBuildInputs = [makeWrapper];
src = self;
patchPhase = ''patchShebangs --build app/manage.py'';
buildPhase = ''mkdir -p $out'';
installPhase = ''
cp -r app $out
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} \
${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-archive}" \
--add-flags --bind=127.0.0.1:\$E11SYNC_HTTP_PORT \
--add-flags e11sync.wsgi
makeWrapper $out/app/manage.py $out/bin/e11sync \
--set GEOIP_PATH "${geoip-archive}"
'';
2024-01-14 23:31:23 +02:00
passthru.tests.unit =
runCommand "e11sync-test" {
src = self;
2024-01-14 23:31:23 +02:00
buildInputs = [
python3Packages.django_5
python3Packages.django-compressor
python3Packages.geoip2
dart-sass
];
} ''
unpackPhase
patchShebangs --build $sourceRoot/app/manage.py
cd $sourceRoot
2024-01-14 23:31:23 +02:00
export GEOIP_PATH="${geoip-archive}"
app/manage.py test app
mkdir -p $out
2024-01-14 23:31:23 +02:00
'';
2024-01-14 19:54:32 +02:00
}