1{ lib, stdenv, fetchFromGitHub, fetchpatch, shared-mime-info
2, autoconf, automake, intltool, libtool, pkg-config, cmake
3, ruby, librsvg
4, ncurses, m17n_lib, m17n_db, expat
5, withAnthy ? true, anthy ? null
6, withGtk ? true
7, withGtk2 ? withGtk, gtk2 ? null
8, withGtk3 ? withGtk, gtk3 ? null
9, withQt ? true
10, withQt4 ? withQt, qt4 ? null
11, withQt5 ? false, qt5 ? null
12, withLibnotify ? true, libnotify ? null
13, withSqlite ? true, sqlite ? null
14, withNetworking ? true, curl ? null, openssl ? null
15, withFFI ? true, libffi ? null
16
17# Things that are clearly an overkill to be enabled by default
18, withMisc ? false, libeb ? null
19}:
20
21with lib;
22
23assert withGtk2 -> gtk2 != null;
24assert withGtk3 -> gtk3 != null;
25
26# TODO(@oxij): ./configure can't find both qmakes at the same time
27# this can be fixed by adding an alias qmake -> qmaka${version} in qmake derivation
28assert withQt4 -> !withQt5 && qt4 != null;
29assert withQt5 -> !withQt4 && qt5 != null;
30
31assert !withQt5; # fails to build with "Makefile.qmake: No such file or directory"
32
33assert withAnthy -> anthy != null;
34assert withLibnotify -> libnotify != null;
35assert withSqlite -> sqlite != null;
36assert withNetworking -> curl != null && openssl != null;
37assert withFFI -> libffi != null;
38assert withMisc -> libeb != null;
39
40stdenv.mkDerivation rec {
41 version = "1.8.8";
42 pname = "uim";
43
44 src = fetchFromGitHub {
45 owner = "uim";
46 repo = "uim";
47 rev = "2c0958c9c505a87e70e344c2192e2e5123c71ea5";
48 fetchSubmodules = true;
49 sha256 = "1hkjxi5r49gcna37m3jvykny5hz9ram4y8a3q7lw4qzr52mz9pdp";
50 };
51
52 nativeBuildInputs = [
53 autoconf automake intltool libtool pkg-config cmake
54
55 ruby # used by sigscheme build to generate function tables
56 librsvg # used by uim build to generate png pixmaps from svg
57 ];
58
59 buildInputs = [
60 ncurses m17n_lib m17n_db expat
61 ]
62 ++ optional withAnthy anthy
63 ++ optional withGtk2 gtk2
64 ++ optional withGtk3 gtk3
65 ++ optional withQt4 qt4
66 ++ optionals withQt5 [ qt5.qtbase.bin qt5.qtbase.dev ]
67 ++ optional withLibnotify libnotify
68 ++ optional withSqlite sqlite
69 ++ optionals withNetworking [
70 curl openssl
71 ]
72 ++ optional withFFI libffi
73 ++ optional withMisc libeb;
74
75 prePatch = ''
76 patchShebangs *.sh */*.sh */*/*.sh
77
78 # configure sigscheme in maintainer mode or else some function tables won't get autogenerated
79 substituteInPlace configure.ac \
80 --replace "--with-master-pkg=uim --enable-conf=uim" \
81 "--enable-maintainer-mode --with-master-pkg=uim --enable-conf=uim"
82
83 # generate ./configure files
84 (cd sigscheme/libgcroots; ./autogen.sh)
85 (cd sigscheme; ./autogen.sh)
86 ./autogen.sh
87 '';
88
89 patches = [
90 ./data-hook.patch
91
92 # Pull upstream fix for -fno-common toolchains
93 # https://github.com/uim/libgcroots/pull/4
94 (fetchpatch {
95 name = "libgcroots-fno-common.patch";
96 url = "https://github.com/uim/libgcroots/commit/7e39241344ad0663409e836560ae6b5eb231e1fc.patch";
97 sha256 = "0iifcl5lk8bvl0cflm47gkymg88aiwzj0gxh2aj3mqlyhvyx78nz";
98 # Patch comes from git submodule. Relocate as:
99 # a/include/private/gc_priv.h -> a/sigscheme/libgcroots/include/private/gc_priv.h
100 stripLen = 1;
101 extraPrefix = "sigscheme/libgcroots/";
102 })
103 ];
104
105 configureFlags = [
106 # configure in maintainer mode or else some pixmaps won't get autogenerated
107 # this should imply the above `--enable-maintainer-mode`, but it does not
108 "--enable-maintainer-mode"
109
110 "--enable-pref"
111 "--with-skk"
112 "--with-x"
113 "--with-xft"
114 "--with-expat=${expat.dev}"
115 ]
116 ++ optional withAnthy "--with-anthy-utf8"
117 ++ optional withGtk2 "--with-gtk2"
118 ++ optional withGtk3 "--with-gtk3"
119 ++ optionals withQt4 [
120 "--with-qt4"
121 "--with-qt4-immodule"
122 ]
123 ++ optionals withQt5 [
124 "--with-qt5"
125 "--with-qt5-immodule"
126 ]
127 ++ optional withLibnotify "--enable-notify=libnotify"
128 ++ optional withSqlite "--with-sqlite3"
129 ++ optionals withNetworking [
130 "--with-curl"
131 "--with-openssl-dir=${openssl.dev}"
132 ]
133 ++ optional withFFI "--with-ffi"
134 ++ optional withMisc "--with-eb";
135
136 # TODO: things in `./configure --help`, but not in nixpkgs
137 #--with-canna Use Canna [default=no]
138 #--with-wnn Build with libwnn [default=no]
139 #--with-mana Build a plugin for Mana [default=yes]
140 #--with-prime Build a plugin for PRIME [default=yes]
141 #--with-sj3 Use SJ3 [default=no]
142 #--with-osx-dcs Build with OS X Dictionary Services [default=no]
143
144 # TODO: fix this in librsvg/glib later
145 # https://github.com/NixOS/nixpkgs/pull/57027#issuecomment-475461733
146 preBuild = ''
147 export XDG_DATA_DIRS="${shared-mime-info}/share"
148 '';
149
150 dontUseCmakeConfigure = true;
151
152 meta = with lib; {
153 homepage = src.meta.homepage;
154 description = "A multilingual input method framework";
155 license = licenses.bsd3;
156 platforms = platforms.unix;
157 broken = stdenv.hostPlatform.isAarch64; # fails to build libgcroots (not supported on aarch64)
158 maintainers = with maintainers; [ ericsagnes oxij ];
159 };
160}