zaphyra's git: nixfiles

zaphyra and void's nixfiles

commit e11a8f6728217775e55784fcd7acd20f21889799
parent b18be6283dbe39b102f7e19429809c9f90bea2e5
Author: Katja (zaphyra) <git@ctu.cx>
Date: Mon, 26 May 2025 11:10:52 +0200

packages: add `mautrix-telegramgo`
1 file changed, 48 insertions(+), 0 deletions(-)
A
packages/mautrix-telegramgo.nix
|
48
++++++++++++++++++++++++++++++++++++++++++++++++
diff --git a/packages/mautrix-telegramgo.nix b/packages/mautrix-telegramgo.nix
@@ -0,0 +1,48 @@
+{
+  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 = "ea4626107c56799ad3ca503e63450823a7f36546";
+  version = "0.0.0-${builtins.substring 0 6 rev}";
+  hash = "sha256-wV6wH60+qF+A/KHS9BDQbSG0pD2yRedqbqH1ea0gCKU=";
+
+  src = fetchFromGitHub {
+    owner = "mautrix";
+    repo = "telegramgo";
+    inherit rev hash;
+  };
+
+  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-3gJwR4gmkoOKQfiWe3pI04638wgJjyissAND5XbBGHM=";
+
+  meta = with lib; {
+    homepage = "https://github.com/mautrix/telegramgo";
+    description = "Go rewrite of mautrix-telegram";
+    license = licenses.agpl3Plus;
+    mainProgram = "mautrix-telegram";
+  };
+}