1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 libcommuni,
6 qmake,
7 qtbase,
8 wrapQtAppsHook,
9}:
10
11stdenv.mkDerivation {
12 pname = "communi";
13 version = "3.6.0";
14
15 src = fetchFromGitHub {
16 owner = "communi";
17 repo = "communi-desktop";
18 # Without https://github.com/communi/communi-desktop/pull/146 fetching fails with
19 # fatal: unable to connect to github.com:
20 # github.com[0: 140.82.112.3]: errno=Connection timed out
21 rev = "5d813dc6e64a623cd5d78f024c8a0720a5155a28";
22 hash = "sha256-ci91Bf0EkhlPDO+NcpnMmT/vE41i5RD2mXbRAnMB++M=";
23 fetchSubmodules = true;
24 };
25
26 nativeBuildInputs = [
27 qmake
28 wrapQtAppsHook
29 ];
30
31 buildInputs = [
32 libcommuni
33 qtbase
34 ];
35
36 # libCommuni.dylib is installed in $out/Applications/Communi.app/Contents/Frameworks/ on Darwin
37 # Wrapper hook thinks it's a binary because it's in $out/Applications, wraps it with a shell script
38 # So we manually call the wrapper script on just the binary
39 dontWrapQtApps = stdenv.hostPlatform.isDarwin;
40
41 preConfigure = ''
42 export QMAKEFEATURES=${libcommuni}/features
43 '';
44
45 qmakeFlags = [
46 "COMMUNI_INSTALL_PREFIX=${placeholder "out"}"
47 "COMMUNI_INSTALL_PLUGINS=${placeholder "out"}/lib/communi/plugins"
48 "COMMUNI_INSTALL_ICONS=${placeholder "out"}/share/icons/hicolor"
49 "COMMUNI_INSTALL_DESKTOP=${placeholder "out"}/share/applications"
50 "COMMUNI_INSTALL_THEMES=${placeholder "out"}/share/communi/themes"
51 "COMMUNI_INSTALL_BINS=${placeholder "out"}/${
52 if stdenv.hostPlatform.isDarwin then "Applications" else "bin"
53 }"
54 ];
55
56 postInstall =
57 if stdenv.hostPlatform.isDarwin then
58 ''
59 # Nix qmake does not add the bundle rpath by default.
60 install_name_tool \
61 -add_rpath @executable_path/../Frameworks \
62 $out/Applications/Communi.app/Contents/MacOS/Communi
63
64 # Do not remove until wrapQtAppsHook doesn't wrap dylibs in app bundles anymore
65 wrapQtApp $out/Applications/Communi.app/Contents/MacOS/Communi
66 ''
67 else
68 ''
69 substituteInPlace "$out/share/applications/communi.desktop" \
70 --replace "/usr/bin" "$out/bin"
71 '';
72
73 preFixup = ''
74 rm -rf lib
75 '';
76
77 meta = with lib; {
78 description = "Simple and elegant cross-platform IRC client";
79 mainProgram = "communi";
80 homepage = "https://github.com/communi/communi-desktop";
81 license = licenses.bsd3;
82 maintainers = with maintainers; [ hrdinka ];
83 platforms = platforms.all;
84 };
85}