biome: 1.9.2 -> 1.9.3
[NixPkgs.git] / pkgs / tools / inputmethods / ibus / wrapper.nix
blobc1328fbe984a78863dec2fba0ee59d9d57d09b57
1 { lib
2 , buildEnv
3 , makeWrapper
4 , dconf
5 , hicolor-icon-theme
6 , ibus
7 , librsvg
8 , plugins ? [ ]
9 }:
11 buildEnv {
12   name = "ibus-with-plugins-" + lib.getVersion ibus;
14   paths = [ ibus ] ++ plugins;
16   pathsToLink = [
17     "/bin"
18     "/etc"
19     "/lib"
20     "/libexec"
21     "/share"
22     # Need to link contents so that the directories are writeable.
23     "/lib/systemd"
24     "/share/dbus-1/services"
25     "/share/systemd/user"
26     "/share/systemd/user/gnome-session.target.wants"
27   ];
29   nativeBuildInputs = [
30     makeWrapper
31   ];
33   buildInputs = [ ibus ] ++ plugins;
35   postBuild = ''
36     for prog in ibus; do
37         wrapProgram "$out/bin/$prog" \
38           --set GDK_PIXBUF_MODULE_FILE ${librsvg.out}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache \
39           --prefix GI_TYPELIB_PATH : "$GI_TYPELIB_PATH:$out/lib/girepository-1.0" \
40           --prefix GIO_EXTRA_MODULES : "${lib.getLib dconf}/lib/gio/modules" \
41           --set IBUS_COMPONENT_PATH "$out/share/ibus/component/" \
42           --set IBUS_DATAROOTDIR "$out/share" \
43           --set IBUS_LIBEXECDIR "$out/libexec" \
44           --set IBUS_LOCALEDIR "$out/share/locale" \
45           --set IBUS_PREFIX "$out" \
46           --set IBUS_TABLE_BIN_PATH "$out/bin" \
47           --set IBUS_TABLE_DATA_DIR "$out/share" \
48           --set IBUS_TABLE_LIB_LOCATION "$out/libexec" \
49           --set IBUS_TABLE_LOCATION "$out/share/ibus-table" \
50           --prefix PYTHONPATH : "$PYTHONPATH" \
51           --prefix XDG_DATA_DIRS : "$out/share:$GSETTINGS_SCHEMAS_PATH" \
52           --suffix XDG_DATA_DIRS : "${hicolor-icon-theme}/share"
53     done
55     for prog in ibus-daemon; do
56         wrapProgram "$out/bin/$prog" \
57           --set GDK_PIXBUF_MODULE_FILE ${librsvg.out}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache \
58           --prefix GI_TYPELIB_PATH : "$GI_TYPELIB_PATH:$out/lib/girepository-1.0" \
59           --prefix GIO_EXTRA_MODULES : "${lib.getLib dconf}/lib/gio/modules" \
60           --set IBUS_COMPONENT_PATH "$out/share/ibus/component/" \
61           --set IBUS_DATAROOTDIR "$out/share" \
62           --set IBUS_LIBEXECDIR "$out/libexec" \
63           --set IBUS_LOCALEDIR "$out/share/locale" \
64           --set IBUS_PREFIX "$out" \
65           --set IBUS_TABLE_BIN_PATH "$out/bin" \
66           --set IBUS_TABLE_DATA_DIR "$out/share" \
67           --set IBUS_TABLE_LIB_LOCATION "$out/libexec" \
68           --set IBUS_TABLE_LOCATION "$out/share/ibus-table" \
69           --prefix PYTHONPATH : "$PYTHONPATH" \
70           --prefix XDG_DATA_DIRS : "$out/share:$GSETTINGS_SCHEMAS_PATH" \
71           --suffix XDG_DATA_DIRS : "${hicolor-icon-theme}/share" \
72           --add-flags "--cache=refresh"
73     done
75     ibusPackage="${ibus}"
77     # Update services.
78     for service in \
79         "share/dbus-1/services/org.freedesktop.IBus.service" \
80         "share/systemd/user/org.freedesktop.IBus.session.generic.service" \
81         "share/systemd/user/org.freedesktop.IBus.session.GNOME.service"
82     do
83         unlink "$out/$service"
84         substitute "$ibusPackage/$service" "$out/$service" --replace "$ibusPackage/bin" "$out/bin"
85     done
87     # Re-create relative symbolic links.
88     for link in \
89         "$out/share/systemd/user/gnome-session.target.wants/"*
90     do
91         target="$link"
92         until [[ "''${target:0:1}" != "/" ]]; do
93             target="$(readlink "$target")"
94         done
95         unlink "$link"
96         ln -s "$target" "$link"
97     done
99     # Update absolute symbolic links.
100     for link in \
101         "$out/lib/systemd/user"
102     do
103         target="$(readlink -f "$link")"
104         relativeTarget="''${target#$ibusPackage/}"
105         if [[ "$ibusPackage/$relativeTarget" != "$target" ]]; then
106             >&2 echo "File $link does not point to to a file in $ibusPackage"
107             exit 1
108         fi
109         unlink "$link"
110         ln -s "$out/$relativeTarget" "$link"
111     done
112   '';
114   inherit (ibus) meta;