summary refs log tree commit diff
diff options
context:
space:
mode:
authorlinsui <linsui555@gmail.com>2023-07-28 22:26:53 +0800
committerlinsui <linsui@inbox.lv>2023-07-29 00:54:25 +0800
commit71540ff21654635d2d617ff31f07b69c76b71423 (patch)
treea432b5e6ee2d1af2286f2c16a64e3ab6096e6295
parent2a9d660ff0f7ffde9d73be328ee6e6f10ef66b28 (diff)
downloadnixpkgs-71540ff21654635d2d617ff31f07b69c76b71423.tar
nixpkgs-71540ff21654635d2d617ff31f07b69c76b71423.tar.gz
nixpkgs-71540ff21654635d2d617ff31f07b69c76b71423.tar.bz2
nixpkgs-71540ff21654635d2d617ff31f07b69c76b71423.tar.lz
nixpkgs-71540ff21654635d2d617ff31f07b69c76b71423.tar.xz
nixpkgs-71540ff21654635d2d617ff31f07b69c76b71423.tar.zst
nixpkgs-71540ff21654635d2d617ff31f07b69c76b71423.zip
nixos/fcitx5: add quickPhrase
-rw-r--r--nixos/modules/i18n/input-method/fcitx5.nix34
1 files changed, 33 insertions, 1 deletions
diff --git a/nixos/modules/i18n/input-method/fcitx5.nix b/nixos/modules/i18n/input-method/fcitx5.nix
index 7251240d26a..39952d6c399 100644
--- a/nixos/modules/i18n/input-method/fcitx5.nix
+++ b/nixos/modules/i18n/input-method/fcitx5.nix
@@ -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";