{ config, lib, pkgs, ... }: let phppoolName = "roundcube_pool"; roundcubeDataDir = config.services.mymailserver.internal.roundcubeDataDir; roundcubeUser = config.services.mymailserver.internal.roundcubeUser; roundcubeGroup = config.services.mymailserver.internal.roundcubeGroup; roundcube = (pkgs.callPackage ./pkg-roundcube.nix { conf = pkgs.writeText "roundcube-config.inc.php" '' /dev/null | ${pkgs.coreutils}/bin/base64 > "${roundcubeDataDir}/des_key" chown -c "${roundcubeUser}":root "${roundcubeDataDir}/des_key" chmod -c 400 "${roundcubeDataDir}/des_key" if [ -s "${roundcubeDataDir}/roundcube.sqlite" ]; then # Just go ahead and remove the sessions, the key to decrypt them has just been destroyed anyway. ${pkgs.sqlite}/bin/sqlite3 "${roundcubeDataDir}/roundcube.sqlite" "DELETE FROM session;" fi ''; }; services.phpfpm.pools."${phppoolName}" = { user = "${roundcubeUser}"; group = "${roundcubeGroup}"; settings = { "listen.owner" = "nginx"; "listen.group" = "nginx"; "user" = "${roundcubeUser}"; "group" = "${roundcubeGroup}"; "pm" = "dynamic"; "pm.max_children" = "75"; "pm.min_spare_servers" = "5"; "pm.max_spare_servers" = "20"; "pm.max_requests" = "10"; "catch_workers_output" = "1"; }; }; users.users."${roundcubeUser}" = { group = "${roundcubeGroup}"; isSystemUser = true; }; users.groups."${roundcubeGroup}" = { }; }