Merge pull request #224042 from linyinfeng/rime-data-refactor

{ibus,fcitx5}-rime: Refactor RIME data support
This commit is contained in:
Nick Cao 2023-04-05 16:16:18 +08:00 committed by GitHub
commit 2d2abaa467
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 48 deletions

View File

@ -130,6 +130,8 @@ In addition to numerous new and upgraded packages, this release has the followin
- The [services.unifi-video.openFirewall](#opt-services.unifi-video.openFirewall) module option default value has been changed from `true` to `false`. You will need to explicitly set this option to `true`, or configure your firewall.
- The option `i18n.inputMethod.fcitx5.enableRimeData` has been removed. Default RIME data is now included in `fcitx5-rime` by default, and can be customized using `fcitx5-rime.override { rimeDataPkgs = [ pkgs.rime-data, package2, ... ]; }`
- Kime has been updated from 2.5.6 to 3.0.2 and the `i18n.inputMethod.kime.config` option has been removed. Users should use `daemonModules`, `iconColor`, and `extraConfig` options under `i18n.inputMethod.kime` instead.
- `tut` has been updated from 1.0.34 to 2.0.0, and now uses the TOML format for the configuration file instead of INI. Additional information can be found [here](https://github.com/RasmusLindroth/tut/releases/tag/2.0.0).

View File

@ -5,10 +5,9 @@ with lib;
let
im = config.i18n.inputMethod;
cfg = im.fcitx5;
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 {
fcitx5Package = pkgs.fcitx5-with-addons.override { inherit (cfg) addons; };
in
{
options = {
i18n.inputMethod.fcitx5 = {
addons = mkOption {
@ -19,30 +18,23 @@ in {
Enabled Fcitx5 addons.
'';
};
enableRimeData = mkEnableOption (lib.mdDoc "default rime-data with fcitx5-rime");
};
};
imports = [
(mkRemovedOptionModule [ "i18n" "inputMethod" "fcitx5" "enableRimeData" ] ''
RIME data is now included in `fcitx5-rime` by default, and can be customized using `fcitx5-rime.override { rimeDataPkgs = ...; }`
'')
];
config = mkIf (im.enabled == "fcitx5") {
i18n.inputMethod.package = fcitx5Package;
environment = mkMerge [{
variables = {
GTK_IM_MODULE = "fcitx";
QT_IM_MODULE = "fcitx";
XMODIFIERS = "@im=fcitx";
QT_PLUGIN_PATH = [ "${fcitx5Package}/${pkgs.qt6.qtbase.qtPluginPrefix}" ];
};
}
(mkIf whetherRimeDataDir {
pathsToLink = [
"/share/rime-data"
];
variables = {
NIX_RIME_DATA_DIR = "/run/current-system/sw/share/rime-data";
};
})];
environment.variables = {
GTK_IM_MODULE = "fcitx";
QT_IM_MODULE = "fcitx";
XMODIFIERS = "@im=fcitx";
QT_PLUGIN_PATH = [ "${fcitx5Package}/${pkgs.qt6.qtbase.qtPluginPrefix}" ];
};
};
}

View File

@ -1,18 +0,0 @@
: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

@ -6,6 +6,9 @@
, gettext
, fcitx5
, librime
, rime-data
, symlinkJoin
, rimeDataPkgs ? [ rime-data ]
}:
stdenv.mkDerivation rec {
@ -35,7 +38,14 @@ stdenv.mkDerivation rec {
librime
];
patches = [ ./fcitx5-rime-with-nix-env-variable.patch ];
rimeDataDrv = symlinkJoin {
name = "fcitx5-rime-data";
paths = rimeDataPkgs;
};
postInstall = ''
cp -r "${rimeDataDrv}/share/rime-data/." $out/share/rime-data/
'';
meta = with lib; {
description = "RIME support for Fcitx5";

View File

@ -9,6 +9,8 @@
, librime
, pkg-config
, rime-data
, symlinkJoin
, rimeDataPkgs ? [ rime-data ]
}:
stdenv.mkDerivation rec {
@ -22,15 +24,18 @@ stdenv.mkDerivation rec {
sha256 = "0gdxg6ia0i31jn3cvh1nrsjga1j31hf8a2zfgg8rzn25chrfr319";
};
buildInputs = [ gdk-pixbuf glib ibus libnotify librime rime-data ];
buildInputs = [ gdk-pixbuf glib ibus libnotify librime ];
nativeBuildInputs = [ cmake pkg-config ];
cmakeFlags = [ "-DRIME_DATA_DIR=${rime-data}/share/rime-data" ];
cmakeFlags = [ "-DRIME_DATA_DIR=${placeholder "out"}/share/rime-data" ];
prePatch = ''
substituteInPlace CMakeLists.txt \
--replace 'DESTINATION "''${RIME_DATA_DIR}"' \
'DESTINATION "''${CMAKE_INSTALL_DATADIR}/rime-data"'
rimeDataDrv = symlinkJoin {
name = "ibus-rime-data";
paths = rimeDataPkgs;
};
postInstall = ''
cp -r "${rimeDataDrv}/share/rime-data/." $out/share/rime-data/
'';
meta = with lib; {