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