Commit 337605d

HPCesia <me@hpcesia.com>
2025-10-03 14:29:15
refactor: migrate fcitx5
1 parent 62e18c4
Changed files (4)
home
linux
gui
modules
desktop
input-method
shell
plasma6
home/linux/gui/fcitx5/default.nix
@@ -1,28 +0,0 @@
-{pkgs, ...}: let
-  fcitx5-rime = pkgs.fcitx5-rime.override {
-    rimeDataPkgs = [pkgs.nur.repos.xyenon.rime-ice];
-  };
-in {
-  xdg.configFile = {
-    "fcitx5/profile" = {
-      source = ./profile;
-      # every time fcitx5 switch input method, it will modify ~/.config/fcitx5/profile,
-      # so we need to force replace it in every rebuild to avoid file conflict.
-      force = true;
-    };
-  };
-
-  i18n.inputMethod = {
-    enable = true;
-    type = "fcitx5";
-    fcitx5 = {
-      # To fix configtool in plasma6
-      fcitx5-with-addons = pkgs.qt6Packages.fcitx5-with-addons;
-      addons = with pkgs; [
-        fcitx5-rime
-        fcitx5-gtk # gtk im module
-      ];
-      waylandFrontend = true;
-    };
-  };
-}
modules/desktop/input-method/fcitx5/default.nix
@@ -0,0 +1,45 @@
+{lib, ...}: {
+  flake.modules.homeManager.desktop = {
+    pkgs,
+    config,
+    osConfig,
+    ...
+  }: let
+    fcitx5-rime = pkgs.fcitx5-rime.override {
+      rimeDataPkgs = [pkgs.nur.repos.xyenon.rime-ice];
+    };
+
+    hasPlasma =
+      osConfig.services.desktopManager.plasma6.enable
+      && lib.hasAttr "plasma" config.programs
+      && config.programs.plasma.enable;
+  in {
+    xdg.configFile = lib.mkIf pkgs.stdenv.hostPlatform.isLinux {
+      "fcitx5/profile" = {
+        source = ./profile;
+        # every time fcitx5 switch input method, it will modify ~/.config/fcitx5/profile,
+        # so we need to force replace it in every rebuild to avoid file conflict.
+        force = true;
+      };
+    };
+
+    i18n.inputMethod = lib.mkIf pkgs.stdenv.hostPlatform.isLinux {
+      enable = true;
+      type = "fcitx5";
+      fcitx5 = {
+        # To fix configtool in plasma6
+        fcitx5-with-addons = pkgs.qt6Packages.fcitx5-with-addons;
+        addons = with pkgs; [
+          fcitx5-rime
+          fcitx5-gtk # gtk im module
+        ];
+        waylandFrontend = true;
+      };
+    };
+
+    programs.plasma.configFile.kwinrc.Wayland.InputMethod = lib.mkIf hasPlasma {
+      shellExpand = true;
+      value = "/etc/profiles/per-user/hpcesia/share/applications/fcitx5-wayland-launcher.desktop";
+    };
+  };
+}
home/linux/gui/fcitx5/profile → modules/desktop/input-method/fcitx5/profile
File renamed without changes
modules/desktop/shell/plasma6/options/configs.nix
@@ -11,12 +11,6 @@
         Formats.LANG = "zh_CN.UTF-8";
         Translations.LANGUAGE = "zh_CN";
       };
-      kwinrc = {
-        Wayland.InputMethod = {
-          shellExpand = true;
-          value = "/etc/profiles/per-user/hpcesia/share/applications/fcitx5-wayland-launcher.desktop";
-        };
-      };
     };
   };
 }