1{
2 lib,
3 stdenv,
4 replaceVars,
5 fetchFromGitHub,
6 autoreconfHook,
7 gettext,
8 makeWrapper,
9 pkg-config,
10 vala,
11 wrapGAppsHook3,
12 dbus,
13 systemd,
14 dconf ? null,
15 glib,
16 gdk-pixbuf,
17 gobject-introspection,
18 gtk3,
19 gtk4,
20 gtk-doc,
21 libdbusmenu-gtk3,
22 runCommand,
23 isocodes,
24 cldr-annotations,
25 unicode-character-database,
26 unicode-emoji,
27 python3,
28 json-glib,
29 libnotify ? null,
30 enableUI ? !libOnly,
31 withWayland ? !libOnly,
32 libxkbcommon,
33 wayland,
34 wayland-protocols,
35 wayland-scanner,
36 buildPackages,
37 runtimeShell,
38 nixosTests,
39 versionCheckHook,
40 nix-update-script,
41 libX11,
42 libOnly ? false,
43}:
44
45let
46 python3Runtime = python3.withPackages (ps: with ps; [ pygobject3 ]);
47 python3BuildEnv = python3.pythonOnBuildForHost.buildEnv.override {
48 # ImportError: No module named site
49 postBuild = ''
50 makeWrapper ${glib.dev}/bin/gdbus-codegen $out/bin/gdbus-codegen --unset PYTHONPATH
51 makeWrapper ${glib.dev}/bin/glib-genmarshal $out/bin/glib-genmarshal --unset PYTHONPATH
52 makeWrapper ${glib.dev}/bin/glib-mkenums $out/bin/glib-mkenums --unset PYTHONPATH
53 '';
54 };
55 # make-dconf-override-db.sh needs to execute dbus-launch in the sandbox,
56 # it will fail to read /etc/dbus-1/session.conf unless we add this flag
57 dbus-launch =
58 runCommand "sandbox-dbus-launch"
59 {
60 nativeBuildInputs = [ makeWrapper ];
61 }
62 ''
63 makeWrapper ${dbus}/bin/dbus-launch $out/bin/dbus-launch \
64 --add-flags --config-file=${dbus}/share/dbus-1/session.conf
65 '';
66in
67
68stdenv.mkDerivation (finalAttrs: {
69 pname = "ibus";
70 version = "1.5.32";
71
72 src = fetchFromGitHub {
73 owner = "ibus";
74 repo = "ibus";
75 tag = finalAttrs.version;
76 hash = "sha256-Rp2Aw2C2LXMBp8++pnZtPHiPoFDERpkDsKd0E//twuY=";
77 };
78
79 patches = [
80 (replaceVars ./fix-paths.patch {
81 pythonInterpreter = python3Runtime.interpreter;
82 pythonSitePackages = python3.sitePackages;
83 # patch context
84 prefix = null;
85 datarootdir = null;
86 localedir = null;
87 # removed line only
88 PYTHON = null;
89 })
90 ./build-without-dbus-launch.patch
91 ];
92
93 outputs = [
94 "out"
95 "dev"
96 ]
97 ++ lib.optionals (!libOnly) [
98 "installedTests"
99 ];
100
101 postPatch = ''
102 # Maintainer does not want to create separate tarballs for final release candidate and release versions,
103 # so we need to set `ibus_released` to `1` in `configure.ac`. Otherwise, anyone running `ibus version` gets
104 # a version with an inaccurate `-rcX` suffix.
105 # https://github.com/ibus/ibus/issues/2584
106 substituteInPlace configure.ac --replace "m4_define([ibus_released], [0])" "m4_define([ibus_released], [1])"
107
108 patchShebangs --build data/dconf/make-dconf-override-db.sh
109 cp ${buildPackages.gtk-doc}/share/gtk-doc/data/gtk-doc.make .
110 substituteInPlace bus/services/org.freedesktop.IBus.session.GNOME.service.in --replace "ExecStart=sh" "ExecStart=${runtimeShell}"
111 substituteInPlace bus/services/org.freedesktop.IBus.session.generic.service.in --replace "ExecStart=sh" "ExecStart=${runtimeShell}"
112 '';
113
114 preAutoreconf = "touch ChangeLog";
115
116 configureFlags = [
117 # The `AX_PROG_{CC,CXX}_FOR_BUILD` autoconf macros can pick up unwrapped GCC binaries,
118 # so we set `{CC,CXX}_FOR_BUILD` to override that behavior.
119 # https://github.com/NixOS/nixpkgs/issues/21751
120 "CC_FOR_BUILD=${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}cc"
121 "CXX_FOR_BUILD=${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}c++"
122 "GLIB_COMPILE_RESOURCES=${lib.getDev buildPackages.glib}/bin/glib-compile-resources"
123 "PKG_CONFIG_VAPIGEN_VAPIGEN=${lib.getBin buildPackages.vala}/bin/vapigen"
124 "--disable-memconf"
125 "--disable-gtk2"
126 "--with-python=${python3BuildEnv.interpreter}"
127 (lib.enableFeature (!libOnly && dconf != null) "dconf")
128 (lib.enableFeature (!libOnly && libnotify != null) "libnotify")
129 (lib.enableFeature withWayland "wayland")
130 (lib.enableFeature enableUI "ui")
131 (lib.enableFeature (!libOnly) "gtk3")
132 (lib.enableFeature (!libOnly) "gtk4")
133 (lib.enableFeature (!libOnly) "xim")
134 (lib.enableFeature (!libOnly) "appindicator")
135 (lib.enableFeature (!libOnly) "tests")
136 (lib.enableFeature (!libOnly) "install-tests")
137 (lib.enableFeature (!libOnly) "emoji-dict")
138 (lib.enableFeature (!libOnly) "unicode-dict")
139 ]
140 ++ lib.optionals (!libOnly) [
141 "--with-unicode-emoji-dir=${unicode-emoji}/share/unicode/emoji"
142 "--with-emoji-annotation-dir=${cldr-annotations}/share/unicode/cldr/common/annotations"
143 "--with-ucd-dir=${unicode-character-database}/share/unicode"
144 ];
145
146 makeFlags = lib.optionals (!libOnly) [
147 "test_execsdir=${placeholder "installedTests"}/libexec/installed-tests/ibus"
148 "test_sourcesdir=${placeholder "installedTests"}/share/installed-tests/ibus"
149 ];
150
151 depsBuildBuild = [
152 pkg-config
153 ];
154
155 nativeBuildInputs = [
156 autoreconfHook
157 gtk-doc
158 gettext
159 makeWrapper
160 pkg-config
161 python3BuildEnv
162 dbus-launch
163 glib # required to satisfy AM_PATH_GLIB_2_0
164 vala
165 gobject-introspection
166 ]
167 ++ lib.optionals (!libOnly) [
168 wrapGAppsHook3
169 ]
170 ++ lib.optionals withWayland [
171 wayland-scanner
172 ];
173
174 propagatedBuildInputs = [
175 glib
176 ];
177
178 buildInputs = [
179 dbus
180 systemd
181 dconf
182 python3.pkgs.pygobject3 # for pygobject overrides
183 isocodes
184 json-glib
185 libX11
186 vala # for share/vala/Makefile.vapigen (PKG_CONFIG_VAPIGEN_VAPIGEN)
187 ]
188 ++ lib.optionals (!libOnly) [
189 gtk3
190 gtk4
191 gdk-pixbuf
192 libdbusmenu-gtk3
193 libnotify
194 ]
195 ++ lib.optionals withWayland [
196 libxkbcommon
197 wayland
198 wayland-protocols
199 wayland-scanner # For cross, build uses $PKG_CONFIG to look for wayland-scanner
200 ];
201
202 enableParallelBuilding = true;
203 strictDeps = true;
204
205 doCheck = false; # requires X11 daemon
206
207 doInstallCheck = true;
208 nativeInstallCheckInputs = [ versionCheckHook ];
209 versionCheckProgramArg = "version";
210 versionCheckProgram = "${placeholder "out"}/bin/ibus";
211
212 postInstall = lib.optionalString (!libOnly) ''
213 # It has some hardcoded FHS paths and also we do not use it
214 # since we set up the environment in NixOS tests anyway.
215 moveToOutput "bin/ibus-desktop-testing-runner" "$installedTests"
216 '';
217
218 postFixup = lib.optionalString (!libOnly) ''
219 # set necessary environment also for tests
220 for f in $installedTests/libexec/installed-tests/ibus/*; do
221 wrapGApp $f
222 done
223 '';
224
225 passthru = {
226 tests = lib.optionalAttrs (!libOnly) {
227 installed-tests = nixosTests.installed-tests.ibus;
228 };
229 updateScript = nix-update-script { };
230 };
231
232 meta = {
233 changelog = "https://github.com/ibus/ibus/releases/tag/${finalAttrs.src.tag}";
234 homepage = "https://github.com/ibus/ibus";
235 description = "Intelligent Input Bus, input method framework";
236 license = lib.licenses.lgpl21Plus;
237 platforms = lib.platforms.linux;
238 mainProgram = "ibus";
239 maintainers = with lib.maintainers; [ ttuegel ];
240 };
241})