at 16.09-beta 1.5 kB view raw
1{ config, pkgs, lib, ... }: 2 3with lib; 4 5let 6 cfg = config.i18n.inputMethod.ibus; 7 ibusPackage = pkgs.ibus-with-plugins.override { plugins = cfg.engines; }; 8 ibusEngine = types.package // { 9 name = "ibus-engine"; 10 check = x: (lib.types.package.check x) && (attrByPath ["meta" "isIbusEngine"] false x); 11 }; 12 13 ibusAutostart = pkgs.writeTextFile { 14 name = "autostart-ibus-daemon"; 15 destination = "/etc/xdg/autostart/ibus-daemon.desktop"; 16 text = '' 17 [Desktop Entry] 18 Name=IBus 19 Type=Application 20 Exec=${ibusPackage}/bin/ibus-daemon --daemonize --xim --cache=refresh 21 ''; 22 }; 23in 24{ 25 options = { 26 i18n.inputMethod.ibus = { 27 engines = mkOption { 28 type = with types; listOf ibusEngine; 29 default = []; 30 example = literalExample "with pkgs.ibus-engines; [ mozc hangul ]"; 31 description = 32 let 33 engines = 34 lib.concatStringsSep ", " 35 (map (name: "<literal>${name}</literal>") 36 (lib.attrNames pkgs.ibus-engines)); 37 in 38 "Enabled IBus engines. Available engines are: ${engines}."; 39 }; 40 }; 41 }; 42 43 config = mkIf (config.i18n.inputMethod.enabled == "ibus") { 44 i18n.inputMethod.package = ibusPackage; 45 46 # Without dconf enabled it is impossible to use IBus 47 environment.systemPackages = with pkgs; [ 48 ibus-qt gnome3.dconf ibusAutostart 49 ]; 50 51 environment.variables = { 52 GTK_IM_MODULE = "ibus"; 53 QT_IM_MODULE = "ibus"; 54 XMODIFIERS = "@im=ibus"; 55 }; 56 }; 57}