feat(rime): share the Rime config and user dictionary across Linux and macOS (#385)

* feat(rime): share the Rime config and user dictionary across Linux and macOS

Move the Rime data, preferences, and user dictionary into home/base/gui/rime so fcitx5-rime and Squirrel read the same files.

* feat(vinput): open the command palette with right Ctrl

Pin keyd's right-hand modifiers (rightcontrol/rightshift/rightmeta) to their own keycodes; keyd otherwise folds them into the left keys. Set Vinput's MenuKey to right Ctrl and clear CommandKeys, which would shadow it.

* feat(fcitx5): switch CN/EN with Ctrl+Space and right Shift

Clear AltTriggerKeys, whose Shift_L default toggled on left Shift. Left Shift is now a plain modifier and right Shift switches through the shared Rime config.
This commit is contained in:
ryan4yin | 二花 authored and GitHub committed 2026-10-05 22:43:20 +08:00
commit 85c51f5769
19 files changed
+215 -119

No files matched your search

+1 -1
View File
@@ -11,7 +11,7 @@ extend-exclude = [
"rime-data/",
# small-duck flypy user dictionary: entries are pinyin codes ("delt", "juli"),
# not English words, so the spell checker flags every one of them
"overlays/fcitx5/flypy_user.txt",
"home/base/gui/rime/flypy_user.txt",
]
[default]
+1
View File
@@ -36,6 +36,7 @@ A setting that works around a bug or a hardware quirk.
| WA-009 | USB-SATA bridge mitigations (`usbcore.autosuspend=-1`, `usb-storage.delay_use=10`) — `hosts/12kingdoms-youko/default.nix` | flaky JMicron JMS567 resets with UDMA-CRC and I/O errors | Drop once the bridge/controller is replaced; the signal is smartctl CRC/media errors | 2026-09-21 | on hardware change or CRC errors | active |
| WA-010 | Insta360 Link USB reset on S3 resume — `hosts/idols-ai/default.nix` | the camera stays enumerated with a stalled UVC endpoint after resume | Drop after the Insta360 firmware or the kernel `uvcvideo` fixes it | 2026-08-01 | on kernel or firmware change | active |
| WA-011 | Kernel module blacklist (`esp4`, `esp6`, `rxrpc`) — `hardening/kernel-hardening.nix` | attack surface for the Dirty Frag LPE (CVE-2026-43284 / CVE-2026-43500) | Kept as defence in depth; drop only if something needs those modules | 2026-10-03 | rarely | active |
| WA-017 | keyd right-hand modifier passthrough — `modules/nixos/desktop/peripherals.nix` | keyd folds right Ctrl/Shift/Meta into their left keys | Drop once keyd or fcitx5 keeps right-hand modifiers distinct | 2026-10-05 | on keyd bump | active |
If WA-008 freezes recur, the fallback is to restore
`nvme_core.default_ps_max_latency_us=0 nvme_core.io_timeout=4294967295 pcie_aspm=off`; this is a
Generated
+3 -3
View File
@@ -941,11 +941,11 @@
]
},
"locked": {
"lastModified": 1791100543,
"narHash": "sha256-DsuozPwOkBqrobxHGRdAkIJ/XH4RlkklDAdCRZPspIc=",
"lastModified": 1791202937,
"narHash": "sha256-80qCd/nbv2E2SybjMwzu9nQNXEkU14skcWj4tBpM/wo=",
"owner": "ryan4yin",
"repo": "nur-packages",
"rev": "f7b563dd38adf37579465b28bfa5f34305cb59f3",
"rev": "ff5441119f114a934578f8c092bd6d1d01696ae8",
"type": "github"
},
"original": {
+1
View File
@@ -27,6 +27,7 @@ systems.
- **dev-tools.nix**: Misc development and network tools (mitmproxy, wireshark)
- **media.nix**: Media players and utilities
- **zed-editor.nix**: Zed editor configuration (primary GUI editor)
- **rime/**: Rime (flypy) customisation shared by fcitx5-rime (Linux) and Squirrel (macOS)
- **terminal/**: Terminal emulator configurations
- **ghostty.nix**: Ghostty terminal (default)
- **kitty.nix**: Kitty terminal
+47
View File
@@ -0,0 +1,47 @@
# Rime (flypy) customisation
Personal Rime setup for the [flypy](https://flypy.com/) (小鹤音形) schema, shared by fcitx5-rime
(Linux) and Squirrel (macOS) so both behave the same.
## Files
- `flypy.custom.yaml`: the preferences, layered by Rime on top of the shared rime-data.
- `flypy_user.txt`: the user dictionary (custom phrases, symbols, missing characters).
- `default.nix`: per-platform wiring (see that file for the details).
The schema data comes from the `rime-data-flypy` package in `nur-ryan4yin` and stays untouched, so
updates survive. Personal preferences and the dictionary live here. On macOS the shared data
includes an empty `flypy_user.txt`, so the user files set `home.fileOverlapResolution = "override"`
to win over it.
## Preferences
- Right Shift switches CN/EN. Left Shift stays a plain modifier; Ctrl+Space also switches (fcitx5 on
Linux, the system input-source shortcut on macOS).
- Shift+Space does not toggle full/half width.
- `[ ] { }` produce corner brackets `「」『』`.
These sit in a schema-level patch rather than `default.custom.yaml` so they also override the
`default` preset and flypy's own bindings, and to avoid colliding with the `default.custom.yaml`
that ships in Squirrel's user directory.
## Hotkeys
The flypy schema brings its own bindings. Two worth remembering:
- Ctrl+J toggles simplified/traditional Chinese (简繁).
- Ctrl+. toggles Chinese/ASCII punctuation (中英标点).
## Applying changes
`flypy.custom.yaml` is a store symlink with an epoch mtime, so Rime does not redeploy when it
changes. Remove `build/` and reload:
```sh
# Linux
rm -rf ~/.local/share/fcitx5/rime/build
fcitx5-remote -r
# macOS: remove build/, then restart Squirrel
rm -rf ~/Library/Rime/build
```
+42
View File
@@ -0,0 +1,42 @@
{
inputs,
lib,
pkgs,
...
}:
let
# flypy (小鹤音形) rime data from nur-ryan4yin (`pkgs/rime-data-flypy`). The
# package stays pristine; personal preferences live in flypy.custom.yaml.
rime-data-flypy = inputs.nur-ryan4yin.packages.${pkgs.stdenv.hostPlatform.system}.rime-data-flypy;
# Personal Rime customisation, layered by Rime on top of the shared rime-data.
custom = ./flypy.custom.yaml;
# Manually maintained user dictionary (custom phrases, symbols, missing
# characters); Rime reads it from the user directory.
user-dict = ./flypy_user.txt;
in
lib.mkMerge [
# Linux: fcitx5-rime, with its user directory in ~/.local/share/fcitx5/rime.
(lib.mkIf pkgs.stdenv.hostPlatform.isLinux {
# Chinese: flypy (小鹤音形) data instead of the default rime-data.
i18n.inputMethod.fcitx5.addons = [
(pkgs.fcitx5-rime.override { rimeDataPkgs = [ rime-data-flypy ]; })
];
xdg.dataFile."fcitx5/rime/flypy.custom.yaml".source = custom;
xdg.dataFile."fcitx5/rime/flypy_user.txt".source = user-dict;
})
# macOS: Squirrel reads shared data from ~/Library/Rime, so link the data there.
# Its `flypy_user.txt` template overlaps our dictionary, so the regular files
# below must win. This is the only recursive link in the configuration.
(lib.mkIf pkgs.stdenv.hostPlatform.isDarwin {
home.fileOverlapResolution = "override";
home.file."Library/Rime" = {
source = "${rime-data-flypy}/share/rime-data";
recursive = true;
# overwrite possible existing data dynamically generated by squirrel
force = true;
};
home.file."Library/Rime/flypy.custom.yaml".source = custom;
home.file."Library/Rime/flypy_user.txt".source = user-dict;
})
]
+52
View File
@@ -0,0 +1,52 @@
# Personal Rime customisation for the flypy (小鹤音形) schema, layered on top of
# the shared rime-data by Rime's <schema>.custom.yaml mechanism. See README.md.
patch:
# Right Shift switches CN/EN; left Shift stays a plain modifier. The stock
# flypy schema switches on Shift_L, so keep the explicit noop. Ctrl+Space also
# switches (fcitx5 on Linux; the system input-source shortcut on macOS).
ascii_composer/switch_key/Shift_L: noop
ascii_composer/switch_key/Shift_R: commit_code
# Disable the stock `Shift+space -> toggle full_shape` binding. flypy declares
# its own copy after the one imported from `default`, so the override must be a
# schema-level `bindings/+` (appended last, highest priority) with `unset_option`.
key_binder/bindings/+:
- { when: always, accept: "Shift+space", unset_option: full_shape }
# Prefer corner brackets over the upstream `【】{}` for [ ] { }.
"punctuator/full_shape/[":
- 「
- 【
- 〔
- [
"punctuator/full_shape/]":
- 」
- 】
- 〕
- ]
"punctuator/full_shape/{":
- 『
- 〖
- {
"punctuator/full_shape/}":
- 』
- 〗
- }
"punctuator/half_shape/[":
- 「
- 【
- 〔
- [
"punctuator/half_shape/]":
- 」
- 】
- 〕
- ]
"punctuator/half_shape/{":
- 『
- 〖
- {
"punctuator/half_shape/}":
- 』
- 〗
- }
File renamed without changes.
-2
View File
@@ -9,8 +9,6 @@ This directory contains macOS-specific Home Manager configurations for Darwin sy
- **default.nix**: Entry point that imports all Darwin configurations
- **shell.nix**: Shell configurations and environment settings
- **terminal.nix**: Sets a 15px font size across Ghostty and Kitty
- **rime-squirrel.nix**: [Rime Squirrel](https://github.com/rime/squirrel) input method
configuration
### Network Configuration
-12
View File
@@ -1,12 +0,0 @@
{ pkgs, ... }:
{
# Squirrel Input Method
home.file."Library/Rime" = {
# my custom squirrel data (flypy input method)
source = "${pkgs.flypy-squirrel}/share/rime-data";
recursive = true;
# overwrite possible existing data dynamically generated by squirrel
# https://github.com/nix-community/home-manager/blob/release-23.05/modules/lib/file-type.nix#L101-L111
force = true;
};
}
+14 -1
View File
@@ -2,11 +2,24 @@
fcitx5 is enabled in `default.nix` with the [flypy](https://flypy.com/) Rime schema (Chinese),
`fcitx5-mozc-ut` (Japanese), and `fcitx5-hangul` (Korean), alongside the US keyboard layouts. The
Rime data ships in the [`overlays/fcitx5`](../../../../../overlays/fcitx5/) overlay.
Rime data comes from the `rime-data-flypy` package in `nur-ryan4yin` (`pkgs/rime-data-flypy`); the
whole Rime configuration, including the `fcitx5-rime` addon and the user customisation shared with
macOS, lives in `home/base/gui/rime/` (see its README).
## Available Configurations
- `fcitx5/config` (global config) → `~/.config/fcitx5/config`; pins `AltTriggerKeys` (see below).
- `profile` → Symlink will be created at: `~/.config/fcitx5/profile`
- `mozc-config1.db` (Mozc config) → Symlink will be created at: `~/.config/mozc/config1.db`
- Main changes from the defaults: use half-width for all alphabets, numbers, and punctuation.
- https://github.com/google/mozc/blob/2.30.5544.102/docs/configurations.md
## Shift keys
- Right Shift: switch CN/EN, through Rime.
- Left Shift: plain modifier.
- Ctrl+Space: switch CN/EN (fcitx5's `TriggerKeys`).
fcitx5's `AltTriggerKeys` (the "temporarily toggle input method" hotkey) defaults to `Shift_L`, so
it would toggle on left Shift; it is empty here. The Rime side, `Shift_R` as `commit_code` and
`Shift_L` as `noop`, is in `home/base/gui/rime/flypy.custom.yaml` (shared with macOS).
+18 -10
View File
@@ -1,4 +1,8 @@
{ config, pkgs, ... }:
{
config,
pkgs,
...
}:
{
catppuccin.fcitx5.enable = false;
xdg.configFile = {
@@ -8,16 +12,20 @@
# so we need to force replace it in every rebuild to avoid file conflict.
force = true;
};
# `AltTriggerKeys` (the "temporarily toggle input method" hotkey) would
# toggle on left Shift, its default being Shift_L. Keep it empty so only
# right Shift (through Rime) and Ctrl+Space switch CN/EN. force = true
# because fcitx5 rewrites this file at runtime, like `profile`.
"fcitx5/config" = {
text = ''
[Hotkey/AltTriggerKeys]
'';
force = true;
};
"mozc/config1.db".source =
config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/nix-config/home/linux/gui/base/fcitx5/mozc-config1.db";
};
xdg.dataFile."fcitx5/rime/default.custom.yaml".text = ''
patch:
ascii_composer/switch_key/Shift_L: noop
ascii_composer/switch_key/Shift_R: commit_code
'';
i18n.inputMethod = {
enable = true;
type = "fcitx5";
@@ -26,9 +34,9 @@
qt6Packages.fcitx5-configtool # GUI for fcitx5
fcitx5-gtk # gtk im module
# Chinese
fcitx5-rime # for flypy chinese input method
# fcitx5-chinese-addons # we use rime instead
# Chinese: the flypy (小鹤音形) fcitx5-rime addon is wired in
# home/base/gui/rime/default.nix, which is also where the rime-data-flypy
# package is resolved. fcitx5-chinese-addons is not used.
# Japanese
# ctrl-i / F7 - convert to takakana
+12 -3
View File
@@ -1,8 +1,17 @@
# Fcitx5 Vinput
On `ai` and `shoukei`, install a Sherpa-ONNX model, then hold and release **right Alt** to dictate.
**Right Shift** toggles Chinese/English; **left Shift** remains a normal modifier. Open Vinput from
the application launcher for settings.
Voice input on `ai` and `shoukei`, backed by a Sherpa-ONNX model. Open Vinput from the application
launcher for settings.
## Key bindings
- Right Alt: record. Hold and release to dictate.
- Right Ctrl: open the command palette (`/model /asr /scene /proc`).
Vinput resolves `TriggerKey` > `CommandKeys` > `MenuKey`. `TriggerKey` is right Alt by default; the
config sets `MenuKey` to right Ctrl and clears `CommandKeys`, which otherwise defaults to right Ctrl
and would shadow `MenuKey`. The addon reads list options as `[Option]` plus `0=`, not the
`[Trigger]` shorthand in upstream's `vinput-config(5)` man page.
## One-time setup (CLI)
+9 -2
View File
@@ -15,11 +15,18 @@ in
config = lib.mkIf cfg.enable {
i18n.inputMethod.fcitx5.addons = [ vinput ];
# MenuKey opens the command palette; set it to right Ctrl. `CommandKeys`
# (voice command on the selection) defaults to right Ctrl and outranks
# `MenuKey`, so clear it or the palette never opens. List options use
# fcitx5's `[Option]` + `0=` form, not upstream's `[Trigger]` shorthand.
xdg.configFile."fcitx5/conf/vinput.conf" = {
text = ''
[Trigger]
MenuKey=Super_R
[MenuKey]
0=Control_R
[CommandKeys]
'';
# fcitx5 rewrites this file at runtime, like `profile` and `config`.
force = true;
};
+11
View File
@@ -64,6 +64,17 @@
# overloads the capslock key to function as both escape (when tapped) and control (when held)
capslock = "overload(control, esc)";
esc = "capslock";
# keyd rewrites right-hand modifiers as their left counterparts, so
# pin them to their own keycodes. Vinput's MenuKey is right Ctrl and
# Rime's right Shift switches CN/EN.
rightcontrol = "rightcontrol";
rightshift = "rightshift";
rightmeta = "rightmeta";
# Right Alt is AltGr, the third-level shift on many European layouts
# (e.g. `AltGr+2` is `@` in Spanish); keyd forwards it as-is.
rightalt = "layer(altgr)";
};
};
};
+1 -1
View File
@@ -192,7 +192,7 @@ in
configPath = ".typos.toml"; # relative to the flake root
# git-hooks passes paths on the command line, which makes typos
# ignore .typos.toml's extend-exclude, so repeat it here
exclude = "rime-data/|overlays/fcitx5/flypy_user.txt";
exclude = "rime-data/|home/base/gui/rime/flypy_user.txt";
};
};
prettier = {
+3 -32
View File
@@ -13,27 +13,8 @@ overlays/
├── default.nix # Entrypoint for all overlays
├── computer-use-linux.nix # computer-use-linux from ryan4yin/nur-packages
├── cua-driver.nix # cua-driver from ryan4yin/nur-packages
├── smartctl-exporter/ # smartctl_exporter pinned to the #329 fix
│ └── default.nix
└── fcitx5/ # Chinese input method configuration
├── README.md
├── default.nix # fcitx5 overlay definition
└── rime-data-flypy/ # Custom rime data for 小鹤音形输入法
└── share/
└── rime-data/
├── build/
├── default.custom.yaml
├── default.yaml
├── flypy.schema.yaml
├── flypy_full全码字.txt
├── flypy_sys.txt
├── flypy_top.txt
├── flypy_user.txt
├── lua/
│ └── calculator_translator.lua
├── rime.lua
├── squirrel.custom.yaml
└── squirrel.yaml
└── smartctl-exporter/ # smartctl_exporter pinned to the #329 fix
└── default.nix
```
## Components
@@ -43,17 +24,7 @@ overlays/
The entrypoint of overlays, it execute and import all overlay files in the current directory with
the given args.
### 2. `fcitx5`
fcitx5's overlay, add my customized Chinese input method - [小鹤音形输入法](https://flypy.com/)
This overlay provides:
- Custom rime data for 小鹤音形输入法 (Flypy input method)
- Cross-platform support for both Linux (fcitx5-rime) and macOS (squirrel)
- Pre-configured input method settings
### 3. Package overlays
### 2. Package overlays
- `computer-use-linux.nix`: exposes `computer-use-linux` from the `nur-ryan4yin` flake input.
- `cua-driver.nix`: exposes `cua-driver` from the `nur-ryan4yin` flake input (used by the
-27
View File
@@ -1,27 +0,0 @@
# rime-data for flypy input method
Useful for Linux(fcitx5-rime) & macOS(squirrel).
## Data source
The schema data comes from the `rime-data-flypy` package in
[nur-ryan4yin](https://github.com/ryan4yin/nur-packages). This overlay adds the personal user
dictionary (`flypy_user.txt`) on top and exposes the merged result as `pkgs.rime-data`,
`pkgs.fcitx5-rime`'s `rimeDataPkgs`, and `pkgs.flypy-squirrel`.
## Linux(fcitx5-rime)
1. `~/.config/fcitx5/profile` is linked to
[home/linux/gui/base/fcitx5/profile](../../home/linux/gui/base/fcitx5/profile), which hardcode
rime as the default input method, so you do not need to use fcitx-configtool to adjust fcitx5's
input method.
## macOS(squirrel)
1. ` ~/Library/Rime/` is force linked to this rime-data, see
[home/darwin/rime-squirrel.nix](../../home/darwin/rime-squirrel.nix) for details.
## Docs about fcitx5
- [Fcitx5 - Arch Linux Wiki](https://wiki.archlinux.org/title/Fcitx5)
- [Fcitx5 - Official Wiki](https://fcitx-im.org/wiki/Fcitx_5/zh-cn)
-25
View File
@@ -1,25 +0,0 @@
# 为了不使用默认的 rime-data,改用小鹤音形数据,这里需要 override
# 参考 https://github.com/NixOS/nixpkgs/blob/e4246ae1e7f78b7087dce9c9da10d28d3725025f/pkgs/tools/inputmethods/fcitx5/fcitx5-rime.nix
{ inputs, ... }:
(
_: super:
let
# 小鹤音形 schema 数据,来自 nur-ryan4yin 的 rime-data-flypy,
# 再叠加我自己的用户词库 flypy_user.txt。
rime-data-flypy = inputs.nur-ryan4yin.packages.${super.stdenv.hostPlatform.system}.rime-data-flypy;
rime-data = super.runCommandLocal "rime-data-flypy-custom" { } ''
mkdir -p $out/share/rime-data
cp -r ${rime-data-flypy}/share/rime-data/. $out/share/rime-data/
chmod -R u+w $out/share/rime-data
cp ${./flypy_user.txt} $out/share/rime-data/flypy_user.txt
'';
in
{
inherit rime-data;
fcitx5-rime = super.fcitx5-rime.override { rimeDataPkgs = [ rime-data ]; };
# used by macOS Squirrel
flypy-squirrel = rime-data;
}
)