diff --git a/doc/packages/ibus.section.md b/doc/packages/ibus.section.md index 817e55d56f1f..0e379723da12 100644 --- a/doc/packages/ibus.section.md +++ b/doc/packages/ibus.section.md @@ -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 ]; }; } diff --git a/nixos/doc/manual/release-notes/rl-2411.section.md b/nixos/doc/manual/release-notes/rl-2411.section.md index dd8bf4b4695d..a9e556fc895f 100644 --- a/nixos/doc/manual/release-notes/rl-2411.section.md +++ b/nixos/doc/manual/release-notes/rl-2411.section.md @@ -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`. diff --git a/nixos/modules/i18n/input-method/default.md b/nixos/modules/i18n/input-method/default.md index 6d12462b788e..8101717a4da7 100644 --- a/nixos/modules/i18n/input-method/default.md +++ b/nixos/modules/i18n/input-method/default.md @@ -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"; }; } ``` diff --git a/nixos/modules/i18n/input-method/default.nix b/nixos/modules/i18n/input-method/default.nix index 3b439c4231b3..15125ceb4a2d 100644 --- a/nixos/modules/i18n/input-method/default.nix +++ b/nixos/modules/i18n/input-method/default.nix @@ -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 ]; }; diff --git a/nixos/modules/i18n/input-method/fcitx5.nix b/nixos/modules/i18n/input-method/fcitx5.nix index bb6661e248f2..2678c4a39e4e 100644 --- a/nixos/modules/i18n/input-method/fcitx5.nix +++ b/nixos/modules/i18n/input-method/fcitx5.nix @@ -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 != { }) [ diff --git a/nixos/modules/i18n/input-method/hime.nix b/nixos/modules/i18n/input-method/hime.nix index 8482130db3e3..baf455bd2366 100644 --- a/nixos/modules/i18n/input-method/hime.nix +++ b/nixos/modules/i18n/input-method/hime.nix @@ -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"; diff --git a/nixos/modules/i18n/input-method/ibus.nix b/nixos/modules/i18n/input-method/ibus.nix index c44c86823599..4af848c72015 100644 --- a/nixos/modules/i18n/input-method/ibus.nix +++ b/nixos/modules/i18n/input-method/ibus.nix @@ -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 = [ diff --git a/nixos/modules/i18n/input-method/kime.nix b/nixos/modules/i18n/input-method/kime.nix index 1fea3aeccf0a..78f5698a8054 100644 --- a/nixos/modules/i18n/input-method/kime.nix +++ b/nixos/modules/i18n/input-method/kime.nix @@ -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 = { diff --git a/nixos/modules/i18n/input-method/nabi.nix b/nixos/modules/i18n/input-method/nabi.nix index 87620ae4e7b2..0eb9a7c825c8 100644 --- a/nixos/modules/i18n/input-method/nabi.nix +++ b/nixos/modules/i18n/input-method/nabi.nix @@ -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 = { diff --git a/nixos/modules/i18n/input-method/uim.nix b/nixos/modules/i18n/input-method/uim.nix index 6a636a771c1f..7517dead6b05 100644 --- a/nixos/modules/i18n/input-method/uim.nix +++ b/nixos/modules/i18n/input-method/uim.nix @@ -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 = { diff --git a/nixos/tests/installed-tests/ibus.nix b/nixos/tests/installed-tests/ibus.nix index 028c20c29f2d..8cae29112f98 100644 --- a/nixos/tests/installed-tests/ibus.nix +++ b/nixos/tests/installed-tests/ibus.nix @@ -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" ];