nixos/i18n.input-method: remove with lib;

This commit is contained in:
Felix Buehler 2024-08-24 22:05:32 +02:00
parent 0db2200f7e
commit 76dd427ca9

View file

@ -1,10 +1,8 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib;
let let
cfg = config.i18n.inputMethod; cfg = config.i18n.inputMethod;
allowedTypes = types.enum [ "ibus" "fcitx5" "nabi" "uim" "hime" "kime" ]; allowedTypes = lib.types.enum [ "ibus" "fcitx5" "nabi" "uim" "hime" "kime" ];
gtk2_cache = pkgs.runCommand "gtk2-immodule.cache" gtk2_cache = pkgs.runCommand "gtk2-immodule.cache"
{ preferLocalBuild = true; { preferLocalBuild = true;
@ -30,22 +28,22 @@ in
{ {
options.i18n = { options.i18n = {
inputMethod = { inputMethod = {
enable = mkEnableOption "an additional input method type" // { enable = lib.mkEnableOption "an additional input method type" // {
default = cfg.enabled != null; default = cfg.enabled != null;
defaultText = literalMD "`true` if the deprecated option `enabled` is set, false otherwise"; defaultText = lib.literalMD "`true` if the deprecated option `enabled` is set, false otherwise";
}; };
enabled = mkOption { enabled = lib.mkOption {
type = types.nullOr allowedTypes; type = lib.types.nullOr allowedTypes;
default = null; default = null;
example = "fcitx5"; example = "fcitx5";
description = "Deprecated - use `type` and `enable = true` instead"; description = "Deprecated - use `type` and `enable = true` instead";
}; };
type = mkOption { type = lib.mkOption {
type = types.nullOr allowedTypes; type = lib.types.nullOr allowedTypes;
default = cfg.enabled; default = cfg.enabled;
defaultText = literalMD "The value of the deprecated option `enabled`, defaulting to null"; defaultText = lib.literalMD "The value of the deprecated option `enabled`, defaulting to null";
example = "fcitx5"; example = "fcitx5";
description = '' description = ''
Select the enabled input method. Input methods is a software to input symbols that are not available on standard input devices. Select the enabled input method. Input methods is a software to input symbols that are not available on standard input devices.
@ -63,9 +61,9 @@ in
''; '';
}; };
package = mkOption { package = lib.mkOption {
internal = true; internal = true;
type = types.nullOr types.path; type = lib.types.nullOr lib.types.path;
default = null; default = null;
description = '' description = ''
The input method method package. The input method method package.
@ -74,8 +72,8 @@ in
}; };
}; };
config = mkIf cfg.enable { config = lib.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"; warnings = lib.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 ]; environment.systemPackages = [ cfg.package gtk2_cache gtk3_cache ];
}; };