mirror of
https://git.sr.ht/~magic_rb/cluster
synced 2024-11-27 02:26:14 +01:00
60ffcb7757
Signed-off-by: Magic_RB <magic_rb@redalder.org>
68 lines
2.1 KiB
Nix
68 lines
2.1 KiB
Nix
{ nglib, nixpkgs }:
|
|
nglib.makeSystem {
|
|
system = "x86_64-linux";
|
|
name = "mautrix-discord";
|
|
inherit nixpkgs;
|
|
config = ({ pkgs, ... }:
|
|
{
|
|
dumb-init = {
|
|
enable = true;
|
|
type.services = { };
|
|
};
|
|
|
|
init.services.mautrix-discord = {
|
|
enabled = true;
|
|
shutdownOnExit = true;
|
|
script =
|
|
let
|
|
config = ./mautrix-discord.yaml;
|
|
inherit (pkgs)
|
|
buildGoModule
|
|
fetchFromGitHub
|
|
olm
|
|
lib
|
|
;
|
|
mautrix-discord =
|
|
buildGoModule rec {
|
|
pname = "mautrix-discord";
|
|
version = "0.3.0";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "mautrix";
|
|
repo = "discord";
|
|
rev = "v${version}";
|
|
hash = "sha256-Qlok8LnnuJYCmkDssyNRfrHSdBNi5J40cXJHX7xa4fI=";
|
|
};
|
|
|
|
buildInputs = [ olm ];
|
|
|
|
vendorSha256 = "sha256-OqMa4hpJLQRID8QxxX++lyFy/6b3Rg9GeQ7Qe+dsIkY=";
|
|
|
|
doCheck = false;
|
|
|
|
meta = with lib; {
|
|
homepage = "https://github.com/tulir/mautrix-whatsapp";
|
|
description = "Matrix <-> Discord hybrid puppeting/relaybot bridge";
|
|
license = licenses.agpl3Plus;
|
|
maintainers = with maintainers; [ ];
|
|
};
|
|
};
|
|
in
|
|
pkgs.writeShellScript "mautrix-discord"
|
|
''
|
|
DATA_DIR="/var/lib/mautrix-discord"
|
|
CONFIG_FILE="$DATA_DIR/config.yaml"
|
|
REGISTRATION_FILE="/var/lib/registrations/mautrix-discord.yaml"
|
|
DB_FILE="$DATA_DIR/sqlite.db"
|
|
|
|
${lib.getExe pkgs.envsubst} < ${config} > "$CONFIG_FILE"
|
|
chmod 755 "$CONFIG_FILE"
|
|
|
|
[ -e "$REGISTRATION_FILE" ] || \
|
|
${lib.getExe mautrix-discord} -c "$CONFIG_FILE" -r "$REGISTRATION_FILE" -g
|
|
${lib.getExe mautrix-discord} -c "$CONFIG_FILE" -r "$REGISTRATION_FILE" -n
|
|
'';
|
|
};
|
|
});
|
|
}
|