2025-03-03 21:03:41 +01:00
{
fetchFromGitHub ,
pkgs ,
stdenv ,
} :
with builtins ;
2025-03-04 12:28:03 +01:00
with pkgs ;
2025-03-03 21:03:41 +01:00
with pkgs . kernelmaft . python ;
with pkgs . python311Packages ;
with stdenv ;
mkDerivation {
pname = " b o o k w y r m " ;
version = " 2 0 2 5 - 0 2 - 1 4 - b a 1 f 1 8 0 " ;
src = fetchFromGitHub {
owner = " b o o k w y r m - s o c i a l " ;
repo = " b o o k w y r m " ;
rev = " b a 1 f 1 8 0 c 8 3 4 e 1 b 8 4 d 3 3 e 5 6 5 a b c 3 d 9 5 f 7 7 2 e 2 c d d 8 " ;
hash = " s h a 2 5 6 - 8 e 1 + p f U R T v z s W u m R p e B Z G D y D 8 U W 1 C 9 8 V v 9 / 1 G q E C L D 4 = " ;
} ;
dontPatch = true ;
dontConfigure = true ;
dontBuild = true ;
installPhase = let
2025-03-08 13:53:29 +01:00
pythonDependencies = [
2025-03-03 21:03:41 +01:00
aiohappyeyeballs
aiohttp
aiosignal
amqp
asgiref
attrs
billiard
bleach
2025-03-08 14:36:12 +01:00
boto3
2025-03-03 21:03:41 +01:00
bw-file-resubmit
celery
certifi
cffi
2025-03-07 13:40:04 +01:00
chardet
2025-03-03 21:03:41 +01:00
click
colorthief
cron-descriptor
cryptography
2025-03-07 16:06:16 +01:00
deprecated
2025-03-03 21:03:41 +01:00
django
2025-03-08 14:10:37 +01:00
django-appconf
2025-03-03 21:03:41 +01:00
django-celery-beat
django-csp
django-imagekit
django-model-utils
django-oauth-toolkit
django-pgtrigger
django-sass-processor
django-storages
django-timezone-field
environs
frozenlist
idna
2025-03-07 16:36:44 +01:00
importlib-metadata
2025-03-03 21:03:41 +01:00
jmespath
jwcrypto
kombu
markdown
marshmallow
multidict
oauthlib
2025-03-07 15:59:14 +01:00
opentelemetry-api
2025-03-07 16:57:37 +01:00
opentelemetry-sdk
2025-03-08 14:17:12 +01:00
pilkit
2025-03-03 21:03:41 +01:00
pillow
psycopg2
pycryptodome
2025-03-07 15:03:51 +01:00
pyotp
2025-03-03 21:03:41 +01:00
python-crontab
python-dateutil
python-dotenv
2025-03-07 15:39:21 +01:00
qrcode # I.e. python311Packages . qrcode
redis # I.e. python311Packages . redis
2025-03-03 21:03:41 +01:00
requests
s3-tar
2025-03-07 15:35:49 +01:00
s3transfer
2025-03-03 21:03:41 +01:00
six
sqlparse
typing-extensions
urllib3
vine
webencodings
2025-03-07 16:33:21 +01:00
wrapt
2025-03-03 21:03:41 +01:00
yarl
] ;
in ''
runHook preInstall
2025-03-04 11:29:42 +01:00
mkdir - p $ out/bin
2025-03-03 21:03:41 +01:00
mkdir - p $ out/lib/python3.11/site-packages
2025-03-04 15:49:14 +01:00
mkdir - p $ out/var/lib/bookwyrm
2025-03-03 21:03:41 +01:00
2025-03-03 21:42:53 +01:00
# Python dependencies
2025-03-08 13:53:29 +01:00
pythonDependencies = " ${ concatStringsSep " " pythonDependencies } "
for package in $ pythonDependencies ; do
2025-03-08 14:29:59 +01:00
for directory in $ ( cd $ package/lib/python3.11/site-packages ; find - mindepth 1 - type d - not - name __pycache__ ) ; do
2025-03-08 14:04:15 +01:00
mkdir - p $ out/lib/python3.11/site-packages / $ directory
2025-03-08 13:53:29 +01:00
done
2025-03-08 14:29:59 +01:00
for file in $ ( cd $ package/lib/python3.11/site-packages ; find - type f - not - path \ * __pycache__ \ * ) ; do
2025-03-08 13:53:29 +01:00
ln - s $ package/lib/python3.11/site-packages / $ file $ out/lib/python3.11/site-packages / $ file
done
2025-03-08 12:40:39 +01:00
done
2025-03-03 21:03:41 +01:00
2025-03-03 21:42:53 +01:00
# Python packages
2025-03-03 21:03:41 +01:00
cp - r $ src/bookwyrm $ out/lib/python3.11/site-packages /
cp - r $ src/celerywyrm $ out/lib/python3.11/site-packages /
2025-03-03 21:42:53 +01:00
# Executables
2025-03-03 22:05:54 +01:00
cat < < - EOF > $ out/bin/bookwyrm
2025-03-04 12:28:03 +01:00
#!${bash}/bin/sh
2025-03-03 21:03:41 +01:00
export PYTHONPATH = " $ o u t / l i b / p y t h o n 3 . 1 1 / s i t e - p a c k a g e s "
2025-03-04 15:49:14 +01:00
export DEBUG = " f a l s e "
2025-03-03 21:03:41 +01:00
export DOMAIN = " "
export EMAIL = " "
export EMAIL_HOST = " "
export EMAIL_HOST_USER = " "
export EMAIL_HOST_PASSWORD = " "
2025-03-07 13:28:06 +01:00
export SECRET_KEY = " \$ ( ${ coreutils-full } / b i n / c a t / e t c / n i x o s / a s s e t s / b o o k w y r m - s e c r e t - k e y ) " # The escape here is required in order to retrieve the key file contents at runtime
2025-03-03 21:03:41 +01:00
2025-03-07 13:34:29 +01:00
exec $ { gunicorn } /bin/gunicorn bookwyrm.wsgi:application - - bind = unix:/run/bookwyrm/http-socket
2025-03-03 21:03:41 +01:00
EOF
chmod + x $ out/bin/bookwyrm
2025-03-04 15:49:14 +01:00
# Working directory contents
cp $ src/VERSION $ out/var/lib/bookwyrm /
2025-03-03 21:03:41 +01:00
runHook postInstall
'' ;
}