python312Packages.dissect-extfs: 3.11 -> 3.12
[NixPkgs.git] / nixos / tests / firefly-iii.nix
blobf8e4ca4bfe2b4a81cf3f2a0a0e21e34048611c56
1 import ./make-test-python.nix ({ lib, ... }:
3 let
4   db-pass = "Test2Test2";
5   app-key = "TestTestTestTestTestTestTestTest";
6 in
8   name = "firefly-iii";
9   meta.maintainers = [ lib.maintainers.savyajha ];
11   nodes.fireflySqlite = { config, ... }: {
12     environment.etc = {
13       "firefly-iii-appkey".text = app-key;
14     };
15     services.firefly-iii = {
16       enable = true;
17       enableNginx = true;
18       settings = {
19         APP_KEY_FILE = "/etc/firefly-iii-appkey";
20         LOG_CHANNEL = "stdout";
21         SITE_OWNER = "mail@example.com";
22       };
23     };
24   };
26   nodes.fireflyPostgresql = { config, pkgs, ... }: {
27     environment.etc = {
28       "firefly-iii-appkey".text = app-key;
29       "postgres-pass".text = db-pass;
30     };
31     services.firefly-iii = {
32       enable = true;
33       enableNginx = true;
34       settings = {
35         APP_KEY_FILE = "/etc/firefly-iii-appkey";
36         LOG_CHANNEL = "stdout";
37         SITE_OWNER = "mail@example.com";
38         DB_CONNECTION = "pgsql";
39         DB_DATABASE = "firefly";
40         DB_USERNAME = "firefly";
41         DB_PASSWORD_FILE = "/etc/postgres-pass";
42         PGSQL_SCHEMA = "firefly";
43       };
44     };
46     services.postgresql = {
47       enable = true;
48       package = pkgs.postgresql_16;
49       authentication = ''
50         local all postgres peer
51         local firefly firefly password
52       '';
53       initialScript = pkgs.writeText "firefly-init.sql" ''
54         CREATE USER "firefly" WITH LOGIN PASSWORD '${db-pass}';
55         CREATE DATABASE "firefly" WITH OWNER "firefly";
56         \c firefly
57         CREATE SCHEMA AUTHORIZATION firefly;
58       '';
59     };
60   };
62   nodes.fireflyMysql = { config, pkgs, ... }: {
63     environment.etc = {
64       "firefly-iii-appkey".text = app-key;
65       "mysql-pass".text = db-pass;
66     };
67     services.firefly-iii = {
68       enable = true;
69       enableNginx = true;
70       settings = {
71         APP_KEY_FILE = "/etc/firefly-iii-appkey";
72         LOG_CHANNEL = "stdout";
73         SITE_OWNER = "mail@example.com";
74         DB_CONNECTION = "mysql";
75         DB_DATABASE = "firefly";
76         DB_USERNAME = "firefly";
77         DB_PASSWORD_FILE = "/etc/mysql-pass";
78         DB_SOCKET = "/run/mysqld/mysqld.sock";
79       };
80     };
82     services.mysql = {
83       enable = true;
84       package = pkgs.mariadb;
85       initialScript = pkgs.writeText "firefly-init.sql" ''
86         create database firefly DEFAULT CHARACTER SET utf8mb4;
87         create user 'firefly'@'localhost' identified by '${db-pass}';
88         grant all on firefly.* to 'firefly'@'localhost';
89       '';
90       settings.mysqld.character-set-server = "utf8mb4";
91     };
92   };
94   testScript = ''
95     fireflySqlite.wait_for_unit("phpfpm-firefly-iii.service")
96     fireflySqlite.wait_for_unit("nginx.service")
97     fireflySqlite.succeed("curl -fvvv -Ls http://localhost/ | grep 'Firefly III'")
98     fireflySqlite.succeed("curl -fvvv -Ls http://localhost/v1/js/app.js")
99     fireflySqlite.succeed("systemctl start firefly-iii-cron.service")
100     fireflyPostgresql.wait_for_unit("phpfpm-firefly-iii.service")
101     fireflyPostgresql.wait_for_unit("nginx.service")
102     fireflyPostgresql.wait_for_unit("postgresql.service")
103     fireflyPostgresql.succeed("curl -fvvv -Ls http://localhost/ | grep 'Firefly III'")
104     fireflyPostgresql.succeed("systemctl start firefly-iii-cron.service")
105     fireflyMysql.wait_for_unit("phpfpm-firefly-iii.service")
106     fireflyMysql.wait_for_unit("nginx.service")
107     fireflyMysql.wait_for_unit("mysql.service")
108     fireflyMysql.succeed("curl -fvvv -Ls http://localhost/ | grep 'Firefly III'")
109     fireflyMysql.succeed("systemctl start firefly-iii-cron.service")
110   '';