1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 pkg-config,
6 libXtst,
7 libvorbis,
8 hunspell,
9 lzo,
10 xz,
11 bzip2,
12 libiconv,
13 qtbase,
14 qtsvg,
15 qtwebkit,
16 qtx11extras,
17 qttools,
18 qmake,
19 wrapQtAppsHook,
20 wrapGAppsHook3,
21 withCC ? true,
22 opencc,
23 withEpwing ? true,
24 libeb,
25 withExtraTiff ? true,
26 libtiff,
27 withFFmpeg ? true,
28 libao,
29 ffmpeg,
30 withMultimedia ? true,
31 withZim ? true,
32 zstd,
33}:
34
35stdenv.mkDerivation rec {
36 pname = "goldendict";
37 version = "1.5.0";
38
39 src = fetchFromGitHub {
40 owner = "goldendict";
41 repo = "goldendict";
42 rev = version;
43 hash = "sha256-80o8y+mbzpyMQYUGHYs/zgQT23nLVCs7Jcr8FbbXn8M=";
44 };
45
46 patches = [
47 ./0001-dont-check-for-updates.patch
48 ./0001-dont-use-maclibs.patch
49 ];
50
51 postPatch = ''
52 substituteInPlace goldendict.pro \
53 --replace "hunspell-1.6.1" "hunspell-${lib.versions.majorMinor hunspell.version}" \
54 --replace "opencc.2" "opencc"
55 '';
56
57 nativeBuildInputs = [
58 pkg-config
59 qmake
60 wrapQtAppsHook
61 wrapGAppsHook3
62 ];
63 buildInputs = [
64 qtbase
65 qtsvg
66 qtwebkit
67 qttools
68 libvorbis
69 hunspell
70 xz
71 lzo
72 ]
73 ++ lib.optionals stdenv.hostPlatform.isLinux [
74 qtx11extras
75 libXtst
76 ]
77 ++ lib.optionals stdenv.hostPlatform.isDarwin [
78 bzip2
79 libiconv
80 ]
81 ++ lib.optional withCC opencc
82 ++ lib.optional withEpwing libeb
83 ++ lib.optional withExtraTiff libtiff
84 ++ lib.optionals withFFmpeg [
85 libao
86 ffmpeg
87 ]
88 ++ lib.optional withZim zstd;
89
90 qmakeFlags = [
91 "goldendict.pro"
92 (lib.optional withCC "CONFIG+=chinese_conversion_support")
93 (lib.optional (!withCC) "CONFIG+=no_chinese_conversion_support")
94 (lib.optional (!withEpwing) "CONFIG+=no_epwing_support")
95 (lib.optional (!withExtraTiff) "CONFIG+=no_extra_tiff_handler")
96 (lib.optional (!withFFmpeg) "CONFIG+=no_ffmpeg_player")
97 (lib.optional (!withMultimedia) "CONFIG+=no_qtmultimedia_player")
98 (lib.optional withZim "CONFIG+=zim_support")
99 ];
100
101 postInstall = lib.optionalString stdenv.hostPlatform.isDarwin ''
102 mkdir -p $out/Applications
103 mv GoldenDict.app $out/Applications
104 '';
105
106 meta = with lib; {
107 homepage = "http://goldendict.org/";
108 description = "Feature-rich dictionary lookup program";
109 platforms = with platforms; linux ++ darwin;
110 mainProgram = "goldendict";
111 maintainers = with maintainers; [
112 sikmir
113 ];
114 license = licenses.gpl3Plus;
115 };
116}