2023-06-13 23:05:35 +02:00
|
|
|
{ inputs, config, ... }:
|
|
|
|
{
|
|
|
|
flake.nixngConfigurations.mautrixDiscord = inputs.nixng.nglib.makeSystem {
|
|
|
|
system = "x86_64-linux";
|
|
|
|
name = "mautrix-discord";
|
|
|
|
inherit (inputs) nixpkgs;
|
|
|
|
config =
|
|
|
|
{ pkgs, lib, ... }:
|
|
|
|
{
|
|
|
|
dumb-init = {
|
|
|
|
enable = true;
|
|
|
|
type.services = { };
|
|
|
|
};
|
|
|
|
|
|
|
|
init.services.mautrix-discord = {
|
|
|
|
enabled = true;
|
|
|
|
shutdownOnExit = true;
|
|
|
|
script =
|
|
|
|
let
|
|
|
|
inherit (lib)
|
2023-10-27 17:37:57 +02:00
|
|
|
getExe'
|
|
|
|
makeBinPath;
|
2023-06-13 23:05:35 +02:00
|
|
|
mautrix-discord = (pkgs.appendOverlays [ config.flake.overlays.mautrix-discord ]).mautrix-discord;
|
|
|
|
in
|
|
|
|
pkgs.writeShellScript "mautrix-discord"
|
|
|
|
''
|
2023-07-09 23:42:46 +02:00
|
|
|
DATA_DIR="/var/lib/mautrix-discord"
|
|
|
|
CONFIG_FILE="$DATA_DIR/config.yaml"
|
|
|
|
REGISTRATION_FILE="/var/lib/registrations/mautrix-discord.yaml"
|
2023-06-13 23:05:35 +02:00
|
|
|
|
2023-10-07 20:25:38 +02:00
|
|
|
${getExe' pkgs.envsubst "envsubst"} < ${./mautrix-discord.yaml} > "$CONFIG_FILE"
|
2023-07-09 23:42:46 +02:00
|
|
|
chmod 755 "$CONFIG_FILE"
|
2023-06-13 23:05:35 +02:00
|
|
|
|
2023-10-27 17:37:57 +02:00
|
|
|
export PATH="$PATH:${makeBinPath [ pkgs.lottieconverter ]};"
|
|
|
|
|
2023-07-09 23:42:46 +02:00
|
|
|
[ -e "$REGISTRATION_FILE" ] || \
|
2023-10-07 20:25:38 +02:00
|
|
|
${getExe' mautrix-discord "mautrix-discord"} -c "$CONFIG_FILE" -r "$REGISTRATION_FILE" -g
|
|
|
|
${getExe' mautrix-discord "mautrix-discord"} -c "$CONFIG_FILE" -r "$REGISTRATION_FILE" -n
|
2023-07-09 23:42:46 +02:00
|
|
|
'';
|
2023-06-13 23:05:35 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|