2021-01-15 22:18:51 +00:00
|
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
im = config.i18n.inputMethod;
|
|
|
|
|
cfg = im.fcitx5;
|
2023-04-12 12:48:02 +00:00
|
|
|
|
fcitx5Package = pkgs.fcitx5-with-addons.override { inherit (cfg) addons; };
|
|
|
|
|
in
|
|
|
|
|
{
|
2021-06-06 07:54:09 +00:00
|
|
|
|
options = {
|
|
|
|
|
i18n.inputMethod.fcitx5 = {
|
|
|
|
|
addons = mkOption {
|
|
|
|
|
type = with types; listOf package;
|
2023-08-04 22:07:22 +00:00
|
|
|
|
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
|
|
|
|
};
|
2023-08-04 22:07:22 +00:00
|
|
|
|
quickPhrase = mkOption {
|
2023-08-10 07:59:29 +00:00
|
|
|
|
type = with types; attrsOf str;
|
2023-08-04 22:07:22 +00:00
|
|
|
|
default = { };
|
|
|
|
|
example = literalExpression ''
|
|
|
|
|
{
|
|
|
|
|
smile = "(・∀・)";
|
|
|
|
|
angry = "( ̄ー ̄)";
|
|
|
|
|
}
|
|
|
|
|
'';
|
|
|
|
|
description = lib.mdDoc "Quick phrases.";
|
|
|
|
|
};
|
|
|
|
|
quickPhraseFiles = mkOption {
|
|
|
|
|
type = with types; attrsOf path;
|
|
|
|
|
default = { };
|
|
|
|
|
example = literalExpression ''
|
|
|
|
|
{
|
|
|
|
|
words = ./words.mb;
|
|
|
|
|
numbers = ./numbers.mb;
|
|
|
|
|
}
|
|
|
|
|
'';
|
|
|
|
|
description = lib.mdDoc "Quick phrase files.";
|
|
|
|
|
};
|
2021-01-15 22:18:51 +00:00
|
|
|
|
};
|
2021-06-06 07:54:09 +00:00
|
|
|
|
};
|
2021-01-15 22:18:51 +00:00
|
|
|
|
|
2023-04-12 12:48:02 +00:00
|
|
|
|
imports = [
|
|
|
|
|
(mkRemovedOptionModule [ "i18n" "inputMethod" "fcitx5" "enableRimeData" ] ''
|
|
|
|
|
RIME data is now included in `fcitx5-rime` by default, and can be customized using `fcitx5-rime.override { rimeDataPkgs = ...; }`
|
|
|
|
|
'')
|
|
|
|
|
];
|
|
|
|
|
|
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
|
|
|
|
|
2023-08-04 22:07:22 +00:00
|
|
|
|
i18n.inputMethod.fcitx5.addons = lib.optionals (cfg.quickPhrase != { }) [
|
|
|
|
|
(pkgs.writeTextDir "share/fcitx5/data/QuickPhrase.mb"
|
|
|
|
|
(lib.concatStringsSep "\n"
|
|
|
|
|
(lib.mapAttrsToList (name: value: "${name} ${value}") cfg.quickPhrase)))
|
|
|
|
|
] ++ lib.optionals (cfg.quickPhraseFiles != { }) [
|
|
|
|
|
(pkgs.linkFarm "quickPhraseFiles" (lib.mapAttrs'
|
|
|
|
|
(name: value: lib.nameValuePair ("share/fcitx5/data/quickphrase.d/${name}.mb") value)
|
|
|
|
|
cfg.quickPhraseFiles))
|
|
|
|
|
];
|
|
|
|
|
|
2023-04-12 12:48:02 +00:00
|
|
|
|
environment.variables = {
|
|
|
|
|
GTK_IM_MODULE = "fcitx";
|
|
|
|
|
QT_IM_MODULE = "fcitx";
|
|
|
|
|
XMODIFIERS = "@im=fcitx";
|
|
|
|
|
QT_PLUGIN_PATH = [ "${fcitx5Package}/${pkgs.qt6.qtbase.qtPluginPrefix}" ];
|
|
|
|
|
};
|
2021-06-06 07:54:09 +00:00
|
|
|
|
};
|
|
|
|
|
}
|