fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert HelgessonMerge PR #421575790441

master
2.4 KiB88 linesraw
1{ config, pkgs, lib, ... }:
2
3with lib;
4let
5
6  cfg = config.i18n.inputMethod;
7
8  gtk2Cache = pkgs.runCommandLocal "gtk2-immodule.cache" {
9    buildInputs = [ pkgs.gtk2 cfg.package ];
10  } ''
11    mkdir -p $out/etc/gtk-2.0/
12    GTK_PATH=${cfg.package}/lib/gtk-2.0/ \
13      gtk-query-immodules-2.0 > $out/etc/gtk-2.0/immodules.cache
14  '';
15
16  gtk3Cache = pkgs.runCommandLocal "gtk3-immodule.cache" {
17    buildInputs = [ pkgs.gtk3 cfg.package ];
18  } ''
19    mkdir -p $out/etc/gtk-3.0/
20    GTK_PATH=${cfg.package}/lib/gtk-3.0/ \
21      gtk-query-immodules-3.0 > $out/etc/gtk-3.0/immodules.cache
22  '';
23
24in {
25  imports = [ ./fcitx5.nix ./hime.nix ./kime.nix ./nabi.nix ./uim.nix ];
26
27  options.i18n = {
28    inputMethod = {
29      enabled = mkOption {
30        type = types.nullOr
31          (types.enum [ "fcitx" "fcitx5" "nabi" "uim" "hime" "kime" ]);
32        default = null;
33        example = "fcitx5";
34        description = ''
35          Select the enabled input method. Input methods are software to input
36          symbols that are not available on standard input devices.
37
38          Input methods are especially used to input Chinese, Japanese and
39          Korean characters.
40
41          Currently the following input methods are available in Home Manager:
42
43          `fcitx5`
44          : A customizable lightweight input method.
45            The next generation of fcitx.
46            Addons (including engines, dictionaries, skins) can be added using
47            [](#opt-i18n.inputMethod.fcitx5.addons).
48
49          `nabi`
50          : A Korean input method based on XIM. Nabi doesn't support Qt 5.
51
52          `uim`
53          : The "universal input method" is a library with an XIM bridge.
54            uim mainly supports Chinese, Japanese and Korean.
55
56          `hime`
57          : An extremely easy-to-use input method framework.
58
59          `kime`
60          : A Korean IME.
61        '';
62      };
63
64      package = mkOption {
65        internal = true;
66        type = types.nullOr types.path;
67        default = null;
68        description = ''
69          The input method method package.
70        '';
71      };
72    };
73  };
74
75  config = mkIf (cfg.enabled != null) {
76    assertions = [
77      (hm.assertions.assertPlatform "i18n.inputMethod" pkgs platforms.linux)
78      {
79        assertion = cfg.enabled != "fcitx";
80        message = "fcitx has been removed, please use fcitx5 instead";
81      }
82    ];
83
84    home.packages = [ cfg.package gtk2Cache gtk3Cache ];
85  };
86
87  meta.maintainers = with lib; [ hm.maintainers.kranzes ];
88}