katja's git: nixfiles

ctucx' nixfiles

1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 
42 
43 
44 
45 
46 
47 
{
  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";
  };
}