From 539597bab8fc7599f6767217aa91ebb7957c0d4a Mon Sep 17 00:00:00 2001 From: Reinout Meliesie Date: Mon, 3 Mar 2025 21:03:41 +0100 Subject: [PATCH] Add Bookwyrm package --- bookwyrm.nix | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 bookwyrm.nix diff --git a/bookwyrm.nix b/bookwyrm.nix new file mode 100644 index 0000000..de83795 --- /dev/null +++ b/bookwyrm.nix @@ -0,0 +1,117 @@ +{ + 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 + + mkdir -p $out/lib/python3.11/site-packages + + ${ concatStringsSep "\n" ( map ( package : '' + ln -s ${package}/lib/python3.11/site-packages/* $out/lib/python3.11/site-packages/ + '' ) dependencies ) } + + # rm $out/lib/python3.11/site-packages/__pycache__ + + cp -r $src/bookwyrm $out/lib/python3.11/site-packages/ + cp -r $src/celerywyrm $out/lib/python3.11/site-packages/ + + mkdir -p $out/bin + + cat << EOF > $out/bin/bookwyrm + #!/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="" + 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 + + ${gunicorn}/bin/gunicorn bookwyrm.wsgi:application + EOF + + chmod +x $out/bin/bookwyrm + + runHook postInstall + '' ; +}