diff --git a/nixos-module.nix b/nixos-module.nix index 6544d04..898a8ab 100644 --- a/nixos-module.nix +++ b/nixos-module.nix @@ -3,60 +3,17 @@ with pkgs ; { - imports = [ - packages/bookwyrm/nixos-module.nix - ] ; - nixpkgs = { overlays = [ ( self : super : { - kernelmaft = { - bookwyrm = callPackage ( - import packages/bookwyrm/package.nix - ) {} ; + journalctl-last-invocation = callPackage ( + import packages/journalctl-last-invocation/package.nix + ) {} ; - journalctl-last-invocation = callPackage ( - import packages/journalctl-last-invocation/package.nix - ) {} ; - - nix-store-fuzzy-find = callPackage ( - import packages/nix-store-fuzzy-find/package.nix - ) {} ; - - python = { - - bw-file-resubmit = callPackage ( - import packages/python3.11-bw-file-resubmit/package.nix - ) {} ; - - django-imagekit = callPackage ( - import packages/python3.11-django-imagekit/package.nix - ) {} ; - - django-pgtrigger = callPackage ( - import packages/python3.11-django-pgtrigger/package.nix - ) {} ; - - django-sass-processor = callPackage ( - import packages/python3.11-django-sass-processor/package.nix - ) {} ; - - s3-tar = callPackage ( - import packages/python3.11-s3-tar/package.nix - ) {} ; - - } ; - - } ; - - # TODO: Use the following template once the custom Python packages have been converted to use `buildPythonPackage` - # - # python311 = super . python311 . override { - # packageOverrides = python-self : python-super : { - # package-name = super . callPackage ( import ./package-file.nix ) {} ; - # } ; - # } ; + nix-store-fuzzy-find = callPackage ( + import packages/nix-store-fuzzy-find/package.nix + ) {} ; } ) ] ; diff --git a/packages/bookwyrm/nixos-module.nix b/packages/bookwyrm/nixos-module.nix deleted file mode 100644 index 464d257..0000000 --- a/packages/bookwyrm/nixos-module.nix +++ /dev/null @@ -1,93 +0,0 @@ -{ pkgs , ... } : - -with pkgs ; -with pkgs . kernelmaft ; - -{ - systemd = { - units = { - "bookwyrm.service" = { - text = '' - [Unit] - - After=network.target - - [Service] - - # 'initdb' fails harmlessly if it has been run on the database before - ExecStartPre=${coreutils-full}/bin/ln -sf ${bookwyrm}/var/lib/bookwyrm/VERSION /var/lib/bookwyrm/ - ExecStartPre=${coreutils-full}/bin/mkdir -p /var/lib/bookwyrm/images - ExecStartPre=${bookwyrm}/bin/bookwyrm-env ${python311}/bin/python ${bookwyrm}/lib/python3.11/manage.py migrate - ExecStartPre=-${bookwyrm}/bin/bookwyrm-env ${python311}/bin/python ${bookwyrm}/lib/python3.11/manage.py initdb - ExecStart=${bookwyrm}/bin/bookwyrm-env ${bookwyrm}/bin/bookwyrm - - WorkingDirectory=/var/lib/bookwyrm - - # Creates /var/lib/bookwyrm directory - StateDirectory=bookwyrm - - # Creates /run/bookwyrm directory - RuntimeDirectory=bookwyrm - - User=bookwyrm - Group=bookwyrm - - ProtectSystem=strict - ProtectHome=tmpfs - PrivateTmp=true - PrivateDevices=true - PrivateIPC=true - ProtectHostname=true - ProtectClock=true - ProtectKernelTunables=true - ProtectKernelModules=true - ProtectControlGroups=true - RestrictNamespaces=true - LockPersonality=true - RestrictRealtime=true - RestrictSUIDSGID=true - '' ; - } ; - } ; - } ; - - users = { - groups = { - bookwyrm = {} ; - } ; - users = { - bookwyrm = { - group = "bookwyrm" ; - home = "/var/lib/bookwyrm" ; - isSystemUser = true ; - } ; - } ; - } ; - - services = { - postgresql = { - ensureUsers = [ - { - name = "bookwyrm" ; - ensureDBOwnership = true ; - } - ] ; - ensureDatabases = [ "bookwyrm" ] ; - } ; - - redis = { - servers = { - bookwyrm-activity = { - enable = true ; - user = "bookwyrm" ; - group = "bookwyrm" ; - } ; - bookwyrm-broker = { - enable = true ; - user = "bookwyrm" ; - group = "bookwyrm" ; - } ; - } ; - } ; - } ; -} diff --git a/packages/bookwyrm/package.nix b/packages/bookwyrm/package.nix deleted file mode 100644 index b993abb..0000000 --- a/packages/bookwyrm/package.nix +++ /dev/null @@ -1,199 +0,0 @@ -{ - fetchFromGitHub , - pkgs , - stdenv , -} : - -with builtins ; -with pkgs ; -with pkgs . kernelmaft . python ; -with pkgs . python311Packages ; -with stdenv ; - -let - pythonDependencies = [ - aiohappyeyeballs - aiohttp - aiosignal - amqp - asgiref - attrs - billiard - bleach - boto3 - botocore - bw-file-resubmit - celery - certifi - cffi - chardet - click - colorthief - cron-descriptor - cryptography - deprecated - django - django-appconf - 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 - googleapis-common-protos - grpcio - idna - importlib-metadata - jmespath - jwcrypto - kombu - libsass - markdown - marshmallow - multidict - oauthlib - packaging - pilkit - pillow - protobuf - psycopg2 - pycryptodome - pyotp - python-crontab - python-dateutil - python-dotenv - qrcode - redis - requests - s3-tar - s3transfer - six - sqlparse - typing-extensions - urllib3 - vine - webencodings - wrapt - yarl - ] ; -in - -mkDerivation { - pname = "bookwyrm" ; - version = "2025-02-14-ba1f180" ; - - src = fetchFromGitea { - domain = "kernelmaft.com/forgejo" ; - owner = "zedfrigg" ; - repo = "bookwyrm" ; - rev = "229a035a2be1811123b5afcb035fab61d13f0a47" ; - hash = "sha256-0pwszQwx/RsCv3pxGifyAEpzXfTBiwOOt+h3pZuN3Bk=" ; - } ; - - dontPatch = true ; - dontConfigure = true ; - - buildPhase = '' - runHook preBuild - - mkdir -p /build/lib/python3.11/site-packages - - # Python dependencies - - for dependency in ${ concatStringsSep " " pythonDependencies } ; do - ln -sf $dependency/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/ - done - - export PYTHONPATH=/build/lib/python3.11/site-packages - - export DOMAIN="" - export EMAIL="" - export EMAIL_HOST="" - export EMAIL_HOST_USER="" - export EMAIL_HOST_PASSWORD="" - export SECRET_KEY="" - - ${python311}/bin/python manage.py compile_themes - ${python311}/bin/python manage.py collectstatic --no-input - - runHook postBuild - '' ; - - installPhase = '' - runHook preInstall - - - # Python packages - - mkdir -p $out/lib/python3.11/site-packages - - for dependency in ${ concatStringsSep " " pythonDependencies } ; do - ln -sf $dependency/lib/python3.11/site-packages/* $out/lib/python3.11/site-packages/ - done - - cp -r /build/source/bookwyrm $out/lib/python3.11/site-packages/ - cp -r /build/source/celerywyrm $out/lib/python3.11/site-packages/ - - - # Python scripts - - cp /build/source/manage.py $out/lib/python3.11/ - - - # Static web files - - mkdir -p $out/srv/http - - cp -r /build/source/static/* $out/srv/http/ - - ln -s \ - ${source-han-sans}/share/fonts/opentype/source-han-sans/SourceHanSans.ttc \ - $out/srv/http/fonts/source_han_sans/SourceHanSans-VF.ttf.ttc - - - # Executables - - mkdir -p $out/bin - - cat <<- EOF > $out/bin/bookwyrm - #!${bash}/bin/sh - - exec ${gunicorn}/bin/gunicorn bookwyrm.wsgi:application --bind=unix:/run/bookwyrm/http-socket - EOF - - cat <<- EOF > $out/bin/bookwyrm-env - #!${bash}/bin/sh - - PATH=${coreutils-full}/bin - - if [ \$( id -un ) != "bookwyrm" -o \$( id -gn ) != "bookwyrm" ] ; then - echo "You are not running as the 'bookwyrm' user and group, quitting" - exit 1 - fi - - export PYTHONPATH=$out/lib/python3.11/site-packages - - export DEBUG=false - export STATIC_ROOT_ABS=$out/srv/http - - exec \$@ - EOF - - chmod +x $out/bin/* - - - # Working directory contents - - mkdir -p $out/var/lib/bookwyrm - - cp $src/VERSION $out/var/lib/bookwyrm/ - - - runHook postInstall - '' ; -} diff --git a/packages/python3.11-bw-file-resubmit/package.nix b/packages/python3.11-bw-file-resubmit/package.nix deleted file mode 100644 index 10a88fd..0000000 --- a/packages/python3.11-bw-file-resubmit/package.nix +++ /dev/null @@ -1,40 +0,0 @@ -{ - 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 - '' ; -} diff --git a/packages/python3.11-django-imagekit/package.nix b/packages/python3.11-django-imagekit/package.nix deleted file mode 100644 index f9e1006..0000000 --- a/packages/python3.11-django-imagekit/package.nix +++ /dev/null @@ -1,42 +0,0 @@ -{ - 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 - '' ; -} diff --git a/packages/python3.11-django-pgtrigger/package.nix b/packages/python3.11-django-pgtrigger/package.nix deleted file mode 100644 index d4b97a2..0000000 --- a/packages/python3.11-django-pgtrigger/package.nix +++ /dev/null @@ -1,51 +0,0 @@ -{ - 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 - '' ; -} diff --git a/packages/python3.11-django-sass-processor/package.nix b/packages/python3.11-django-sass-processor/package.nix deleted file mode 100644 index 994468c..0000000 --- a/packages/python3.11-django-sass-processor/package.nix +++ /dev/null @@ -1,47 +0,0 @@ -{ - fetchFromGitHub , - pkgs , - stdenv , -} : - -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/ - ln -s ${django-compressor}/lib/python3.11/site-packages/* $out/lib/python3.11/site-packages/ - ln -s ${jinja2}/lib/python3.11/site-packages/* $out/lib/python3.11/site-packages/ - ln -s ${libsass}/lib/python3.11/site-packages/* $out/lib/python3.11/site-packages/ - - # The package itself - - cp $src/sass_processor/*.py $out/lib/python3.11/site-packages/sass_processor/ - - 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/ - cp -r $src/sass_processor/jinja2 $out/lib/python3.11/site-packages/sass_processor/ - - runHook postInstall - '' ; -} diff --git a/packages/python3.11-s3-tar/package.nix b/packages/python3.11-s3-tar/package.nix deleted file mode 100644 index 133dbea..0000000 --- a/packages/python3.11-s3-tar/package.nix +++ /dev/null @@ -1,41 +0,0 @@ -{ - 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 - '' ; -}