11{
22 lib ,
3+ buildGoModule ,
34 fetchFromGitHub ,
45 file , # for libmagic
56 ncurses ,
1314 darwin ,
1415} :
1516
16- stdenv . mkDerivation rec {
17- pname = "nchat" ;
17+ let
1818 version = "5.4.2" ;
1919
2020 src = fetchFromGitHub {
@@ -24,16 +24,55 @@ stdenv.mkDerivation rec {
2424 hash = "sha256-NrAU47GA7ZASJ7vCo1S8nyGBpfsZn4EBBqx2c4HKx7k=" ;
2525 } ;
2626
27+ libcgowm = buildGoModule {
28+ pname = "nchat-wmchat-libcgowm" ;
29+ inherit version src ;
30+
31+ sourceRoot = "${ src . name } /lib/wmchat/go" ;
32+ vendorHash = "sha256-EdbOO5cCDT1CcPlCBgMoPDg65FcoOYvBwZa4bz0hfGE=" ;
33+
34+ buildPhase = ''
35+ mkdir -p $out/
36+ go build -o $out/ -buildmode=c-archive
37+ mv $out/go.a $out/libcgowm.a
38+ ln -s $out/libcgowm.a $out/libref-cgowm.a
39+ mv $out/go.h $out/libcgowm.h
40+ '' ;
41+ } ;
42+ in
43+ stdenv . mkDerivation rec {
44+ pname = "nchat" ;
45+ inherit version src ;
46+
47+ nl = "\n " ;
2748 postPatch = ''
2849 substituteInPlace lib/tgchat/ext/td/CMakeLists.txt \
2950 --replace "get_git_head_revision" "#get_git_head_revision"
3051 substituteInPlace lib/tgchat/CMakeLists.txt \
3152 --replace-fail "list(APPEND OPENSSL_ROOT_DIR" "#list(APPEND OPENSSL_ROOT_DIR"
53+
54+ # specific mangling to handle whatsapp go module:
55+
56+ substituteInPlace CMakeLists.txt \
57+ --replace "if(HAS_WHATSAPP AND (NOT GO_VERSION VERSION_GREATER_EQUAL GO_VERSION_MIN))" \
58+ "if(FALSE AND (NOT GO_VERSION VERSION_GREATER_EQUAL GO_VERSION_MIN))"
59+
60+ substituteInPlace lib/wmchat/CMakeLists.txt \
61+ --replace-fail "add_subdirectory(go)" \
62+ "set(GO_LIBRARIES ${ libcgowm } /libcgowm.a)${ nl } target_include_directories(wmchat PRIVATE ${ libcgowm } )"
63+
64+ substituteInPlace lib/wmchat/CMakeLists.txt \
65+ --replace-fail "target_link_libraries(wmchat PUBLIC ref-cgowm ncutil \'' ${GO_LIBRARIES})" \
66+ "target_link_libraries(wmchat PUBLIC ${ libcgowm } /libcgowm.a ncutil \'' ${GO_LIBRARIES})"
67+
68+ substituteInPlace lib/wmchat/CMakeLists.txt \
69+ --replace-fail "add_dependencies(wmchat ref-cgowm)" "#add_dependencies(wmchat ref-cgowm)"
3270 '' ;
3371
3472 nativeBuildInputs = [
3573 cmake
3674 gperf
75+ libcgowm
3776 ] ;
3877
3978 buildInputs =
@@ -56,7 +95,6 @@ stdenv.mkDerivation rec {
5695
5796 cmakeFlags = [
5897 "-DCMAKE_INSTALL_LIBDIR=lib"
59- "-DHAS_WHATSAPP=OFF" # go module build required
6098 ] ;
6199
62100 meta = {
0 commit comments