This repository has no description
1.6 kB
65 lines
1{ config, pkgs, ... }:
2let
3 snappymail = pkgs.snappymail;
4 dataDir = "/var/lib/snappymail";
5 pool = "snappymail";
6 fpmSocket = config.services.phpfpm.pools.${pool}.socket;
7in
8{
9 services.phpfpm.pools.${pool} = {
10 user = "snappymail";
11 group = "snappymail";
12 settings = {
13 "listen.owner" = "nginx";
14 "listen.group" = "nginx";
15 "pm" = "dynamic";
16 "pm.max_children" = 4;
17 "pm.start_servers" = 1;
18 "pm.min_spare_servers" = 1;
19 "pm.max_spare_servers" = 2;
20 };
21 phpOptions = ''
22 upload_max_filesize = 25M
23 post_max_size = 25M
24 '';
25 phpEnv = {
26 SNAPPYMAIL_DATA_PATH = dataDir;
27 };
28 };
29
30 users.users.snappymail = {
31 isSystemUser = true;
32 group = "snappymail";
33 home = dataDir;
34 createHome = true;
35 };
36 users.groups.snappymail = { };
37
38 systemd.tmpfiles.rules = [
39 "d ${dataDir} 0750 snappymail snappymail -"
40 ];
41
42 services.nginx.virtualHosts."mail.lassul.us" = {
43 forceSSL = true;
44 useACMEHost = "mail.lassul.us";
45 root = "${snappymail}";
46 locations."/" = {
47 index = "index.php";
48 tryFiles = "$uri $uri/ /index.php$is_args$args";
49 };
50 locations."~ \\.php$" = {
51 extraConfig = ''
52 fastcgi_pass unix:${fpmSocket};
53 include ${pkgs.nginx}/conf/fastcgi.conf;
54 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
55 fastcgi_param SNAPPYMAIL_DATA_PATH ${dataDir};
56 '';
57 };
58 locations."~ /\\." = {
59 extraConfig = "deny all;";
60 };
61 locations."^~ /data" = {
62 extraConfig = "deny all;";
63 };
64 };
65}