diff options
Diffstat (limited to '')
| -rw-r--r-- | pkgs/bookwyrm.nix | 142 | ||||
| -rw-r--r-- | pkgs/bookwyrm/default.nix | 93 | ||||
| -rw-r--r-- | pkgs/bookwyrm/unwrapped.nix | 81 | ||||
| -rw-r--r-- | pkgs/overlay.nix | 89 |
4 files changed, 226 insertions, 179 deletions
diff --git a/pkgs/bookwyrm.nix b/pkgs/bookwyrm.nix deleted file mode 100644 index 92764ce..0000000 --- a/pkgs/bookwyrm.nix +++ /dev/null @@ -1,142 +0,0 @@ -{ lib -, fetchFromGitHub -, python -, writeShellScriptBin -, writeText -, settings ? { } -}: - -let - # set some dummy values to make the package build - settingsWithDefaults = { - DOMAIN = "localhost"; - DEBUG = false; - USE_HTTPS = false; - EMAIL = "your@email.here"; - PGPORT = 5432; - POSTGRES_USER = "bookwyrm"; - POSTGRES_DB = "bookwyrm"; - POSTGRES_HOST = "localhost"; - REDIS_ACTIVITY_HOST = "localhost"; - REDIS_ACTIVITY_PORT = 6379; - REDIS_BROKER_HOST = "localhost"; - REDIS_BROKER_PORT = 6379; - EMAIL_HOST = "smtp.example.com"; - EMAIL_PORT = 587; - EMAIL_HOST_USER = "mail@example.org"; - EMAIL_HOST_PASSWORD = "blub"; - MEDIA_ROOT = "/var/lib/bookwyrm/images"; - } // settings; - - # toShellVar produces "" for false, which bookwyrm rejects - toDjangoVar = name: value: lib.toShellVar name - (if value == false then "false" else - (if value == true then "true" else value)); - - envfile = writeText "bookwyrm.env" - (lib.strings.concatLines - (lib.mapAttrsToList toDjangoVar settingsWithDefaults)); - - bookwyrm = python.pkgs.buildPythonApplication rec { - pname = "bookwyrm"; - version = "0.7.5"; - - format = "other"; - - src = fetchFromGitHub { - owner = "bookwyrm-social"; - repo = "bookwyrm"; - rev = "refs/tags/v${version}"; - hash = "sha256-/oak9dEB2rR2z8b9oXVQ6+F2H7s0F5hVxmAlPdpaA0w="; - }; - - propagatedBuildInputs = with python.pkgs; [ - aiohttp - bleach - celery - colorthief - django - django-celery-beat - bw-file-resubmit - django-compressor - django-imagekit - django-model-utils - django-sass-processor - django-csp - django-oauth-toolkit - django-storages - django-pgtrigger - s3-tar - environs - flower - gunicorn - libsass - markdown - packaging - pillow - psycopg2 - pycryptodome - dateutil - redis - requests - responses - pytz - boto3 - django-storages - django-redis - opentelemetry-api - opentelemetry-exporter-otlp-proto-grpc - # opentelemetry-instrumentation-celery - opentelemetry-instrumentation-django - # opentelemetry-instrumentation-pyscopg2 - opentelemetry-sdk - protobuf - pyotp - qrcode - grpcio - ]; - - postBuild = '' - ln -s ${envfile} .env - # needed for the python settings.py file to not fail, but not - # used during the commands executed below, so this is safe - export SECRET_KEY=fnord - - substituteInPlace contrib/systemd/* \ - --replace /opt/bookwyrm/venv/bin/gunicorn ${lib.getExe python.pkgs.gunicorn} \ - --replace /opt/bookwyrm/venv/bin/celery ${lib.getExe' python.pkgs.celery "celery"} \ - --replace /opt/bookwyrm $out - - sed -i /BindPath/d contrib/systemd/* - - python manage.py compile_themes - python manage.py collectstatic --no-input - ''; - - postInstall = '' - mkdir -p $out/lib/systemd/system - cp -r * .env $out - cp -r contrib/systemd/* $out/lib/systemd/system - ''; - - passthru = { - pythonPath = python.pkgs.makePythonPath propagatedBuildInputs; - gunicorn = python.pkgs.gunicorn; - celery = python.pkgs.celery; - manage = environmentFile: writeShellScriptBin "bookwyrm-manage.py" '' - set -a - ${if environmentFile != null - then "source ${environmentFile}" - else ""} - export PYTHONPATH=${passthru.pythonPath} - cd ${bookwyrm.outPath} - exec ${bookwyrm.outPath}/manage.py "$@" - ''; - }; - - # hacky hacky hack - shellHook = '' - export PYTHONPATH=${passthru.pythonPath} - ''; - }; -in bookwyrm diff --git a/pkgs/bookwyrm/default.nix b/pkgs/bookwyrm/default.nix new file mode 100644 index 0000000..6e0756b --- /dev/null +++ b/pkgs/bookwyrm/default.nix @@ -0,0 +1,93 @@ +{ lib +, stdenvNoCC +, writeShellScriptBin +, writeText +, source-han-sans-vf-ttf +, bookwyrm-unwrapped +, settings ? { } +}: + +let + # set some dummy values to make the package build + settingsWithDefaults = { + DOMAIN = "localhost"; + DEBUG = false; + EMAIL = "your@email.here"; + PGPORT = 5432; + POSTGRES_USER = "bookwyrm"; + POSTGRES_DB = "bookwyrm"; + POSTGRES_HOST = "localhost"; + REDIS_ACTIVITY_HOST = "localhost"; + REDIS_ACTIVITY_PORT = 6379; + REDIS_BROKER_HOST = "localhost"; + REDIS_BROKER_PORT = 6379; + EMAIL_HOST = "smtp.example.com"; + EMAIL_PORT = 587; + EMAIL_HOST_USER = "mail@example.org"; + EMAIL_HOST_PASSWORD = "blub"; + MEDIA_ROOT = "/var/lib/bookwyrm/images"; + } // settings; + + # toShellVar produces "" for false, which bookwyrm rejects + toDjangoVar = name: value: lib.toShellVar name + (if value == false then "false" else + (if value == true then "true" else value)); + + envfile = writeText "bookwyrm.env" + (lib.strings.concatLines + (lib.mapAttrsToList toDjangoVar settingsWithDefaults)); + +in stdenvNoCC.mkDerivation (finalAttrs: { + pname = "bookwyrm"; + inherit (bookwyrm-unwrapped) version; + src = bookwyrm-unwrapped; + + dontConfigure = true; + + buildPhase = '' + runHook preBuild + + ln -s ${envfile} .env + # needed for the python settings.py file to not fail, but not + # used during the commands executed below, so this is safe + export SECRET_KEY=fnord + + export PYTHONPATH=${bookwyrm-unwrapped.pythonPath} + ./manage.py compile_themes + ./manage.py collectstatic --no-input + + ln -s ${source-han-sans-vf-ttf}/share/fonts/variable/SourceHanSans-VF.ttf.ttc static/fonts/source_han_sans/ + + substituteInPlace contrib/systemd/* \ + --replace /opt/bookwyrm/venv/bin/gunicorn ${lib.getExe bookwyrm-unwrapped.gunicorn} \ + --replace /opt/bookwyrm/venv/bin/celery ${lib.getExe' bookwyrm-unwrapped.celery "celery"} \ + --replace /opt/bookwyrm $out + + sed -i /BindPath/d contrib/systemd/* + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + mkdir -p $out/lib/systemd/system + cp -r * .env $out + cp -r contrib/systemd/* $out/lib/systemd/system + + runHook postInstall + ''; + + passthru = rec { + inherit (bookwyrm-unwrapped) celery gunicorn pythonPath; + manage = environmentFile: writeShellScriptBin "bookwyrm-manage.py" '' + set -a + ${if environmentFile != null + then "source ${environmentFile}" + else ""} + export PYTHONPATH=${pythonPath} + cd ${finalAttrs.finalPackage.outPath} + exec ${finalAttrs.finalPackage.outPath}/manage.py "$@" + ''; + }; +}) diff --git a/pkgs/bookwyrm/unwrapped.nix b/pkgs/bookwyrm/unwrapped.nix new file mode 100644 index 0000000..dce4279 --- /dev/null +++ b/pkgs/bookwyrm/unwrapped.nix @@ -0,0 +1,81 @@ +{ lib +, fetchFromGitHub +, python +}: + +python.pkgs.buildPythonApplication rec { + pname = "bookwyrm-unwrapped"; + version = "0.8.0"; + + format = "other"; + + src = fetchFromGitHub { + owner = "bookwyrm-social"; + repo = "bookwyrm"; + rev = "refs/tags/v${version}"; + hash = "sha256-juJLl6yN/u5Tx9j2rgT6d+92U4QAqhxG/LFZlIQtFxA="; + }; + + propagatedBuildInputs = with python.pkgs; [ + aiohttp + bleach + celery + colorthief + django + django-celery-beat + bw-file-resubmit + django-compressor + django-imagekit + django-model-utils + django-sass-processor + django-csp + django-oauth-toolkit + django-storages + django-pgtrigger + s3-tar + environs + flower + gunicorn + libsass + markdown + packaging + pillow + psycopg + pycryptodome + dateutil + redis + requests + responses + pytz + boto3 + django-storages + django-redis + opentelemetry-api + opentelemetry-exporter-otlp-proto-grpc + # opentelemetry-instrumentation-celery + opentelemetry-instrumentation-django + # opentelemetry-instrumentation-pyscopg2 + opentelemetry-sdk + protobuf + pyotp + qrcode + grpcio + ua-parser + ]; + + postInstall = '' + mkdir $out + cp -r * $out + ''; + + passthru = { + pythonPath = python.pkgs.makePythonPath propagatedBuildInputs; + gunicorn = python.pkgs.gunicorn; + celery = python.pkgs.celery; + }; + + # hacky hacky hack + shellHook = '' + export PYTHONPATH=${passthru.pythonPath} + ''; +} diff --git a/pkgs/overlay.nix b/pkgs/overlay.nix index e981f8f..e02fdef 100644 --- a/pkgs/overlay.nix +++ b/pkgs/overlay.nix @@ -53,39 +53,6 @@ in cargoLock.lockFile = "${src}/Cargo.lock"; }; - mergiraf = self.rustPlatform.buildRustPackage rec { - pname = "mergiraf"; - version = "git"; - src = self.fetchgit { - url = "https://codeberg.org/mergiraf/mergiraf"; - rev = "v0.2.0"; - hash = "sha256-egtX2daCbPXi5rX2OxbEZA/VI9R4HMj5LRKbUEBFo+E="; - }; - # TODO: probably unnecessary once we are on nixpkgs 24.11; earlier version - # hardcode --frozen here, but cargo wants --offline. - # the postBuild hook is necessary to set up things for the install hook - buildPhase = '' - cargo build -j $NIX_BUILD_CORES \ - --target x86_64-unknown-linux-gnu \ - --release \ - --offline - - runHook postBuild - ''; - # no idea why this didn't work with either test or build inputs .. - preCheck = '' - export PATH=$PATH:${self.gitMinimal}/bin - ''; - cargoLock = { - lockFile = "${src}/Cargo.lock"; - outputHashes = { - "tree-sitter-go-0.23.1" = "sha256-elPqkvVYs0vADOuN/umDteWP5hqcXhQAoSkqYDtTxaU="; - "tree-sitter-xml-0.7.0" = "sha256-RTWvOUAs3Uql9DKsP1jf9FZZHaZORE40GXd+6g6RQZw="; - "tree-sitter-yaml-0.6.1" = "sha256-gS+SjOnGl/86U9VV/y1ca7naYIe7DAOvOv++jCRLTKo="; - }; - }; - }; - rustex = rustPlatform.buildRustPackage rec { pname = "rustex"; version = "git"; @@ -198,10 +165,56 @@ in overrides = self': super': with self.haskell.lib; { fuzzyfind = unmarkBroken (doJailbreak super'.fuzzyfind); fuzzyset = unmarkBroken (doJailbreak super'.fuzzyset); + rustls = self.haskellPackages.callPackage + ({ mkDerivation, async, base, bytestring, containers + , derive-storable, directory, filepath, hedgehog, lib, mtl, network + , process, resourcet, stm, tasty, tasty-hedgehog + , tasty-hunit, temporary, text, transformers + }: + mkDerivation { + pname = "rustls"; + version = "0.2.2.0"; + sha256 = "3c610437b4fb8b6ae86e6d3bebca8c15631b0d793d925ab5eeebb88b8ac77371"; + libraryHaskellDepends = [ + base bytestring containers derive-storable mtl network resourcet + text transformers + ]; + libraryPkgconfigDepends = [ self.rustls-ffi ]; + testHaskellDepends = [ + async base bytestring containers directory filepath hedgehog + process resourcet stm tasty tasty-hedgehog tasty-hunit temporary + text transformers + ]; + homepage = "https://github.com/amesgen/hs-rustls/tree/main/rustls"; + description = "TLS bindings for Rustls"; + license = lib.licenses.cc0; + doCheck = false; + }) {}; + http-client-rustls = self'.callPackage + ({ mkDerivation, base, bytestring, directory, filepath, http-client + , http-types, lib, network, port-utils, process, resourcet, rustls + , tasty, tasty-hunit, temporary, text + }: + mkDerivation { + pname = "http-client-rustls"; + version = "0.0.2.0"; + sha256 = "05505bf77e3d967b01187ffb55ea6c3f658ba446aeffeccdac16cbb6960d940d"; + libraryHaskellDepends = [ + base bytestring http-client network resourcet rustls text + ]; + testHaskellDepends = [ + base bytestring directory filepath http-client http-types network + port-utils process rustls tasty tasty-hunit temporary + ]; + homepage = "https://github.com/amesgen/hs-rustls/tree/main/http-client-rustls"; + description = "http-client TLS backend using Rustls"; + license = lib.licenses.cc0; + doCheck = false; + }) {}; }; }); pkg = { mkDerivation, base, bytestring, cassava, containers - , fuzzyfind, fuzzyset, http-client, http-client-openssl, http-types + , fuzzyfind, fuzzyset, http-client, http-client-rustls, http-types , lib, stm, text, time, vector, wai, wai-extra, warp }: mkDerivation { @@ -212,7 +225,7 @@ in isExecutable = true; executableHaskellDepends = [ base bytestring cassava containers fuzzyfind fuzzyset http-client - http-client-openssl http-types stm text time vector wai wai-extra + http-client-rustls http-types stm text time vector wai wai-extra warp ]; jailbreak = true; @@ -255,7 +268,7 @@ in owner = "sinclairtarget"; repo = "git-who"; rev = "v${version}"; - hash = "sha256-H6RbmkM8/n0HDMI3auz6YyEn/vsfXWk5ig+pBhZG3nI="; + hash = "sha256-W3PDD0Gp9KStfa3+Wf2n8oxC5sp+YI/G5I3ukTg7H6k="; # submodules contain test data and have ssh urls, hence this absurdity fetchSubmodules = true; leaveDotGit = true; @@ -281,9 +294,11 @@ in #### packaged mostly as shitpost / to play around with #### - bookwyrm = (self.callPackage ./bookwyrm.nix { + bookwyrm = self.callPackage ./bookwyrm {}; + bookwyrm-unwrapped = (self.callPackage ./bookwyrm/unwrapped.nix { python = super.python312.override ({ packageOverrides = self: super: { + django = self.django_5; django-sass-processor = self.callPackage ./python/django-sass-processor.nix {}; django-imagekit = self.callPackage ./python/django-imagekit.nix {}; django-pgtrigger = self.callPackage ./python/django-pgtrigger.nix {}; |
