diff options
author | GY <20533356+importantblimp@users.noreply.github.com> | 2024-05-10 19:46:04 +1200 |
---|---|---|
committer | éclairevoyant <848000+eclairevoyant@users.noreply.github.com> | 2024-07-12 03:59:20 -0400 |
commit | bcc7eff2c580649de8f8c92faf0fc64141f7f026 (patch) | |
tree | 7c563e80ac64005ef2e2fd67b8dd594b8713d253 /nixos/modules/i18n/input-method | |
parent | d253e9a94dad82c610a9d8ceb660645d164f6e6a (diff) |
nixos/input-method: deprecate .enabled option; add .type and .enable options
This commit introduces two new properties:
`enable` and `type`, to replace the `enabled` property.
`enable` has the same meaning as is common across nixpkgs.
`type` has the same meaning as the existing `enabled` property.
`enabled` property is now deprecated and will be removed in a future release.
Fixes #180654
Diffstat (limited to 'nixos/modules/i18n/input-method')
-rw-r--r-- | nixos/modules/i18n/input-method/default.md | 18 | ||||
-rw-r--r-- | nixos/modules/i18n/input-method/default.nix | 20 | ||||
-rw-r--r-- | nixos/modules/i18n/input-method/fcitx5.nix | 6 | ||||
-rw-r--r-- | nixos/modules/i18n/input-method/hime.nix | 6 | ||||
-rw-r--r-- | nixos/modules/i18n/input-method/ibus.nix | 5 | ||||
-rw-r--r-- | nixos/modules/i18n/input-method/kime.nix | 5 | ||||
-rw-r--r-- | nixos/modules/i18n/input-method/nabi.nix | 5 | ||||
-rw-r--r-- | nixos/modules/i18n/input-method/uim.nix | 5 |
8 files changed, 51 insertions, 19 deletions
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 c82f0099253b..7431d5e20d4a 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 = types.package // { name = "ibus-engine"; @@ -52,7 +53,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 = { |