From 97728d9f5a27680dcefacb87bc07acaa10b001bb Mon Sep 17 00:00:00 2001 From: linsui <36977733+linsui@users.noreply.github.com> Date: Sun, 22 Dec 2024 17:10:51 +0800 Subject: [PATCH] nixos/fcitx5: handle multi-line string and escape in quickPhrase --- nixos/modules/i18n/input-method/fcitx5.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nixos/modules/i18n/input-method/fcitx5.nix b/nixos/modules/i18n/input-method/fcitx5.nix index 8156f424b2cb..06b1000c9959 100644 --- a/nixos/modules/i18n/input-method/fcitx5.nix +++ b/nixos/modules/i18n/input-method/fcitx5.nix @@ -117,7 +117,9 @@ in 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.mapAttrsToList ( + name: value: "${name} ${builtins.replaceStrings [ "\\" "\n" ] [ "\\\\" "\\n" ] value}" + ) cfg.quickPhrase )) ] ++ lib.optionals (cfg.quickPhraseFiles != { }) [