-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathhm-module.nix
126 lines (114 loc) · 3.22 KB
/
hm-module.nix
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
self:
{
config,
pkgs,
lib,
...
}:
let
cfg = config.programs.plover;
iniFormat = pkgs.formats.ini { };
in
{
options.programs.plover = {
enable = lib.mkEnableOption "plover";
package = lib.mkOption {
type = lib.types.package;
default = self.packages.${pkgs.system}.plover;
example =
lib.literalExpression # nix
''
inputs.plover-flake.${pkgs.system}.plover.withPlugins (ps: with ps; [
plover-lapwing-aio
plover-console-ui
])
'';
};
settings = lib.mkOption {
description = ''
The plover configuration, written to `$XDG_CONFIG_HOME/plover/plover.cfg`.
If null, the configuration will not be managed by home-manager.
'';
type =
with lib.types;
with lib.options;
let
mkConfig =
type: example:
mkOption {
inherit example;
type = nullOr type;
default = null;
};
in
nullOr (submodule {
freeformType = iniFormat.type;
options = {
"Machine Configuration" = {
machine_type = mkConfig str "Gemini PR";
auto_start = mkConfig bool false;
};
"Output Configuration" = {
undo_levels = mkConfig int 100;
};
"Translation Frame" = {
opacity = mkConfig int 100;
};
"Gemini PR" = {
baudrate = mkConfig int 9600;
bytesize = mkConfig int 8;
parity = mkConfig str "N";
port = mkConfig str "/dev/ttyACM0";
stopbits = mkConfig int 1;
timeout = mkConfig float 2.0;
};
"Plugins" = {
enabled_extensions = mkConfig (listOf str) [
"modal_update"
"plover_auto_reconnect_machine"
];
};
"System" = {
name = mkConfig str "Lapwing";
};
"Startup" = {
"start minimized" = mkConfig bool false;
};
"Logging Configuration" = {
log_file = mkConfig str "strokes.log";
};
"System: Lapwing" = {
dictionaries =
mkConfig
(listOf (submodule {
options = {
enabled = mkConfig bool true;
path = mkConfig str "user.json";
};
}))
[
{
enabled = true;
path = "user.json";
}
];
};
};
});
default = null;
};
};
config = lib.mkIf cfg.enable (
lib.mkMerge [
{
home.packages = [ cfg.package ];
}
(lib.mkIf (cfg.settings != null) {
# It is necessary to filter the attrs because the option definitions require a default value, but should be unset in the result.
xdg.configFile."plover/plover.cfg".source = iniFormat.generate "plover.cfg" (
lib.filterAttrsRecursive (n: v: v != null) cfg.settings
);
})
]
);
}