2021-01-15 22:18:51 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
im = config.i18n.inputMethod;
|
|
|
|
cfg = im.fcitx5;
|
2022-04-27 09:35:20 +00:00
|
|
|
addons = cfg.addons ++ optional cfg.enableRimeData pkgs.rime-data;
|
|
|
|
fcitx5Package = pkgs.fcitx5-with-addons.override { inherit addons; };
|
|
|
|
whetherRimeDataDir = any (p: p.pname == "fcitx5-rime") cfg.addons;
|
2021-06-06 07:54:09 +00:00
|
|
|
in {
|
|
|
|
options = {
|
|
|
|
i18n.inputMethod.fcitx5 = {
|
|
|
|
addons = mkOption {
|
|
|
|
type = with types; listOf package;
|
|
|
|
default = [];
|
2021-10-06 13:57:05 +00:00
|
|
|
example = literalExpression "with pkgs; [ fcitx5-rime ]";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2021-06-06 07:54:09 +00:00
|
|
|
Enabled Fcitx5 addons.
|
|
|
|
'';
|
2021-01-15 22:18:51 +00:00
|
|
|
};
|
2022-04-27 09:35:20 +00:00
|
|
|
|
|
|
|
enableRimeData = mkEnableOption "default rime-data with fcitx5-rime";
|
2021-01-15 22:18:51 +00:00
|
|
|
};
|
2021-06-06 07:54:09 +00:00
|
|
|
};
|
2021-01-15 22:18:51 +00:00
|
|
|
|
2021-06-06 07:54:09 +00:00
|
|
|
config = mkIf (im.enabled == "fcitx5") {
|
|
|
|
i18n.inputMethod.package = fcitx5Package;
|
2021-01-15 22:18:51 +00:00
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
environment = mkMerge [{
|
|
|
|
variables = {
|
|
|
|
GTK_IM_MODULE = "fcitx";
|
|
|
|
QT_IM_MODULE = "fcitx";
|
|
|
|
XMODIFIERS = "@im=fcitx";
|
2022-06-16 17:23:12 +00:00
|
|
|
QT_PLUGIN_PATH = [ "${fcitx5Package}/${pkgs.qt6.qtbase.qtPluginPrefix}" ];
|
2022-04-27 09:35:20 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
(mkIf whetherRimeDataDir {
|
|
|
|
pathsToLink = [
|
|
|
|
"/share/rime-data"
|
|
|
|
];
|
2021-06-06 07:54:09 +00:00
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
variables = {
|
|
|
|
NIX_RIME_DATA_DIR = "/run/current-system/sw/share/rime-data";
|
|
|
|
};
|
|
|
|
})];
|
2021-06-06 07:54:09 +00:00
|
|
|
};
|
|
|
|
}
|