From 79c424e08e72854e103dec4aec597de8781fb0bb Mon Sep 17 00:00:00 2001 From: ryan4yin Date: Sun, 7 May 2023 17:48:26 +0800 Subject: [PATCH] feat: try to fix fcitx5 --- flake.lock | 63 ++++-------------- flake.nix | 22 +++--- home/default.nix | 1 - home/fcitx5/default.nix | 28 -------- home/hyprland/default.nix | 13 +++- home/hyprland/hypr-conf/hyprland.conf | 8 +++ home/programs/browsers.nix | 2 +- home/programs/default.nix | 2 +- hosts/msi-rtx4090/default.nix | 1 + hosts/nixos-test/default.nix | 1 + {home => modules}/fcitx5/README.md | 0 modules/fcitx5/default.nix | 28 ++++++++ .../share/rime-data/build/flypy.prism.bin | Bin .../share/rime-data/build/flypy.reverse.bin | Bin .../share/rime-data/build/flypy.table.bin | Bin .../share/rime-data/build/flypydz.prism.bin | Bin .../share/rime-data/build/flypydz.reverse.bin | Bin .../share/rime-data/build/flypydz.table.bin | Bin .../share/rime-data/default.yaml | 0 .../share/rime-data/flypy.schema.yaml | 0 .../share/rime-data/flypy_full全码字.txt | 0 .../share/rime-data/flypy_sys.txt | 0 .../share/rime-data/flypy_top.txt | 0 .../share/rime-data/flypy_user.txt | 0 .../rime-data/lua/calculator_translator.lua | 0 .../rime-data-flypy/share/rime-data/rime.lua | 0 .../share/rime-data/squirrel.custom.yaml | 0 .../share/rime-data/squirrel.yaml | 0 28 files changed, 76 insertions(+), 93 deletions(-) delete mode 100644 home/fcitx5/default.nix rename {home => modules}/fcitx5/README.md (100%) create mode 100644 modules/fcitx5/default.nix rename {home => modules}/fcitx5/rime-data-flypy/share/rime-data/build/flypy.prism.bin (100%) rename {home => modules}/fcitx5/rime-data-flypy/share/rime-data/build/flypy.reverse.bin (100%) rename {home => modules}/fcitx5/rime-data-flypy/share/rime-data/build/flypy.table.bin (100%) rename {home => modules}/fcitx5/rime-data-flypy/share/rime-data/build/flypydz.prism.bin (100%) rename {home => modules}/fcitx5/rime-data-flypy/share/rime-data/build/flypydz.reverse.bin (100%) rename {home => modules}/fcitx5/rime-data-flypy/share/rime-data/build/flypydz.table.bin (100%) rename {home => modules}/fcitx5/rime-data-flypy/share/rime-data/default.yaml (100%) rename {home => modules}/fcitx5/rime-data-flypy/share/rime-data/flypy.schema.yaml (100%) rename {home => modules}/fcitx5/rime-data-flypy/share/rime-data/flypy_full全码字.txt (100%) rename {home => modules}/fcitx5/rime-data-flypy/share/rime-data/flypy_sys.txt (100%) rename {home => modules}/fcitx5/rime-data-flypy/share/rime-data/flypy_top.txt (100%) rename {home => modules}/fcitx5/rime-data-flypy/share/rime-data/flypy_user.txt (100%) rename {home => modules}/fcitx5/rime-data-flypy/share/rime-data/lua/calculator_translator.lua (100%) rename {home => modules}/fcitx5/rime-data-flypy/share/rime-data/rime.lua (100%) rename {home => modules}/fcitx5/rime-data-flypy/share/rime-data/squirrel.custom.yaml (100%) rename {home => modules}/fcitx5/rime-data-flypy/share/rime-data/squirrel.yaml (100%) diff --git a/flake.lock b/flake.lock index 309dd7b8..4d2cc084 100644 --- a/flake.lock +++ b/flake.lock @@ -38,21 +38,6 @@ } }, "flake-utils": { - "locked": { - "lastModified": 1638122382, - "narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "74f7e4319258e287b0f9cb95426c9853b282730b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_2": { "inputs": { "systems": "systems" }, @@ -77,11 +62,11 @@ ] }, "locked": { - "lastModified": 1683276747, - "narHash": "sha256-T3st1VBg3wmhHyBQb0z12sTSGsQgiu3mxkS61nLO8Xs=", + "lastModified": 1683456233, + "narHash": "sha256-BUclM2YmS0rpkSlHSvJ+5aWTu+OcjFiI4iIMRt9qCuI=", "owner": "nix-community", "repo": "home-manager", - "rev": "669669fcb403e3137dfe599bbcc26e60502c3543", + "rev": "990b82ecd31f6372bc4c3f39a9171961bc370a22", "type": "github" }, "original": { @@ -134,7 +119,7 @@ }, "lib-aggregate": { "inputs": { - "flake-utils": "flake-utils_2", + "flake-utils": "flake-utils", "nixpkgs-lib": "nixpkgs-lib" }, "locked": { @@ -170,27 +155,6 @@ "type": "github" } }, - "nixos-cn": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1682818384, - "narHash": "sha256-l8jh9BQj6nfjPDYGyrZkZwX1GaOqBX+pBHU+7fFZU3w=", - "owner": "nixos-cn", - "repo": "flakes", - "rev": "2d475ec68cca251ef6c6c69a9224db5c264c5e5b", - "type": "github" - }, - "original": { - "owner": "nixos-cn", - "repo": "flakes", - "type": "github" - } - }, "nixpkgs": { "locked": { "lastModified": 1683014792, @@ -246,11 +210,11 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1683409501, - "narHash": "sha256-FyLWNsqwp0iZ3EfRqocC/V3Unm0ENVGByyd4dKFRhcI=", + "lastModified": 1683454517, + "narHash": "sha256-T3ObyRj1BsR0MZfIqZ/y8dSqRBeRBulrnWYiFQaz98o=", "owner": "nix-community", "repo": "nixpkgs-wayland", - "rev": "19019499709f728a33b91686dc4b8bb5fd391b8d", + "rev": "e40b5d9061325d66acb598e0ae7038ca149d626d", "type": "github" }, "original": { @@ -261,11 +225,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1683286087, - "narHash": "sha256-xseOd7W7xwF5GOF2RW8qhjmVGrKoBz+caBlreaNzoeI=", + "lastModified": 1683408522, + "narHash": "sha256-9kcPh6Uxo17a3kK3XCHhcWiV1Yu1kYj22RHiymUhMkU=", "owner": "nixos", "repo": "nixpkgs", - "rev": "3e313808bd2e0a0669430787fb22e43b2f4bf8bf", + "rev": "897876e4c484f1e8f92009fd11b7d988a121a4e7", "type": "github" }, "original": { @@ -293,11 +257,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1683286087, - "narHash": "sha256-xseOd7W7xwF5GOF2RW8qhjmVGrKoBz+caBlreaNzoeI=", + "lastModified": 1683408522, + "narHash": "sha256-9kcPh6Uxo17a3kK3XCHhcWiV1Yu1kYj22RHiymUhMkU=", "owner": "nixos", "repo": "nixpkgs", - "rev": "3e313808bd2e0a0669430787fb22e43b2f4bf8bf", + "rev": "897876e4c484f1e8f92009fd11b7d988a121a4e7", "type": "github" }, "original": { @@ -311,7 +275,6 @@ "inputs": { "home-manager": "home-manager", "hyprland": "hyprland", - "nixos-cn": "nixos-cn", "nixpkgs": "nixpkgs_2", "nixpkgs-stable": "nixpkgs-stable", "nixpkgs-wayland": "nixpkgs-wayland" diff --git a/flake.nix b/flake.nix index 435c8d35..b7349496 100644 --- a/flake.nix +++ b/flake.nix @@ -19,13 +19,13 @@ extra-substituters = [ "https://nix-community.cachix.org" "https://nixpkgs-wayland.cachix.org" - "https://nixos-cn.cachix.org" + # "https://nixos-cn.cachix.org" ]; extra-trusted-public-keys = [ "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" "nixpkgs-wayland.cachix.org-1:3lwxaILxMRkVhehr5StQprHdEo4IrE8sRho9R9HOLYA=" - "nixos-cn.cachix.org-1:L0jEaL6w7kwQOPlLoCR3ADx+E3Q8SEFEcB9Jaibl0Xg=" + # "nixos-cn.cachix.org-1:L0jEaL6w7kwQOPlLoCR3ADx+E3Q8SEFEcB9Jaibl0Xg=" ]; }; @@ -47,12 +47,12 @@ # community wayland nixpkgs nixpkgs-wayland.url = "github:nix-community/nixpkgs-wayland"; - # nixos-cn 提供了一些国内常用的程序包,如 qq wechat dingtalk 等 - nixos-cn = { - url = "github:nixos-cn/flakes"; - # 强制 nixos-cn 和该 flake 使用相同版本的 nixpkgs - inputs.nixpkgs.follows = "nixpkgs"; - }; + # # nixos-cn 提供了一些国内常用的程序包,如 qq wechat dingtalk 等 + # nixos-cn = { + # url = "github:nixos-cn/flakes"; + # # 强制 nixos-cn 和该 flake 使用相同版本的 nixpkgs + # inputs.nixpkgs.follows = "nixpkgs"; + # }; }; # outputs 的参数都是 inputs 中定义的依赖项,可以通过它们的名称来引用。 @@ -63,7 +63,7 @@ nixpkgs, nixpkgs-stable, home-manager, - nixos-cn, + # nixos-cn, ... }: { # 名为 nixosConfigurations 的 outputs 会在执行 `nixos-rebuild switch --flake .` 时被使用 @@ -88,7 +88,7 @@ # nix flake 的 modules 系统可将配置模块化,提升配置的可维护性 # 默认只能传上面这四个参数,如果需要传其他参数,必须使用 specialArgs specialArgs = { - inherit nixos-cn; + # inherit nixos-cn; inherit nixpkgs-stable; }; modules = [ @@ -121,7 +121,7 @@ system = "x86_64-linux"; specialArgs = { - inherit nixos-cn; + # inherit nixos-cn; inherit nixpkgs-stable; }; modules = [ diff --git a/home/default.nix b/home/default.nix index ac589f0b..814a5ae4 100644 --- a/home/default.nix +++ b/home/default.nix @@ -3,7 +3,6 @@ { imports = [ - ./fcitx5 ./hyprland ./programs ./rofi diff --git a/home/fcitx5/default.nix b/home/fcitx5/default.nix deleted file mode 100644 index 4ab94352..00000000 --- a/home/fcitx5/default.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ config, pkgs, ... }: - -{ - i18n.inputMethod = { - enabled = "fcitx5"; - fcitx5.addons = - let - # 为了不使用默认的 rime-data,改用我自定义的小鹤音形数据,这里需要 override - # 参考 https://github.com/NixOS/nixpkgs/blob/e4246ae1e7f78b7087dce9c9da10d28d3725025f/pkgs/tools/inputmethods/fcitx5/fcitx5-rime.nix - config.packageOverrides = pkgs: { - fcitx5-rime = pkgs.fcitx5-rime.override {rimeDataPkgs = [ - # 小鹤音形配置,配置来自 flypy.com 官方网盘的鼠须管配置压缩包「小鹤音形“鼠须管”for macOS.zip」 - # 我仅修改了 default.yaml 文件,将其中的半角括号改为了直角括号「 与 」。 - ./rime-data-flypy - ];}; - }; - in - with pkgs; [ - # for flypy chinese input method - fcitx5-rime - # needed enable rime using configtool after installed - fcitx5-configtool - # fcitx5-chinese-addons - # fcitx5-mozc # japanese input method - fcitx5-gtk # gtk im module - ]; - }; -} diff --git a/home/hyprland/default.nix b/home/hyprland/default.nix index d706505c..028c3e59 100644 --- a/home/hyprland/default.nix +++ b/home/hyprland/default.nix @@ -17,6 +17,7 @@ systemd.user.sessionVariables = { "NIXOS_OZONE_WL" = "1"; # for any ozone-based browser & electron apps to run on wayland "MOZ_ENABLE_WAYLAND" = "1"; # for firefox to run on wayland + "MOZ_WEBRENDER" = "1"; # for hyprland with nvidia gpu, ref https://wiki.hyprland.org/Nvidia/ "LIBVA_DRIVER_NAME" = "nvidia"; @@ -24,5 +25,15 @@ "GBM_BACKEND" = "nvidia-drm"; "__GLX_VENDOR_LIBRARY_NAME" = "nvidia"; "WLR_NO_HARDWARE_CURSORS" = "1"; + "WLR_EGL_NO_MODIFIRES" = "1"; + + # copy from https://github.com/nix-community/home-manager/blob/master/modules/i18n/input-method/fcitx5.nix + GLFW_IM_MODULE = "fcitx"; + GTK_IM_MODULE = "fcitx"; + QT_IM_MODULE = "fcitx"; + XMODIFIERS = "@im=fcitx"; + INPUT_METHOD = "fcitx"; + IMSETTINGS_MODULE = "fcitx"; }; -} \ No newline at end of file +} + diff --git a/home/hyprland/hypr-conf/hyprland.conf b/home/hyprland/hypr-conf/hyprland.conf index 4788db50..721c28b9 100644 --- a/home/hyprland/hypr-conf/hyprland.conf +++ b/home/hyprland/hypr-conf/hyprland.conf @@ -190,3 +190,11 @@ bind=SUPER,mouse_up,workspace,e-1 #-- Startup ---------------------------------------------------- exec-once=~/.config/hypr/scripts/startup + + +#-- Fcitx5 input method ---------------------------------------------------- +windowrule=pseudo,fcitx +exec-once=fcitx5-remote -r +exec-once=fcitx5 -d --replace +exec-once=fcitx5-remote -r +bind=ALT,E,exec,pkill fcitx5 -9;sleep 1;fcitx5 -d --replace; sleep 1;fcitx5-remote -r \ No newline at end of file diff --git a/home/programs/browsers.nix b/home/programs/browsers.nix index 45a0bbf8..1dc307f4 100644 --- a/home/programs/browsers.nix +++ b/home/programs/browsers.nix @@ -7,7 +7,7 @@ pkgs-stable = import nixpkgs-stable { system = pkgs.system; config.allowUnfree = true; -}; + }; in { home.packages = with pkgs-stable; [ firefox-wayland diff --git a/home/programs/default.nix b/home/programs/default.nix index 5a6729f4..96ea884d 100644 --- a/home/programs/default.nix +++ b/home/programs/default.nix @@ -8,7 +8,7 @@ ./common.nix ./git.nix ./media.nix - ./nixos-cn.nix + # ./nixos-cn.nix ./xdg.nix ]; } \ No newline at end of file diff --git a/hosts/msi-rtx4090/default.nix b/hosts/msi-rtx4090/default.nix index 25164021..1955c2a6 100644 --- a/hosts/msi-rtx4090/default.nix +++ b/hosts/msi-rtx4090/default.nix @@ -9,6 +9,7 @@ [ ../../modules/system.nix ../../modules/hyprland.nix + ../../modules/fcitx5 # Include the results of the hardware scan. ./hardware-configuration.nix diff --git a/hosts/nixos-test/default.nix b/hosts/nixos-test/default.nix index 059f6d98..c6c28552 100644 --- a/hosts/nixos-test/default.nix +++ b/hosts/nixos-test/default.nix @@ -9,6 +9,7 @@ [ ../../modules/system.nix ../../modules/hyprland.nix + ../../modules/fcitx5 # Include the results of the hardware scan. ./hardware-configuration.nix diff --git a/home/fcitx5/README.md b/modules/fcitx5/README.md similarity index 100% rename from home/fcitx5/README.md rename to modules/fcitx5/README.md diff --git a/modules/fcitx5/default.nix b/modules/fcitx5/default.nix new file mode 100644 index 00000000..9f31d596 --- /dev/null +++ b/modules/fcitx5/default.nix @@ -0,0 +1,28 @@ +{ config, pkgs, ... }: + +# related issues: https://github.com/hyprwm/Hyprland/discussions/421 +{ + # 为了不使用默认的 rime-data,改用我自定义的小鹤音形数据,这里需要 override + # 参考 https://github.com/NixOS/nixpkgs/blob/e4246ae1e7f78b7087dce9c9da10d28d3725025f/pkgs/tools/inputmethods/fcitx5/fcitx5-rime.nix + nixpkgs.overlays = [ + (self: super: { + # 小鹤音形配置,配置来自 flypy.com 官方网盘的鼠须管配置压缩包「小鹤音形“鼠须管”for macOS.zip」 + # 我仅修改了 default.yaml 文件,将其中的半角括号改为了直角括号「 与 」。 + rime-data = ./rime-data-flypy; + fcitx5-rime = super.fcitx5-rime.override { rimeDataPkgs = [ ./rime-data-flypy ]; }; + }) + ]; + + i18n.inputMethod = { + enabled = "fcitx5"; + fcitx5.addons = with pkgs; [ + # for flypy chinese input method + fcitx5-rime + # needed enable rime using configtool after installed + fcitx5-configtool + fcitx5-chinese-addons + # fcitx5-mozc # japanese input method + fcitx5-gtk # gtk im module + ]; + }; +} diff --git a/home/fcitx5/rime-data-flypy/share/rime-data/build/flypy.prism.bin b/modules/fcitx5/rime-data-flypy/share/rime-data/build/flypy.prism.bin similarity index 100% rename from home/fcitx5/rime-data-flypy/share/rime-data/build/flypy.prism.bin rename to modules/fcitx5/rime-data-flypy/share/rime-data/build/flypy.prism.bin diff --git a/home/fcitx5/rime-data-flypy/share/rime-data/build/flypy.reverse.bin b/modules/fcitx5/rime-data-flypy/share/rime-data/build/flypy.reverse.bin similarity index 100% rename from home/fcitx5/rime-data-flypy/share/rime-data/build/flypy.reverse.bin rename to modules/fcitx5/rime-data-flypy/share/rime-data/build/flypy.reverse.bin diff --git a/home/fcitx5/rime-data-flypy/share/rime-data/build/flypy.table.bin b/modules/fcitx5/rime-data-flypy/share/rime-data/build/flypy.table.bin similarity index 100% rename from home/fcitx5/rime-data-flypy/share/rime-data/build/flypy.table.bin rename to modules/fcitx5/rime-data-flypy/share/rime-data/build/flypy.table.bin diff --git a/home/fcitx5/rime-data-flypy/share/rime-data/build/flypydz.prism.bin b/modules/fcitx5/rime-data-flypy/share/rime-data/build/flypydz.prism.bin similarity index 100% rename from home/fcitx5/rime-data-flypy/share/rime-data/build/flypydz.prism.bin rename to modules/fcitx5/rime-data-flypy/share/rime-data/build/flypydz.prism.bin diff --git a/home/fcitx5/rime-data-flypy/share/rime-data/build/flypydz.reverse.bin b/modules/fcitx5/rime-data-flypy/share/rime-data/build/flypydz.reverse.bin similarity index 100% rename from home/fcitx5/rime-data-flypy/share/rime-data/build/flypydz.reverse.bin rename to modules/fcitx5/rime-data-flypy/share/rime-data/build/flypydz.reverse.bin diff --git a/home/fcitx5/rime-data-flypy/share/rime-data/build/flypydz.table.bin b/modules/fcitx5/rime-data-flypy/share/rime-data/build/flypydz.table.bin similarity index 100% rename from home/fcitx5/rime-data-flypy/share/rime-data/build/flypydz.table.bin rename to modules/fcitx5/rime-data-flypy/share/rime-data/build/flypydz.table.bin diff --git a/home/fcitx5/rime-data-flypy/share/rime-data/default.yaml b/modules/fcitx5/rime-data-flypy/share/rime-data/default.yaml similarity index 100% rename from home/fcitx5/rime-data-flypy/share/rime-data/default.yaml rename to modules/fcitx5/rime-data-flypy/share/rime-data/default.yaml diff --git a/home/fcitx5/rime-data-flypy/share/rime-data/flypy.schema.yaml b/modules/fcitx5/rime-data-flypy/share/rime-data/flypy.schema.yaml similarity index 100% rename from home/fcitx5/rime-data-flypy/share/rime-data/flypy.schema.yaml rename to modules/fcitx5/rime-data-flypy/share/rime-data/flypy.schema.yaml diff --git a/home/fcitx5/rime-data-flypy/share/rime-data/flypy_full全码字.txt b/modules/fcitx5/rime-data-flypy/share/rime-data/flypy_full全码字.txt similarity index 100% rename from home/fcitx5/rime-data-flypy/share/rime-data/flypy_full全码字.txt rename to modules/fcitx5/rime-data-flypy/share/rime-data/flypy_full全码字.txt diff --git a/home/fcitx5/rime-data-flypy/share/rime-data/flypy_sys.txt b/modules/fcitx5/rime-data-flypy/share/rime-data/flypy_sys.txt similarity index 100% rename from home/fcitx5/rime-data-flypy/share/rime-data/flypy_sys.txt rename to modules/fcitx5/rime-data-flypy/share/rime-data/flypy_sys.txt diff --git a/home/fcitx5/rime-data-flypy/share/rime-data/flypy_top.txt b/modules/fcitx5/rime-data-flypy/share/rime-data/flypy_top.txt similarity index 100% rename from home/fcitx5/rime-data-flypy/share/rime-data/flypy_top.txt rename to modules/fcitx5/rime-data-flypy/share/rime-data/flypy_top.txt diff --git a/home/fcitx5/rime-data-flypy/share/rime-data/flypy_user.txt b/modules/fcitx5/rime-data-flypy/share/rime-data/flypy_user.txt similarity index 100% rename from home/fcitx5/rime-data-flypy/share/rime-data/flypy_user.txt rename to modules/fcitx5/rime-data-flypy/share/rime-data/flypy_user.txt diff --git a/home/fcitx5/rime-data-flypy/share/rime-data/lua/calculator_translator.lua b/modules/fcitx5/rime-data-flypy/share/rime-data/lua/calculator_translator.lua similarity index 100% rename from home/fcitx5/rime-data-flypy/share/rime-data/lua/calculator_translator.lua rename to modules/fcitx5/rime-data-flypy/share/rime-data/lua/calculator_translator.lua diff --git a/home/fcitx5/rime-data-flypy/share/rime-data/rime.lua b/modules/fcitx5/rime-data-flypy/share/rime-data/rime.lua similarity index 100% rename from home/fcitx5/rime-data-flypy/share/rime-data/rime.lua rename to modules/fcitx5/rime-data-flypy/share/rime-data/rime.lua diff --git a/home/fcitx5/rime-data-flypy/share/rime-data/squirrel.custom.yaml b/modules/fcitx5/rime-data-flypy/share/rime-data/squirrel.custom.yaml similarity index 100% rename from home/fcitx5/rime-data-flypy/share/rime-data/squirrel.custom.yaml rename to modules/fcitx5/rime-data-flypy/share/rime-data/squirrel.custom.yaml diff --git a/home/fcitx5/rime-data-flypy/share/rime-data/squirrel.yaml b/modules/fcitx5/rime-data-flypy/share/rime-data/squirrel.yaml similarity index 100% rename from home/fcitx5/rime-data-flypy/share/rime-data/squirrel.yaml rename to modules/fcitx5/rime-data-flypy/share/rime-data/squirrel.yaml