summary refs log tree commit diff
path: root/nixos/modules/i18n/input-method/ibus.nix
diff options
context:
space:
mode:
authorEric Sagnes <eric.sagnes@gmail.com>2016-04-12 19:46:12 +0900
committerEric Sagnes <eric.sagnes@gmail.com>2016-04-12 19:50:26 +0900
commite6ae05dd8ac9e42b1394701b65452e1e9cef6529 (patch)
tree5ec6ac166f5a68c2523ee6818058a281fc81b3ca /nixos/modules/i18n/input-method/ibus.nix
parentde78fe8f2d78a5ef20d0d355c5dbe9d21b4be22c (diff)
downloadnixpkgs-e6ae05dd8ac9e42b1394701b65452e1e9cef6529.tar
nixpkgs-e6ae05dd8ac9e42b1394701b65452e1e9cef6529.tar.gz
nixpkgs-e6ae05dd8ac9e42b1394701b65452e1e9cef6529.tar.bz2
nixpkgs-e6ae05dd8ac9e42b1394701b65452e1e9cef6529.tar.lz
nixpkgs-e6ae05dd8ac9e42b1394701b65452e1e9cef6529.tar.xz
nixpkgs-e6ae05dd8ac9e42b1394701b65452e1e9cef6529.tar.zst
nixpkgs-e6ae05dd8ac9e42b1394701b65452e1e9cef6529.zip
input-method module: fix folder case
Diffstat (limited to 'nixos/modules/i18n/input-method/ibus.nix')
-rw-r--r--nixos/modules/i18n/input-method/ibus.nix55
1 files changed, 55 insertions, 0 deletions
diff --git a/nixos/modules/i18n/input-method/ibus.nix b/nixos/modules/i18n/input-method/ibus.nix
new file mode 100644
index 00000000000..bb80f43634d
--- /dev/null
+++ b/nixos/modules/i18n/input-method/ibus.nix
@@ -0,0 +1,55 @@
+{ config, pkgs, lib, ... }:
+
+with lib;
+
+let
+  cfg = config.i18n.inputMethod.ibus;
+  ibusPackage = pkgs.ibus-with-plugins.override { plugins = cfg.engines; };
+  ibusEngine = types.package // {
+    name  = "ibus-engine";
+    check = x: (lib.types.package.check x) && (attrByPath ["meta" "isIbusEngine"] false x);
+  };
+
+  ibusAutostart = pkgs.writeTextFile {
+    name = "autostart-ibus-daemon";
+    destination = "/etc/xdg/autostart/ibus-daemon.desktop";
+    text = ''
+      [Desktop Entry]
+      Name=IBus
+      Type=Application
+      Exec=${ibusPackage}/bin/ibus-daemon --daemonize --xim --cache=refresh
+    '';
+  };
+in
+{
+  options = {
+    i18n.inputMethod.ibus = {
+      engines = mkOption {
+        type    = with types; listOf ibusEngine;
+        default = [];
+        example = literalExample "with pkgs.ibus-engines; [ mozc hangul ]";
+        description =
+          let
+            engines =
+              lib.concatStringsSep ", "
+              (map (name: "<literal>${name}</literal>")
+               (lib.attrNames pkgs.ibus-engines));
+          in
+            "Enabled IBus engines. Available engines are: ${engines}.";
+      };
+    };
+  };
+
+  config = mkIf (config.i18n.inputMethod.enabled == "ibus") {
+    # Without dconf enabled it is impossible to use IBus
+    environment.systemPackages = with pkgs; [
+      ibusPackage ibus-qt gnome3.dconf ibusAutostart
+    ];
+
+    environment.variables = {
+      GTK_IM_MODULE = "ibus";
+      QT_IM_MODULE = "ibus";
+      XMODIFIERS = "@im=ibus";
+    };
+  };
+}