bekkalokk: add snappymail #39
|
@ -2,6 +2,7 @@
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./roundcube.nix
|
./roundcube.nix
|
||||||
|
./snappymail.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
services.nginx.virtualHosts."webmail.pvv.ntnu.no" = {
|
services.nginx.virtualHosts."webmail.pvv.ntnu.no" = {
|
||||||
|
@ -10,9 +11,11 @@
|
||||||
kTLS = true;
|
kTLS = true;
|
||||||
locations = {
|
locations = {
|
||||||
"= /".return = "302 https://webmail.pvv.ntnu.no/roundcube";
|
"= /".return = "302 https://webmail.pvv.ntnu.no/roundcube";
|
||||||
|
|
||||||
"/afterlogic_lite".return = "302 https://webmail.pvv.ntnu.no/roundcube";
|
"/afterlogic_lite".return = "302 https://webmail.pvv.ntnu.no/roundcube";
|
||||||
"/squirrelmail".return = "302 https://webmail.pvv.ntnu.no/roundcube";
|
"/squirrelmail".return = "302 https://webmail.pvv.ntnu.no/roundcube";
|
||||||
"/rainloop".return = "302 https://webmail.pvv.ntnu.no/roundcube";
|
"/rainloop".return = "302 https://snappymail.pvv.ntnu.no/";
|
||||||
|
"/snappymail".return = "302 https://snappymail.pvv.ntnu.no/";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
let
|
||||||
|
cfg = config.services.snappymail;
|
||||||
|
in {
|
||||||
|
imports = [ ../../../../modules/snappymail.nix ];
|
||||||
|
|
||||||
|
services.snappymail = {
|
||||||
|
enable = true;
|
||||||
|
hostname = "snappymail.pvv.ntnu.no";
|
||||||
|
};
|
||||||
|
|
||||||
|
services.nginx.virtualHosts.${cfg.hostname} = {
|
||||||
|
forceSSL = true;
|
||||||
|
enableACME = true;
|
||||||
|
kTLS = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,103 @@
|
||||||
|
{ config, pkgs, lib, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
inherit (lib) mkDefault mkEnableOption mkForce mkIf mkOption mkPackageOption generators types;
|
||||||
|
|
||||||
|
cfg = config.services.snappymail;
|
||||||
|
maxUploadSize = "256M";
|
||||||
|
in {
|
||||||
|
options.services.snappymail = {
|
||||||
|
enable = mkEnableOption "Snappymail";
|
||||||
felixalb marked this conversation as resolved
Outdated
|
|||||||
|
|
||||||
|
package = mkPackageOption pkgs "snappymail" { };
|
||||||
felixalb marked this conversation as resolved
Outdated
pederbs
commented
`mkPackageOption pkgs "snappymail" {};`
oysteikt
commented
```
package = mkPackageOption pkgs "snappymail" { };
```
|
|||||||
|
|
||||||
|
dataDir = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "/var/lib/snappymail";
|
||||||
|
description = "State directory for snappymail";
|
||||||
|
};
|
||||||
|
|
||||||
|
hostname = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = null;
|
||||||
|
example = "mail.example.com";
|
||||||
|
description = "Enable nginx with this hostname, null disables nginx";
|
||||||
|
};
|
||||||
|
|
||||||
|
user = mkOption {
|
||||||
felixalb marked this conversation as resolved
Outdated
oysteikt
commented
uncomment? uncomment?
|
|||||||
|
type = types.str;
|
||||||
|
default = "snappymail";
|
||||||
|
description = "System user under which snappymail runs";
|
||||||
|
};
|
||||||
|
|
||||||
|
group = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "snappymail";
|
||||||
|
description = "System group under which snappymail runs";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
users.users = mkIf (cfg.user == "snappymail") {
|
||||||
|
snappymail = {
|
||||||
|
description = "Snappymail service";
|
||||||
|
group = cfg.group;
|
||||||
|
home = cfg.dataDir;
|
||||||
|
isSystemUser = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
users.groups = mkIf (cfg.group == "snappymail") {
|
||||||
|
snappymail = {};
|
||||||
|
};
|
||||||
felixalb marked this conversation as resolved
Outdated
oysteikt
commented
Does this actually need a home and shell? If so, could you leave a comment explaining why? Does this actually need a home and shell? If so, could you leave a comment explaining why?
felixalb
commented
Nope, didn't need :) Nope, didn't need :)
|
|||||||
|
|
||||||
|
services.phpfpm.pools.snappymail = {
|
||||||
|
user = cfg.user;
|
||||||
|
group = cfg.group;
|
||||||
|
phpOptions = generators.toKeyValue {} {
|
||||||
|
upload_max_filesize = maxUploadSize;
|
||||||
|
post_max_size = maxUploadSize;
|
||||||
|
memory_limit = maxUploadSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
"listen.owner" = config.services.nginx.user;
|
||||||
|
"listen.group" = config.services.nginx.group;
|
||||||
|
"pm" = "ondemand";
|
||||||
|
"pm.max_children" = 32;
|
||||||
|
"pm.process_idle_timeout" = "10s";
|
||||||
|
"pm.max_requests" = 500;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
services.nginx = mkIf (cfg.hostname != null) {
|
||||||
|
virtualHosts."${cfg.hostname}" = {
|
||||||
|
locations."/".extraConfig = ''
|
||||||
|
index index.php;
|
||||||
|
autoindex on;
|
||||||
|
autoindex_exact_size off;
|
||||||
|
autoindex_localtime on;
|
||||||
|
'';
|
||||||
|
locations."^~ /data".extraConfig = ''
|
||||||
|
deny all;
|
||||||
|
'';
|
||||||
|
locations."~ \\.php$".extraConfig = ''
|
||||||
|
include ${config.services.nginx.package}/conf/fastcgi_params;
|
||||||
|
|
||||||
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
|
fastcgi_pass unix:${config.services.phpfpm.pools.snappymail.socket};
|
||||||
|
'';
|
||||||
|
extraConfig = ''
|
||||||
|
client_max_body_size ${maxUploadSize};
|
||||||
|
'';
|
||||||
felixalb marked this conversation as resolved
Outdated
pederbs
commented
`include ${config.services.nginx.package}/conf/fastcgi_params; `
oysteikt
commented
Already included: Already included: https://github.com/NixOS/nixpkgs/blob/46397778ef1f73414b03ed553a3368f0e7e33c2f/nixos/modules/services/web-servers/nginx/default.nix#L139
felixalb
commented
Dette er trollvirksomhet, funkittj >:( Dette er trollvirksomhet, funkittj >:(
|
|||||||
|
|
||||||
|
root = if (cfg.package == pkgs.snappymail) then
|
||||||
|
pkgs.snappymail.override {
|
||||||
|
dataPath = cfg.dataDir;
|
||||||
|
}
|
||||||
|
else cfg.package;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
mdDoc
no longer needed