-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhm-module.nix
More file actions
122 lines (118 loc) · 3.15 KB
/
hm-module.nix
File metadata and controls
122 lines (118 loc) · 3.15 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
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
{ self }:
{
config,
pkgs,
lib,
...
}:
let
cfgProgram = config.programs.postar;
cfgService = config.services.postar;
postarPackage = self.packages.${pkgs.system}.default;
tomlFormat = pkgs.formats.toml { };
in
with lib;
{
options.programs.postar = {
enable = mkEnableOption "postar";
package = mkOption {
type = types.package;
default = postarPackage;
description = "The postar package to use.";
};
config = mkOption {
type = tomlFormat.type;
description = ''
Configuration written to {file}`$XDG_CONFIG_HOME/postar/config.toml`
See <https://github.com/filiptrplan/postar?tab=readme-ov-file#toml-configuration-reference> for details.
'';
default = { };
example = ''
imap = [
{
name = "Main";
server = "mail.example.com";
port = 3993;
username = "user@example.com";
password = "pass";
default = true;
}
{
name = "Secondary";
server = "mail.example.org";
port = 3993;
self_signed_cert = true;
username = "user2@example.org";
password = "pass";
}
];
postar = {
polling_delay = 5;
};
'';
};
rules = mkOption {
type = types.str;
default = "";
description = ''
Rules file written to {file}`$XDG_CONFIG_HOME/postar/rules.ptar`
See <https://github.com/filiptrplan/postar?tab=readme-ov-file#rule-dsl> for details.
'';
example = ''
folder test1 { name: "INBOX.tests1" }
folder inbox { name: "INBOX" }
rule test {
matcher: subject contains "TEST"
action: moveto [test1]
}
rule complex_rule {
matcher: and [
subject contains "HI"
or [
to startswith "MyName"
not from contains "TEST"
]
]
action: moveto [test1]
}
'';
};
};
options.services.postar = {
enable = mkEnableOption "postar service";
package = mkOption {
type = types.package;
default = postarPackage;
description = "The postar package to use.";
};
};
config = mkMerge [
(mkIf cfgProgram.enable {
home.packages = mkIf (cfgProgram.package != null) [
# Parentheses are REQUIRED here, otherwise you are adding
# the function 'trace' itself to your packages list
cfgProgram.package
];
xdg.configFile."postar/config.toml" = mkIf (cfgProgram.config != { }) {
source = tomlFormat.generate "config.toml" cfgProgram.config;
};
xdg.configFile."postar/rules.ptar" = mkIf (cfgProgram.rules != "") {
text = cfgProgram.rules;
};
})
(mkIf cfgService.enable {
systemd.user.services.postar = {
Unit = {
Description = "An email filtering service.";
After = [ "network-online.target" ];
};
Install = {
WantedBy = [ "default.target" ];
};
Service = {
ExecStart = "${cfgService.package}/bin/postar";
};
};
})
];
}