{ 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 ''; }; }); }