]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - modules/private/websites/tools/mail/default.nix
Move secrets to flakes
[perso/Immae/Config/Nix.git] / modules / private / websites / tools / mail / default.nix
CommitLineData
ab8f306d 1{ lib, pkgs, config, ... }:
afcc5de0
IB
2let
3 roundcubemail = pkgs.callPackage ./roundcubemail.nix {
34c7b88e 4 inherit (pkgs.webapps) roundcubemail;
ab8f306d 5 env = config.myEnv.tools.roundcubemail;
da30ae4f 6 inherit config;
afcc5de0 7 };
dcac3ec7
IB
8 rainloop = pkgs.callPackage ./rainloop.nix {
9 rainloop = pkgs.rainloop-community;
10 };
afcc5de0 11 cfg = config.myServices.websites.tools.email;
5400b9b6 12 pcfg = config.services.phpfpm.pools;
afcc5de0
IB
13in
14{
15 options.myServices.websites.tools.email = {
16 enable = lib.mkEnableOption "enable email website";
17 };
18
19 imports = [
20 ./mta-sts.nix
21 ];
22
23 config = lib.mkIf cfg.enable {
d2e703c5 24 services.duplyBackup.profiles.mail.excludeFile = ''
6a8252b1
IB
25 + ${rainloop.varDir}
26 + ${roundcubemail.varDir}
27 '';
afcc5de0
IB
28 secrets.keys = roundcubemail.keys;
29
30 services.websites.env.tools.modules =
31 [ "proxy_fcgi" ]
32 ++ rainloop.apache.modules
33 ++ roundcubemail.apache.modules;
34
35 services.websites.env.tools.vhostConfs.mail = {
36 certName = "mail";
37 addToCerts = true;
38 hosts = ["mail.immae.eu"];
39 root = "/run/current-system/webapps/_mail";
40 extraConfig = [
5400b9b6
IB
41 (rainloop.apache.vhostConf pcfg.rainloop.socket)
42 (roundcubemail.apache.vhostConf pcfg.roundcubemail.socket)
afcc5de0
IB
43 ''
44 <Directory /run/current-system/webapps/_mail>
45 Require all granted
46 Options -Indexes
47 </Directory>
48 ''
49 ];
50 };
51 systemd.services = {
52 phpfpm-rainloop = {
53 after = lib.mkAfter rainloop.phpFpm.serviceDeps;
54 wants = rainloop.phpFpm.serviceDeps;
55 };
56 phpfpm-roundcubemail = {
57 after = lib.mkAfter roundcubemail.phpFpm.serviceDeps;
58 wants = roundcubemail.phpFpm.serviceDeps;
59 };
60 };
61
62 services.phpfpm.pools.roundcubemail = {
5400b9b6
IB
63 user = "wwwrun";
64 group = "wwwrun";
65 settings = roundcubemail.phpFpm.pool;
dcac3ec7
IB
66 phpOptions = config.services.phpfpm.phpOptions + ''
67 date.timezone = 'CET'
dcac3ec7 68 '';
2053ddac 69 phpPackage = pkgs.php72.withExtensions({ enabled, all }: enabled ++ [ all.imagick ]);
afcc5de0 70 };
441da8aa 71 services.phpfpm.pools.rainloop = {
5400b9b6
IB
72 user = "wwwrun";
73 group = "wwwrun";
74 settings = rainloop.phpFpm.pool;
dcac3ec7 75 phpPackage = pkgs.php72;
afcc5de0
IB
76 };
77 system.activationScripts = {
78 roundcubemail = roundcubemail.activationScript;
79 rainloop = rainloop.activationScript;
80 };
81
d3452fc5 82 services.websites.webappDirs = {
afcc5de0
IB
83 _mail = ./www;
84 "${roundcubemail.apache.webappName}" = roundcubemail.webRoot;
85 "${rainloop.apache.webappName}" = rainloop.webRoot;
86 };
87
88 };
89
90}