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.
This commit is contained in:
Ryan Yin committed 2026-10-05 22:41:48 +08:00
1 parent 0ec5b8032c
commit 5e5707dd13
13 files changed
+150 -103

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]
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;
};
}
+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;
}
)