2025-03-03 21:03:41 +01:00
|
|
|
{
|
|
|
|
fetchFromGitHub ,
|
|
|
|
pkgs ,
|
|
|
|
stdenv ,
|
|
|
|
} :
|
|
|
|
|
|
|
|
with builtins ;
|
|
|
|
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
|
|
|
|
dependencies = [
|
|
|
|
aiohappyeyeballs
|
|
|
|
aiohttp
|
|
|
|
aiosignal
|
|
|
|
amqp
|
|
|
|
asgiref
|
|
|
|
attrs
|
|
|
|
billiard
|
|
|
|
bleach
|
|
|
|
bw-file-resubmit
|
|
|
|
celery
|
|
|
|
certifi
|
|
|
|
cffi
|
|
|
|
click
|
|
|
|
colorthief
|
|
|
|
cron-descriptor
|
|
|
|
cryptography
|
|
|
|
django
|
|
|
|
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
|
|
|
|
jmespath
|
|
|
|
jwcrypto
|
|
|
|
kombu
|
|
|
|
markdown
|
|
|
|
marshmallow
|
|
|
|
multidict
|
|
|
|
oauthlib
|
|
|
|
pillow
|
|
|
|
psycopg2
|
|
|
|
pycryptodome
|
|
|
|
python-crontab
|
|
|
|
python-dateutil
|
|
|
|
python-dotenv
|
|
|
|
requests
|
|
|
|
s3-tar
|
|
|
|
six
|
|
|
|
sqlparse
|
|
|
|
typing-extensions
|
|
|
|
urllib3
|
|
|
|
vine
|
|
|
|
webencodings
|
|
|
|
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 11:29:42 +01:00
|
|
|
mkdir -p $out/lib/systemd/system
|
2025-03-03 21:03:41 +01:00
|
|
|
|
2025-03-03 21:42:53 +01:00
|
|
|
# Python dependencies
|
|
|
|
|
2025-03-03 21:03:41 +01:00
|
|
|
${ concatStringsSep "\n" ( map ( package : ''
|
2025-03-03 21:42:53 +01:00
|
|
|
ln -sf ${package}/lib/python3.11/site-packages/* $out/lib/python3.11/site-packages/
|
2025-03-03 21:03:41 +01:00
|
|
|
'' ) dependencies ) }
|
|
|
|
|
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-03 21:03:41 +01:00
|
|
|
#!/run/current-system/sw/bin/sh
|
|
|
|
|
|
|
|
export PYTHONPATH="$out/lib/python3.11/site-packages"
|
|
|
|
|
|
|
|
export DEBUG=false
|
|
|
|
export DOMAIN=""
|
|
|
|
export EMAIL=""
|
|
|
|
export EMAIL_HOST=""
|
|
|
|
export EMAIL_HOST_USER=""
|
|
|
|
export EMAIL_HOST_PASSWORD=""
|
2025-03-03 22:25:23 +01:00
|
|
|
export SECRET_KEY="\$( 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
|
|
|
|
|
|
|
${gunicorn}/bin/gunicorn bookwyrm.wsgi:application
|
|
|
|
EOF
|
|
|
|
|
|
|
|
chmod +x $out/bin/bookwyrm
|
|
|
|
|
2025-03-04 11:13:29 +01:00
|
|
|
# Systemd units
|
|
|
|
|
2025-03-04 11:29:42 +01:00
|
|
|
cat <<- EOF > $out/lib/systemd/system/bookwyrm.service
|
2025-03-04 11:13:29 +01:00
|
|
|
[Unit]
|
|
|
|
After=network.target
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
ExecStart=$out/bin/bookwyrm
|
|
|
|
WorkingDirectory=/var/lib/bookwyrm
|
|
|
|
EOF
|
|
|
|
|
2025-03-03 21:03:41 +01:00
|
|
|
runHook postInstall
|
|
|
|
'' ;
|
|
|
|
}
|