Merge pull request #310708 from importantblimp/180654

nixos/input-method: deprecate .enabled option; add .type and .enable options
This commit is contained in:
éclairevoyant 2024-07-14 00:02:13 +00:00 committed by GitHub
commit 9665639708
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 60 additions and 21 deletions

View File

@ -11,7 +11,8 @@ On NixOS, you need to explicitly enable `ibus` with given engines before customi
```nix
{ pkgs, ... }: {
i18n.inputMethod = {
enabled = "ibus";
enable = true;
type = "ibus";
ibus.engines = with pkgs.ibus-engines; [ typing-booster ];
};
}

View File

@ -220,6 +220,9 @@
The derivation now installs "impl" headers selectively instead of by a wildcard.
Use `imgui.src` if you just want to access the unpacked sources.
- The `i18n.inputMethod` module introduces two new properties:
`enable` and `type`, for declaring whether to enable an alternative input method and defining which input method respectfully. The options available in `type` are the same as the existing `enabled` option. `enabled` is now deprecated, and will be removed in a future release.
- `security.pam.u2f` now follows RFC42.
All module options are now settable through the freeform `.settings`.

View File

@ -25,7 +25,8 @@ The following snippet can be used to configure IBus:
```nix
{
i18n.inputMethod = {
enabled = "ibus";
enable = true;
type = "ibus";
ibus.engines = with pkgs.ibus-engines; [ anthy hangul mozc ];
};
}
@ -81,7 +82,8 @@ The following snippet can be used to configure Fcitx:
```nix
{
i18n.inputMethod = {
enabled = "fcitx5";
enable = true;
type = "fcitx5";
fcitx5.addons = with pkgs; [ fcitx5-mozc fcitx5-hangul fcitx5-m17n ];
};
}
@ -119,7 +121,8 @@ The following snippet can be used to configure Nabi:
```nix
{
i18n.inputMethod = {
enabled = "nabi";
enable = true;
type = "nabi";
};
}
```
@ -134,7 +137,8 @@ The following snippet can be used to configure uim:
```nix
{
i18n.inputMethod = {
enabled = "uim";
enable = true;
type = "uim";
};
}
```
@ -154,7 +158,8 @@ The following snippet can be used to configure Hime:
```nix
{
i18n.inputMethod = {
enabled = "hime";
enable = true;
type = "hime";
};
}
```
@ -168,7 +173,8 @@ The following snippet can be used to configure Kime:
```nix
{
i18n.inputMethod = {
enabled = "kime";
enable = true;
type = "kime";
};
}
```

View File

@ -4,6 +4,8 @@ with lib;
let
cfg = config.i18n.inputMethod;
allowedTypes = types.enum [ "ibus" "fcitx5" "nabi" "uim" "hime" "kime" ];
gtk2_cache = pkgs.runCommand "gtk2-immodule.cache"
{ preferLocalBuild = true;
allowSubstitutes = false;
@ -28,10 +30,23 @@ in
{
options.i18n = {
inputMethod = {
enable = mkEnableOption "an additional input method type" // {
default = cfg.enabled != null;
defaultText = literalMD "`true` if the deprecated option `enabled` is set, false otherwise";
};
enabled = mkOption {
type = types.nullOr (types.enum [ "ibus" "fcitx5" "nabi" "uim" "hime" "kime" ]);
type = types.nullOr allowedTypes;
default = null;
example = "fcitx5";
description = "Deprecated - use `type` and `enable = true` instead";
};
type = mkOption {
type = types.nullOr allowedTypes;
default = cfg.enabled;
defaultText = literalMD "The value of the deprecated option `enabled`, defaulting to null";
example = "fcitx5";
description = ''
Select the enabled input method. Input methods is a software to input symbols that are not available on standard input devices.
@ -59,7 +74,8 @@ in
};
};
config = mkIf (cfg.enabled != null) {
config = mkIf cfg.enable {
warnings = optional (cfg.enabled != null) "i18n.inputMethod.enabled will be removed in a future release. Please use .type, and .enable = true instead";
environment.systemPackages = [ cfg.package gtk2_cache gtk3_cache ];
};

View File

@ -3,8 +3,8 @@
with lib;
let
im = config.i18n.inputMethod;
cfg = im.fcitx5;
imcfg = config.i18n.inputMethod;
cfg = imcfg.fcitx5;
fcitx5Package =
if cfg.plasma6Support
then pkgs.qt6Packages.fcitx5-with-addons.override { inherit (cfg) addons; }
@ -108,7 +108,7 @@ in
'')
];
config = mkIf (im.enabled == "fcitx5") {
config = mkIf (imcfg.enable && imcfg.type == "fcitx5") {
i18n.inputMethod.package = fcitx5Package;
i18n.inputMethod.fcitx5.addons = lib.optionals (cfg.quickPhrase != { }) [

View File

@ -1,8 +1,12 @@
{ config, pkgs, lib, ... }:
with lib;
let
imcfg = config.i18n.inputMethod;
in
{
config = mkIf (config.i18n.inputMethod.enabled == "hime") {
config = mkIf (imcfg.enable && imcfg.type == "hime") {
i18n.inputMethod.package = pkgs.hime;
environment.variables = {
GTK_IM_MODULE = "hime";

View File

@ -3,7 +3,8 @@
with lib;
let
cfg = config.i18n.inputMethod.ibus;
imcfg = config.i18n.inputMethod;
cfg = imcfg.ibus;
ibusPackage = pkgs.ibus-with-plugins.override { plugins = cfg.engines; };
ibusEngine = lib.types.mkOptionType {
name = "ibus-engine";
@ -53,7 +54,7 @@ in
};
};
config = mkIf (config.i18n.inputMethod.enabled == "ibus") {
config = mkIf (imcfg.enable && imcfg.type == "ibus") {
i18n.inputMethod.package = ibusPackage;
environment.systemPackages = [

View File

@ -1,5 +1,6 @@
{ config, pkgs, lib, generators, ... }:
let imcfg = config.i18n.inputMethod;
let
imcfg = config.i18n.inputMethod;
in {
imports = [
(lib.mkRemovedOptionModule [ "i18n" "inputMethod" "kime" "config" ] "Use i18n.inputMethod.kime.* instead")
@ -31,7 +32,7 @@ in {
};
};
config = lib.mkIf (imcfg.enabled == "kime") {
config = lib.mkIf (imcfg.enable && imcfg.type == "kime") {
i18n.inputMethod.package = pkgs.kime;
environment.variables = {

View File

@ -1,8 +1,11 @@
{ config, pkgs, lib, ... }:
with lib;
let
imcfg = config.i18n.inputMethod;
in
{
config = mkIf (config.i18n.inputMethod.enabled == "nabi") {
config = mkIf (imcfg.enable && imcfg.type == "nabi") {
i18n.inputMethod.package = pkgs.nabi;
environment.variables = {

View File

@ -3,7 +3,8 @@
with lib;
let
cfg = config.i18n.inputMethod.uim;
imcfg = config.i18n.inputMethod;
cfg = imcfg.uim;
in
{
options = {
@ -21,7 +22,7 @@ in
};
config = mkIf (config.i18n.inputMethod.enabled == "uim") {
config = mkIf (imcfg.enable && imcfg.type == "uim") {
i18n.inputMethod.package = pkgs.uim;
environment.variables = {

View File

@ -5,7 +5,10 @@ makeInstalledTest {
testConfig = {
i18n.supportedLocales = [ "all" ];
i18n.inputMethod.enabled = "ibus";
i18n.inputMethod = {
enable = true;
type = "ibus";
};
systemd.user.services.ibus-daemon = {
serviceConfig.ExecStart = "${pkgs.ibus}/bin/ibus-daemon --xim --verbose";
wantedBy = [ "graphical-session.target" ];