nix-packages/packages/bookwyrm/package.nix

146 lines
2.9 KiB
Nix
Raw Normal View History

2025-03-03 21:03:41 +01:00
{
fetchFromGitHub ,
pkgs ,
stdenv ,
} :
with builtins ;
with pkgs ;
2025-03-03 21:03:41 +01:00
with pkgs . kernelmaft . python ;
with pkgs . python311Packages ;
with stdenv ;
mkDerivation {
pname = "bookwyrm" ;
version = "2025-02-14-ba1f180" ;
src = fetchFromGitHub {
owner = "bookwyrm-social" ;
repo = "bookwyrm" ;
rev = "ba1f180c834e1b84d33e565abc3d95f772e2cdd8" ;
hash = "sha256-8e1+pfURTvzsWumRpeBZGDyD8UW1C98Vv9/1GqECLD4=" ;
} ;
dontPatch = true ;
dontConfigure = true ;
dontBuild = true ;
installPhase = let
pythonDependencies = [
2025-03-03 21:03:41 +01:00
aiohappyeyeballs
aiohttp
aiosignal
amqp
asgiref
attrs
billiard
bleach
bw-file-resubmit
celery
certifi
cffi
chardet
2025-03-03 21:03:41 +01:00
click
colorthief
cron-descriptor
cryptography
deprecated
2025-03-03 21:03:41 +01:00
django
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
importlib-metadata
2025-03-03 21:03:41 +01:00
jmespath
jwcrypto
kombu
markdown
marshmallow
multidict
oauthlib
opentelemetry-api
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
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
mkdir -p $out/bin
2025-03-03 21:03:41 +01:00
mkdir -p $out/lib/python3.11/site-packages
mkdir -p $out/var/lib/bookwyrm
2025-03-03 21:03:41 +01:00
# Python dependencies
pythonDependencies="${ concatStringsSep " " pythonDependencies }"
for package in $pythonDependencies ; do
for directory in $( sh -c "cd $package/lib/python3.11/site-packages ; find -mindepth 1 -type d -not -name __pycache__" ) ; do
mkdir -p $out/lib/python3.11/site-packages/$directory
done
for file in $( sh -c "cd $package/lib/python3.11/site-packages ; find -type f -not -path \*__pycache__\*" ) ; do
ln -s $package/lib/python3.11/site-packages/$file $out/lib/python3.11/site-packages/$file
done
done
2025-03-03 21:03:41 +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/
# Executables
cat <<- EOF > $out/bin/bookwyrm
#!${bash}/bin/sh
2025-03-03 21:03:41 +01:00
export PYTHONPATH="$out/lib/python3.11/site-packages"
export DEBUG="false"
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}/bin/cat /etc/nixos/assets/bookwyrm-secret-key )" # The escape here is required in order to retrieve the key file contents at runtime
2025-03-03 21:03:41 +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
# Working directory contents
cp $src/VERSION $out/var/lib/bookwyrm/
2025-03-03 21:03:41 +01:00
runHook postInstall
'' ;
}