Fcitx5
Fcitx5 is a lightweight input method framework with addon support.
Setup
nixos-unstable
The following is a simple NixOS configuration that sets up fcitx5 on nixos-unstable:
i18n.inputMethod = { type = "fcitx5"; enable = true; fcitx5.addons = with pkgs; [ fcitx5-mozc fcitx5-gtk ]; };
nixos-24.05 and before
The i18n.inputMethod.enabled option will be removed in favor of .type and .enable (see above).
Until then, a simple example for Simplified Chinese:
{ config, pkgs, ... }: { i18n.inputMethod = { enabled = "fcitx5"; waylandFrontend = true; fcitx5.addons = with pkgs; [ fcitx5-gtk # alternatively, kdePackages.fcitx5-qt fcitx5-chinese-addons # table input method support fcitx5-nord # a color theme ]; }; }
For Traditional Chinese, one can use the RIME Input Method Engine:
{ config, pkgs, ... }: { i18n.inputMethod = { enabled = "fcitx5"; waylandFrontend = true; fcitx5.addons = with pkgs; [ rime-data fcitx5-gtk fcitx5-rime ]; }; }
The i18n.inputMethod.enabled option provides alternative input methods to fcitx5, but these can also be enabled as fcitx5 addons.
Addons include:
- __input methods__: fcitx5-rime, fcitx5-skk, fcitx5-mozc, fcitx5-openbangla-keyboard, fcitx5-bamboo
- __themes__: fcitx5-nord, fcitx5-rose-pine, fcitx5-material-color
- Zhuyin/Bopomofo input via fcitx5-chewing
Notably, NixOS sets session variables that are required for fcitx5.
Currently, home-manager does not have fcitx5 settings.
So it may be necessary to update settings in ~/.config/fcitx5, e.g.
# ~/.config/fcitx5/conf/classicui.conf Theme=Nord-Dark Font="Meslo 20"
If you run Hyprland and want the GUI to appear on start:
# ~/.config/hypr/hyprland.conf windowrule = pseudo, fcitx exec-once=fcitx5 -d -r exec-once=fcitx5-remote -r
Troubleshooting
Add-ons Not Detected
Installing fcitx5 using environment.systemPackages
can interfere with add-on detection. Make sure to only add fcitx5 to your config as shown in Setup.
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
As of NixOS 23.11 i18n.inputMethod.enabled
no longer creates systemd services for fcitx5. Instead it relies on XDG autostart files. If using a Window Manager (WM), such as Sway, you may need to add services.xserver.desktopManager.runXdgAutostartIfNone
to your NixOS configuration.
See the NixOS 23.11 Release Notes for more information.
Using Wayland
Set boolean i18n.inputMethod.fcitx5.waylandFrontend
to true to suppress warnings about environment variables.
Simplified Pinyin layout does not appear
When running fcitx5-configtool, the Simplified Chinese layouts don't appear if you write "Chinese", but they appear if you write "cn": Here a "Pinyin" option occurs under "简体中文":