fcitx5-rime: add an environment variable for shared data dir passing librime.

The original RIME_DATA_DIR is fixed at build time which is set to the package
dir under nix store. A such dir is read only for users so if some one want to
add a shared data, he has to override fcitx5-rime or librime, which isn't
user-friendly.

On other distributions, RIME_DATA_DIR may be under /usr/local/share/fcitx5 which
is not existed on NixOS. If we set its to /run/current-system/sw/share/..., this
will break for non-NixOS user.

Therefore, we patch it with a special environment variable to let user to load
it dynamically.

Co-Authored-by: Lan Tian <xuyh0120@outlook.com>
This commit is contained in:
Vonfry 2022-04-02 18:43:39 +08:00
parent b43d3db768
commit 6031ae21f6
No known key found for this signature in database
GPG Key ID: 7E3128A1AAF71FCC
2 changed files with 20 additions and 0 deletions

View File

@ -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;

View File

@ -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";