mirror of
https://github.com/js0ny/dotfiles.git
synced 2025-12-21 16:53:00 +00:00
feat(rime): add rime config for multiple dialects
This commit is contained in:
parent
4b9a026a9e
commit
ab5bc055c6
1 changed files with 85 additions and 11 deletions
|
|
@ -4,18 +4,82 @@
|
|||
...
|
||||
}: let
|
||||
version = "v13.3.12";
|
||||
rimeConfig = pkgs.fetchzip {
|
||||
rimeWanxiang = pkgs.fetchzip {
|
||||
url = "https://github.com/amzxyz/rime_wanxiang/releases/download/${version}/rime-wanxiang-zrm-fuzhu.zip";
|
||||
# sha256 = lib.fakeHash;
|
||||
sha256 = "sha256-vnhg+//ByZmQ2uxBZTn3cDYKrUFckLAuU8MfB8kSDVA=";
|
||||
stripRoot = false;
|
||||
};
|
||||
|
||||
# Create a modified version of rimeConfig without custom_phrase.txt
|
||||
rimeConfigFiltered = pkgs.runCommand "rime-config-filtered" {} ''
|
||||
cp -r ${rimeConfig} $out
|
||||
rimeCantonese = pkgs.fetchFromGitHub {
|
||||
owner = "rime";
|
||||
repo = "rime-cantonese";
|
||||
rev = "69615390ccb65736186f5cb76b32bed365fd18ed";
|
||||
sha256 = "sha256-vkE+kag5ZXwJwlGBWCTDZkP00h4/XwanpK1aChj+S2o=";
|
||||
};
|
||||
|
||||
rimeTeochew = pkgs.fetchFromGitHub {
|
||||
owner = "kahaani";
|
||||
repo = "dieghv";
|
||||
rev = "1709bb786a144de7be2229755011fde9034457de";
|
||||
sha256 = "sha256-rMViEO0nxNEjVZbHwB0e9vSpe5TfHV7CuJoouS84Pjg=";
|
||||
};
|
||||
|
||||
rimeLatex = pkgs.fetchFromGitHub {
|
||||
owner = "shenlebantongying";
|
||||
repo = "rime_latex";
|
||||
rev = "858f2abc645f0e459e468e98122470ce20b16b30";
|
||||
sha256 = "sha256-i8Rgze+tQhbE+nl+JSj09ILXeUvf6MOS9Eqsuqis1n0=";
|
||||
};
|
||||
|
||||
rimeLatexFiltered = pkgs.runCommand "rime-latex-filtered" {} ''
|
||||
cp -r ${rimeLatex} $out
|
||||
chmod -R u+w $out
|
||||
rm -f $out/custom_phrase.txt
|
||||
|
||||
find $out -name "*.md" -type f -delete
|
||||
rm -rf $out/.scripts
|
||||
rm -f $out/LICENSE # GPLv3
|
||||
'';
|
||||
|
||||
rimeTeochewFiltered = pkgs.runCommand "rime-teochew-filtered" {} ''
|
||||
cp -r ${rimeTeochew} $out
|
||||
chmod -R u+w $out
|
||||
|
||||
find $out -name "*.md" -type f -delete
|
||||
'';
|
||||
|
||||
# Filter rime-cantonese: remove .md files and unwanted directories
|
||||
rimeCantoneseFiltered = pkgs.runCommand "rime-cantonese-filtered" {} ''
|
||||
cp -r ${rimeCantonese} $out
|
||||
chmod -R u+w $out
|
||||
|
||||
# Remove unwanted directories
|
||||
rm -rf $out/.ci
|
||||
rm -rf $out/.github
|
||||
rm -rf $out/demo
|
||||
|
||||
# Remove all .md files
|
||||
find $out -name "*.md" -type f -delete
|
||||
'';
|
||||
|
||||
# Create a modified version of rimeWanxiang with custom_phrase.txt modifications
|
||||
# and merge with rime-cantonese
|
||||
rimeConfigFiltered = pkgs.runCommand "rime-config-filtered" {} ''
|
||||
cp -r ${rimeWanxiang} $out
|
||||
chmod -R u+w $out
|
||||
|
||||
# Modify custom_phrase.txt: replace the third line
|
||||
if [ -f $out/custom_phrase.txt ]; then
|
||||
sed -i '3c\test\tt\t50' $out/custom_phrase.txt
|
||||
else
|
||||
# If the file doesn't exist, create it with the desired content
|
||||
echo -e "# Line 1\n# Line 2\ntest\tt\t50" > $out/custom_phrase.txt
|
||||
fi
|
||||
|
||||
# Merge rime files
|
||||
cp -r ${rimeCantoneseFiltered}/* $out/
|
||||
cp -r ${rimeTeochewFiltered}/* $out/
|
||||
cp -r ${rimeLatexFiltered}/* $out/
|
||||
'';
|
||||
|
||||
rimePath =
|
||||
|
|
@ -37,11 +101,21 @@ in {
|
|||
];
|
||||
};
|
||||
};
|
||||
home.file = {
|
||||
${rimePath} = {
|
||||
source = rimeConfigFiltered;
|
||||
recursive = true;
|
||||
};
|
||||
"${rimePath}/custom_phrase.txt".text = "";
|
||||
home.file.${rimePath} = {
|
||||
source = rimeConfigFiltered;
|
||||
recursive = true;
|
||||
};
|
||||
home.file."${rimePath}/default.custom.yaml" = {
|
||||
text = ''
|
||||
patch:
|
||||
schema_list:
|
||||
- schema: wanxiang_pro
|
||||
- schema: latex
|
||||
- schema: jyut6ping3
|
||||
- schema: dioion
|
||||
- schema: gekion
|
||||
|
||||
'';
|
||||
enable = true;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue