1{ lib, stdenv
2, substituteAll
3, fetchFromGitHub
4, fetchpatch
5, autoreconfHook
6, gettext
7, makeWrapper
8, pkg-config
9, vala
10, wrapGAppsHook
11, dbus
12, systemd
13, dconf ? null
14, glib
15, gdk-pixbuf
16, gobject-introspection
17, gtk2
18, gtk3
19, gtk4
20, gtk-doc
21, runCommand
22, isocodes
23, cldr-annotations
24, unicode-character-database
25, unicode-emoji
26, python3
27, json-glib
28, libnotify ? null
29, enableUI ? true
30, withWayland ? false
31, libxkbcommon
32, wayland
33, buildPackages
34, runtimeShell
35, nixosTests
36}:
37
38let
39 python3Runtime = python3.withPackages (ps: with ps; [ pygobject3 ]);
40 python3BuildEnv = python3.buildEnv.override {
41 # ImportError: No module named site
42 postBuild = ''
43 makeWrapper ${glib.dev}/bin/gdbus-codegen $out/bin/gdbus-codegen --unset PYTHONPATH
44 makeWrapper ${glib.dev}/bin/glib-genmarshal $out/bin/glib-genmarshal --unset PYTHONPATH
45 makeWrapper ${glib.dev}/bin/glib-mkenums $out/bin/glib-mkenums --unset PYTHONPATH
46 '';
47 };
48 # make-dconf-override-db.sh needs to execute dbus-launch in the sandbox,
49 # it will fail to read /etc/dbus-1/session.conf unless we add this flag
50 dbus-launch = runCommand "sandbox-dbus-launch" {
51 nativeBuildInputs = [ makeWrapper ];
52 } ''
53 makeWrapper ${dbus}/bin/dbus-launch $out/bin/dbus-launch \
54 --add-flags --config-file=${dbus}/share/dbus-1/session.conf
55 '';
56in
57
58stdenv.mkDerivation rec {
59 pname = "ibus";
60 version = "1.5.28";
61
62 src = fetchFromGitHub {
63 owner = "ibus";
64 repo = "ibus";
65 rev = version;
66 sha256 = "sha256-zjV+QkhVkrHFs9Vt1FpbvmS4nRHxwKaKU3mQkSgyLaQ=";
67 };
68
69 patches = [
70 (substituteAll {
71 src = ./fix-paths.patch;
72 pythonInterpreter = python3Runtime.interpreter;
73 pythonSitePackages = python3.sitePackages;
74 })
75 ./build-without-dbus-launch.patch
76 # unicode and emoji input are broken before 1.5.29
77 # https://github.com/NixOS/nixpkgs/issues/226526
78 (fetchpatch {
79 url = "https://github.com/ibus/ibus/commit/7c8abbe89403c2fcb08e3fda42049a97187e53ab.patch";
80 hash = "sha256-59HzAdLq8ahrF7K+tFGLjTodwIiTkJGEkFe8quqIkhU=";
81 })
82 ];
83
84 outputs = [ "out" "dev" "installedTests" ];
85
86 postPatch = ''
87 patchShebangs --build data/dconf/make-dconf-override-db.sh
88 cp ${buildPackages.gtk-doc}/share/gtk-doc/data/gtk-doc.make .
89 substituteInPlace bus/services/org.freedesktop.IBus.session.GNOME.service.in --replace "ExecStart=sh" "ExecStart=${runtimeShell}"
90 substituteInPlace bus/services/org.freedesktop.IBus.session.generic.service.in --replace "ExecStart=sh" "ExecStart=${runtimeShell}"
91 '';
92
93 preAutoreconf = "touch ChangeLog";
94
95 configureFlags = [
96 "--disable-memconf"
97 (lib.enableFeature (dconf != null) "dconf")
98 (lib.enableFeature (libnotify != null) "libnotify")
99 (lib.enableFeature withWayland "wayland")
100 (lib.enableFeature enableUI "ui")
101 "--enable-gtk4"
102 "--enable-install-tests"
103 "--with-unicode-emoji-dir=${unicode-emoji}/share/unicode/emoji"
104 "--with-emoji-annotation-dir=${cldr-annotations}/share/unicode/cldr/common/annotations"
105 "--with-ucd-dir=${unicode-character-database}/share/unicode"
106 ];
107
108 # missing make dependency
109 # https://github.com/NixOS/nixpkgs/pull/218120#issuecomment-1514027173
110 preBuild = ''
111 make -C src ibusenumtypes.h
112 '';
113
114 makeFlags = [
115 "test_execsdir=${placeholder "installedTests"}/libexec/installed-tests/ibus"
116 "test_sourcesdir=${placeholder "installedTests"}/share/installed-tests/ibus"
117 ];
118
119 nativeBuildInputs = [
120 autoreconfHook
121 gtk-doc
122 gettext
123 makeWrapper
124 pkg-config
125 python3BuildEnv
126 vala
127 wrapGAppsHook
128 dbus-launch
129 ];
130
131 propagatedBuildInputs = [
132 glib
133 ];
134
135 buildInputs = [
136 dbus
137 systemd
138 dconf
139 gdk-pixbuf
140 gobject-introspection
141 python3.pkgs.pygobject3 # for pygobject overrides
142 gtk2
143 gtk3
144 gtk4
145 isocodes
146 json-glib
147 libnotify
148 ] ++ lib.optionals withWayland [
149 libxkbcommon
150 wayland
151 ];
152
153 enableParallelBuilding = true;
154
155 doCheck = false; # requires X11 daemon
156 doInstallCheck = true;
157 installCheckPhase = ''
158 $out/bin/ibus version
159 '';
160
161 postInstall = ''
162 # It has some hardcoded FHS paths and also we do not use it
163 # since we set up the environment in NixOS tests anyway.
164 moveToOutput "bin/ibus-desktop-testing-runner" "$installedTests"
165 '';
166
167 postFixup = ''
168 # set necessary environment also for tests
169 for f in $installedTests/libexec/installed-tests/ibus/*; do
170 wrapGApp $f
171 done
172 '';
173
174 passthru = {
175 tests = {
176 installed-tests = nixosTests.installed-tests.ibus;
177 };
178 };
179
180 meta = with lib; {
181 homepage = "https://github.com/ibus/ibus";
182 description = "Intelligent Input Bus, input method framework";
183 license = licenses.lgpl21Plus;
184 platforms = platforms.linux;
185 maintainers = with maintainers; [ ttuegel yana ];
186 };
187}