Merge pull request #167032 from Vonfry/feature/fcitx5/rime/with-custom-data-dirs

fcitx5-rime: support custom data dir from environment variable for nixos and nix specially

authored by Sandro and committed by GitHub e76dd523 86a69080

+41 -6
+21 -6
nixos/modules/i18n/input-method/fcitx5.nix
··· 5 let 6 im = config.i18n.inputMethod; 7 cfg = im.fcitx5; 8 - fcitx5Package = pkgs.fcitx5-with-addons.override { inherit (cfg) addons; }; 9 in { 10 options = { 11 i18n.inputMethod.fcitx5 = { ··· 17 Enabled Fcitx5 addons. 18 ''; 19 }; 20 }; 21 }; 22 23 config = mkIf (im.enabled == "fcitx5") { 24 i18n.inputMethod.package = fcitx5Package; 25 26 - environment.variables = { 27 - GTK_IM_MODULE = "fcitx"; 28 - QT_IM_MODULE = "fcitx"; 29 - XMODIFIERS = "@im=fcitx"; 30 - }; 31 }; 32 }
··· 5 let 6 im = config.i18n.inputMethod; 7 cfg = im.fcitx5; 8 + addons = cfg.addons ++ optional cfg.enableRimeData pkgs.rime-data; 9 + fcitx5Package = pkgs.fcitx5-with-addons.override { inherit addons; }; 10 + whetherRimeDataDir = any (p: p.pname == "fcitx5-rime") cfg.addons; 11 in { 12 options = { 13 i18n.inputMethod.fcitx5 = { ··· 19 Enabled Fcitx5 addons. 20 ''; 21 }; 22 + 23 + enableRimeData = mkEnableOption "default rime-data with fcitx5-rime"; 24 }; 25 }; 26 27 config = mkIf (im.enabled == "fcitx5") { 28 i18n.inputMethod.package = fcitx5Package; 29 30 + environment = mkMerge [{ 31 + variables = { 32 + GTK_IM_MODULE = "fcitx"; 33 + QT_IM_MODULE = "fcitx"; 34 + XMODIFIERS = "@im=fcitx"; 35 + }; 36 + } 37 + (mkIf whetherRimeDataDir { 38 + pathsToLink = [ 39 + "/share/rime-data" 40 + ]; 41 + 42 + variables = { 43 + NIX_RIME_DATA_DIR = "/run/current-system/sw/share/rime-data"; 44 + }; 45 + })]; 46 }; 47 }
+18
pkgs/tools/inputmethods/fcitx5/fcitx5-rime-with-nix-env-variable.patch
···
··· 1 + :100644 100644 fac4f53 aed9617 M src/rimeengine.cpp 2 + 3 + diff --git a/src/rimeengine.cpp b/src/rimeengine.cpp 4 + index fac4f53..aed9617 100644 5 + --- a/src/rimeengine.cpp 6 + +++ b/src/rimeengine.cpp 7 + @@ -164,7 +164,10 @@ void RimeEngine::rimeStart(bool fullcheck) { 8 + RIME_ERROR() << "Failed to create user directory: " << userDir; 9 + } 10 + } 11 + - const char *sharedDataDir = RIME_DATA_DIR; 12 + + const char *sharedDataDir = getenv("NIX_RIME_DATA_DIR"); 13 + + if (!sharedDataDir) { 14 + + sharedDataDir = RIME_DATA_DIR; 15 + + } 16 + 17 + RIME_STRUCT(RimeTraits, fcitx_rime_traits); 18 + fcitx_rime_traits.shared_data_dir = sharedDataDir;
+2
pkgs/tools/inputmethods/fcitx5/fcitx5-rime.nix
··· 35 librime 36 ]; 37 38 meta = with lib; { 39 description = "RIME support for Fcitx5"; 40 homepage = "https://github.com/fcitx/fcitx5-rime";
··· 35 librime 36 ]; 37 38 + patches = [ ./fcitx5-rime-with-nix-env-variable.patch ]; 39 + 40 meta = with lib; { 41 description = "RIME support for Fcitx5"; 42 homepage = "https://github.com/fcitx/fcitx5-rime";