nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
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 ? true,
31 withWayland ? true,
32 libxkbcommon,
33 wayland,
34 buildPackages,
35 runtimeShell,
36 nixosTests,
37}:
38
39let
40 python3Runtime = python3.withPackages (ps: with ps; [ pygobject3 ]);
41 python3BuildEnv = python3.pythonOnBuildForHost.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 =
52 runCommand "sandbox-dbus-launch"
53 {
54 nativeBuildInputs = [ makeWrapper ];
55 }
56 ''
57 makeWrapper ${dbus}/bin/dbus-launch $out/bin/dbus-launch \
58 --add-flags --config-file=${dbus}/share/dbus-1/session.conf
59 '';
60in
61
62stdenv.mkDerivation rec {
63 pname = "ibus";
64 version = "1.5.31";
65
66 src = fetchFromGitHub {
67 owner = "ibus";
68 repo = "ibus";
69 rev = version;
70 sha256 = "sha256-YMCtLIK/9iUdS37Oiow7WMhFFPKhomNXvzWbLzlUkdQ=";
71 };
72
73 patches = [
74 (replaceVars ./fix-paths.patch {
75 pythonInterpreter = python3Runtime.interpreter;
76 pythonSitePackages = python3.sitePackages;
77 # patch context
78 prefix = null;
79 datarootdir = null;
80 localedir = null;
81 # removed line only
82 PYTHON = null;
83 })
84 ./build-without-dbus-launch.patch
85 ];
86
87 outputs = [
88 "out"
89 "dev"
90 "installedTests"
91 ];
92
93 postPatch = ''
94 # Maintainer does not want to create separate tarballs for final release candidate and release versions,
95 # so we need to set `ibus_released` to `1` in `configure.ac`. Otherwise, anyone running `ibus version` gets
96 # a version with an inaccurate `-rcX` suffix.
97 # https://github.com/ibus/ibus/issues/2584
98 substituteInPlace configure.ac --replace "m4_define([ibus_released], [0])" "m4_define([ibus_released], [1])"
99
100 patchShebangs --build data/dconf/make-dconf-override-db.sh
101 cp ${buildPackages.gtk-doc}/share/gtk-doc/data/gtk-doc.make .
102 substituteInPlace bus/services/org.freedesktop.IBus.session.GNOME.service.in --replace "ExecStart=sh" "ExecStart=${runtimeShell}"
103 substituteInPlace bus/services/org.freedesktop.IBus.session.generic.service.in --replace "ExecStart=sh" "ExecStart=${runtimeShell}"
104 '';
105
106 preAutoreconf = "touch ChangeLog";
107
108 configureFlags = [
109 # The `AX_PROG_{CC,CXX}_FOR_BUILD` autoconf macros can pick up unwrapped GCC binaries,
110 # so we set `{CC,CXX}_FOR_BUILD` to override that behavior.
111 # https://github.com/NixOS/nixpkgs/issues/21751
112 "CC_FOR_BUILD=${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}cc"
113 "CXX_FOR_BUILD=${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}c++"
114 "GLIB_COMPILE_RESOURCES=${lib.getDev buildPackages.glib}/bin/glib-compile-resources"
115 "PKG_CONFIG_VAPIGEN_VAPIGEN=${lib.getBin buildPackages.vala}/bin/vapigen"
116 "--disable-memconf"
117 (lib.enableFeature (dconf != null) "dconf")
118 (lib.enableFeature (libnotify != null) "libnotify")
119 (lib.enableFeature withWayland "wayland")
120 (lib.enableFeature enableUI "ui")
121 "--disable-gtk2"
122 "--enable-gtk4"
123 "--enable-install-tests"
124 "--with-unicode-emoji-dir=${unicode-emoji}/share/unicode/emoji"
125 "--with-emoji-annotation-dir=${cldr-annotations}/share/unicode/cldr/common/annotations"
126 "--with-python=${python3BuildEnv.interpreter}"
127 "--with-ucd-dir=${unicode-character-database}/share/unicode"
128 ];
129
130 makeFlags = [
131 "test_execsdir=${placeholder "installedTests"}/libexec/installed-tests/ibus"
132 "test_sourcesdir=${placeholder "installedTests"}/share/installed-tests/ibus"
133 ];
134
135 depsBuildBuild = [
136 pkg-config
137 ];
138
139 nativeBuildInputs = [
140 autoreconfHook
141 gtk-doc
142 gettext
143 makeWrapper
144 pkg-config
145 python3BuildEnv
146 vala
147 wrapGAppsHook3
148 dbus-launch
149 gobject-introspection
150 ];
151
152 propagatedBuildInputs = [
153 glib
154 ];
155
156 buildInputs =
157 [
158 dbus
159 systemd
160 dconf
161 gdk-pixbuf
162 python3.pkgs.pygobject3 # for pygobject overrides
163 gtk3
164 gtk4
165 isocodes
166 json-glib
167 libnotify
168 libdbusmenu-gtk3
169 vala # for share/vala/Makefile.vapigen (PKG_CONFIG_VAPIGEN_VAPIGEN)
170 ]
171 ++ lib.optionals withWayland [
172 libxkbcommon
173 wayland
174 ];
175
176 enableParallelBuilding = true;
177
178 doCheck = false; # requires X11 daemon
179 doInstallCheck = true;
180 installCheckPhase = ''
181 $out/bin/ibus version
182 '';
183
184 postInstall = ''
185 # It has some hardcoded FHS paths and also we do not use it
186 # since we set up the environment in NixOS tests anyway.
187 moveToOutput "bin/ibus-desktop-testing-runner" "$installedTests"
188 '';
189
190 postFixup = ''
191 # set necessary environment also for tests
192 for f in $installedTests/libexec/installed-tests/ibus/*; do
193 wrapGApp $f
194 done
195 '';
196
197 passthru = {
198 tests = {
199 installed-tests = nixosTests.installed-tests.ibus;
200 };
201 };
202
203 meta = with lib; {
204 homepage = "https://github.com/ibus/ibus";
205 description = "Intelligent Input Bus, input method framework";
206 license = licenses.lgpl21Plus;
207 platforms = platforms.linux;
208 maintainers = with maintainers; [ ttuegel ];
209 };
210}