summaryrefslogtreecommitdiffstats
path: root/nixos/tests/bookstack.nix
blob: 59924e0395ee8567730608580fb44385141d2d44 (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
{ pkgs, ... }:

let
  app-key = "TestTestTestTestTestTestTestTest";
in
{
  name = "bookstack";
  meta = {
    maintainers = [ pkgs.lib.maintainers.savyajha ];
    platforms = pkgs.lib.platforms.linux;
  };

  nodes.bookstackMysql = {
    services.bookstack = {
      enable = true;
      hostname = "localhost";
      nginx.onlySSL = false;
      settings = {
        APP_KEY_FILE = pkgs.writeText "bookstack-appkey" app-key;
        LOG_CHANNEL = "stdout";
        SITE_OWNER = "mail@example.com";
        DB_DATABASE = "bookstack";
        DB_USERNAME = "bookstack";
        DB_SOCKET = "/run/mysqld/mysqld.sock";
      };
    };

    services.mysql = {
      enable = true;
      package = pkgs.mariadb;
      settings.mysqld.character-set-server = "utf8mb4";
      ensureDatabases = [
        "bookstack"
      ];
      ensureUsers = [
        {
          name = "bookstack";
          ensurePermissions = {
            "bookstack.*" = "ALL PRIVILEGES";
          };
        }
      ];
    };
  };

  testScript = ''
    bookstackMysql.wait_for_unit("phpfpm-bookstack.service")
    bookstackMysql.wait_for_unit("nginx.service")
    bookstackMysql.wait_for_unit("mysql.service")
    bookstackMysql.succeed("curl -fvvv -Ls http://localhost/ | grep 'Log In'")
  '';
}