mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 11:36:05 +01:00
i18n.inputMethod: add module
This commit is contained in:
parent
ab0e6c3e0e
commit
7e2b1a42aa
15 changed files with 399 additions and 0 deletions
102
modules/i18n/input-method/default.nix
Normal file
102
modules/i18n/input-method/default.nix
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
let
|
||||
|
||||
cfg = config.i18n.inputMethod;
|
||||
|
||||
gtk2Cache = pkgs.runCommandLocal "gtk2-immodule.cache" {
|
||||
buildInputs = [ pkgs.gtk2 cfg.package ];
|
||||
} ''
|
||||
mkdir -p $out/etc/gtk-2.0/
|
||||
GTK_PATH=${cfg.package}/lib/gtk-2.0/ \
|
||||
gtk-query-immodules-2.0 > $out/etc/gtk-2.0/immodules.cache
|
||||
'';
|
||||
|
||||
gtk3Cache = pkgs.runCommandLocal "gtk3-immodule.cache" {
|
||||
buildInputs = [ pkgs.gtk3 cfg.package ];
|
||||
} ''
|
||||
mkdir -p $out/etc/gtk-3.0/
|
||||
GTK_PATH=${cfg.package}/lib/gtk-3.0/ \
|
||||
gtk-query-immodules-3.0 > $out/etc/gtk-3.0/immodules.cache
|
||||
'';
|
||||
|
||||
in {
|
||||
imports =
|
||||
[ ./fcitx.nix ./fcitx5.nix ./hime.nix ./kime.nix ./nabi.nix ./uim.nix ];
|
||||
|
||||
options.i18n = {
|
||||
inputMethod = {
|
||||
enabled = mkOption {
|
||||
type = types.nullOr
|
||||
(types.enum [ "fcitx" "fcitx5" "nabi" "uim" "hime" "kime" ]);
|
||||
default = null;
|
||||
example = "fcitx";
|
||||
description = ''
|
||||
Select the enabled input method. Input methods is a software to input
|
||||
symbols that are not available on standard input devices.
|
||||
</para><para>
|
||||
Input methods are specially used to input Chinese, Japanese and Korean
|
||||
characters.
|
||||
</para><para>
|
||||
Currently the following input methods are available in Home Manager:
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><literal>fcitx</literal></term>
|
||||
<listitem><para>
|
||||
A customizable lightweight input method
|
||||
extra input engines can be added using
|
||||
<literal>i18n.inputMethod.fcitx.engines</literal>.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><literal>fcitx5</literal></term>
|
||||
<listitem><para>
|
||||
The next generation of fcitx,
|
||||
addons (including engines, dictionaries, skins) can be added using
|
||||
<literal>i18n.inputMethod.fcitx5.addons</literal>.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><literal>nabi</literal></term>
|
||||
<listitem><para>
|
||||
A Korean input method based on XIM. Nabi doesn't support Qt 5.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><literal>uim</literal></term>
|
||||
<listitem><para>
|
||||
The universal input method, is a library with a XIM bridge.
|
||||
uim mainly support Chinese, Japanese and Korean.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><literal>hime</literal></term>
|
||||
<listitem><para>An extremely easy-to-use input method framework.</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><literal>kime</literal></term>
|
||||
<listitem><para>A Korean IME.</para></listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
'';
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
internal = true;
|
||||
type = types.nullOr types.path;
|
||||
default = null;
|
||||
description = ''
|
||||
The input method method package.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf (cfg.enabled != null) {
|
||||
home.packages = [ cfg.package gtk2Cache gtk3Cache ];
|
||||
};
|
||||
|
||||
meta.maintainers = with lib; [ hm.maintainers.kranzes ];
|
||||
}
|
||||
50
modules/i18n/input-method/fcitx.nix
Normal file
50
modules/i18n/input-method/fcitx.nix
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.i18n.inputMethod.fcitx;
|
||||
fcitxPackage = pkgs.fcitx.override { plugins = cfg.engines; };
|
||||
fcitxEngine = types.package // {
|
||||
name = "fcitx-engine";
|
||||
check = x:
|
||||
types.package.check x && attrByPath [ "meta" "isFcitxEngine" ] false x;
|
||||
};
|
||||
in {
|
||||
options = {
|
||||
|
||||
i18n.inputMethod.fcitx = {
|
||||
engines = mkOption {
|
||||
type = with types; listOf fcitxEngine;
|
||||
default = [ ];
|
||||
example = literalExample "with pkgs.fcitx-engines; [ mozc hangul ]";
|
||||
description = let
|
||||
enginesDrv = filterAttrs (const isDerivation) pkgs.fcitx-engines;
|
||||
engines = concatStringsSep ", "
|
||||
(map (name: "<literal>${name}</literal>") (attrNames enginesDrv));
|
||||
in "Enabled Fcitx engines. Available engines are: ${engines}.";
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
config = mkIf (config.i18n.inputMethod.enabled == "fcitx") {
|
||||
i18n.inputMethod.package = fcitxPackage;
|
||||
|
||||
home.sessionVariables = {
|
||||
GTK_IM_MODULE = "fcitx";
|
||||
QT_IM_MODULE = "fcitx";
|
||||
XMODIFIERS = "@im=fcitx";
|
||||
};
|
||||
|
||||
systemd.user.services.fcitx-daemon = {
|
||||
Unit = {
|
||||
Description = "Fcitx input method editor";
|
||||
PartOf = [ "graphical-session.desktop" ];
|
||||
};
|
||||
Service.ExecStart = "${fcitxPackage}/bin/fcitx";
|
||||
Install.WantedBy = [ "graphical-session.target" ];
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
42
modules/i18n/input-method/fcitx5.nix
Normal file
42
modules/i18n/input-method/fcitx5.nix
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
im = config.i18n.inputMethod;
|
||||
cfg = im.fcitx5;
|
||||
fcitx5Package = pkgs.fcitx5-with-addons.override { inherit (cfg) addons; };
|
||||
in {
|
||||
options = {
|
||||
i18n.inputMethod.fcitx5 = {
|
||||
addons = mkOption {
|
||||
type = with types; listOf package;
|
||||
default = [ ];
|
||||
example = literalExample "with pkgs; [ fcitx5-rime ]";
|
||||
description = ''
|
||||
Enabled Fcitx5 addons.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf (im.enabled == "fcitx5") {
|
||||
i18n.inputMethod.package = fcitx5Package;
|
||||
|
||||
home.sessionVariables = {
|
||||
GTK_IM_MODULE = "fcitx";
|
||||
QT_IM_MODULE = "fcitx";
|
||||
XMODIFIERS = "@im=fcitx";
|
||||
};
|
||||
|
||||
systemd.user.services.fcitx5-daemon = {
|
||||
Unit = {
|
||||
Description = "Fcitx5 input method editor";
|
||||
PartOf = [ "graphical-session.target" ];
|
||||
};
|
||||
Service.ExecStart = "${fcitx5Package}/bin/fcitx5";
|
||||
Install.WantedBy = [ "graphical-session.target" ];
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
23
modules/i18n/input-method/hime.nix
Normal file
23
modules/i18n/input-method/hime.nix
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib; {
|
||||
config = mkIf (config.i18n.inputMethod.enabled == "hime") {
|
||||
i18n.inputMethod.package = pkgs.hime;
|
||||
|
||||
home.sessionVariables = {
|
||||
GTK_IM_MODULE = "hime";
|
||||
QT_IM_MODULE = "hime";
|
||||
XMODIFIERS = "@im=hime";
|
||||
};
|
||||
|
||||
systemd.user.services.hime-daemon = {
|
||||
Unit = {
|
||||
Description = "Hime input method editor";
|
||||
PartOf = [ "graphical-session.desktop" ];
|
||||
};
|
||||
Service.ExecStart = "${pkgs.hime}/bin/hime";
|
||||
Install.WantedBy = [ "graphical-session.target" ];
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
58
modules/i18n/input-method/kime.nix
Normal file
58
modules/i18n/input-method/kime.nix
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
{ config, pkgs, lib, generators, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.i18n.inputMethod.kime;
|
||||
yamlFormat = pkgs.formats.yaml { };
|
||||
in {
|
||||
options = {
|
||||
i18n.inputMethod.kime = {
|
||||
config = mkOption {
|
||||
type = yamlFormat.type;
|
||||
default = { };
|
||||
example = literalExample ''
|
||||
{
|
||||
daemon = {
|
||||
modules = ["Xim" "Indicator"];
|
||||
};
|
||||
|
||||
indicator = {
|
||||
icon_color = "White";
|
||||
};
|
||||
|
||||
engine = {
|
||||
hangul = {
|
||||
layout = "dubeolsik";
|
||||
};
|
||||
};
|
||||
}
|
||||
'';
|
||||
description = ''
|
||||
kime configuration. Refer to
|
||||
<link xlink:href="https://github.com/Riey/kime/blob/develop/docs/CONFIGURATION.md"/>
|
||||
for details on supported values.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf (config.i18n.inputMethod.enabled == "kime") {
|
||||
i18n.inputMethod.package = pkgs.kime;
|
||||
|
||||
home.sessionVariables = {
|
||||
GTK_IM_MODULE = "kime";
|
||||
QT_IM_MODULE = "kime";
|
||||
XMODIFIERS = "@im=kime";
|
||||
};
|
||||
|
||||
xdg.configFile."kime/config.yaml".text =
|
||||
replaceStrings [ "\\\\" ] [ "\\" ] (builtins.toJSON cfg.config);
|
||||
|
||||
systemd.user.services.kime-daemon = {
|
||||
Unit = { Description = "Kime input method editor"; };
|
||||
PartOf = [ "graphical-session.target" ];
|
||||
Service.ExecStart = "${pkgs.kime}/bin/kime";
|
||||
Install.WantedBy = [ "graphical-session.target" ];
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
23
modules/i18n/input-method/nabi.nix
Normal file
23
modules/i18n/input-method/nabi.nix
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib; {
|
||||
config = mkIf (config.i18n.inputMethod.enabled == "nabi") {
|
||||
i18n.inputMethod.package = pkgs.nabi;
|
||||
|
||||
home.sessionVariables = {
|
||||
GTK_IM_MODULE = "nabi";
|
||||
QT_IM_MODULE = "nabi";
|
||||
XMODIFIERS = "@im=nabi";
|
||||
};
|
||||
|
||||
systemd.user.services.nabi-daemon = {
|
||||
Unit = {
|
||||
Description = "Nabi input method editor";
|
||||
PartOf = [ "graphical-session.desktop" ];
|
||||
};
|
||||
Service.ExecStart = "${pkgs.nabi}/bin/nabi";
|
||||
Install.WantedBy = [ "graphical-session.target" ];
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
45
modules/i18n/input-method/uim.nix
Normal file
45
modules/i18n/input-method/uim.nix
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let cfg = config.i18n.inputMethod.uim;
|
||||
in {
|
||||
options = {
|
||||
|
||||
i18n.inputMethod.uim = {
|
||||
toolbar = mkOption {
|
||||
type = types.enum [ "gtk" "gtk3" "gtk-systray" "gtk3-systray" "qt4" ];
|
||||
default = "gtk";
|
||||
example = "gtk-systray";
|
||||
description = ''
|
||||
Selected UIM toolbar.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
config = mkIf (config.i18n.inputMethod.enabled == "uim") {
|
||||
i18n.inputMethod.package = pkgs.uim;
|
||||
|
||||
home.sessionVariables = {
|
||||
GTK_IM_MODULE = "uim";
|
||||
QT_IM_MODULE = "uim";
|
||||
XMODIFIERS = "@im=uim";
|
||||
};
|
||||
|
||||
systemd.user.services.uim-daemon = {
|
||||
Unit = {
|
||||
Description = "Uim input method editor";
|
||||
PartOf = [ "graphical-session.desktop" ];
|
||||
};
|
||||
Service.ExecStart = toString
|
||||
(pkgs.writeShellScript "start-uim-xim-and-uim-toolbar" ''
|
||||
${pkgs.uim}/bin/uim-xim &
|
||||
${pkgs.uim}/bin/uim-toolbar-${cfg.toolbar}
|
||||
'');
|
||||
Install.WantedBy = [ "graphical-session.target" ];
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue