add tgs-to-gif support

This commit is contained in:
Clansty 2022-09-12 00:28:42 +08:00
parent eca1f8ce3d
commit f244013433
3 changed files with 17 additions and 2 deletions

View File

@ -11,6 +11,20 @@ with pkgs.lib;
type = types.package;
default = import ../default.nix { inherit pkgs; };
};
tgs-to-gif-package = mkOption {
type = types.package;
default =
let
clansty-flake = pkgs.fetchFromGitHub {
owner = "Clansty";
repo = "flake";
rev = "d602b0359456457b8d92d1f84e42e7aec3baa9be";
fetchSubmodules = true;
sha256 = "na+HvJ7B/rP+qew1b58hTkHzc6BRvOERUHgva7cEY5k=";
};
in
pkgs.callPackage "${clansty-flake}/packages/tgs-to-gif" { };
};
tg.api-id = mkOption {
type = types.int;
};

View File

@ -18,7 +18,7 @@ in
};
systemd.services.q2tg = {
description = "Q2TG checkin";
description = "Q2TG service";
path = [ cfg.package ];
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
@ -35,6 +35,7 @@ in
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";
TGS_TO_GIF = "${cfg.tgs-to-gif-package}/bin/tgs-to-gif";
};
serviceConfig = {
User = "q2tg";

View File

@ -2,7 +2,7 @@ import { spawn } from 'child_process';
export default function tgsToGif(tgsPath: string) {
return new Promise(resolve => {
spawn('tgs_to_gif', [tgsPath]).on('exit', () => {
spawn(process.env.TGS_TO_GIF || 'tgs_to_gif', [tgsPath]).on('exit', () => {
resolve(tgsPath + '.gif');
});
});