1{ config, pkgs, lib, ... }:
2
3with lib;
4
5let
6 im = config.i18n.inputMethod;
7 cfg = im.fcitx5;
8 fcitx5Package = pkgs.fcitx5-with-addons.override { inherit (cfg) addons; };
9in {
10 options = {
11 i18n.inputMethod.fcitx5 = {
12 addons = mkOption {
13 type = with types; listOf package;
14 default = [];
15 example = literalExpression "with pkgs; [ fcitx5-rime ]";
16 description = ''
17 Enabled Fcitx5 addons.
18 '';
19 };
20 };
21 };
22
23 config = mkIf (im.enabled == "fcitx5") {
24 i18n.inputMethod.package = fcitx5Package;
25
26 environment.variables = {
27 GTK_IM_MODULE = "fcitx";
28 QT_IM_MODULE = "fcitx";
29 XMODIFIERS = "@im=fcitx";
30 };
31
32 systemd.user.services.fcitx5-daemon = {
33 enable = true;
34 script = "${fcitx5Package}/bin/fcitx5";
35 wantedBy = [ "graphical-session.target" ];
36 };
37 };
38}