tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
0
fork
atom
lol
0
fork
atom
overview
issues
pulls
pipelines
nixos/zeyple: init
ettom
3 years ago
a375b000
f163a047
+126
2 changed files
expand all
collapse all
unified
split
nixos
modules
module-list.nix
services
mail
zeyple.nix
+1
nixos/modules/module-list.nix
···
564
564
./services/mail/schleuder.nix
565
565
./services/mail/spamassassin.nix
566
566
./services/mail/sympa.nix
567
567
+
./services/mail/zeyple.nix
567
568
./services/matrix/appservice-discord.nix
568
569
./services/matrix/appservice-irc.nix
569
570
./services/matrix/conduit.nix
+125
nixos/modules/services/mail/zeyple.nix
···
1
1
+
{ config, pkgs, lib, ... }:
2
2
+
3
3
+
with lib;
4
4
+
let
5
5
+
cfg = config.services.zeyple;
6
6
+
ini = pkgs.formats.ini { };
7
7
+
8
8
+
gpgHome = pkgs.runCommand "zeyple-gpg-home" { } ''
9
9
+
mkdir -p $out
10
10
+
for file in ${lib.concatStringsSep " " cfg.keys}; do
11
11
+
${config.programs.gnupg.package}/bin/gpg --homedir="$out" --import "$file"
12
12
+
done
13
13
+
14
14
+
# Remove socket files
15
15
+
rm -f $out/S.*
16
16
+
'';
17
17
+
in {
18
18
+
options.services.zeyple = {
19
19
+
enable = mkEnableOption (lib.mdDoc "Zeyple, an utility program to automatically encrypt outgoing emails with GPG");
20
20
+
21
21
+
user = mkOption {
22
22
+
type = types.str;
23
23
+
default = "zeyple";
24
24
+
description = lib.mdDoc ''
25
25
+
User to run Zeyple as.
26
26
+
27
27
+
::: {.note}
28
28
+
If left as the default value this user will automatically be created
29
29
+
on system activation, otherwise the sysadmin is responsible for
30
30
+
ensuring the user exists.
31
31
+
:::
32
32
+
'';
33
33
+
};
34
34
+
35
35
+
group = mkOption {
36
36
+
type = types.str;
37
37
+
default = "zeyple";
38
38
+
description = lib.mdDoc ''
39
39
+
Group to use to run Zeyple.
40
40
+
41
41
+
::: {.note}
42
42
+
If left as the default value this group will automatically be created
43
43
+
on system activation, otherwise the sysadmin is responsible for
44
44
+
ensuring the user exists.
45
45
+
:::
46
46
+
'';
47
47
+
};
48
48
+
49
49
+
settings = mkOption {
50
50
+
type = ini.type;
51
51
+
default = { };
52
52
+
description = lib.mdDoc ''
53
53
+
Zeyple configuration. refer to
54
54
+
<https://github.com/infertux/zeyple/blob/master/zeyple/zeyple.conf.example>
55
55
+
for details on supported values.
56
56
+
'';
57
57
+
};
58
58
+
59
59
+
keys = mkOption {
60
60
+
type = with types; listOf path;
61
61
+
description = lib.mdDoc "List of public key files that will be imported by gpg.";
62
62
+
};
63
63
+
64
64
+
rotateLogs = mkOption {
65
65
+
type = types.bool;
66
66
+
default = true;
67
67
+
description = lib.mdDoc "Whether to enable rotation of log files.";
68
68
+
};
69
69
+
};
70
70
+
71
71
+
config = mkIf cfg.enable {
72
72
+
users.groups = optionalAttrs (cfg.group == "zeyple") { "${cfg.group}" = { }; };
73
73
+
users.users = optionalAttrs (cfg.user == "zeyple") {
74
74
+
"${cfg.user}" = {
75
75
+
isSystemUser = true;
76
76
+
group = cfg.group;
77
77
+
};
78
78
+
};
79
79
+
80
80
+
services.zeyple.settings = {
81
81
+
zeyple = mapAttrs (name: mkDefault) {
82
82
+
log_file = "/var/log/zeyple/zeyple.log";
83
83
+
force_encrypt = true;
84
84
+
};
85
85
+
86
86
+
gpg = mapAttrs (name: mkDefault) { home = "${gpgHome}"; };
87
87
+
88
88
+
relay = mapAttrs (name: mkDefault) {
89
89
+
host = "localhost";
90
90
+
port = 10026;
91
91
+
};
92
92
+
};
93
93
+
94
94
+
environment.etc."zeyple.conf".source = ini.generate "zeyple.conf" cfg.settings;
95
95
+
96
96
+
systemd.tmpfiles.rules = [ "f '${cfg.settings.zeyple.log_file}' 0600 ${cfg.user} ${cfg.group} - -" ];
97
97
+
services.logrotate = mkIf cfg.rotateLogs {
98
98
+
enable = true;
99
99
+
settings.zeyple = {
100
100
+
files = cfg.settings.zeyple.log_file;
101
101
+
frequency = "weekly";
102
102
+
rotate = 5;
103
103
+
compress = true;
104
104
+
copytruncate = true;
105
105
+
};
106
106
+
};
107
107
+
108
108
+
services.postfix.extraMasterConf = ''
109
109
+
zeyple unix - n n - - pipe
110
110
+
user=${cfg.user} argv=${pkgs.zeyple}/bin/zeyple ''${recipient}
111
111
+
112
112
+
localhost:${toString cfg.settings.relay.port} inet n - n - 10 smtpd
113
113
+
-o content_filter=
114
114
+
-o receive_override_options=no_unknown_recipient_checks,no_header_body_checks,no_milters
115
115
+
-o smtpd_helo_restrictions=
116
116
+
-o smtpd_client_restrictions=
117
117
+
-o smtpd_sender_restrictions=
118
118
+
-o smtpd_recipient_restrictions=permit_mynetworks,reject
119
119
+
-o mynetworks=127.0.0.0/8,[::1]/128
120
120
+
-o smtpd_authorized_xforward_hosts=127.0.0.0/8,[::1]/128
121
121
+
'';
122
122
+
123
123
+
services.postfix.extraConfig = "content_filter = zeyple";
124
124
+
};
125
125
+
}