summaryrefslogtreecommitdiff
path: root/pkgs
diff options
context:
space:
mode:
authorstuebinm2024-02-14 23:24:52 +0100
committerstuebinm2024-02-14 23:24:52 +0100
commit4b3096a7022f2785b58eddfe5f1d98eed0495165 (patch)
tree18de680037c21ebc04460956ec1aa40843b3c57b /pkgs
parent767d153297e348586be571ace3e031990517f44f (diff)
modules/bookwyrm: init
this should be mostly usable for actual deployments. Only thing that's really still annoying is having to set the SECRET_KEY via Nix, since not having set it makes the package fail to build. But it doesn't actually end up in the derivation, so changing it afterwards should be fine; I've just not tested that yet.
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/bookwyrm.nix50
1 files changed, 46 insertions, 4 deletions
diff --git a/pkgs/bookwyrm.nix b/pkgs/bookwyrm.nix
index c3838f2..309e90b 100644
--- a/pkgs/bookwyrm.nix
+++ b/pkgs/bookwyrm.nix
@@ -1,9 +1,42 @@
-{ lib, fetchFromGitHub, python, writeShellScriptBin, writeText, settings ? { }
+{ lib
+, fetchFromGitHub
+, python
+, writeShellScriptBin
+, writeText
+, settings ? { }
}:
let
+ # set some dummy values to make the package build
+ settingsWithDefaults = {
+ DOMAIN = "localhost";
+ DEBUG = false;
+ SECRET_KEY = "fnord";
+ 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 lib.toShellVar settings));
+ (lib.strings.concatLines
+ (lib.mapAttrsToList toDjangoVar settingsWithDefaults));
bookwyrm = python.pkgs.buildPythonApplication rec {
pname = "bookwyrm";
@@ -62,13 +95,22 @@ let
postBuild = ''
ln -s ${envfile} .env
+
+ 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
+ python manage.py collectstatic --no-input --ignore=*.scss
'';
postInstall = ''
- mkdir -p $out
+ mkdir -p $out/lib/systemd/system
cp -r * .env $out
+ cp -r contrib/systemd/* $out/lib/systemd/system
'';
passthru = {