summaryrefslogtreecommitdiffstats
path: root/nixos/modules/i18n/input-method/kime.nix
blob: c579731a965dc26d9feb4c9ad74bf428a2f59137 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{
  config,
  pkgs,
  lib,
  generators,
  ...
}:
let
  imcfg = config.i18n.inputMethod;
in
{
  imports = [
    (lib.mkRemovedOptionModule [
      "i18n"
      "inputMethod"
      "kime"
      "config"
    ] "Use i18n.inputMethod.kime.* instead")
  ];

  options.i18n.inputMethod.kime = {
    daemonModules = lib.mkOption {
      type = lib.types.listOf (
        lib.types.enum [
          "Xim"
          "Wayland"
          "Indicator"
        ]
      );
      default = [
        "Xim"
        "Wayland"
        "Indicator"
      ];
      example = [
        "Xim"
        "Indicator"
      ];
      description = ''
        List of enabled daemon modules
      '';
    };
    iconColor = lib.mkOption {
      type = lib.types.enum [
        "Black"
        "White"
      ];
      default = "Black";
      example = "White";
      description = ''
        Color of the indicator icon
      '';
    };
    extraConfig = lib.mkOption {
      type = lib.types.lines;
      default = "";
      description = ''
        extra kime configuration. Refer to <https://github.com/Riey/kime/blob/v${pkgs.kime.version}/docs/CONFIGURATION.md> for details on supported values.
      '';
    };
  };

  config = lib.mkIf (imcfg.enable && imcfg.type == "kime") {
    i18n.inputMethod.package = pkgs.kime;

    environment.variables = {
      GTK_IM_MODULE = "kime";
      QT_IM_MODULE = "kime";
      XMODIFIERS = "@im=kime";
    };

    environment.etc."xdg/kime/config.yaml".text = ''
      daemon:
        modules: [${lib.concatStringsSep "," imcfg.kime.daemonModules}]
      indicator:
        icon_color: ${imcfg.kime.iconColor}
    ''
    + imcfg.kime.extraConfig;
  };

  # uses attributes of the linked package
  meta.buildDocsInSandbox = false;
}