lol
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 [
71 autoconf
72 automake
73 intltool
74 libtool
75 pkg-config
76 cmake
77
78 ruby # used by sigscheme build to generate function tables
79 librsvg # used by uim build to generate png pixmaps from svg
80 ]
81 ++ lib.optionals withQt5 [
82 qt5.wrapQtAppsHook
83 ];
84
85 buildInputs =
86 [
87 ncurses
88 m17n_lib
89 m17n_db
90 expat
91 ]
92 ++ lib.optional withAnthy anthy
93 ++ lib.optional withGtk2 gtk2
94 ++ lib.optional withGtk3 gtk3
95 ++ lib.optionals withQt5 [
96 qt5.qtbase
97 qt5.qtx11extras
98 ]
99 ++ lib.optional withLibnotify libnotify
100 ++ lib.optional withSqlite sqlite
101 ++ lib.optionals withNetworking [
102 curl
103 openssl
104 ]
105 ++ lib.optional withFFI libffi
106 ++ lib.optional withMisc libeb;
107
108 postPatch = ''
109 patchShebangs *.sh */*.sh */*/*.sh
110
111 # configure sigscheme in maintainer mode or else some function tables won't get autogenerated
112 substituteInPlace configure.ac \
113 --replace-fail \
114 "--with-master-pkg=uim --enable-conf=uim" \
115 "--enable-maintainer-mode --with-master-pkg=uim --enable-conf=uim"
116
117 # generate ./configure files
118 (cd sigscheme/libgcroots; ./autogen.sh)
119 (cd sigscheme; ./autogen.sh)
120 ./autogen.sh
121 '';
122
123 patches = [
124 ./data-hook.patch
125 ];
126
127 configureFlags =
128 [
129 # configure in maintainer mode or else some pixmaps won't get autogenerated
130 # this should imply the above `--enable-maintainer-mode`, but it does not
131 "--enable-maintainer-mode"
132
133 "--enable-pref"
134 "--with-skk"
135 "--with-x"
136 "--with-xft"
137 "--with-expat=${expat.dev}"
138 ]
139 ++ lib.optional withAnthy "--with-anthy-utf8"
140 ++ lib.optional withGtk2 "--with-gtk2"
141 ++ lib.optional withGtk3 "--with-gtk3"
142 ++ lib.optionals withQt5 [
143 "--with-qt5"
144 "--with-qt5-immodule"
145 ]
146 ++ lib.optional withLibnotify "--enable-notify=libnotify"
147 ++ lib.optional withSqlite "--with-sqlite3"
148 ++ lib.optionals withNetworking [
149 "--with-curl"
150 "--with-openssl-dir=${openssl.dev}"
151 ]
152 ++ lib.optional withFFI "--with-ffi"
153 ++ lib.optional withMisc "--with-eb";
154
155 # TODO: things in `./configure --help`, but not in nixpkgs
156 #--with-canna Use Canna [default=no]
157 #--with-wnn Build with libwnn [default=no]
158 #--with-mana Build a plugin for Mana [default=yes]
159 #--with-prime Build a plugin for PRIME [default=yes]
160 #--with-sj3 Use SJ3 [default=no]
161 #--with-osx-dcs Build with OS X Dictionary Services [default=no]
162
163 # TODO: fix this in librsvg/glib later
164 # https://github.com/NixOS/nixpkgs/pull/57027#issuecomment-475461733
165 preBuild = ''
166 export XDG_DATA_DIRS="${shared-mime-info}/share"
167 '';
168
169 dontUseCmakeConfigure = true;
170
171 meta = {
172 inherit (finalAttrs.src.meta) homepage;
173 description = "Multilingual input method framework";
174 license = lib.licenses.bsd3;
175 platforms = lib.platforms.unix;
176 maintainers = with lib.maintainers; [
177 oxij
178 ];
179 };
180})