2022-09-11 13:14:47 +00:00
|
|
|
{ pkgs, lib, config, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.q2tg;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
users = {
|
|
|
|
users.q2tg = {
|
|
|
|
isSystemUser = true;
|
|
|
|
createHome = true;
|
|
|
|
home = "/var/lib/q2tg";
|
|
|
|
group = "q2tg";
|
|
|
|
description = "Q2TG service";
|
|
|
|
};
|
|
|
|
|
|
|
|
groups.q2tg = { };
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.q2tg = {
|
2022-09-11 16:28:42 +00:00
|
|
|
description = "Q2TG service";
|
2022-09-11 13:14:47 +00:00
|
|
|
path = [ cfg.package ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
environment = {
|
|
|
|
DATA_DIR = "/var/lib/q2tg";
|
|
|
|
TG_API_ID = toString cfg.tg.api-id;
|
|
|
|
TG_API_HASH = cfg.tg.api-hash;
|
|
|
|
TG_BOT_TOKEN = cfg.tg.bot-token;
|
|
|
|
CRV_API = cfg.crv.api;
|
|
|
|
CRV_KEY = cfg.crv.key;
|
|
|
|
DATABASE_URL = cfg.database;
|
2022-09-14 15:30:04 +00:00
|
|
|
PROXY_IP = toString cfg.proxy.ip;
|
2022-09-14 14:59:50 +00:00
|
|
|
PROXY_PORT = toString cfg.proxy.port;
|
2022-09-11 13:14:47 +00:00
|
|
|
PRISMA_MIGRATION_ENGINE_BINARY = "${pkgs.prisma-engines}/bin/migration-engine";
|
|
|
|
PRISMA_QUERY_ENGINE_BINARY = "${pkgs.prisma-engines}/bin/query-engine";
|
|
|
|
PRISMA_QUERY_ENGINE_LIBRARY = "${pkgs.prisma-engines}/lib/libquery_engine.node";
|
|
|
|
PRISMA_INTROSPECTION_ENGINE_BINARY = "${pkgs.prisma-engines}/bin/introspection-engine";
|
|
|
|
PRISMA_FMT_BINARY = "${pkgs.prisma-engines}/bin/prisma-fmt";
|
2022-09-11 16:28:42 +00:00
|
|
|
TGS_TO_GIF = "${cfg.tgs-to-gif-package}/bin/tgs-to-gif";
|
2022-09-12 13:29:34 +00:00
|
|
|
FFMPEG_PATH = "${cfg.ffmpeg-package}/bin/ffmpeg";
|
|
|
|
FFPROBE_PATH = "${cfg.ffmpeg-package}/bin/ffprobe";
|
2023-01-15 09:06:40 +00:00
|
|
|
FONTCONFIG_PATH = cfg.quotly-fonts;
|
2023-01-16 07:30:35 +00:00
|
|
|
IPV6 = "1";
|
2022-09-11 13:14:47 +00:00
|
|
|
};
|
|
|
|
serviceConfig = {
|
|
|
|
User = "q2tg";
|
|
|
|
Group = "q2tg";
|
2022-09-14 14:46:52 +00:00
|
|
|
Restart = "on-failure";
|
2022-09-14 15:30:04 +00:00
|
|
|
ExecStartPre = "${cfg.prisma-package}/bin/prisma db push --accept-data-loss --skip-generate --schema ${cfg.package}/libexec/q2tg/node_modules/.prisma/client/schema.prisma";
|
2022-09-11 13:14:47 +00:00
|
|
|
ExecStart = "${cfg.package}/bin/q2tg";
|
2022-12-24 14:03:09 +00:00
|
|
|
WorkingDirectory = "${cfg.package}/libexec/q2tg";
|
2022-09-11 13:14:47 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|