Fcitx5 failed to start on Wayland

Hello,

I installed Fcitx5 on my NixOS, but it doesn’t auto-launch with my desktop.

Here is my opinion on what goes wrong: There are 3 relevant systemd service: app-org.fcitx.Fcitx5@autostart.service (seems like auto-generated from an XDG autostart file managed by home-manager) and fcitx5-daemon.service generated by home-manager i18n configuration for Fcitx5, and niri.service for my WM. When I log in to my desktop, these happen:

  • app-org.fcitx.Fcitx5@autostart.service auto-started before my WM, and hanged after failing to open Wayland connection instead of exiting and occupied DBus name.
  • My WM started to listen on Wayland socket, and started fcitx5-daemon.service, which is intended.
  • fcitx5-daemon.service failed due to a failing request for the DBus name occupied by app-org.fcitx.Fcitx5@autostart.service before.

My system version:

  • Nixpkgs 9cdd04;
  • home-manager 080e8b;
  • niri 25.05.1;
  • Fcitx5 5.1.12.

journalctl output:

$ journalctl --user -u app-org.fcitx.Fcitx5@autostart.service --no-pager
6月 29 12:53:22 desktop systemd[1404]: Starting Fcitx 5...
6月 29 12:53:22 desktop systemd[1404]: Started Fcitx 5.
6月 29 12:53:22 desktop fcitx5[1460]: I2025-06-29 12:53:22.397746 instance.cpp:1394] Override Enabled Addons: {}
6月 29 12:53:22 desktop fcitx5[1460]: I2025-06-29 12:53:22.397803 instance.cpp:1395] Override Disabled Addons: {}
6月 29 12:53:22 desktop fcitx5[1460]: I2025-06-29 12:53:22.399967 addonmanager.cpp:205] Loaded addon imselector
6月 29 12:53:22 desktop fcitx5[1460]: I2025-06-29 12:53:22.401949 addonmanager.cpp:205] Loaded addon quickphrase
6月 29 12:53:22 desktop fcitx5[1460]: I2025-06-29 12:53:22.403846 addonmanager.cpp:205] Loaded addon xcb
6月 29 12:53:22 desktop fcitx5[1460]: E2025-06-29 12:53:22.406049 waylandmodule.cpp:239] Failed to open wayland connection
6月 29 12:53:22 desktop fcitx5[1460]: I2025-06-29 12:53:22.406073 addonmanager.cpp:205] Loaded addon wayland
6月 29 12:53:22 desktop fcitx5[1460]: I2025-06-29 12:53:22.406354 addonmanager.cpp:205] Loaded addon waylandim
...
$ journalctl --user -u fcitx5-daemon.service --no-pager
6月 29 12:53:22 desktop systemd[1404]: Started Fcitx5 input method editor.
6月 29 12:53:22 desktop fcitx5[1436]: I2025-06-29 12:53:22.330676 instance.cpp:1394] Override Enabled Addons: {}
6月 29 12:53:22 desktop fcitx5[1436]: I2025-06-29 12:53:22.330752 instance.cpp:1395] Override Disabled Addons: {}
6月 29 12:53:22 desktop fcitx5[1436]: I2025-06-29 12:53:22.336666 addonmanager.cpp:205] Loaded addon imselector
6月 29 12:53:22 desktop fcitx5[1436]: I2025-06-29 12:53:22.340227 addonmanager.cpp:205] Loaded addon quickphrase
6月 29 12:53:22 desktop fcitx5[1436]: I2025-06-29 12:53:22.350024 addonmanager.cpp:205] Loaded addon xcb
6月 29 12:53:22 desktop fcitx5[1436]: E2025-06-29 12:53:22.355254 waylandmodule.cpp:239] Failed to open wayland connection
6月 29 12:53:22 desktop fcitx5[1436]: I2025-06-29 12:53:22.355375 addonmanager.cpp:205] Loaded addon wayland
6月 29 12:53:22 desktop fcitx5[1436]: I2025-06-29 12:53:22.358986 addonmanager.cpp:205] Loaded addon waylandim
6月 29 12:53:22 desktop fcitx5[1436]: I2025-06-29 12:53:22.365320 addonmanager.cpp:205] Loaded addon keyboard
6月 29 12:53:22 desktop fcitx5[1436]: I2025-06-29 12:53:22.367617 addonmanager.cpp:205] Loaded addon clipboard
6月 29 12:53:22 desktop fcitx5[1436]: I2025-06-29 12:53:22.416571 addonmanager.cpp:205] Loaded addon pinyinhelper
6月 29 12:53:22 desktop fcitx5[1436]: I2025-06-29 12:53:22.432097 addonmanager.cpp:205] Loaded addon luaaddonloader
6月 29 12:53:22 desktop fcitx5[1436]: E2025-06-29 12:53:22.437380 addonloader.cpp:95] Failed to create addon: dbus Unable to request dbus name. Is there another fcitx already running?
6月 29 12:53:22 desktop fcitx5[1436]: I2025-06-29 12:53:22.437404 addonmanager.cpp:201] Could not load addon dbus
6月 29 12:53:22 desktop fcitx5[1436]: I2025-06-29 12:53:22.437619 addonmanager.cpp:308] Unloading addon luaaddonloader
6月 29 12:53:22 desktop fcitx5[1436]: I2025-06-29 12:53:22.437644 addonmanager.cpp:308] Unloading addon pinyinhelper
6月 29 12:53:22 desktop fcitx5[1436]: I2025-06-29 12:53:22.437667 addonmanager.cpp:308] Unloading addon clipboard
6月 29 12:53:22 desktop fcitx5[1436]: I2025-06-29 12:53:22.437711 addonmanager.cpp:308] Unloading addon keyboard
6月 29 12:53:22 desktop fcitx5[1436]: I2025-06-29 12:53:22.437864 addonmanager.cpp:308] Unloading addon waylandim
6月 29 12:53:22 desktop fcitx5[1436]: I2025-06-29 12:53:22.437893 addonmanager.cpp:308] Unloading addon wayland
6月 29 12:53:22 desktop fcitx5[1436]: I2025-06-29 12:53:22.437913 addonmanager.cpp:308] Unloading addon xcb
6月 29 12:53:22 desktop fcitx5[1436]: I2025-06-29 12:53:22.437932 addonmanager.cpp:308] Unloading addon quickphrase
6月 29 12:53:22 desktop fcitx5[1436]: I2025-06-29 12:53:22.438114 addonmanager.cpp:308] Unloading addon imselector
6月 29 12:53:23 desktop systemd[1404]: Started Fcitx5 input method editor.
$ journalctl --user -u niri.service --no-pager
6月 29 12:53:22 desktop systemd[1404]: Starting A scrollable-tiling Wayland compositor...
6月 29 12:53:22 desktop niri[1464]: 2025-06-29T04:53:22.532243Z  INFO niri: starting version 25.05.1 (Nixpkgs)
6月 29 12:53:22 desktop niri[1464]: 2025-06-29T04:53:22.540230Z DEBUG niri_config: loaded config from "/home/alice/.config/niri/config.kdl"
6月 29 12:53:22 desktop niri[1464]: 2025-06-29T04:53:22.609393Z  INFO niri::backend::tty: using as the render node: "/dev/dri/renderD129"
6月 29 12:53:22 desktop niri[1464]: 2025-06-29T04:53:22.663130Z DEBUG niri::backend::tty: device added: 57856 "/dev/dri/card0"
6月 29 12:53:23 desktop niri[1464]: 2025-06-29T04:53:23.273655Z DEBUG niri::backend::tty: this is the primary node
6月 29 12:53:23 desktop niri[1464]: 2025-06-29T04:53:23.273666Z DEBUG niri::backend::tty: this is the primary render node
6月 29 12:53:23 desktop niri[1464]: 2025-06-29T04:53:23.336304Z DEBUG niri::backend::tty: device changed: 57856
6月 29 12:53:23 desktop niri[1464]: 2025-06-29T04:53:23.423814Z DEBUG niri::backend::tty: new connector: HDMI-A-2 "Samsung Electric Company S27E360 0x304C5430"
6月 29 12:53:23 desktop niri[1464]: 2025-06-29T04:53:23.423836Z DEBUG niri::backend::tty: connecting connector: HDMI-A-2
6月 29 12:53:23 desktop niri[1464]: 2025-06-29T04:53:23.423851Z DEBUG niri::backend::tty: picking mode: Mode { name: "1920x1080", clock: 148500, size: (1920, 1080), hsync: (2008, 2052, 2200), vsync: (1084, 1089, 1125), hskew: 0, vscan: 0, vrefresh: 60, mode_type: ModeTypeFlags(PREFERRED | DRIVER) }
6月 29 12:53:23 desktop niri[1464]: 2025-06-29T04:53:23.423885Z DEBUG niri::backend::tty: error setting max bpc: couldn't find max bpc property
6月 29 12:53:23 desktop niri[1464]: 2025-06-29T04:53:23.455287Z DEBUG niri::niri: putting output HDMI-A-2 at x=0 y=0
6月 29 12:53:23 desktop niri[1464]: 2025-06-29T04:53:23.455309Z DEBUG niri::backend::tty: device added: 57857 "/dev/dri/card1"
6月 29 12:53:23 desktop niri[1464]: 2025-06-29T04:53:23.488180Z DEBUG niri::backend::tty: device changed: 57857
6月 29 12:53:23 desktop niri[1464]: 2025-06-29T04:53:23.492207Z  INFO niri: listening on Wayland socket: wayland-1
6月 29 12:53:23 desktop niri[1464]: 2025-06-29T04:53:23.492214Z  INFO niri: IPC listening on: /run/user/1000/niri.wayland-1.1464.sock
6月 29 12:53:23 desktop systemd[1404]: Started A scrollable-tiling Wayland compositor.
...

Thanks in advance for any helps!

my fcitx5 works fine with nixpkgs-unstable and niri-flake(unstable) but i cant find app-org.fcitx.Fcitx5@autostart.service.

i only declare i18n.inputMethod as home-manager module and not as system module.
my setting like this

i18n.inputMethod = {
  enable = true;
  type = "fcitx5";
  fcitx5.addons = with pkgs; [ fcitx5-mozc ];
  fcitx5.waylandFrontend = true;
};

Your DE needs to support XDG autostart. But share the code you wrote.

Pick either nixos or hm config, don’t enable it in both if that’s what you did.

I am using niri, which supports XDG autostart.
Here are my code about Fcitx5:

# modules/im.nix
{
  pkgs,
  lib,
  config,
  ...
}: let
  cfg = config.user.fcitx;
in {
  options.user.fcitx = with lib; {
    enable = mkEnableOption "Fcitx5";
    addons = mkOption {
      type = types.listOf types.package;
      description = ''
        Addons for fcitx5.
      '';
      default = [
        fcitx5-gtk
        fcitx5-chinese-addons
        fcitx5-lua
        libsForQt5.fcitx5-configtool
      ];
    };
    settings = mkOption {
      type = types.attrs;
      description = ''
        Settings for Fcitx5.
      '';
      default = {};
    };
  };

  config = lib.mkIf cfg.enable {
    i18n.inputMethod = {
      enable = true;
      type = "fcitx5";
      fcitx5 = {
        addons = with pkgs; [
          fcitx5-gtk
          fcitx5-chinese-addons
          fcitx5-lua
          libsForQt5.fcitx5-configtool
        ];
        inherit (cfg) settings;
        waylandFrontend = true;
      };
    };
  };
}

# home.nix
{
  pkgs,
  inputs,
  ...
}: {
  # ...

  user = {
    # ...
    fcitx = {
      enable = true;
      addons = with pkgs; [
        fcitx5-gtk
        fcitx5-chinese-addons
        fcitx5-rime
        fcitx5-lua
        libsForQt5.fcitx5-configtool
      ];
      # ...
    };
    # ...
  };
}

And it evaluates to:

nix-repl> :p nixosConfigurations.desktop.config.home-manager.users.alice.i18n.inputMethod
{
  enable = true;
  enabled = null;
  fcitx5 = {
    addons = [
      «derivation /nix/store/shvw3dfy6dn32j9l479cbd0diyr9l9z6-fcitx5-gtk-5.1.3.drv»
      «derivation /nix/store/0nb64jvhw2m45g25zc82pv3g5jp1aq9w-fcitx5-chinese-addons-5.1.8.drv»
      «derivation /nix/store/523wyrv7xwdg53gvlk7sxkx3rcgxqv90-fcitx5-lua-5.0.14.drv»
      «derivation /nix/store/nq0paiq9m02v0fh54mwzzs44slxr82gd-fcitx5-configtool-5.1.9.drv»
    ];
    fcitx5-with-addons = «derivation /nix/store/i1jmzxyy4gx76jzdaq9hl3gnr0zjqprm-fcitx5-with-addons-5.1.12.drv»;
    # ...
    waylandFrontend = true;
  };
  # ...
  package = «derivation /nix/store/44qdh169xx2nx4b9msghay5bx7l56mjp-fcitx5-with-addons-5.1.12.drv»;
  type = "fcitx5";
  uim = { toolbar = "gtk"; };
}

I picked hm config only:

nix-repl> :p nixosConfigurations.desktop.config.i18n.inputMethod
{
  enable = false;
  enableGtk2 = false;
  enableGtk3 = true;
  enabled = null;
  # ...
  package = null;
  type = null;
  uim = { toolbar = "gtk"; };
}