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