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