Japanese input in 2023/2024

How can I get Japanese input, preferably with anthy, to work with either home manager, or configuration.nix? I’m trying all sorts of things, but I’m just not able to get it to work. Right now I am trying home-manager with:

18n.inputMethod.enabled = "fcitx5";
i18n.inputMethod.fcitx5.addons = with pkgs; [ fcitx5-configtool fcitx5-anthy ];

doesn’t work. I can add a Japanese keyboard but I’m unable to switch to Japanese input. No kana to be found.

I’ve also tried my configuration.nix:

  i18n.inputMethod = {
    enabled = "fcitx5";
    fcitx5.addons = with pkgs; [
      fcitx5-anthy
      fcitx5-gtk
    ];
    ibus.engines = with pkgs.ibus-engines; [ anthy ];
  };

But this also does not work.

You’d think that anthy would work since it exists in nixpkgs, but so far no luck. Any light on this? Please shine it :laughing:

Found the solution (of course just one minute after asking the question) so here it is the trick for those looking it up later:

in fcitx5-config-qt (what I am using), don’t add the Japanese keyboard but simply add the mozc or anthy keyboard. They both work for me, but visually mozc is a little bit nicer because the kanji suggestions of anthy are a bit too small.

So that’s the trick. Fixed!

As another reference, here’s my config: https://github.com/infinisil/system/blob/07534666e0592d9ceb1fc157dc48baa7b1494d99/config/modules/japanese-input/default.nix :slight_smile:

And you can run fcitx5-configtool to configure some stuff. Not sure if that’s the default but to switch inputs I use Ctrl-Shift

2 Likes

Thank you! That helps me when I am going to try to setup kitty later on.

I setup a config similar to yours @Infinisil but I’m not seeing mozc in the list of languages.

Here is mine for reference.

{pkgs, ...}: {
  config = {
    i18n.inputMethod.enabled = "fcitx5";
    i18n.inputMethod.fcitx5.addons = [
      pkgs.fcitx5-mozc
      pkgs.fcitx5-gtk
      pkgs.fcitx5-configtool
    ];

    # Would normally set this to fcitx, but kitty only supports ibus, and fcitx
    # provides an ibus interface. Can't use ibus for e.g. QT_IM_MODULE though,
    # because that at least breaks mumble
    environment.variables.GLFW_IM_MODULE = "ibus";
  };
}

Ah so I had to reboot before mozc showed up in fcitx5-configtool. I was trying things out with rebuild test but it wasn’t working until I did a rebuild switch and rebooted.

Now the only thing to figure out is why the tab window for alternative kanji isn’t showing up in kitty.

I’m dealing with a similar issue (mozc isn’t showing despite having it in my config here). Any ideas on why this might be the case?

I tried restarted and everything above, but nothing seemed to help.

Hey two things that tripped me up the first time I tried this:

  1. When you open the config tool, you have to check/uncheck a box to show all the languages. For me it was disabled by default.
  2. You don’t search for “Japanese” in the language list; you search for “mozc”.

Still no beans (this include the checkbox being unchecked)

Just to be extra sure and because I don’t see it on your screenshot, did you uncheck this box?

If all else fails, I’ve heard people have had success with ibus. :sweat_smile:

Guess I’m going to ibus

Thanks for the help regardless lol

Yeah sorry I couldn’t be of more help. I guess I got lucky that it worked after some poking.

Regarding ibus, here is the config from my friend’s repo.

{
  config,
  pkgs,
  ...
}: {
  # Install Japanese IME MOZC
  i18n.inputMethod.enabled = "ibus";
  i18n.inputMethod.ibus.engines = with pkgs.ibus-engines; [mozc];
}

Like others here, I had issues getting fcitx to work, but ibus worked for me. It did introduce issues with plover and my QMK keyboard, so I have the following in my config:

  # By default, ibus handles input events asynchronously. This creates the potential for input events at approximately
  # the same time to be handled in the wrong order -- for example, when the stenography application Plover emits input
  # events after the keys of a chord are lifted, or when rolling home row modifier keys on a QMK-powered keyboard. In
  # order to ensure that input events are handled in order, we set IBUS_ENABLE_SYNC_MODE to 1 to force synchronous
  # handling of input events by ibus.
  i18n.inputMethod = {
    enabled = "ibus";
    ibus.engines = with pkgs.ibus-engines; [ anthy ];
  };
  environment.variables = {
    IBUS_ENABLE_SYNC_MODE = "1";
  };
1 Like