1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 shared-mime-info,
6 autoconf,
7 automake,
8 intltool,
9 libtool,
10 pkg-config,
11 cmake,
12 ruby,
13 librsvg,
14 ncurses,
15 m17n_lib,
16 m17n_db,
17 expat,
18 withAnthy ? true,
19 anthy ? null,
20 withGtk ? true,
21 withGtk2 ? withGtk,
22 gtk2 ? null,
23 withGtk3 ? withGtk,
24 gtk3 ? null,
25 # Was never enabled in the history of this package and is not needed by any
26 # dependent package, hence disabled to save up closure size.
27 withQt ? false,
28 withQt5 ? withQt,
29 qt5 ? null,
30 withLibnotify ? true,
31 libnotify ? null,
32 withSqlite ? true,
33 sqlite ? null,
34 withNetworking ? true,
35 curl ? null,
36 openssl ? null,
37 withFFI ? true,
38 libffi ? null,
39
40 # Things that are clearly an overkill to be enabled by default
41 withMisc ? false,
42 libeb ? null,
43}:
44
45assert withGtk2 -> gtk2 != null;
46assert withGtk3 -> gtk3 != null;
47
48assert withAnthy -> anthy != null;
49assert withLibnotify -> libnotify != null;
50assert withSqlite -> sqlite != null;
51assert withNetworking -> curl != null && openssl != null;
52assert withFFI -> libffi != null;
53assert withMisc -> libeb != null;
54
55stdenv.mkDerivation (finalAttrs: {
56 # Includes multiple GCC 14 related fixes, and other bugs. Last 1.8.9 release
57 # was in August 2022 - too long ago.
58 version = "1.8.9-unstable-2024-12-09";
59 pname = "uim";
60
61 src = fetchFromGitHub {
62 owner = "uim";
63 repo = "uim";
64 rev = "b6803aa7ea433f92855284ec832aeff957c63904";
65 fetchSubmodules = true;
66 hash = "sha256-7Ng9IPF6xN1Zb9uEacq7SUhpJc1jWzneVSbbjyqL6g4=";
67 };
68
69 nativeBuildInputs = [
70 autoconf
71 automake
72 intltool
73 libtool
74 pkg-config
75 cmake
76
77 ruby # used by sigscheme build to generate function tables
78 librsvg # used by uim build to generate png pixmaps from svg
79 ]
80 ++ lib.optionals withQt5 [
81 qt5.wrapQtAppsHook
82 ];
83
84 buildInputs = [
85 ncurses
86 m17n_lib
87 m17n_db
88 expat
89 ]
90 ++ lib.optional withAnthy anthy
91 ++ lib.optional withGtk2 gtk2
92 ++ lib.optional withGtk3 gtk3
93 ++ lib.optionals withQt5 [
94 qt5.qtbase
95 qt5.qtx11extras
96 ]
97 ++ lib.optional withLibnotify libnotify
98 ++ lib.optional withSqlite sqlite
99 ++ lib.optionals withNetworking [
100 curl
101 openssl
102 ]
103 ++ lib.optional withFFI libffi
104 ++ lib.optional withMisc libeb;
105
106 postPatch = ''
107 patchShebangs *.sh */*.sh */*/*.sh
108
109 # configure sigscheme in maintainer mode or else some function tables won't get autogenerated
110 substituteInPlace configure.ac \
111 --replace-fail \
112 "--with-master-pkg=uim --enable-conf=uim" \
113 "--enable-maintainer-mode --with-master-pkg=uim --enable-conf=uim"
114
115 # generate ./configure files
116 (cd sigscheme/libgcroots; ./autogen.sh)
117 (cd sigscheme; ./autogen.sh)
118 ./autogen.sh
119 '';
120
121 patches = [
122 ./data-hook.patch
123 ];
124
125 configureFlags = [
126 # configure in maintainer mode or else some pixmaps won't get autogenerated
127 # this should imply the above `--enable-maintainer-mode`, but it does not
128 "--enable-maintainer-mode"
129
130 "--enable-pref"
131 "--with-skk"
132 "--with-x"
133 "--with-xft"
134 "--with-expat=${expat.dev}"
135 ]
136 ++ lib.optional withAnthy "--with-anthy-utf8"
137 ++ lib.optional withGtk2 "--with-gtk2"
138 ++ lib.optional withGtk3 "--with-gtk3"
139 ++ lib.optionals withQt5 [
140 "--with-qt5"
141 "--with-qt5-immodule"
142 ]
143 ++ lib.optional withLibnotify "--enable-notify=libnotify"
144 ++ lib.optional withSqlite "--with-sqlite3"
145 ++ lib.optionals withNetworking [
146 "--with-curl"
147 "--with-openssl-dir=${openssl.dev}"
148 ]
149 ++ lib.optional withFFI "--with-ffi"
150 ++ lib.optional withMisc "--with-eb";
151
152 # TODO: things in `./configure --help`, but not in nixpkgs
153 #--with-canna Use Canna [default=no]
154 #--with-wnn Build with libwnn [default=no]
155 #--with-mana Build a plugin for Mana [default=yes]
156 #--with-prime Build a plugin for PRIME [default=yes]
157 #--with-sj3 Use SJ3 [default=no]
158 #--with-osx-dcs Build with OS X Dictionary Services [default=no]
159
160 # TODO: fix this in librsvg/glib later
161 # https://github.com/NixOS/nixpkgs/pull/57027#issuecomment-475461733
162 preBuild = ''
163 export XDG_DATA_DIRS="${shared-mime-info}/share"
164 '';
165
166 dontUseCmakeConfigure = true;
167
168 meta = {
169 inherit (finalAttrs.src.meta) homepage;
170 description = "Multilingual input method framework";
171 license = lib.licenses.bsd3;
172 platforms = lib.platforms.unix;
173 maintainers = with lib.maintainers; [
174 oxij
175 ];
176 };
177})