From e0bb6ff8dc262f3b6cc88be6a13b3e1ab95387c2 Mon Sep 17 00:00:00 2001 From: command_block Date: Tue, 11 Jun 2024 05:08:33 +0800 Subject: [PATCH] feat(nixos): add fcitx5 module Co-authored-by: Weathercold Co-authored-by: seth --- modules/nixos/all-modules.nix | 1 + modules/nixos/fcitx5.nix | 31 +++++++++++++++++++++++++++++++ tests/nixos.nix | 5 +++++ 3 files changed, 37 insertions(+) create mode 100644 modules/nixos/fcitx5.nix diff --git a/modules/nixos/all-modules.nix b/modules/nixos/all-modules.nix index de89b521..f74516ae 100644 --- a/modules/nixos/all-modules.nix +++ b/modules/nixos/all-modules.nix @@ -1,5 +1,6 @@ [ ./console.nix + ./fcitx5.nix ./globals.nix ./grub.nix ./plymouth.nix diff --git a/modules/nixos/fcitx5.nix b/modules/nixos/fcitx5.nix new file mode 100644 index 00000000..43dcc544 --- /dev/null +++ b/modules/nixos/fcitx5.nix @@ -0,0 +1,31 @@ +{ + config, + pkgs, + lib, + ... +}: +let + inherit (config.catppuccin) sources; + cfg = config.i18n.inputMethod.fcitx5.catppuccin; + enable = + cfg.enable + && ( + config.i18n.inputMethod.enable or true + && config.i18n.inputMethod.type or config.i18n.inputMethod.enabled == "fcitx5" + ); + + theme = pkgs.runCommand "catppuccin-fcitx5" { } '' + mkdir -p $out/share/fcitx5/themes/ + cp -r ${sources.fcitx5}/src/catppuccin-${cfg.flavor}-${cfg.accent}/ $out/share/fcitx5/themes/ + ''; +in +{ + options.i18n.inputMethod.fcitx5.catppuccin = lib.ctp.mkCatppuccinOpt { name = "Fcitx5"; } // { + accent = lib.ctp.mkAccentOpt "Fcitx5"; + }; + + config.i18n.inputMethod.fcitx5 = lib.mkIf enable { + addons = [ theme ]; + settings.addons.classicui.globalSection.Theme = "catppuccin-${cfg.flavor}-${cfg.accent}"; + }; +} diff --git a/tests/nixos.nix b/tests/nixos.nix index 9f39471e..22742488 100644 --- a/tests/nixos.nix +++ b/tests/nixos.nix @@ -26,6 +26,11 @@ testers.runNixOSTest { console.enable = true; + i18n.inputMethod = { + enable = true; + type = "fcitx5"; + }; + users.users.test = { isNormalUser = true; home = "/home/test";