summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstuebinm2024-02-15 19:44:47 +0100
committerstuebinm2024-02-15 19:44:47 +0100
commit5461fc6f762952d58ea0c2ede321e301aa011e3f (patch)
tree7bbabe6974a37c93e03455c52c38c0c095caa243
parent5788f8499e5e7089e1c64e397c2308f26874c3a5 (diff)
modules/bookwyrm: add a nixos test
because like, why not learn how to use these out-of-tree?
Diffstat (limited to '')
-rw-r--r--flake.nix2
-rw-r--r--tests/bookwyrm.nix66
2 files changed, 68 insertions, 0 deletions
diff --git a/flake.nix b/flake.nix
index 18dbeb2..de1169f 100644
--- a/flake.nix
+++ b/flake.nix
@@ -142,6 +142,8 @@
travelynx crs-tracker crs-php bahnhof-name matrix-to
hikari_unstable heartwood radicle-interface radicle-tui
inweb nomsring bookwyrm;
+
+ tests.bookwyrm = nixpkgs.nixosTest ./tests/bookwyrm.nix;
};
nixosModules = { glitchtip = import ./modules/glitchtip.nix; };
diff --git a/tests/bookwyrm.nix b/tests/bookwyrm.nix
new file mode 100644
index 0000000..0e9768f
--- /dev/null
+++ b/tests/bookwyrm.nix
@@ -0,0 +1,66 @@
+{
+ name = "bookwyrm-can-start";
+
+ nodes.bookwyrm = { config, pkgs, ... }: {
+
+ imports = [ ../modules/bookwyrm.nix ];
+
+ services.bookwyrm = {
+ enable = true;
+ settings = {
+ DOMAIN = "localhost";
+ DEBUG = false;
+ USE_HTTPS = true;
+ 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";
+ };
+ setupNginx = true;
+ environmentFile = pkgs.writeText ".env" ''
+ SECRET_KEY=fnord2
+ '';
+ };
+ services.redis.servers."bookwyrm" = {
+ enable = true;
+ port = 6379;
+ };
+ services.postgresql = {
+ enable = true;
+ ensureDatabases = [ "bookwyrm" ];
+ ensureUsers = [{
+ name = "bookwyrm";
+ ensureDBOwnership = true;
+ }];
+ authentication = ''
+ local all all trust
+ host all all 127.0.0.1/32 trust
+ host all all ::1/127 trust
+ '';
+ };
+ };
+
+ testScript = ''
+ machine.start()
+ machine.wait_for_unit("bookwyrm.service")
+ machine.wait_for_open_port(8000)
+
+ # does bookwyrm work?
+ machine.succeed("curl -f http://localhost")
+ # does nginx serve static files?
+ machine.succeed("curl -f http://localhost/static/css/themes/bookwyrm-light.css")
+
+ # does the manage.py wrapper work?
+ machine.succeed("bookwyrm-manage.py admin_code")
+ '';
+}