mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-12 12:45:27 +03:00
nixos/fcitx5: format
This commit is contained in:
parent
9e1ab011aa
commit
fedf16bc04
1 changed files with 43 additions and 31 deletions
|
@ -1,11 +1,17 @@
|
||||||
{ config, pkgs, lib, ... }:
|
{
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
imcfg = config.i18n.inputMethod;
|
imcfg = config.i18n.inputMethod;
|
||||||
cfg = imcfg.fcitx5;
|
cfg = imcfg.fcitx5;
|
||||||
fcitx5Package =
|
fcitx5Package =
|
||||||
if cfg.plasma6Support
|
if cfg.plasma6Support then
|
||||||
then pkgs.qt6Packages.fcitx5-with-addons.override { inherit (cfg) addons; }
|
pkgs.qt6Packages.fcitx5-with-addons.override { inherit (cfg) addons; }
|
||||||
else pkgs.libsForQt5.fcitx5-with-addons.override { inherit (cfg) addons; };
|
else
|
||||||
|
pkgs.libsForQt5.fcitx5-with-addons.override { inherit (cfg) addons; };
|
||||||
settingsFormat = pkgs.formats.ini { };
|
settingsFormat = pkgs.formats.ini { };
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
@ -108,40 +114,46 @@ in
|
||||||
config = lib.mkIf (imcfg.enable && imcfg.type == "fcitx5") {
|
config = lib.mkIf (imcfg.enable && imcfg.type == "fcitx5") {
|
||||||
i18n.inputMethod.package = fcitx5Package;
|
i18n.inputMethod.package = fcitx5Package;
|
||||||
|
|
||||||
i18n.inputMethod.fcitx5.addons = lib.optionals (cfg.quickPhrase != { }) [
|
i18n.inputMethod.fcitx5.addons =
|
||||||
(pkgs.writeTextDir "share/fcitx5/data/QuickPhrase.mb"
|
lib.optionals (cfg.quickPhrase != { }) [
|
||||||
(lib.concatStringsSep "\n"
|
(pkgs.writeTextDir "share/fcitx5/data/QuickPhrase.mb" (
|
||||||
(lib.mapAttrsToList (name: value: "${name} ${value}") cfg.quickPhrase)))
|
lib.concatStringsSep "\n" (lib.mapAttrsToList (name: value: "${name} ${value}") cfg.quickPhrase)
|
||||||
] ++ lib.optionals (cfg.quickPhraseFiles != { }) [
|
))
|
||||||
(pkgs.linkFarm "quickPhraseFiles" (lib.mapAttrs'
|
]
|
||||||
(name: value: lib.nameValuePair ("share/fcitx5/data/quickphrase.d/${name}.mb") value)
|
++ lib.optionals (cfg.quickPhraseFiles != { }) [
|
||||||
cfg.quickPhraseFiles))
|
(pkgs.linkFarm "quickPhraseFiles" (
|
||||||
];
|
lib.mapAttrs' (
|
||||||
|
name: value: lib.nameValuePair ("share/fcitx5/data/quickphrase.d/${name}.mb") value
|
||||||
|
) cfg.quickPhraseFiles
|
||||||
|
))
|
||||||
|
];
|
||||||
environment.etc =
|
environment.etc =
|
||||||
let
|
let
|
||||||
optionalFile = p: f: v: lib.optionalAttrs (v != { }) {
|
optionalFile =
|
||||||
"xdg/fcitx5/${p}".text = f v;
|
p: f: v:
|
||||||
};
|
lib.optionalAttrs (v != { }) {
|
||||||
|
"xdg/fcitx5/${p}".text = f v;
|
||||||
|
};
|
||||||
in
|
in
|
||||||
lib.attrsets.mergeAttrsList [
|
lib.attrsets.mergeAttrsList [
|
||||||
(optionalFile "config" (lib.generators.toINI { }) cfg.settings.globalOptions)
|
(optionalFile "config" (lib.generators.toINI { }) cfg.settings.globalOptions)
|
||||||
(optionalFile "profile" (lib.generators.toINI { }) cfg.settings.inputMethod)
|
(optionalFile "profile" (lib.generators.toINI { }) cfg.settings.inputMethod)
|
||||||
(lib.concatMapAttrs
|
(lib.concatMapAttrs (
|
||||||
(name: value: optionalFile
|
name: value: optionalFile "conf/${name}.conf" (lib.generators.toINIWithGlobalSection { }) value
|
||||||
"conf/${name}.conf"
|
) cfg.settings.addons)
|
||||||
(lib.generators.toINIWithGlobalSection { })
|
|
||||||
value)
|
|
||||||
cfg.settings.addons)
|
|
||||||
];
|
];
|
||||||
|
|
||||||
environment.variables = {
|
environment.variables =
|
||||||
XMODIFIERS = "@im=fcitx";
|
{
|
||||||
QT_PLUGIN_PATH = [ "${fcitx5Package}/${pkgs.qt6.qtbase.qtPluginPrefix}" ];
|
XMODIFIERS = "@im=fcitx";
|
||||||
} // lib.optionalAttrs (!cfg.waylandFrontend) {
|
QT_PLUGIN_PATH = [ "${fcitx5Package}/${pkgs.qt6.qtbase.qtPluginPrefix}" ];
|
||||||
GTK_IM_MODULE = "fcitx";
|
}
|
||||||
QT_IM_MODULE = "fcitx";
|
// lib.optionalAttrs (!cfg.waylandFrontend) {
|
||||||
} // lib.optionalAttrs cfg.ignoreUserConfig {
|
GTK_IM_MODULE = "fcitx";
|
||||||
SKIP_FCITX_USER_PATH = "1";
|
QT_IM_MODULE = "fcitx";
|
||||||
};
|
}
|
||||||
|
// lib.optionalAttrs cfg.ignoreUserConfig {
|
||||||
|
SKIP_FCITX_USER_PATH = "1";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue