2024-05-20 13:33:51 +02:00
|
|
|
import ./make-test-python.nix ({ lib, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
db-pass = "Test2Test2";
|
|
|
|
app-key = "TestTestTestTestTestTestTestTest";
|
|
|
|
in
|
|
|
|
{
|
2024-04-06 17:37:34 +02:00
|
|
|
name = "firefly-iii";
|
|
|
|
meta.maintainers = [ lib.maintainers.savyajha ];
|
|
|
|
|
2024-05-20 13:33:51 +02:00
|
|
|
nodes.fireflySqlite = { config, ... }: {
|
2024-04-06 17:37:34 +02:00
|
|
|
environment.etc = {
|
2024-05-20 13:33:51 +02:00
|
|
|
"firefly-iii-appkey".text = app-key;
|
2024-04-06 17:37:34 +02:00
|
|
|
};
|
|
|
|
services.firefly-iii = {
|
|
|
|
enable = true;
|
|
|
|
enableNginx = true;
|
|
|
|
settings = {
|
|
|
|
APP_KEY_FILE = "/etc/firefly-iii-appkey";
|
|
|
|
LOG_CHANNEL = "stdout";
|
|
|
|
SITE_OWNER = "mail@example.com";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-05-20 13:33:51 +02:00
|
|
|
nodes.fireflyPostgresql = { config, pkgs, ... }: {
|
|
|
|
environment.etc = {
|
|
|
|
"firefly-iii-appkey".text = app-key;
|
|
|
|
"postgres-pass".text = db-pass;
|
|
|
|
};
|
|
|
|
services.firefly-iii = {
|
|
|
|
enable = true;
|
|
|
|
enableNginx = true;
|
|
|
|
settings = {
|
|
|
|
APP_KEY_FILE = "/etc/firefly-iii-appkey";
|
|
|
|
LOG_CHANNEL = "stdout";
|
|
|
|
SITE_OWNER = "mail@example.com";
|
|
|
|
DB_CONNECTION = "pgsql";
|
|
|
|
DB_DATABASE = "firefly";
|
|
|
|
DB_USERNAME = "firefly";
|
|
|
|
DB_PASSWORD_FILE = "/etc/postgres-pass";
|
2024-06-15 15:31:08 +02:00
|
|
|
PGSQL_SCHEMA = "firefly";
|
2024-05-20 13:33:51 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
services.postgresql = {
|
|
|
|
enable = true;
|
2024-06-15 15:31:08 +02:00
|
|
|
package = pkgs.postgresql_16;
|
2024-05-20 13:33:51 +02:00
|
|
|
authentication = ''
|
|
|
|
local all postgres peer
|
|
|
|
local firefly firefly password
|
|
|
|
'';
|
|
|
|
initialScript = pkgs.writeText "firefly-init.sql" ''
|
|
|
|
CREATE USER "firefly" WITH LOGIN PASSWORD '${db-pass}';
|
|
|
|
CREATE DATABASE "firefly" WITH OWNER "firefly";
|
2024-06-15 15:31:08 +02:00
|
|
|
\c firefly
|
2024-05-20 13:33:51 +02:00
|
|
|
CREATE SCHEMA AUTHORIZATION firefly;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
nodes.fireflyMysql = { config, pkgs, ... }: {
|
|
|
|
environment.etc = {
|
|
|
|
"firefly-iii-appkey".text = app-key;
|
|
|
|
"mysql-pass".text = db-pass;
|
|
|
|
};
|
|
|
|
services.firefly-iii = {
|
|
|
|
enable = true;
|
|
|
|
enableNginx = true;
|
|
|
|
settings = {
|
|
|
|
APP_KEY_FILE = "/etc/firefly-iii-appkey";
|
|
|
|
LOG_CHANNEL = "stdout";
|
|
|
|
SITE_OWNER = "mail@example.com";
|
|
|
|
DB_CONNECTION = "mysql";
|
|
|
|
DB_DATABASE = "firefly";
|
|
|
|
DB_USERNAME = "firefly";
|
|
|
|
DB_PASSWORD_FILE = "/etc/mysql-pass";
|
|
|
|
DB_SOCKET = "/run/mysqld/mysqld.sock";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
services.mysql = {
|
|
|
|
enable = true;
|
|
|
|
package = pkgs.mariadb;
|
|
|
|
initialScript = pkgs.writeText "firefly-init.sql" ''
|
|
|
|
create database firefly DEFAULT CHARACTER SET utf8mb4;
|
|
|
|
create user 'firefly'@'localhost' identified by '${db-pass}';
|
|
|
|
grant all on firefly.* to 'firefly'@'localhost';
|
|
|
|
'';
|
|
|
|
settings.mysqld.character-set-server = "utf8mb4";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-04-06 17:37:34 +02:00
|
|
|
testScript = ''
|
2024-05-20 13:33:51 +02:00
|
|
|
fireflySqlite.wait_for_unit("phpfpm-firefly-iii.service")
|
|
|
|
fireflySqlite.wait_for_unit("nginx.service")
|
|
|
|
fireflySqlite.succeed("curl -fvvv -Ls http://localhost/ | grep 'Firefly III'")
|
|
|
|
fireflySqlite.succeed("curl -fvvv -Ls http://localhost/v1/js/app.js")
|
|
|
|
fireflySqlite.succeed("systemctl start firefly-iii-cron.service")
|
|
|
|
fireflyPostgresql.wait_for_unit("phpfpm-firefly-iii.service")
|
|
|
|
fireflyPostgresql.wait_for_unit("nginx.service")
|
|
|
|
fireflyPostgresql.wait_for_unit("postgresql.service")
|
|
|
|
fireflyPostgresql.succeed("curl -fvvv -Ls http://localhost/ | grep 'Firefly III'")
|
|
|
|
fireflyPostgresql.succeed("systemctl start firefly-iii-cron.service")
|
|
|
|
fireflyMysql.wait_for_unit("phpfpm-firefly-iii.service")
|
|
|
|
fireflyMysql.wait_for_unit("nginx.service")
|
|
|
|
fireflyMysql.wait_for_unit("mysql.service")
|
|
|
|
fireflyMysql.succeed("curl -fvvv -Ls http://localhost/ | grep 'Firefly III'")
|
|
|
|
fireflyMysql.succeed("systemctl start firefly-iii-cron.service")
|
2024-04-06 17:37:34 +02:00
|
|
|
'';
|
|
|
|
})
|