summaryrefslogtreecommitdiff
path: root/pkgs/bookwyrm.nix
blob: c3838f2f13cfc746684a1020263b7007caabe1f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
{ lib, fetchFromGitHub, python, writeShellScriptBin, writeText, settings ? { }
}:

let
  envfile = writeText "bookwyrm.env"
    (lib.strings.concatLines (lib.mapAttrsToList lib.toShellVar settings));

  bookwyrm = python.pkgs.buildPythonApplication rec {
    pname = "bookwyrm";
    version = "0.7.2";

    format = "other";

    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
    ];

    postBuild = ''
      ln -s ${envfile} .env
      python manage.py compile_themes
      python manage.py collectstatic --no-input
    '';

    postInstall = ''
      mkdir -p $out
      cp -r * .env $out
    '';

    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}
    '';
  };
in bookwyrm