nixpkgs/pkgs/tools/inputmethods/ibus/wrapper.nix
Silvan Mosberger 4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00

117 lines
3.8 KiB
Nix

{
lib,
buildEnv,
makeWrapper,
dconf,
hicolor-icon-theme,
ibus,
librsvg,
plugins ? [ ],
}:
buildEnv {
name = "ibus-with-plugins-" + lib.getVersion ibus;
paths = [ ibus ] ++ plugins;
pathsToLink = [
"/bin"
"/etc"
"/lib"
"/libexec"
"/share"
# Need to link contents so that the directories are writeable.
"/lib/systemd"
"/share/dbus-1/services"
"/share/systemd/user"
"/share/systemd/user/gnome-session.target.wants"
];
nativeBuildInputs = [
makeWrapper
];
buildInputs = [ ibus ] ++ plugins;
postBuild = ''
for prog in ibus; do
wrapProgram "$out/bin/$prog" \
--set GDK_PIXBUF_MODULE_FILE ${librsvg.out}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache \
--prefix GI_TYPELIB_PATH : "$GI_TYPELIB_PATH:$out/lib/girepository-1.0" \
--prefix GIO_EXTRA_MODULES : "${lib.getLib dconf}/lib/gio/modules" \
--set IBUS_COMPONENT_PATH "$out/share/ibus/component/" \
--set IBUS_DATAROOTDIR "$out/share" \
--set IBUS_LIBEXECDIR "$out/libexec" \
--set IBUS_LOCALEDIR "$out/share/locale" \
--set IBUS_PREFIX "$out" \
--set IBUS_TABLE_BIN_PATH "$out/bin" \
--set IBUS_TABLE_DATA_DIR "$out/share" \
--set IBUS_TABLE_LIB_LOCATION "$out/libexec" \
--set IBUS_TABLE_LOCATION "$out/share/ibus-table" \
--prefix PYTHONPATH : "$PYTHONPATH" \
--prefix XDG_DATA_DIRS : "$out/share:$GSETTINGS_SCHEMAS_PATH" \
--suffix XDG_DATA_DIRS : "${hicolor-icon-theme}/share"
done
for prog in ibus-daemon; do
wrapProgram "$out/bin/$prog" \
--set GDK_PIXBUF_MODULE_FILE ${librsvg.out}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache \
--prefix GI_TYPELIB_PATH : "$GI_TYPELIB_PATH:$out/lib/girepository-1.0" \
--prefix GIO_EXTRA_MODULES : "${lib.getLib dconf}/lib/gio/modules" \
--set IBUS_COMPONENT_PATH "$out/share/ibus/component/" \
--set IBUS_DATAROOTDIR "$out/share" \
--set IBUS_LIBEXECDIR "$out/libexec" \
--set IBUS_LOCALEDIR "$out/share/locale" \
--set IBUS_PREFIX "$out" \
--set IBUS_TABLE_BIN_PATH "$out/bin" \
--set IBUS_TABLE_DATA_DIR "$out/share" \
--set IBUS_TABLE_LIB_LOCATION "$out/libexec" \
--set IBUS_TABLE_LOCATION "$out/share/ibus-table" \
--prefix PYTHONPATH : "$PYTHONPATH" \
--prefix XDG_DATA_DIRS : "$out/share:$GSETTINGS_SCHEMAS_PATH" \
--suffix XDG_DATA_DIRS : "${hicolor-icon-theme}/share" \
--add-flags "--cache=refresh"
done
ibusPackage="${ibus}"
# Update services.
for service in \
"share/dbus-1/services/org.freedesktop.IBus.service" \
"share/systemd/user/org.freedesktop.IBus.session.generic.service" \
"share/systemd/user/org.freedesktop.IBus.session.GNOME.service"
do
unlink "$out/$service"
substitute "$ibusPackage/$service" "$out/$service" --replace "$ibusPackage/bin" "$out/bin"
done
# Re-create relative symbolic links.
for link in \
"$out/share/systemd/user/gnome-session.target.wants/"*
do
target="$link"
until [[ "''${target:0:1}" != "/" ]]; do
target="$(readlink "$target")"
done
unlink "$link"
ln -s "$target" "$link"
done
# Update absolute symbolic links.
for link in \
"$out/lib/systemd/user"
do
target="$(readlink -f "$link")"
relativeTarget="''${target#$ibusPackage/}"
if [[ "$ibusPackage/$relativeTarget" != "$target" ]]; then
>&2 echo "File $link does not point to to a file in $ibusPackage"
exit 1
fi
unlink "$link"
ln -s "$out/$relativeTarget" "$link"
done
'';
inherit (ibus) meta;
}