summary refs log tree commit diff
diff options
context:
space:
mode:
authorJan Tojnar <jtojnar@gmail.com>2018-09-19 23:43:56 +0200
committerGitHub <noreply@github.com>2018-09-19 23:43:56 +0200
commit82cc6a7510d932542eae1b8e17846f98fd24e12c (patch)
tree71b4e871e9b1b7298c61ad2f4ab6ebb921bfcf6f
parenta0c5dd8a09215e47a67122005a0525febdee8d72 (diff)
parentdee2dab7c6a84c7615e81d20aec5e12ed3b0ae1b (diff)
downloadnixlib-82cc6a7510d932542eae1b8e17846f98fd24e12c.tar
nixlib-82cc6a7510d932542eae1b8e17846f98fd24e12c.tar.gz
nixlib-82cc6a7510d932542eae1b8e17846f98fd24e12c.tar.bz2
nixlib-82cc6a7510d932542eae1b8e17846f98fd24e12c.tar.lz
nixlib-82cc6a7510d932542eae1b8e17846f98fd24e12c.tar.xz
nixlib-82cc6a7510d932542eae1b8e17846f98fd24e12c.tar.zst
nixlib-82cc6a7510d932542eae1b8e17846f98fd24e12c.zip
Merge pull request #46779 from Ma27/package-ibus-typing-booster
ibus-typing-booster: init at 2.1.1
-rw-r--r--doc/package-notes.xml60
-rw-r--r--pkgs/tools/inputmethods/ibus-engines/ibus-typing-booster/default.nix41
-rw-r--r--pkgs/tools/inputmethods/ibus-engines/ibus-typing-booster/hunspell-dirs.patch31
-rw-r--r--pkgs/tools/inputmethods/ibus-engines/ibus-typing-booster/wrapper.nix30
-rw-r--r--pkgs/top-level/all-packages.nix6
5 files changed, 168 insertions, 0 deletions
diff --git a/doc/package-notes.xml b/doc/package-notes.xml
index 1f088e8aaa0e..05e820bcabe5 100644
--- a/doc/package-notes.xml
+++ b/doc/package-notes.xml
@@ -814,4 +814,64 @@ citrix_receiver.override {
    </para>
   </section>
  </section>
+ <section xml:id="sec-ibus-typing-booster">
+  <title>ibus-engines.typing-booster</title>
+
+  <para>This package is an ibus-based completion method to speed up typing.</para>
+
+  <section xml:id="sec-ibus-typing-booster-activate">
+   <title>Activating the engine</title>
+
+   <para>
+    IBus needs to be configured accordingly to activate <literal>typing-booster</literal>. The configuration
+    depends on the desktop manager in use. For detailed instructions, please refer to the
+    <link xlink:href="https://mike-fabian.github.io/ibus-typing-booster/documentation.html">upstream docs</link>.
+   </para>
+   <para>
+    On NixOS you need to explicitly enable <literal>ibus</literal> with given engines
+    before customizing your desktop to use <literal>typing-booster</literal>. This can be achieved
+    using the <literal>ibus</literal> module:
+<programlisting>{ pkgs, ... }: {
+  i18n.inputMethod = {
+    enabled = "ibus";
+    ibus.engines = with pkgs.ibus-engines; [ typing-booster ];
+  };
+}</programlisting>
+   </para>
+  </section>
+
+  <section xml:id="sec-ibus-typing-booster-customize-hunspell">
+   <title>Using custom hunspell dictionaries</title>
+
+   <para>
+    The IBus engine is based on <literal>hunspell</literal> to support completion in many languages.
+    By default the dictionaries <literal>de-de</literal>, <literal>en-us</literal>, <literal>es-es</literal>,
+    <literal>it-it</literal>, <literal>sv-se</literal> and <literal>sv-fi</literal>
+    are in use. To add another dictionary, the package can be overridden like this:
+<programlisting>ibus-engines.typing-booster.override {
+  langs = [ "de-at" "en-gb" ];
+}</programlisting>
+   </para>
+   <para>
+     <emphasis>Note: each language passed to <literal>langs</literal> must be an attribute name in
+     <literal>pkgs.hunspellDicts</literal>.</emphasis>
+   </para>
+  </section>
+
+  <section xml:id="sec-ibus-typing-booster-emoji-picker">
+   <title>Built-in emoji picker</title>
+
+   <para>
+    The <literal>ibus-engines.typing-booster</literal> package contains a program
+    named <literal>emoji-picker</literal>. To display all emojis correctly,
+    a special font such as <literal>noto-fonts-emoji</literal> is needed:
+   </para>
+   <para>
+    On NixOS it can be installed using the following expression:
+<programlisting>{ pkgs, ... }: {
+  fonts.fonts = with pkgs; [ noto-fonts-emoji ];
+}</programlisting>
+   </para>
+  </section>
+ </section>
 </chapter>
diff --git a/pkgs/tools/inputmethods/ibus-engines/ibus-typing-booster/default.nix b/pkgs/tools/inputmethods/ibus-engines/ibus-typing-booster/default.nix
new file mode 100644
index 000000000000..c5aaa032b40e
--- /dev/null
+++ b/pkgs/tools/inputmethods/ibus-engines/ibus-typing-booster/default.nix
@@ -0,0 +1,41 @@
+{ stdenv, fetchFromGitHub, autoreconfHook, python3, ibus, pkgconfig, gtk3, m17n_lib
+, wrapGAppsHook, gobjectIntrospection
+}:
+
+let
+
+  python = python3.withPackages (ps: with ps; [
+    pygobject3
+    dbus-python
+  ]);
+
+in
+
+stdenv.mkDerivation rec {
+  name = "ibus-typing-booster-${version}";
+  version = "2.1.1";
+
+  src = fetchFromGitHub {
+    owner = "mike-fabian";
+    repo = "ibus-typing-booster";
+    rev = version;
+    sha256 = "01kpxplk9nh56f32fkq3nnsqykbzpi7pcxbfp38dq0prgrhw9a6b";
+  };
+
+  patches = [ ./hunspell-dirs.patch ];
+
+  nativeBuildInputs = [ autoreconfHook pkgconfig wrapGAppsHook gobjectIntrospection ];
+  buildInputs = [ python ibus gtk3 m17n_lib ];
+
+  preFixup = ''
+    gappsWrapperArgs+=(--prefix LD_LIBRARY_PATH : "${m17n_lib}/lib")
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://mike-fabian.github.io/ibus-typing-booster/;
+    license = licenses.gpl3Plus;
+    description = "A typing booster engine for the IBus platform";
+    maintainers = with maintainers; [ ma27 ];
+    isIbusEngine = true;
+  };
+}
diff --git a/pkgs/tools/inputmethods/ibus-engines/ibus-typing-booster/hunspell-dirs.patch b/pkgs/tools/inputmethods/ibus-engines/ibus-typing-booster/hunspell-dirs.patch
new file mode 100644
index 000000000000..7b624b379a26
--- /dev/null
+++ b/pkgs/tools/inputmethods/ibus-engines/ibus-typing-booster/hunspell-dirs.patch
@@ -0,0 +1,31 @@
+diff --git a/engine/itb_util.py b/engine/itb_util.py
+index ded236a..633525a 100755
+--- a/engine/itb_util.py
++++ b/engine/itb_util.py
+@@ -1876,14 +1876,18 @@ def find_hunspell_dictionary(language):
+             If no dictionary can be found for the requested language,
+             the return value is ('', '').
+     '''
+-    dirnames = [
+-        '/usr/share/hunspell',
+-        '/usr/share/myspell',
+-        '/usr/share/myspell/dicts',
+-        '/usr/local/share/hunspell', # On FreeBSD the dictionaries are here
+-        '/usr/local/share/myspell',
+-        '/usr/local/share/myspell/dicts',
+-    ]
++
++    if "NIX_HUNSPELL_DIRS" in os.environ:
++        dirnames = os.environ["NIX_HUNSPELL_DIRS"].split(":")
++    else:       # fallback to the original behavior
++        dirnames = [
++            '/usr/share/hunspell',
++            '/usr/share/myspell',
++            '/usr/share/myspell/dicts',
++            '/usr/local/share/hunspell', # On FreeBSD the dictionaries are here
++            '/usr/local/share/myspell',
++            '/usr/local/share/myspell/dicts',
++        ]
+     dic_path = ''
+     aff_path = ''
+     for language in expand_languages([language]):
diff --git a/pkgs/tools/inputmethods/ibus-engines/ibus-typing-booster/wrapper.nix b/pkgs/tools/inputmethods/ibus-engines/ibus-typing-booster/wrapper.nix
new file mode 100644
index 000000000000..e6505f3cc468
--- /dev/null
+++ b/pkgs/tools/inputmethods/ibus-engines/ibus-typing-booster/wrapper.nix
@@ -0,0 +1,30 @@
+{ typing-booster, symlinkJoin, hunspellDicts, lib, makeWrapper
+, langs ? [ "de-de" "en-us" "es-es" "it-it" "sv-se" "sv-fi" ]
+}:
+
+let
+
+  hunspellDirs = with lib; makeSearchPath ":" (flatten (flip map langs (lang: [
+    "${hunspellDicts.${lang}}/share/hunspell"
+    "${hunspellDicts.${lang}}/share/myspell"
+    "${hunspellDicts.${lang}}/share/myspell/dicts"
+  ])));
+
+in
+
+symlinkJoin {
+  name = "${typing-booster.name}-with-hunspell";
+  paths = [ typing-booster ];
+  nativeBuildInputs = [ makeWrapper ];
+
+  postBuild = ''
+    for i in bin/emoji-picker libexec/ibus-{setup,engine}-typing-booster; do
+      wrapProgram "$out/$i" \
+        --prefix NIX_HUNSPELL_DIRS : ${hunspellDirs}
+    done
+
+    sed -i -e "s,${typing-booster},$out," $out/share/ibus/component/typing-booster.xml
+  '';
+
+  inherit (typing-booster) meta;
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 525b2eeb951a..814c5e9d6073 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -1910,6 +1910,12 @@ with pkgs;
     };
 
     uniemoji = callPackage ../tools/inputmethods/ibus-engines/ibus-uniemoji { };
+
+    typing-booster-unwrapped = callPackage ../tools/inputmethods/ibus-engines/ibus-typing-booster { };
+
+    typing-booster = callPackage ../tools/inputmethods/ibus-engines/ibus-typing-booster/wrapper.nix {
+      typing-booster = ibus-engines.typing-booster-unwrapped;
+    };
   };
 
   ibus-with-plugins = callPackage ../tools/inputmethods/ibus/wrapper.nix {