Pidgin plugin purple-gowhatsapp how to build

To build the purple-gowhatsapp libpurple plugin, to use with pidgin, use the following package definition

{
  buildGoModule,
  fetchFromGitHub,
  gcc,
  glib,
  go,
  lib,
  libogg,
  opusfile,
  pidgin,
  pkg-config,
  sysprof,
}:

buildGoModule (finalAttrs: {
  pname = "purple-gowhatsapp";
  version = "6eb33d398142e5791cf065026b542ad5b0596007";

  src = fetchFromGitHub {
    owner = "hoehermann";
    repo = finalAttrs.pname;
    rev = finalAttrs.version;
    hash = "sha256-qbRbDOwUJOqARF5M0lezWQunycnSYzWw/uIP7plmW30=";
  };

  buildInputs = [
    glib.dev
    libogg
    opusfile
    pidgin
  ];

  strictDeps = true;
  env.CGO_CFLAGS = "-I${pidgin}/include/libpurple -I${glib.dev}/include/glib-2.0 -I${glib.out}/lib/glib-2.0/include -I${sysprof.dev}/include/sysprof-6 -I${opusfile.dev}/include/opus";

  buildPhase = ''
    runHook preBuild

    if [ -z "$enableParallelBuilding" ]; then
        export NIX_BUILD_CORES=1
    fi

    go build '-ldflags=-buildid=' -buildmode=c-archive -o libwhatsmeow.a -p "$NIX_BUILD_CORES" .

    gcc -DPLUGIN_VERSION=${finalAttrs.version} -Dwhatsmeow_EXPORTS -Wl,-soname,libwhatsmeow.so -I. -I./glue -L ${pidgin}/lib -lpurple -L ${glib.out}/lib -lglib-2.0 -L ${opusfile}/lib -lopusfile $CGO_CFLAGS -shared -fPIC -o libwhatsmeow.so bridge.c constants.c glue/blist.c glue/bridge.c glue/commands.c glue/display_message.c glue/groups.c glue/handle_attachment.c glue/init.c glue/login.c glue/options.c glue/pixbuf.c glue/presence.c glue/process_message.c glue/qrcode.c glue/receipt.c glue/send_file.c glue/send_message.c libwhatsmeow.a

    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall

    mkdir -p $out/lib/purple-2
    cp libwhatsmeow.so $out/lib/purple-2

    runHook postInstall
  '';

  vendorHash = "sha256-wCAnRiaByhM61FcMwLY0ZGFQD1UtSNhueIVIGunU0Jg=";

  meta = {
    homepage = "https://github.com/hoehermann/purple-gowhatsapp";
    description = "libpurple plugin for Whatsapp in go";
    license = lib.licenses.gpl3Plus;
    platforms = lib.platforms.unix;
  };
})

i hope you’re able to find this usefull, i have had some struggles trying to make this work, since it seemed to use cmake and cgo, and i wasn’t able to make it work the first times around and took almost a week to do.