{ lib, stdenv, buildGoModule, fetchFromGitHub, olm, versionCheckHook, # This option enables the use of an experimental pure-Go implementation of # the Olm protocol instead of libolm for end-to-end encryption. Using goolm # is not recommended by the mautrix developers, but they are interested in # people trying it out in non-production-critical environments and reporting # any issues they run into. withGoolm ? true, }: let cppStdLib = if stdenv.hostPlatform.isDarwin then "-lc++" else "-lstdc++"; in buildGoModule rec { pname = "mautrix-telegramgo"; rev = "09b1e69c0fa0d915290411274861aee04191cab6"; version = "0.0.0-${builtins.substring 0 6 rev}"; src = fetchFromGitHub { owner = "mautrix"; repo = "telegramgo"; hash = "sha256-HNwtmV1Op7zO+BJzij12CitOciqrZETbz+AbrcaMyD4="; inherit rev; }; buildInputs = (lib.optional (!withGoolm) olm) ++ (lib.optional withGoolm stdenv.cc.cc.lib); CGO_LDFLAGS = lib.optional withGoolm [ cppStdLib ]; tags = lib.optional withGoolm "goolm"; doCheck = false; vendorHash = "sha256-oIkeNnABb9GZfeLrvkVEWcJ6iutC2uS217EkGhEAFcs="; meta = with lib; { homepage = "https://github.com/mautrix/telegramgo"; description = "Go rewrite of mautrix-telegram"; license = licenses.agpl3Plus; mainProgram = "mautrix-telegram"; }; }