Set up state directory for webmail

This commit is contained in:
niten 2024-02-04 22:45:38 -08:00
parent fe27dc3f3d
commit cc0a8b5cba
1 changed files with 143 additions and 135 deletions

View File

@ -6,13 +6,12 @@ let
cfg = config.fudo.webmail;
base-data-path = cfg.state-directory;
webmail-user = cfg.user;
webmail-group = cfg.group;
base-data-path = "/run/rainloop";
concatMapAttrs = f: attrs:
foldr (a: b: a // b) {} (mapAttrsToList f attrs);
concatMapAttrs = f: attrs: foldr (a: b: a // b) { } (mapAttrsToList f attrs);
fastcgi-conf = builtins.toFile "fastcgi.conf" ''
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
@ -57,7 +56,8 @@ let
'';
})) cfg.sites;
siteOpts = { site-host, ... }: with types; {
siteOpts = { name, ... }:
with types; {
options = {
title = mkOption {
type = str;
@ -130,6 +130,11 @@ let
default = true;
};
state-directory = mkOption {
type = str;
description = "The path at which to store server state.";
};
database = mkOption {
type = nullOr (submodule databaseOpts);
description = "Database configuration for storing contact data.";
@ -150,7 +155,8 @@ let
};
};
databaseOpts = { ... }: with types; {
databaseOpts = { ... }:
with types; {
options = {
type = mkOption {
type = enum [ "pgsql" "mysql" ];
@ -240,9 +246,8 @@ in {
};
};
security.acme.certs = mapAttrs
(site: site-cfg: { email = site-cfg.admin-email; })
cfg.sites;
security.acme.certs =
mapAttrs (site: site-cfg: { email = site-cfg.admin-email; }) cfg.sites;
services = {
phpfpm = {
@ -298,11 +303,12 @@ in {
};
};
fudo.secrets.host-secrets.${hostname} = concatMapAttrs
(site: site-cfg: let
fudo.secrets.host-secrets.${hostname} = concatMapAttrs (site: site-cfg:
let
site-config-file = builtins.toFile "${site}-rainloop.cfg"
(import ./include/rainloop.nix lib site site-cfg site-packages.${site}.version);
(import ./include/rainloop.nix lib site site-cfg
site-packages.${site}.version);
domain-config-file = builtins.toFile "${site}-domain.cfg" ''
imap_host = "${site-cfg.mail-server}"
@ -341,8 +347,10 @@ in {
webmail-init = let
link-configs = concatStringsSep "\n" (mapAttrsToList (site: site-cfg:
let
cfg-file = config.fudo.secrets.host-secrets.${hostname}."${site}-site-config".target-file;
domain-cfg-file = config.fudo.secrets.host-secrets.${hostname}."${site}-domain-config".target-file;
cfg-file =
config.fudo.secrets.host-secrets.${hostname}."${site}-site-config".target-file;
domain-cfg-file =
config.fudo.secrets.host-secrets.${hostname}."${site}-domain-config".target-file;
in ''
${pkgs.coreutils}/bin/mkdir -p ${base-data-path}/${site}/_data_/_default_/configs
${pkgs.coreutils}/bin/cp ${cfg-file} ${base-data-path}/${site}/_data_/_default_/configs/application.ini