From 1fa88825a8ad9bb9ce664c27886e413de536f3bc 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 8156f424b2cbaf..fec06413abc240 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 != { }) [