summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--pkgs/bookwyrm.nix156
1 files changed, 80 insertions, 76 deletions
diff --git a/pkgs/bookwyrm.nix b/pkgs/bookwyrm.nix
index 5720d4c..c3838f2 100644
--- a/pkgs/bookwyrm.nix
+++ b/pkgs/bookwyrm.nix
@@ -1,86 +1,90 @@
-{ lib
-, fetchFromGitHub
-, python
+{ lib, fetchFromGitHub, python, writeShellScriptBin, writeText, settings ? { }
}:
+let
+ envfile = writeText "bookwyrm.env"
+ (lib.strings.concatLines (lib.mapAttrsToList lib.toShellVar settings));
-python.pkgs.buildPythonApplication rec {
- pname = "bookwyrm";
- version = "0.7.2";
+ bookwyrm = python.pkgs.buildPythonApplication rec {
+ pname = "bookwyrm";
+ version = "0.7.2";
- format = "other";
+ format = "other";
- src = fetchFromGitHub {
- owner = "bookwyrm-social";
- repo = "bookwyrm";
- rev = "refs/tags/v${version}";
- hash = "sha256-5QhIHpNUn65qTh7ARlnGfUESoxw8hqFaoS2D2z+OSlM=";
- };
+ src = fetchFromGitHub {
+ owner = "bookwyrm-social";
+ repo = "bookwyrm";
+ rev = "refs/tags/v${version}";
+ hash = "sha256-5QhIHpNUn65qTh7ARlnGfUESoxw8hqFaoS2D2z+OSlM=";
+ };
- propagatedBuildInputs = with python.pkgs; [
- aiohttp
- bleach
- celery
- colorthief
- django
- django-celery-beat
- bw-file-resubmit
- django-compressor
- django-imagekit
- django-model-utils
- django-sass-processor
- django-csp
- environs
- flower
- gunicorn
- libsass
- markdown
- packaging
- pillow
- psycopg2
- pycryptodome
- dateutil
- redis
- requests
- responses
- pytz
- boto3
- django-storages
- django-redis
- opentelemetry-api
- opentelemetry-exporter-otlp-proto-grpc
- # opentelemetry-instrumentation-celery
- opentelemetry-instrumentation-django
- # opentelemetry-instrumentation-pyscopg2
- opentelemetry-sdk
- protobuf
- pyotp
- qrcode
- grpcio
- ];
+ propagatedBuildInputs = with python.pkgs; [
+ aiohttp
+ bleach
+ celery
+ colorthief
+ django
+ django-celery-beat
+ bw-file-resubmit
+ django-compressor
+ django-imagekit
+ django-model-utils
+ django-sass-processor
+ django-csp
+ environs
+ flower
+ gunicorn
+ libsass
+ markdown
+ packaging
+ pillow
+ psycopg2
+ pycryptodome
+ dateutil
+ redis
+ requests
+ responses
+ pytz
+ boto3
+ django-storages
+ django-redis
+ opentelemetry-api
+ opentelemetry-exporter-otlp-proto-grpc
+ # opentelemetry-instrumentation-celery
+ opentelemetry-instrumentation-django
+ # opentelemetry-instrumentation-pyscopg2
+ opentelemetry-sdk
+ protobuf
+ pyotp
+ qrcode
+ grpcio
+ ];
- postBuild = ''
- # TODO: nice build input for customisable settings
- cp .env.example .env
- substituteInPlace .env --replace " = (1024**2 * 100)" "=10000000"
- substituteInPlace .env --replace "7(2w1sedok=aznpq)ta1mc4i%4h=xx@hxwx*o57ctsuml0x%fr" "asdjtuledjijkhtjphkedjjstihwhod"
- python manage.py compile_themes
- python manage.py collectstatic --no-input
- '';
+ postBuild = ''
+ ln -s ${envfile} .env
+ python manage.py compile_themes
+ python manage.py collectstatic --no-input
+ '';
- postInstall = ''
- mkdir -p $out
- cp -r static bookwyrm celerywyrm $out
- '';
+ postInstall = ''
+ mkdir -p $out
+ cp -r * .env $out
+ '';
- passthru = {
- pythonPath = python.pkgs.makePythonPath propagatedBuildInputs;
- gunicorn = python.pkgs.gunicorn;
- celery = python.pkgs.celery;
- };
+ passthru = {
+ pythonPath = python.pkgs.makePythonPath propagatedBuildInputs;
+ gunicorn = python.pkgs.gunicorn;
+ celery = python.pkgs.celery;
+ manage = writeShellScriptBin "bookwyrm-manage.py" ''
+ export PYTHONPATH=${passthru.pythonPath}
+ cd ${bookwyrm.outPath}
+ exec ${bookwyrm.outPath}/manage.py "$@"
+ '';
+ };
- # hacky hacky hack
- shellHook = ''
- export PYTHONPATH=${passthru.pythonPath}
- '';
-}
+ # hacky hacky hack
+ shellHook = ''
+ export PYTHONPATH=${passthru.pythonPath}
+ '';
+ };
+in bookwyrm