summaryrefslogtreecommitdiff
path: root/tests/bookwyrm.nix
blob: 0e9768fe8b549e5af65c78e238e2554bd0ccd24a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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")
  '';
}