1{
2 config,
3 pkgs,
4 lib,
5 ...
6}:
7let
8 cfg = config.i18n.inputMethod;
9
10 allowedTypes = lib.types.enum [
11 "ibus"
12 "fcitx5"
13 "nabi"
14 "uim"
15 "hime"
16 "kime"
17 ];
18
19 gtk2_cache =
20 pkgs.runCommand "gtk2-immodule.cache"
21 {
22 preferLocalBuild = true;
23 allowSubstitutes = false;
24 buildInputs = [
25 pkgs.gtk2
26 cfg.package
27 ];
28 }
29 ''
30 mkdir -p $out/etc/gtk-2.0/
31 GTK_PATH=${cfg.package}/lib/gtk-2.0/ gtk-query-immodules-2.0 > $out/etc/gtk-2.0/immodules.cache
32 '';
33
34 gtk3_cache =
35 pkgs.runCommand "gtk3-immodule.cache"
36 {
37 preferLocalBuild = true;
38 allowSubstitutes = false;
39 buildInputs = [
40 pkgs.gtk3
41 cfg.package
42 ];
43 }
44 ''
45 mkdir -p $out/etc/gtk-3.0/
46 GTK_PATH=${cfg.package}/lib/gtk-3.0/ gtk-query-immodules-3.0 > $out/etc/gtk-3.0/immodules.cache
47 '';
48
49in
50{
51 options.i18n = {
52 inputMethod = {
53 enable = lib.mkEnableOption "an additional input method type" // {
54 default = cfg.enabled != null;
55 defaultText = lib.literalMD "`true` if the deprecated option `enabled` is set, false otherwise";
56 };
57
58 enabled = lib.mkOption {
59 type = lib.types.nullOr allowedTypes;
60 default = null;
61 example = "fcitx5";
62 description = "Deprecated - use `type` and `enable = true` instead";
63 };
64
65 type = lib.mkOption {
66 type = lib.types.nullOr allowedTypes;
67 default = cfg.enabled;
68 defaultText = lib.literalMD "The value of the deprecated option `enabled`, defaulting to null";
69 example = "fcitx5";
70 description = ''
71 Select the enabled input method. Input methods is a software to input symbols that are not available on standard input devices.
72
73 Input methods are specially used to input Chinese, Japanese and Korean characters.
74
75 Currently the following input methods are available in NixOS:
76
77 - ibus: The intelligent input bus, extra input engines can be added using `i18n.inputMethod.ibus.engines`.
78 - fcitx5: The next generation of fcitx, addons (including engines, dictionaries, skins) can be added using `i18n.inputMethod.fcitx5.addons`.
79 - nabi: A Korean input method based on XIM. Nabi doesn't support Qt 5.
80 - uim: The universal input method, is a library with a XIM bridge. uim mainly support Chinese, Japanese and Korean.
81 - hime: An extremely easy-to-use input method framework.
82 - kime: Koream IME.
83 '';
84 };
85
86 package = lib.mkOption {
87 internal = true;
88 type = lib.types.nullOr lib.types.path;
89 default = null;
90 description = ''
91 The input method method package.
92 '';
93 };
94
95 enableGtk2 = lib.mkEnableOption "Gtk2 support";
96
97 enableGtk3 = lib.mkEnableOption "Gtk3 support" // {
98 default = true;
99 };
100 };
101 };
102
103 config = lib.mkIf cfg.enable {
104 warnings =
105 lib.optional (cfg.enabled != null)
106 "i18n.inputMethod.enabled will be removed in a future release. Please use .type, and .enable = true instead";
107 environment.systemPackages =
108 [
109 cfg.package
110 ]
111 ++ lib.optional cfg.enableGtk2 gtk2_cache
112 ++ lib.optional cfg.enableGtk3 gtk3_cache;
113 };
114
115 meta = {
116 maintainers = with lib.maintainers; [ ];
117 doc = ./default.md;
118 };
119
120}