-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathflake.nix
More file actions
89 lines (80 loc) · 2.72 KB
/
flake.nix
File metadata and controls
89 lines (80 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
{
description = "KeyTao (星空键道6) - Rime input method schema";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
packages.default = pkgs.callPackage ./default.nix { };
packages.rime-keytao = self.packages.${system}.default;
}
)
// {
# Overlay for easy integration
overlays.default = final: prev: {
rime-keytao = final.callPackage ./default.nix { };
};
# Home Manager module
homeManagerModules.default =
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.programs.rime-keytao;
rime-keytao-pkg = pkgs.callPackage ./default.nix { };
in
{
options.programs.rime-keytao = {
enable = mkEnableOption "KeyTao (Rime Xingkong Jiandao) input method schema";
package = mkOption {
type = types.package;
default = rime-keytao-pkg;
description = "The rime-keytao package to use";
};
rimeDataDir = mkOption {
type = types.str;
default = if pkgs.stdenv.isDarwin then "Library/Rime" else ".local/share/fcitx5/rime";
description = ''
Rime user data directory relative to home.
Default values:
- Library/Rime (macOS Squirrel, automatically set)
- .local/share/fcitx5/rime (Linux fcitx5-rime, automatically set)
Other common values:
- .config/ibus/rime (ibus-rime)
'';
};
};
config = mkIf cfg.enable {
home.activation.installRimeKeytao = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
$DRY_RUN_CMD mkdir -p "${config.home.homeDirectory}/${cfg.rimeDataDir}"
# Sync schema/dict files from Nix store, overwriting stale files.
# Exclude user-generated data that must never be overwritten.
$DRY_RUN_CMD ${pkgs.rsync}/bin/rsync -av \
--chmod=D0755,F0644 \
--exclude='*.userdb/' \
--exclude='user.yaml' \
--exclude='installation.yaml' \
--exclude='sync/' \
"${cfg.package}/share/rime-data/" \
"${config.home.homeDirectory}/${cfg.rimeDataDir}/"
$VERBOSE_ECHO "KeyTao Rime schema files installed to ${cfg.rimeDataDir}"
'';
};
};
};
}