nixpkgs/nixos/tests/web-apps/gotosocial.nix
Wolfgang Walther 41c5662cbe
nixos/postgresql: move postStart into separate unit
This avoids restarting the postgresql server, when only ensureDatabases
or ensureUsers have been changed. It will also allow to properly wait
for recovery to finish later.

To wait for "postgresql is ready" in other services, we now provide a
postgresql.target.

Resolves #400018

Co-authored-by: Marcel <me@m4rc3l.de>
2025-06-24 15:26:47 +02:00

33 lines
1.0 KiB
Nix

{ lib, ... }:
{
name = "gotosocial";
meta.maintainers = with lib.maintainers; [ blakesmith ];
nodes.machine =
{ pkgs, ... }:
{
environment.systemPackages = [ pkgs.jq ];
services.gotosocial = {
enable = true;
setupPostgresqlDB = true;
settings = {
host = "localhost:8081";
port = 8081;
instance-stats-mode = "serve";
};
};
};
testScript = ''
machine.wait_for_unit("gotosocial.service")
machine.wait_for_unit("postgresql.target")
machine.wait_for_open_port(8081)
# Database migrations are running, wait until gotosocial no longer serves 503
machine.wait_until_succeeds("curl -sS -f http://localhost:8081/readyz", timeout=300)
# check user registration via cli
machine.succeed("gotosocial-admin account create --username nickname --email email@example.com --password kurtz575VPeBgjVm")
machine.wait_until_succeeds("curl -sS -f http://localhost:8081/nodeinfo/2.0 | jq '.usage.users.total' | grep -q '^1$'")
'';
}