This repository has no description
1.7 kB
68 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 default_socket_timeout = 30
25 max_execution_time = 60
26 '';
27 phpEnv = {
28 SNAPPYMAIL_DATA_PATH = dataDir;
29 };
30 };
31
32 users.users.snappymail = {
33 isSystemUser = true;
34 group = "snappymail";
35 home = dataDir;
36 createHome = true;
37 };
38 users.groups.snappymail = { };
39
40 systemd.tmpfiles.rules = [
41 "d ${dataDir} 0750 snappymail snappymail -"
42 ];
43
44 services.nginx.virtualHosts."mail.lassul.us" = {
45 forceSSL = true;
46 useACMEHost = "mail.lassul.us";
47 root = "${snappymail}";
48 locations."/" = {
49 index = "index.php";
50 tryFiles = "$uri $uri/ /index.php$is_args$args";
51 };
52 locations."~ \\.php$" = {
53 extraConfig = ''
54 fastcgi_pass unix:${fpmSocket};
55 include ${pkgs.nginx}/conf/fastcgi.conf;
56 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
57 fastcgi_param SNAPPYMAIL_DATA_PATH ${dataDir};
58 fastcgi_read_timeout 60s;
59 '';
60 };
61 locations."~ /\\." = {
62 extraConfig = "deny all;";
63 };
64 locations."^~ /data" = {
65 extraConfig = "deny all;";
66 };
67 };
68}