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
This commit is contained in:
commit
e76dd5230f
3 changed files with 41 additions and 6 deletions
|
@ -5,7 +5,9 @@ with lib;
|
|||
let
|
||||
im = config.i18n.inputMethod;
|
||||
cfg = im.fcitx5;
|
||||
fcitx5Package = pkgs.fcitx5-with-addons.override { inherit (cfg) addons; };
|
||||
addons = cfg.addons ++ optional cfg.enableRimeData pkgs.rime-data;
|
||||
fcitx5Package = pkgs.fcitx5-with-addons.override { inherit addons; };
|
||||
whetherRimeDataDir = any (p: p.pname == "fcitx5-rime") cfg.addons;
|
||||
in {
|
||||
options = {
|
||||
i18n.inputMethod.fcitx5 = {
|
||||
|
@ -17,16 +19,29 @@ in {
|
|||
Enabled Fcitx5 addons.
|
||||
'';
|
||||
};
|
||||
|
||||
enableRimeData = mkEnableOption "default rime-data with fcitx5-rime";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf (im.enabled == "fcitx5") {
|
||||
i18n.inputMethod.package = fcitx5Package;
|
||||
|
||||
environment.variables = {
|
||||
GTK_IM_MODULE = "fcitx";
|
||||
QT_IM_MODULE = "fcitx";
|
||||
XMODIFIERS = "@im=fcitx";
|
||||
};
|
||||
environment = mkMerge [{
|
||||
variables = {
|
||||
GTK_IM_MODULE = "fcitx";
|
||||
QT_IM_MODULE = "fcitx";
|
||||
XMODIFIERS = "@im=fcitx";
|
||||
};
|
||||
}
|
||||
(mkIf whetherRimeDataDir {
|
||||
pathsToLink = [
|
||||
"/share/rime-data"
|
||||
];
|
||||
|
||||
variables = {
|
||||
NIX_RIME_DATA_DIR = "/run/current-system/sw/share/rime-data";
|
||||
};
|
||||
})];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
:100644 100644 fac4f53 aed9617 M src/rimeengine.cpp
|
||||
|
||||
diff --git a/src/rimeengine.cpp b/src/rimeengine.cpp
|
||||
index fac4f53..aed9617 100644
|
||||
--- a/src/rimeengine.cpp
|
||||
+++ b/src/rimeengine.cpp
|
||||
@@ -164,7 +164,10 @@ void RimeEngine::rimeStart(bool fullcheck) {
|
||||
RIME_ERROR() << "Failed to create user directory: " << userDir;
|
||||
}
|
||||
}
|
||||
- const char *sharedDataDir = RIME_DATA_DIR;
|
||||
+ const char *sharedDataDir = getenv("NIX_RIME_DATA_DIR");
|
||||
+ if (!sharedDataDir) {
|
||||
+ sharedDataDir = RIME_DATA_DIR;
|
||||
+ }
|
||||
|
||||
RIME_STRUCT(RimeTraits, fcitx_rime_traits);
|
||||
fcitx_rime_traits.shared_data_dir = sharedDataDir;
|
|
@ -35,6 +35,8 @@ stdenv.mkDerivation rec {
|
|||
librime
|
||||
];
|
||||
|
||||
patches = [ ./fcitx5-rime-with-nix-env-variable.patch ];
|
||||
|
||||
meta = with lib; {
|
||||
description = "RIME support for Fcitx5";
|
||||
homepage = "https://github.com/fcitx/fcitx5-rime";
|
||||
|
|
Loading…
Reference in a new issue