about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/inputmethods/ibus
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/tools/inputmethods/ibus')
-rw-r--r--nixpkgs/pkgs/tools/inputmethods/ibus/build-without-dbus-launch.patch21
-rw-r--r--nixpkgs/pkgs/tools/inputmethods/ibus/default.nix196
-rw-r--r--nixpkgs/pkgs/tools/inputmethods/ibus/fix-paths.patch51
-rw-r--r--nixpkgs/pkgs/tools/inputmethods/ibus/wrapper.nix115
4 files changed, 383 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/tools/inputmethods/ibus/build-without-dbus-launch.patch b/nixpkgs/pkgs/tools/inputmethods/ibus/build-without-dbus-launch.patch
new file mode 100644
index 000000000000..cb587ccf47d8
--- /dev/null
+++ b/nixpkgs/pkgs/tools/inputmethods/ibus/build-without-dbus-launch.patch
@@ -0,0 +1,21 @@
+diff --git a/data/dconf/make-dconf-override-db.sh b/data/dconf/make-dconf-override-db.sh
+index 601c1c3f..fcb7305d 100755
+--- a/data/dconf/make-dconf-override-db.sh
++++ b/data/dconf/make-dconf-override-db.sh
+@@ -12,10 +12,6 @@ export XDG_CACHE_HOME="$TMPDIR/cache"
+ export GSETTINGS_SCHEMA_DIR="$TMPDIR/schemas"
+ mkdir -p $XDG_CONFIG_HOME $XDG_CACHE_HOME $GSETTINGS_SCHEMA_DIR
+ 
+-eval `dbus-launch --sh-syntax`
+-
+-trap 'rm -rf $TMPDIR; kill $DBUS_SESSION_BUS_PID' ERR
+-
+ # in case that schema is not installed on the system
+ glib-compile-schemas --targetdir "$GSETTINGS_SCHEMA_DIR" "$PWD"
+ 
+@@ -52,5 +48,3 @@ if [ -d $TMPDIR/cache/gvfs ] ; then
+     umount $TMPDIR/cache/gvfs
+ fi
+ rm -rf $TMPDIR
+-
+-kill $DBUS_SESSION_BUS_PID
diff --git a/nixpkgs/pkgs/tools/inputmethods/ibus/default.nix b/nixpkgs/pkgs/tools/inputmethods/ibus/default.nix
new file mode 100644
index 000000000000..417b1be605d5
--- /dev/null
+++ b/nixpkgs/pkgs/tools/inputmethods/ibus/default.nix
@@ -0,0 +1,196 @@
+{ lib, stdenv
+, substituteAll
+, fetchFromGitHub
+, fetchpatch
+, autoreconfHook
+, gettext
+, makeWrapper
+, pkg-config
+, vala
+, wrapGAppsHook
+, dbus
+, systemd
+, dconf ? null
+, glib
+, gdk-pixbuf
+, gobject-introspection
+, gtk3
+, gtk4
+, gtk-doc
+, runCommand
+, isocodes
+, cldr-annotations
+, unicode-character-database
+, unicode-emoji
+, python3
+, json-glib
+, libnotify ? null
+, enableUI ? true
+, withWayland ? false
+, libxkbcommon
+, wayland
+, buildPackages
+, runtimeShell
+, nixosTests
+}:
+
+let
+  python3Runtime = python3.withPackages (ps: with ps; [ pygobject3 ]);
+  python3BuildEnv = python3.buildEnv.override {
+    # ImportError: No module named site
+    postBuild = ''
+      makeWrapper ${glib.dev}/bin/gdbus-codegen $out/bin/gdbus-codegen --unset PYTHONPATH
+      makeWrapper ${glib.dev}/bin/glib-genmarshal $out/bin/glib-genmarshal --unset PYTHONPATH
+      makeWrapper ${glib.dev}/bin/glib-mkenums $out/bin/glib-mkenums --unset PYTHONPATH
+    '';
+  };
+  # make-dconf-override-db.sh needs to execute dbus-launch in the sandbox,
+  # it will fail to read /etc/dbus-1/session.conf unless we add this flag
+  dbus-launch = runCommand "sandbox-dbus-launch" {
+    nativeBuildInputs = [ makeWrapper ];
+  } ''
+      makeWrapper ${dbus}/bin/dbus-launch $out/bin/dbus-launch \
+        --add-flags --config-file=${dbus}/share/dbus-1/session.conf
+  '';
+in
+
+stdenv.mkDerivation rec {
+  pname = "ibus";
+  version = "1.5.28";
+
+  src = fetchFromGitHub {
+    owner = "ibus";
+    repo = "ibus";
+    rev = version;
+    sha256 = "sha256-zjV+QkhVkrHFs9Vt1FpbvmS4nRHxwKaKU3mQkSgyLaQ=";
+  };
+
+  patches = [
+    (substituteAll {
+      src = ./fix-paths.patch;
+      pythonInterpreter = python3Runtime.interpreter;
+      pythonSitePackages = python3.sitePackages;
+    })
+    ./build-without-dbus-launch.patch
+    # unicode and emoji input are broken before 1.5.29
+    # https://github.com/NixOS/nixpkgs/issues/226526
+    (fetchpatch {
+      url = "https://github.com/ibus/ibus/commit/7c8abbe89403c2fcb08e3fda42049a97187e53ab.patch";
+      hash = "sha256-59HzAdLq8ahrF7K+tFGLjTodwIiTkJGEkFe8quqIkhU=";
+    })
+    # fix SIGABRT in X11 https://github.com/ibus/ibus/issues/2484
+    (fetchpatch {
+      url = "https://github.com/ibus/ibus/commit/8f706d160631f1ffdbfa16543a38b9d5f91c16ad.patch";
+      hash = "sha256-YzS9TmUWW0OmheDeCeU00kFK2U2QEmKYMSRJAbu14ec=";
+    })
+    # fix missing key releases in Wine https://github.com/ibus/ibus/issues/2480
+    (fetchpatch {
+      url = "https://github.com/ibus/ibus/commit/497f0c74230a65309e22ce5569060ce48310406b.patch";
+      hash = "sha256-PAZcUxmzjChs1/K8hXgOcytyS4LYoNL1dtU6X5Tx8ic=";
+    })
+  ];
+
+  outputs = [ "out" "dev" "installedTests" ];
+
+  postPatch = ''
+    patchShebangs --build data/dconf/make-dconf-override-db.sh
+    cp ${buildPackages.gtk-doc}/share/gtk-doc/data/gtk-doc.make .
+    substituteInPlace bus/services/org.freedesktop.IBus.session.GNOME.service.in --replace "ExecStart=sh" "ExecStart=${runtimeShell}"
+    substituteInPlace bus/services/org.freedesktop.IBus.session.generic.service.in --replace "ExecStart=sh" "ExecStart=${runtimeShell}"
+  '';
+
+  preAutoreconf = "touch ChangeLog";
+
+  configureFlags = [
+    "--disable-memconf"
+    (lib.enableFeature (dconf != null) "dconf")
+    (lib.enableFeature (libnotify != null) "libnotify")
+    (lib.enableFeature withWayland "wayland")
+    (lib.enableFeature enableUI "ui")
+    "--disable-gtk2"
+    "--enable-gtk4"
+    "--enable-install-tests"
+    "--with-unicode-emoji-dir=${unicode-emoji}/share/unicode/emoji"
+    "--with-emoji-annotation-dir=${cldr-annotations}/share/unicode/cldr/common/annotations"
+    "--with-ucd-dir=${unicode-character-database}/share/unicode"
+  ];
+
+  # missing make dependency
+  # https://github.com/NixOS/nixpkgs/pull/218120#issuecomment-1514027173
+  preBuild = ''
+    make -C src ibusenumtypes.h
+  '';
+
+  makeFlags = [
+    "test_execsdir=${placeholder "installedTests"}/libexec/installed-tests/ibus"
+    "test_sourcesdir=${placeholder "installedTests"}/share/installed-tests/ibus"
+  ];
+
+  nativeBuildInputs = [
+    autoreconfHook
+    gtk-doc
+    gettext
+    makeWrapper
+    pkg-config
+    python3BuildEnv
+    vala
+    wrapGAppsHook
+    dbus-launch
+    gobject-introspection
+  ];
+
+  propagatedBuildInputs = [
+    glib
+  ];
+
+  buildInputs = [
+    dbus
+    systemd
+    dconf
+    gdk-pixbuf
+    python3.pkgs.pygobject3 # for pygobject overrides
+    gtk3
+    gtk4
+    isocodes
+    json-glib
+    libnotify
+  ] ++ lib.optionals withWayland [
+    libxkbcommon
+    wayland
+  ];
+
+  enableParallelBuilding = true;
+
+  doCheck = false; # requires X11 daemon
+  doInstallCheck = true;
+  installCheckPhase = ''
+    $out/bin/ibus version
+  '';
+
+  postInstall = ''
+    # It has some hardcoded FHS paths and also we do not use it
+    # since we set up the environment in NixOS tests anyway.
+    moveToOutput "bin/ibus-desktop-testing-runner" "$installedTests"
+  '';
+
+  postFixup = ''
+    # set necessary environment also for tests
+    for f in $installedTests/libexec/installed-tests/ibus/*; do
+        wrapGApp $f
+    done
+  '';
+
+  passthru = {
+    tests = {
+      installed-tests = nixosTests.installed-tests.ibus;
+    };
+  };
+
+  meta = with lib; {
+    homepage = "https://github.com/ibus/ibus";
+    description = "Intelligent Input Bus, input method framework";
+    license = licenses.lgpl21Plus;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ ttuegel yana ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/inputmethods/ibus/fix-paths.patch b/nixpkgs/pkgs/tools/inputmethods/ibus/fix-paths.patch
new file mode 100644
index 000000000000..340ec22130f0
--- /dev/null
+++ b/nixpkgs/pkgs/tools/inputmethods/ibus/fix-paths.patch
@@ -0,0 +1,51 @@
+diff --git a/configure.ac b/configure.ac
+index a3cdb2da..cade9466 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -469,11 +469,11 @@ PKG_CHECK_EXISTS([pygobject-3.0 >= $PYGOBJECT_REQUIRED],
+ if test "x$enable_pygobject" = "xyes"; then
+     PKG_CHECK_MODULES(PYTHON, [pygobject-3.0 >= $PYGOBJECT_REQUIRED])
+ 
+-    pyoverridesdir=`$PYTHON -c "import gi; print(gi._overridesdir)"`
++    pyoverridesdir="$prefix/@pythonSitePackages@/gi/overrides"
+     AC_SUBST(pyoverridesdir)
+ 
+     if test x"$enable_python2" = x"yes"; then
+-        py2overridesdir=`$PYTHON2 -c "import gi; print(gi._overridesdir)"`
++        py2overridesdir="$prefix/@pythonSitePackages@/gi/overrides"
+         AC_SUBST(py2overridesdir)
+     fi
+ fi
+@@ -502,7 +502,7 @@ if test x"$enable_python_library" = x"yes"; then
+     PYTHON2_VERSION=`$PYTHON2 -c "import sys; sys.stdout.write(sys.version[[:3]])"`
+     PYTHON2_LIBDIR="$PYTHON2_PREFIX/lib/python$PYTHON2_VERSION"
+     python2dir="$PYTHON2_LIBDIR/site-packages"
+-    pkgpython2dir="$python2dir/ibus"
++    pkgpython2dir="$prefix/@pythonSitePackages@/ibus"
+     AC_SUBST(pkgpython2dir)
+ else
+     enable_python_library="no (disabled, use --enable-python-library to enable)"
+diff --git a/data/dconf/Makefile.am b/data/dconf/Makefile.am
+index 5360f033..6d5e726f 100644
+--- a/data/dconf/Makefile.am
++++ b/data/dconf/Makefile.am
+@@ -50,7 +50,7 @@ man_5dir = $(mandir)/man5
+ 
+ install-data-hook:
+ 	if test -z "$(DESTDIR)"; then \
+-	    dconf update; \
++	    true; \
+ 	fi
+ 
+ EXTRA_DIST = \
+diff --git a/setup/ibus-setup.in b/setup/ibus-setup.in
+index 474ce8a8..ee30808e 100644
+--- a/setup/ibus-setup.in
++++ b/setup/ibus-setup.in
+@@ -27,5 +27,5 @@ export IBUS_PREFIX=@prefix@
+ export IBUS_DATAROOTDIR=@datarootdir@
+ export IBUS_LOCALEDIR=@localedir@
+ export IBUS_LIBEXECDIR=${libexecdir}
+-exec ${PYTHON:-@PYTHON@} @prefix@/share/ibus/setup/main.py "$@"
++exec @pythonInterpreter@ @prefix@/share/ibus/setup/main.py "$@"
+ 
diff --git a/nixpkgs/pkgs/tools/inputmethods/ibus/wrapper.nix b/nixpkgs/pkgs/tools/inputmethods/ibus/wrapper.nix
new file mode 100644
index 000000000000..c1328fbe984a
--- /dev/null
+++ b/nixpkgs/pkgs/tools/inputmethods/ibus/wrapper.nix
@@ -0,0 +1,115 @@
+{ 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;
+}