mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
i18n.inputMethod: align enable option with nixos
see: https://github.com/NixOS/nixpkgs/pull/310708
This commit is contained in:
parent
7ef3137035
commit
585bae4bbb
11 changed files with 89 additions and 23 deletions
|
|
@ -4,11 +4,18 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
cfg = config.i18n.inputMethod;
|
cfg = config.i18n.inputMethod;
|
||||||
|
|
||||||
|
allowedTypes = lib.types.enum [
|
||||||
|
"fcitx"
|
||||||
|
"fcitx5"
|
||||||
|
"nabi"
|
||||||
|
"uim"
|
||||||
|
"hime"
|
||||||
|
"kime"
|
||||||
|
];
|
||||||
|
|
||||||
gtk2Cache =
|
gtk2Cache =
|
||||||
pkgs.runCommandLocal "gtk2-immodule.cache"
|
pkgs.runCommandLocal "gtk2-immodule.cache"
|
||||||
{
|
{
|
||||||
|
|
@ -36,7 +43,6 @@ let
|
||||||
GTK_PATH=${cfg.package}/lib/gtk-3.0/ \
|
GTK_PATH=${cfg.package}/lib/gtk-3.0/ \
|
||||||
gtk-query-immodules-3.0 > $out/etc/gtk-3.0/immodules.cache
|
gtk-query-immodules-3.0 > $out/etc/gtk-3.0/immodules.cache
|
||||||
'';
|
'';
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
|
|
@ -49,19 +55,23 @@ in
|
||||||
|
|
||||||
options.i18n = {
|
options.i18n = {
|
||||||
inputMethod = {
|
inputMethod = {
|
||||||
|
enable = lib.mkEnableOption "an additional input method type" // {
|
||||||
|
default = cfg.enabled != null;
|
||||||
|
defaultText = lib.literalMD "`true` if the deprecated option `enabled` is set, false otherwise";
|
||||||
|
};
|
||||||
|
|
||||||
enabled = lib.mkOption {
|
enabled = lib.mkOption {
|
||||||
type = lib.types.nullOr (
|
type = lib.types.nullOr allowedTypes;
|
||||||
lib.types.enum [
|
|
||||||
"fcitx"
|
|
||||||
"fcitx5"
|
|
||||||
"nabi"
|
|
||||||
"uim"
|
|
||||||
"hime"
|
|
||||||
"kime"
|
|
||||||
]
|
|
||||||
);
|
|
||||||
default = null;
|
default = null;
|
||||||
example = "fcitx5";
|
example = "fcitx5";
|
||||||
|
description = "Deprecated - use `type` and `enable = true` instead";
|
||||||
|
};
|
||||||
|
|
||||||
|
type = lib.mkOption {
|
||||||
|
type = lib.types.nullOr allowedTypes;
|
||||||
|
default = cfg.enabled;
|
||||||
|
defaultText = lib.literalMD "The value of the deprecated option `enabled`, defaulting to null";
|
||||||
|
example = "fcitx5";
|
||||||
description = ''
|
description = ''
|
||||||
Select the enabled input method. Input methods are software to input
|
Select the enabled input method. Input methods are software to input
|
||||||
symbols that are not available on standard input devices.
|
symbols that are not available on standard input devices.
|
||||||
|
|
@ -112,6 +122,10 @@ in
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
warnings =
|
||||||
|
lib.optional (cfg.enabled != null)
|
||||||
|
"i18n.inputMethod.enabled will be removed in a future release. Please use .type, and .enable = true instead";
|
||||||
|
|
||||||
home.packages = [
|
home.packages = [
|
||||||
cfg.package
|
cfg.package
|
||||||
gtk2Cache
|
gtk2Cache
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf (im.enabled == "fcitx5") {
|
config = lib.mkIf (im.enable && im.type == "fcitx5") {
|
||||||
i18n.inputMethod.package = fcitx5Package;
|
i18n.inputMethod.package = fcitx5Package;
|
||||||
|
|
||||||
home = {
|
home = {
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,11 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
let
|
||||||
|
im = config.i18n.inputMethod;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
config = lib.mkIf (config.i18n.inputMethod.enabled == "hime") {
|
config = lib.mkIf (im.enable && im.type == "hime") {
|
||||||
i18n.inputMethod.package = pkgs.hime;
|
i18n.inputMethod.package = pkgs.hime;
|
||||||
|
|
||||||
home.sessionVariables = {
|
home.sessionVariables = {
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ let
|
||||||
types
|
types
|
||||||
;
|
;
|
||||||
|
|
||||||
|
im = config.i18n.inputMethod;
|
||||||
cfg = config.i18n.inputMethod.kime;
|
cfg = config.i18n.inputMethod.kime;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
@ -46,7 +47,7 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf (config.i18n.inputMethod.enabled == "kime") {
|
config = mkIf (im.enable && im.type == "kime") {
|
||||||
i18n.inputMethod.package = pkgs.kime;
|
i18n.inputMethod.package = pkgs.kime;
|
||||||
|
|
||||||
home.sessionVariables = {
|
home.sessionVariables = {
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,11 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
let
|
||||||
|
im = config.i18n.inputMethod;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
config = lib.mkIf (config.i18n.inputMethod.enabled == "nabi") {
|
config = lib.mkIf (im.enable && im.type == "nabi") {
|
||||||
i18n.inputMethod.package = pkgs.nabi;
|
i18n.inputMethod.package = pkgs.nabi;
|
||||||
|
|
||||||
home.sessionVariables = {
|
home.sessionVariables = {
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.i18n.inputMethod.uim;
|
cfg = config.i18n.inputMethod.uim;
|
||||||
|
im = config.i18n.inputMethod;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
|
|
@ -30,7 +31,7 @@ in
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf (config.i18n.inputMethod.enabled == "uim") {
|
config = lib.mkIf (im.enable && im.type == "uim") {
|
||||||
i18n.inputMethod.package = pkgs.uim;
|
i18n.inputMethod.package = pkgs.uim;
|
||||||
|
|
||||||
home.sessionVariables = {
|
home.sessionVariables = {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
input-method-fcitx5-configuration = ./fcitx5-configuration.nix;
|
input-method-fcitx5-configuration = ./fcitx5-configuration.nix;
|
||||||
|
input-method-fcitx5-old-enable = ./fcitx5-configuration.nix;
|
||||||
input-method-kime-configuration = ./kime-configuration.nix;
|
input-method-kime-configuration = ./kime-configuration.nix;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,8 @@
|
||||||
|
|
||||||
lib.mkIf config.test.enableBig {
|
lib.mkIf config.test.enableBig {
|
||||||
i18n.inputMethod = {
|
i18n.inputMethod = {
|
||||||
enabled = "fcitx5";
|
enable = true;
|
||||||
|
type = "fcitx5";
|
||||||
fcitx5 = {
|
fcitx5 = {
|
||||||
waylandFrontend = true;
|
waylandFrontend = true;
|
||||||
themes.example = {
|
themes.example = {
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,8 @@ let
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
i18n.inputMethod = {
|
i18n.inputMethod = {
|
||||||
enabled = "kime";
|
enable = true;
|
||||||
|
type = "kime";
|
||||||
kime.extraConfig = kimeConfig;
|
kime.extraConfig = kimeConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
40
tests/modules/i18n/input-method/old-fcitx5-enable.nix
Normal file
40
tests/modules/i18n/input-method/old-fcitx5-enable.nix
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
realPkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
lib.mkIf config.test.enableBig {
|
||||||
|
i18n.inputMethod = {
|
||||||
|
enabled = "fcitx5";
|
||||||
|
fcitx5 = {
|
||||||
|
waylandFrontend = true;
|
||||||
|
themes.example = {
|
||||||
|
theme = ''
|
||||||
|
[Metadata]
|
||||||
|
Name=example
|
||||||
|
Version=0.1
|
||||||
|
Author=home-manager
|
||||||
|
Description=Theme for testing
|
||||||
|
ScaleWithDPI=True
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
classicUiConfig = "Theme=example";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
_module.args.pkgs = lib.mkForce realPkgs;
|
||||||
|
|
||||||
|
test.asserts.warnings.expected = [
|
||||||
|
"i18n.inputMethod.enabled will be removed in a future release. Please use .type, and .enable = true instead"
|
||||||
|
];
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.config/systemd/user/fcitx5-daemon.service
|
||||||
|
assertFileExists home-files/.local/share/fcitx5/themes/example/theme.conf
|
||||||
|
assertFileExists home-files/.local/share/fcitx5/conf/classicui.conf
|
||||||
|
assertFileNotRegex home-path/etc/profile.d/hm-session-vars.sh 'GTK_IM_MODULE'
|
||||||
|
assertFileNotRegex home-path/etc/profile.d/hm-session-vars.sh 'QT_IM_MODULE'
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
@ -6,7 +6,10 @@
|
||||||
platformTheme.name = "gtk";
|
platformTheme.name = "gtk";
|
||||||
};
|
};
|
||||||
|
|
||||||
i18n.inputMethod.enabled = "fcitx5";
|
i18n.inputMethod = {
|
||||||
|
enable = true;
|
||||||
|
type = "fcitx5";
|
||||||
|
};
|
||||||
|
|
||||||
nixpkgs.overlays = [
|
nixpkgs.overlays = [
|
||||||
(final: prev: {
|
(final: prev: {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue