mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-11 04:02:55 +03:00
Merge pull request #245886 from linsui/quickphase
nixos/fcitx5: add quickPhrase
This commit is contained in:
commit
4ad78e3e98
@ -12,12 +12,34 @@ in
|
||||
i18n.inputMethod.fcitx5 = {
|
||||
addons = mkOption {
|
||||
type = with types; listOf package;
|
||||
default = [];
|
||||
default = [ ];
|
||||
example = literalExpression "with pkgs; [ fcitx5-rime ]";
|
||||
description = lib.mdDoc ''
|
||||
Enabled Fcitx5 addons.
|
||||
'';
|
||||
};
|
||||
quickPhrase = mkOption {
|
||||
type = with types; attrsOf string;
|
||||
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.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@ -30,6 +52,16 @@ in
|
||||
config = mkIf (im.enabled == "fcitx5") {
|
||||
i18n.inputMethod.package = fcitx5Package;
|
||||
|
||||
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))
|
||||
];
|
||||
|
||||
environment.variables = {
|
||||
GTK_IM_MODULE = "fcitx";
|
||||
QT_IM_MODULE = "fcitx";
|
||||
|
Loading…
Reference in New Issue
Block a user