Restructure packages into subdirectories

This commit is contained in:
Reinout Meliesie 2025-03-04 13:13:22 +01:00
parent 3961e33ca1
commit f91196c8a4
Signed by: zedfrigg
GPG key ID: 3AFCC06481308BC6
9 changed files with 45 additions and 20 deletions

View file

@ -0,0 +1,20 @@
{ pkgs } :
with pkgs . kernelmaft ;
{
systemd = {
units = {
"bookwyrm.service" = {
text = ''
[Unit]
After=network.target
[Service]
ExecStart=${bookwyrm}/bin/bookwyrm
WorkingDirectory=/var/lib/bookwyrm
'' ;
} ;
} ;
} ;
}

View file

@ -0,0 +1,122 @@
{
fetchFromGitHub ,
pkgs ,
stdenv ,
} :
with builtins ;
with pkgs ;
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/bin
mkdir -p $out/lib/python3.11/site-packages
mkdir -p $out/lib/systemd/system
# Python dependencies
${ concatStringsSep "\n" ( map ( package : ''
ln -sf ${package}/lib/python3.11/site-packages/* $out/lib/python3.11/site-packages/
'' ) dependencies ) }
# Python packages
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
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
'' ;
}

View file

@ -0,0 +1,40 @@
{
fetchFromGitHub ,
pkgs ,
stdenv ,
} :
with pkgs . python311Packages ;
with stdenv ;
mkDerivation {
pname = "python-bw-file-resubmit" ;
version = "2023-11-08-0655eb2" ;
src = fetchFromGitHub {
owner = "bookwyrm-social" ;
repo = "bw-file-resubmit" ;
rev = "0655eb24d77b5440f0221df99d87bbb1ea588181" ;
hash = "sha256-RT3fF2oMsf0klUwMBJ02Dgdt2rsoB7A3SjiuyVuYU7A=" ;
} ;
dontPatch = true ;
dontConfigure = true ;
dontBuild = true ;
installPhase = ''
runHook preInstall
mkdir -p $out/lib/python3.11/site-packages
# Dependencies
ln -s ${django}/lib/python3.11/site-packages/* $out/lib/python3.11/site-packages/
# The package itself
cp -r $src/src/file_resubmit $out/lib/python3.11/site-packages/
runHook postInstall
'' ;
}

View file

@ -0,0 +1,42 @@
{
fetchFromGitHub ,
pkgs ,
stdenv ,
} :
with pkgs . python311Packages ;
with stdenv ;
mkDerivation {
pname = "python-django-imagekit" ;
version = "2024-07-22-4cbbc52" ;
src = fetchFromGitHub {
owner = "matthewwithanm" ;
repo = "django-imagekit" ;
rev = "4cbbc52fabfd99a6306cdbb8ab2602bb0a0190a9" ;
hash = "sha256-QYWhXh404JNAZN7kXYhsPQpFpyBA/MehxJOxdDKX0Mc=" ;
} ;
dontPatch = true ;
dontConfigure = true ;
dontBuild = true ;
installPhase = ''
runHook preInstall
mkdir -p $out/lib/python3.11/site-packages
# Dependencies
ln -s ${django}/lib/python3.11/site-packages/* $out/lib/python3.11/site-packages/
ln -s ${django-appconf}/lib/python3.11/site-packages/* $out/lib/python3.11/site-packages/
ln -s ${pilkit}/lib/python3.11/site-packages/* $out/lib/python3.11/site-packages/
# The package itself
cp -r $src/imagekit $out/lib/python3.11/site-packages/
runHook postInstall
'' ;
}

View file

@ -0,0 +1,51 @@
{
fetchFromGitHub ,
pkgs ,
stdenv ,
} :
with pkgs . python311Packages ;
with stdenv ;
mkDerivation {
pname = "python-django-pgtrigger" ;
version = "4.13.3" ;
src = fetchFromGitHub {
owner = "ambitioneng" ;
repo = "django-pgtrigger" ;
rev = "4.13.3" ;
hash = "sha256-K+JjAermtSiVUnPbtyabpQN2ghnRIkwt329Ytp8zeQk=" ;
} ;
dontPatch = true ;
dontConfigure = true ;
dontBuild = true ;
installPhase = ''
runHook preInstall
mkdir -p $out/lib/python3.11/site-packages/django_pgtrigger-4.13.3.dist-info
mkdir -p $out/lib/python3.11/site-packages/pgtrigger
# Dependencies
ln -s ${django}/lib/python3.11/site-packages/* $out/lib/python3.11/site-packages/
ln -s ${psycopg}/lib/python3.11/site-packages/* $out/lib/python3.11/site-packages/
# The package itself
cp $src/pgtrigger/*.py $out/lib/python3.11/site-packages/pgtrigger/
cp -r $src/pgtrigger/management $out/lib/python3.11/site-packages/pgtrigger/
# Metadata
cat << EOF > $out/lib/python3.11/site-packages/django_pgtrigger-4.13.3.dist-info/METADATA
Metadata-Version: 2.1
Name: django-pgtrigger
Version: 4.13.3
EOF
runHook postInstall
'' ;
}

View file

@ -0,0 +1,62 @@
{
fetchFromGitHub ,
pkgs ,
stdenv ,
offlineCompilation ? false ,
jinjaSupport ? false ,
} :
with pkgs . python311Packages ;
with stdenv ;
mkDerivation {
pname = "python-django-sass-processor" ;
version = "1.4.1" ;
src = fetchFromGitHub {
owner = "jrief" ;
repo = "django-sass-processor" ;
rev = "1.4.1" ;
hash = "sha256-Z3UzzkHlMNiyhj7YPRDgAX0437BywPG/waNSPoNiKLo=" ;
} ;
dontPatch = true ;
dontConfigure = true ;
dontBuild = true ;
installPhase = ''
runHook preInstall
mkdir -p $out/lib/python3.11/site-packages/sass_processor
# Dependencies
ln -s ${django}/lib/python3.11/site-packages/* $out/lib/python3.11/site-packages/
${ if offlineCompilation then ''
ln -s ${django-compressor}/lib/python3.11/site-packages/* $out/lib/python3.11/site-packages/
'' else ''
ln -s ${libsass}/lib/python3.11/site-packages/* $out/lib/python3.11/site-packages/
'' }
${ if jinjaSupport then ''
ln -s ${jinja2}/lib/python3.11/site-packages/* $out/lib/python3.11/site-packages/
'' else "" }
# The package itself
cp $src/sass_processor/*.py $out/lib/python3.11/site-packages/sass_processor/
${ if offlineCompilation then ''
cp -r $src/sass_processor/management $out/lib/python3.11/site-packages/sass_processor/
cp -r $src/sass_processor/templatetags $out/lib/python3.11/site-packages/sass_processor/
'' else "" }
${ if jinjaSupport then ''
cp -r $src/sass_processor/jinja2 $out/lib/python3.11/site-packages/sass_processor/
'' else "" }
runHook postInstall
'' ;
}

View file

@ -0,0 +1,41 @@
{
fetchFromGitHub ,
pkgs,
stdenv ,
} :
with pkgs . python311Packages ;
with stdenv ;
mkDerivation {
pname = "python-s3-tar" ;
version = "2020-08-05-62f7f11" ;
src = fetchFromGitHub {
owner = "xtream1101" ;
repo = "s3-tar" ;
rev = "62f7f1118f9e83724dbf9e8458b5505b3a0ba758" ;
hash = "sha256-s2ei0joUNDZ2e18YbjMMlGOJpuMTFUwEjgRiUGb4EqI=" ;
} ;
dontPatch = true ;
dontConfigure = true ;
dontBuild = true ;
installPhase = ''
runHook preInstall
mkdir -p $out/lib/python3.11/site-packages
# Dependencies
ln -s ${boto3}/lib/python3.11/site-packages/* $out/lib/python3.11/site-packages/
ln -s ${botocore}/lib/python3.11/site-packages/* $out/lib/python3.11/site-packages/
# The package itself
cp -r $src/s3_tar $out/lib/python3.11/site-packages/
runHook postInstall
'' ;
}