Jump to content

Fcitx5: Difference between revisions

From Official NixOS Wiki
34j (talk | contribs)
→Configuration: Add explanation about ActiveByDefault
Buei (talk | contribs)
 
(One intermediate revision by one other user not shown)
Line 52: Line 52:
}}
}}
<translate>
<translate>
==== Disabling fcitx5-configtool ====
To disable fcitx5-configtool (which pulls in a number of KDE packages), you can use the following [[Overlays|overlay]]:
<syntaxhighlight lang="nix">
(final: prev: {
  qt6Packages = prev.qt6Packages.overrideScope (
    qfinal: qprev: {
      fcitx5-with-addons = qprev.fcitx5-with-addons.override {
        withConfigtool = false;
      };
    }
  );
})
</syntaxhighlight>


== Troubleshooting ==
== Troubleshooting ==
Line 57: Line 71:
=== Add-ons Not Detected ===
=== Add-ons Not Detected ===


'''Do not''' install fcitx5 using <code>environment.systemPackages</code> can interfere with add-on detection. Make sure to only add fcitx5 to your config as shown in [[Special:MyLanguage/Fcitx5#Setup | Setup]].
'''Do not''' install fcitx5 using <code>environment.systemPackages</code>, since it can interfere with add-on detection. Make sure to only add fcitx5 to your config as shown in [[Special:MyLanguage/Fcitx5#Setup | Setup]].


</translate>
</translate>

Latest revision as of 07:57, 25 October 2026

Fcitx5 is a lightweight input method framework with add-on support.

Installation

System Setup

The following is a snippet for a NixOS configuration that sets up fcitx5, its GUI config tool, and two add-ons.

❄︎ /etc/nixos/configuration.nix
{
  i18n.inputMethod = {
    enable = true;
    type = "fcitx5";
    fcitx5.addons = with pkgs; [
      fcitx5-mozc
      fcitx5-gtk
    ];
  };
}

Configuration

Fcitx5 can be configured declaratively (though this is optional) using i18n.inputMethod.fcitx5.settings or i18n.inputMethod.fcitx5.settings (Home Manager). The former generates a config file in /etc/xdg/fcitx5 and the latter in ~/.config/fcitx5.

It would be easier to edit the Fcitx5 profile through GUI tools (i.e. kdePackages.fcitx5-configtool) as recommended in Arch Wiki, then convert the generated configuration files to Nix configuration;

  • cat ~/.config/fcitx5/profile (if exists) to i18n.inputMethod.fcitx5.settings.inputMethod
  • cat ~/.config/fcitx5/config (if exists) to i18n.inputMethod.fcitx5.settings.globalOptions
❄︎ configuration.nix or home.nix
i18n.inputMethod.fcitx5.settings.inputMethod = {
  GroupOrder."0" = "Default";
  "Groups/0" = {
    Name = "Default";
    "Default Layout" = "jp";
    DefaultIM = "mozc";
  };
  "Groups/0/Items/0".Name = "keyboard-jp";
  "Groups/0/Items/1".Name = "mozc";
};
i18n.inputMethod.fcitx5.settings.globalOptions = {
  # Without "Active By Default" set to True, fcitx5 needs to be
  # manually activated by pressing the hotkey etc. after the initial launch
  # ActiveByDefault = True;
};

# Local config at ~/.config/fcitx5 needs to be ignored using the following option.
i18n.inputMethod.fcitx5.ignoreUserConfig = true;

Disabling fcitx5-configtool

To disable fcitx5-configtool (which pulls in a number of KDE packages), you can use the following overlay:

(final: prev: {
  qt6Packages = prev.qt6Packages.overrideScope (
    qfinal: qprev: {
      fcitx5-with-addons = qprev.fcitx5-with-addons.override {
        withConfigtool = false;
      };
    }
  );
})

Troubleshooting

Add-ons Not Detected

Do not install fcitx5 using environment.systemPackages, since it can interfere with add-on detection. Make sure to only add fcitx5 to your config as shown in Setup.

Fcitx5 failing to load IME module (claims "使用不可" (unusable))

Another possibility is that you are calling ${pkgs.fcitx5}/bin/fcitx5 instead of the patched fcitx5-with-addons (/run/current-system/sw/bin/fcitx5). For example in Hyprland:

 # ~/.config/hypr/hyprland.conf
 exec-once=fcitx5 -d # not ${pkgs.fcitx5}/bin/fcitx5 !

Fcitx5 Doesn't Start When Using WM

If using a Window Manager (WM), such as Sway, you may need to add services.xserver.desktopManager.runXdgAutostartIfNone = true; to your NixOS configuration.

Using Wayland

Set boolean i18n.inputMethod.fcitx5.waylandFrontend to true to suppress warnings about environment variables.

For more details on how to correctly set fcitx5 for different compositors and applications, refer to the fcitx5 wiki.

SVG Themes Broken

Themes using SVG format might not be rendered correctly. You need to introduce librsvg. The easiest way to do so is

programs.gdk-pixbuf.modulePackages = [ pkgs.librsvg ];

See also [1][2].