From 865bef34355d7ad22141f44460ecf7f759f0ff77 Mon Sep 17 00:00:00 2001 From: "s.seidenath" Date: Sat, 7 Oct 2023 18:06:10 +0200 Subject: [PATCH] kime: fix configuration Switches the kime configuration format to use unstructured text. This is necessary since version 3 and upwards use YAML tags. --- modules/i18n/input-method/kime.nix | 46 +++++++++---------- .../i18n/input-method/kime-configuration.nix | 37 +++++++++++++-- 2 files changed, 56 insertions(+), 27 deletions(-) diff --git a/modules/i18n/input-method/kime.nix b/modules/i18n/input-method/kime.nix index 5608b54e..8b3ed757 100644 --- a/modules/i18n/input-method/kime.nix +++ b/modules/i18n/input-method/kime.nix @@ -1,34 +1,33 @@ -{ config, pkgs, lib, generators, ... }: -with lib; +{ config, pkgs, lib, ... }: + let + inherit (lib) literalExpression mkIf mkOption mkRemovedOptionModule types; + cfg = config.i18n.inputMethod.kime; - yamlFormat = pkgs.formats.yaml { }; in { + imports = [ + (mkRemovedOptionModule [ "i18n" "inputMethod" "kime" "config" ] '' + Please use 'i18n.inputMethod.kime.extraConfig' instead. + '') + ]; + options = { i18n.inputMethod.kime = { - config = mkOption { - type = yamlFormat.type; - default = { }; + extraConfig = mkOption { + type = types.lines; + default = ""; example = literalExpression '' - { - daemon = { - modules = ["Xim" "Indicator"]; - }; - - indicator = { - icon_color = "White"; - }; - - engine = { - hangul = { - layout = "dubeolsik"; - }; - }; - } + daemon: + modules: [Xim,Indicator] + indicator: + icon_color: White + engine: + hangul: + layout: dubeolsik ''; description = '' kime configuration. Refer to - + for details on supported values. ''; }; @@ -44,8 +43,7 @@ in { XMODIFIERS = "@im=kime"; }; - xdg.configFile."kime/config.yaml".text = - replaceStrings [ "\\\\" ] [ "\\" ] (builtins.toJSON cfg.config); + xdg.configFile."kime/config.yaml".text = cfg.extraConfig; systemd.user.services.kime-daemon = { Unit = { diff --git a/tests/modules/i18n/input-method/kime-configuration.nix b/tests/modules/i18n/input-method/kime-configuration.nix index fe50273f..b7969460 100644 --- a/tests/modules/i18n/input-method/kime-configuration.nix +++ b/tests/modules/i18n/input-method/kime-configuration.nix @@ -1,14 +1,45 @@ { config, pkgs, ... }: -{ +let + + kimeConfig = '' + daemon: + modules: [Xim,Indicator] + indicator: + icon_color: White + engine: + hangul: + layout: dubeolsik + ''; + +in { i18n.inputMethod = { enabled = "kime"; - kime.config = { engine = { hangul = { layout = "dubeolsik"; }; }; }; + kime.extraConfig = kimeConfig; }; - test.stubs.kime = { outPath = null; }; + test.stubs = { + kime = { outPath = null; }; + gtk2 = { + buildScript = '' + mkdir -p $out/bin + echo '#/usr/bin/env bash' > $out/bin/gtk-query-immodules-2.0 + chmod +x $out/bin/* + ''; + }; + gtk3 = { + buildScript = '' + mkdir -p $out/bin + echo '#/usr/bin/env bash' > $out/bin/gtk-query-immodules-3.0 + chmod +x $out/bin/* + ''; + }; + }; nmt.script = '' assertFileExists home-files/.config/systemd/user/kime-daemon.service + assertFileExists home-files/.config/kime/config.yaml + assertFileContent home-files/.config/kime/config.yaml \ + ${builtins.toFile "kime-expected.yaml" kimeConfig} ''; }