Japanese on NixOS
Background
I’ve been studying japanese for some time and because of that I set up most of my devices to be able to also type in japanese. On all my other devices I had no trouble setting this up, but in Linux I had problems since I was using Gentoo, when I moved to NixOS I tried again but no luck. Until some days ago when I found this blog post, it’s kinda outdated, from 2018, but it gave me hope and I tried again. And it worked, with a little bit of tweaking but I can finally type in Japanese すごい.
How
I created two new files fonts.nix
and japanese.nix
on my system configuration
and add fcitx5 &
to my riverwm configuration.
This is the contents of fonts.nix
, in this file I simply add some fonts to the
system and set the default so fontconfig doesn’t use the wrong ones.
{pkgs, ...}: {
fonts = {
packages = with pkgs; [
carlito
dejavu_fonts
ipafont
kochi-substitute
source-code-pro
ttf_bitstream_vera
];
fontconfig = {
defaultFonts = {
monospace = [
"DejaVu Sans Mono"
"IPAGothic"
];
sansSerif = [
"DejaVu Sans"
"IPAPGothic"
];
serif = [
"DejaVu Serif"
"IPAPMincho"
];
};
};
};
}
And here is the contents of japanese.nix
, in this file I set the input method
to be used as fcitx5 and use mozc as IME.
{pkgs, ...}: {
i18n.inputMethod = {
enable = true;
type = "fcitx5";
fcitx5 = {
waylandFrontend = true;
addons = with pkgs; [
fcitx5-mozc
fcitx5-gtk
fcitx5-rose-pine
];
};
};
}
This simple configuration worked, all I had to do after the reboot was to set
the mozc
in the fcitx5
input list.