Minor changes

This commit is contained in:
root 2021-01-06 12:51:40 -06:00
parent eeea25a648
commit f64c331603
4 changed files with 69 additions and 54 deletions

View File

@ -52,8 +52,7 @@ let
ln -s ${base-data-path}/${site} $out/data ln -s ${base-data-path}/${site} $out/data
ln -s ${site-cfg.favicon} $out/favicon.ico ln -s ${site-cfg.favicon} $out/favicon.ico
''; '';
})) })) cfg.sites;
cfg.sites;
siteOpts = { site-host, ... }: { siteOpts = { site-host, ... }: {
options = { options = {
@ -111,13 +110,13 @@ let
}; };
edit-mode = mkOption { edit-mode = mkOption {
type = types.enum ["Plain" "Html" "PlainForced" "HtmlForced"]; type = types.enum [ "Plain" "Html" "PlainForced" "HtmlForced" ];
description = "Default text editing mode for email"; description = "Default text editing mode for email";
default = "Html"; default = "Html";
}; };
layout-mode = mkOption { layout-mode = mkOption {
type = types.enum ["side" "bottom"]; type = types.enum [ "side" "bottom" ];
description = "Layout mode to use for email preview."; description = "Layout mode to use for email preview.";
default = "side"; default = "side";
}; };
@ -157,7 +156,7 @@ let
databaseOpts = { ... }: { databaseOpts = { ... }: {
options = { options = {
type = mkOption { type = mkOption {
type = types.enum ["pgsql" "mysql"]; type = types.enum [ "pgsql" "mysql" ];
description = "Driver to use when connecting to the database."; description = "Driver to use when connecting to the database.";
default = "pgsql"; default = "pgsql";
}; };
@ -176,7 +175,8 @@ let
name = mkOption { name = mkOption {
type = types.str; type = types.str;
description = "Name of the database containing contact info. <user> must have access."; description =
"Name of the database containing contact info. <user> must have access.";
default = "rainloop_contacts"; default = "rainloop_contacts";
}; };
@ -226,13 +226,13 @@ in {
}; };
}; };
security.acme.certs = mapAttrs' (site: site-cfg: security.acme.certs = mapAttrs'
nameValuePair site { (site: site-cfg: nameValuePair site { email = site-cfg.admin-email; })
email = site-cfg.admin-email; cfg.sites;
}) cfg.sites;
services = { services = {
phpfpm = { phpfpm = {
pools.webmail = { pools.webmail = {
settings = { settings = {
"pm" = "dynamic"; "pm" = "dynamic";
@ -242,6 +242,10 @@ in {
"pm.max_spare_servers" = 8; "pm.max_spare_servers" = 8;
}; };
phpOptions = ''
memory_limit = 500M
'';
# Not working....see chmod below # Not working....see chmod below
user = webmail-user; user = webmail-user;
group = webmail-group; group = webmail-group;
@ -258,9 +262,7 @@ in {
root = "${site-packages.${site}}"; root = "${site-packages.${site}}";
locations = { locations = {
"/" = { "/" = { index = "index.php"; };
index = "index.php";
};
"/data" = { "/data" = {
extraConfig = '' extraConfig = ''
@ -279,16 +281,18 @@ in {
fastcgi_pass unix:${config.services.phpfpm.pools.webmail.socket}; fastcgi_pass unix:${config.services.phpfpm.pools.webmail.socket};
} }
''; '';
}) }) cfg.sites;
cfg.sites;
}; };
}; };
systemd.services = { systemd.services = {
webmail-init = let webmail-init = let
link-configs = concatStringsSep "\n" (mapAttrsToList (site: site-cfg: let link-configs = concatStringsSep "\n" (mapAttrsToList (site: site-cfg:
cfg-file = builtins.toFile "${site}-rainloop.cfg" (import ./include/rainloop.nix lib site site-cfg site-packages.${site}.version); let
domain-cfg = builtins.toFile "${site}-domain.cfg" '' cfg-file = builtins.toFile "${site}-rainloop.cfg"
(import ./include/rainloop.nix lib site site-cfg
site-packages.${site}.version);
domain-cfg = builtins.toFile "${site}-domain.cfg" ''
imap_host = "${site-cfg.mail-server}" imap_host = "${site-cfg.mail-server}"
imap_port = 143 imap_port = 143
imap_secure = "TLS" imap_secure = "TLS"
@ -306,7 +310,7 @@ in {
smtp_php_mail = Off smtp_php_mail = Off
white_list = "" white_list = ""
''; '';
in '' in ''
${pkgs.coreutils}/bin/mkdir -p ${base-data-path}/${site}/_data_/_default_/configs ${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 ${pkgs.coreutils}/bin/cp ${cfg-file} ${base-data-path}/${site}/_data_/_default_/configs/application.ini
@ -314,20 +318,22 @@ in {
${pkgs.coreutils}/bin/cp ${domain-cfg} ${base-data-path}/${site}/_data_/_default_/domains/${site-cfg.domain}.ini ${pkgs.coreutils}/bin/cp ${domain-cfg} ${base-data-path}/${site}/_data_/_default_/domains/${site-cfg.domain}.ini
'') cfg.sites); '') cfg.sites);
scriptPkg = (pkgs.writeScriptBin "webmail-init.sh" '' scriptPkg = (pkgs.writeScriptBin "webmail-init.sh" ''
#!${pkgs.bash}/bin/bash -e #!${pkgs.bash}/bin/bash -e
${link-configs} ${link-configs}
${pkgs.coreutils}/bin/chown -R ${webmail-user}:${webmail-group} ${base-data-path} ${pkgs.coreutils}/bin/chown -R ${webmail-user}:${webmail-group} ${base-data-path}
${pkgs.coreutils}/bin/chmod -R ug+w ${base-data-path} ${pkgs.coreutils}/bin/chmod -R ug+w ${base-data-path}
''); '');
in { in {
requiredBy = [ "nginx.service" ]; requiredBy = [ "nginx.service" ];
description = "Initialize webmail service directories prior to starting nginx."; description =
"Initialize webmail service directories prior to starting nginx.";
script = "${scriptPkg}/bin/webmail-init.sh"; script = "${scriptPkg}/bin/webmail-init.sh";
}; };
phpfpm-webmail-socket-perm = { phpfpm-webmail-socket-perm = {
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
description = "Change ownership of the phpfpm socket for webmail once it's started."; description =
"Change ownership of the phpfpm socket for webmail once it's started.";
requires = [ "phpfpm-webmail.service" ]; requires = [ "phpfpm-webmail.service" ];
after = [ "phpfpm.target" ]; after = [ "phpfpm.target" ];
serviceConfig = { serviceConfig = {
@ -338,10 +344,8 @@ in {
}; };
nginx = { nginx = {
requires = [ requires =
"webmail-init.service" [ "webmail-init.service" "phpfpm-webmail-socket-perm.service" ];
"phpfpm-webmail-socket-perm.service"
];
}; };
}; };
}; };

View File

@ -583,7 +583,7 @@ in {
fudo.minecraft-server = { fudo.minecraft-server = {
enable = true; enable = true;
package = pkgs.minecraft-server_1_16_2; package = pkgs.minecraft-server_1_16_4;
data-dir = minecraft-data-dir; data-dir = minecraft-data-dir;
world-name = "selbyland"; world-name = "selbyland";
motd = "Welcome to the Selby Minecraft server."; motd = "Welcome to the Selby Minecraft server.";

View File

@ -17,21 +17,21 @@ in {
}; };
docker-containers = { docker-containers = {
selby-discourse = { # selby-discourse = {
image = "bitnami/discourse"; # image = "bitnami/discourse";
ports = [ ]; # ports = [ ];
user = toString config.users.users.selby-discourse.uid; # user = toString config.users.users.selby-discourse.uid;
volumes = [ # volumes = [
"${config-path}:/opt/bitnami/discourse/mounted-conf" # "${config-path}:/opt/bitnami/discourse/mounted-conf"
"${discourse-data-path}:/bitnami" # "${discourse-data-path}:/bitnami"
]; # ];
extraDockerOptions = [ "--network=selby-discourse" ]; # extraDockerOptions = [ "--network=selby-discourse" ];
environment = { # environment = {
DISCOURSE_SITENAME = "Selby Forum"; # DISCOURSE_SITENAME = "Selby Forum";
DISCOURSE_EMAIL = "forum@selby.ca"; # DISCOURSE_EMAIL = "forum@selby.ca";
DISCOURSE_HOSTNAME = hostname; # DISCOURSE_HOSTNAME = hostname;
}; # };
}; # };
selby-discourse-redis = { selby-discourse-redis = {
image = "bitnami/redis"; image = "bitnami/redis";
@ -41,14 +41,14 @@ in {
environment = { ALLOW_EMPTY_PASSWORD = "yes"; }; environment = { ALLOW_EMPTY_PASSWORD = "yes"; };
}; };
selby-discourse-sidekiq = { # selby-discourse-sidekiq = {
image = "bitnami/discourse"; # image = "bitnami/discourse";
user = toString config.users.users.selby-discourse-sidekiq.uid; # user = toString config.users.users.selby-discourse-sidekiq.uid;
volumes = [ "${sidekiq-data-path}:/bitnami" ]; # volumes = [ "${sidekiq-data-path}:/bitnami" ];
entrypoint = "nami"; # entrypoint = "nami";
cmd = [ "start" "discourse-sidekiq" ]; # cmd = [ "start" "discourse-sidekiq" ];
extraDockerOptions = [ "--network=selby-discourse" ]; # extraDockerOptions = [ "--network=selby-discourse" ];
}; # };
}; };
systemd = { systemd = {

View File

@ -10,6 +10,17 @@ in {
fetchurl = builtins.fetchurl; fetchurl = builtins.fetchurl;
}; };
minecraft-server_1_16_4 = pkgs.minecraft-server.overrideAttrs
(oldAttrs: rec {
version = "1.15.1";
src = builtins.fetchurl {
url =
"https://launcher.mojang.com/v1/objects/35139deedbd5182953cf1caa23835da59ca3d7cd/server.jar";
sha256 =
"01i5nd03sbnffbyni1fa6hsg5yll2h19vfrpcydlivx10gck0ka4";
};
});
minecraft-server_1_15_1 = pkgs.minecraft-server.overrideAttrs minecraft-server_1_15_1 = pkgs.minecraft-server.overrideAttrs
(oldAttrs: rec { (oldAttrs: rec {
version = "1.15.1"; version = "1.15.1";