1 { config, pkgs, lib, ... }:
6 imcfg = config.i18n.inputMethod;
8 ibusPackage = pkgs.ibus-with-plugins.override { plugins = cfg.engines; };
9 ibusEngine = lib.types.mkOptionType {
11 inherit (lib.types.package) descriptionClass merge;
12 check = x: (lib.types.package.check x) && (attrByPath ["meta" "isIbusEngine"] false x);
15 impanel = optionalString (cfg.panel != null) "--panel=${cfg.panel}";
17 ibusAutostart = pkgs.writeTextFile {
18 name = "autostart-ibus-daemon";
19 destination = "/etc/xdg/autostart/ibus-daemon.desktop";
24 Exec=${ibusPackage}/bin/ibus-daemon --daemonize --xim ${impanel}
25 # GNOME will launch ibus using systemd
32 (mkRenamedOptionModule [ "programs" "ibus" "plugins" ] [ "i18n" "inputMethod" "ibus" "engines" ])
36 i18n.inputMethod.ibus = {
38 type = with types; listOf ibusEngine;
40 example = literalExpression "with pkgs.ibus-engines; [ mozc hangul ]";
43 enginesDrv = filterAttrs (const isDerivation) pkgs.ibus-engines;
44 engines = concatStringsSep ", "
45 (map (name: "`${name}`") (attrNames enginesDrv));
46 in "Enabled IBus engines. Available engines are: ${engines}.";
49 type = with types; nullOr path;
51 example = literalExpression ''"''${pkgs.plasma5Packages.plasma-desktop}/libexec/kimpanel-ibus-panel"'';
52 description = "Replace the IBus panel with another panel.";
57 config = mkIf (imcfg.enable && imcfg.type == "ibus") {
58 i18n.inputMethod.package = ibusPackage;
60 environment.systemPackages = [
64 # Without dconf enabled it is impossible to use IBus
65 programs.dconf.enable = true;
67 programs.dconf.packages = [ ibusPackage ];
69 services.dbus.packages = [
73 environment.variables = {
74 GTK_IM_MODULE = "ibus";
75 QT_IM_MODULE = "ibus";
76 XMODIFIERS = "@im=ibus";
79 xdg.portal.extraPortals = mkIf config.xdg.portal.enable [
84 # uses attributes of the linked package
85 meta.buildDocsInSandbox = false;