2015-10-28 20:31:07 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
2016-10-20 18:54:38 +00:00
|
|
|
with import <stockholm/lib>;
|
2015-10-28 20:31:07 +00:00
|
|
|
let
|
2015-10-29 09:55:54 +00:00
|
|
|
sec = toString <secrets>;
|
2016-07-28 11:02:06 +00:00
|
|
|
ext-dom = "wiki.euer.krebsco.de";
|
|
|
|
|
2015-10-28 20:31:07 +00:00
|
|
|
user = config.services.nginx.user;
|
|
|
|
group = config.services.nginx.group;
|
|
|
|
fpm-socket = "/var/run/php5-fpm.sock";
|
|
|
|
hostname = config.krebs.build.host.name;
|
|
|
|
tw-upload = pkgs.tw-upload-plugin;
|
|
|
|
base-dir = "/var/www/wiki.euer";
|
|
|
|
base-cfg = "${base-dir}/twconf.ini";
|
|
|
|
wiki-dir = "${base-dir}/store/";
|
|
|
|
backup-dir = "${base-dir}/backup/";
|
|
|
|
# contains:
|
|
|
|
# user1 = pass1
|
|
|
|
# userN = passN
|
2018-03-23 09:28:33 +00:00
|
|
|
# afterwards put /var/www/<ext-dom>/user1.html as tiddlywiki
|
2015-10-29 09:55:54 +00:00
|
|
|
tw-pass-file = "${sec}/tw-pass.ini";
|
2016-12-24 22:38:01 +00:00
|
|
|
|
2015-10-28 20:31:07 +00:00
|
|
|
in {
|
2018-10-21 21:16:34 +00:00
|
|
|
state = [ base-dir ];
|
2015-10-28 20:31:07 +00:00
|
|
|
services.phpfpm = {
|
2019-10-15 12:26:50 +00:00
|
|
|
pools.euer-wiki = {
|
|
|
|
inherit user group;
|
|
|
|
listen = fpm-socket;
|
2019-10-15 19:42:57 +00:00
|
|
|
settings = {
|
2019-10-15 12:26:50 +00:00
|
|
|
"pm" = "dynamic";
|
|
|
|
"pm.max_children" = 5;
|
|
|
|
"pm.start_servers" = 2;
|
|
|
|
"pm.min_spare_servers" = 1;
|
|
|
|
"pm.max_spare_servers" = 3;
|
2019-10-15 19:42:57 +00:00
|
|
|
"chdir" = "/";
|
|
|
|
"php_admin_value[error_log]" = "stderr";
|
|
|
|
"php_admin_flag[log_errors]" = "on";
|
|
|
|
"catch_workers_output" = "yes";
|
|
|
|
|
2019-10-15 12:26:50 +00:00
|
|
|
};
|
|
|
|
phpEnv.twconf = base-cfg;
|
2015-10-28 20:31:07 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.prepare-tw = {
|
|
|
|
wantedBy = [ "local-fs.target" ];
|
2018-03-23 09:28:33 +00:00
|
|
|
before = [ "phpfpm.service" "nginx.service" ];
|
2015-10-28 20:31:07 +00:00
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = pkgs.writeScript "prepare-tw-service" ''
|
|
|
|
#!/bin/sh
|
2015-11-05 11:31:09 +00:00
|
|
|
if ! test -d "${base-dir}" ;then
|
|
|
|
mkdir -p "${wiki-dir}" "${backup-dir}"
|
2015-10-28 20:31:07 +00:00
|
|
|
|
2015-11-05 11:31:09 +00:00
|
|
|
# write the base configuration
|
|
|
|
cat > "${base-cfg}" <<EOF
|
2015-10-28 20:31:07 +00:00
|
|
|
[users]
|
|
|
|
$(cat "${tw-pass-file}")
|
|
|
|
[directories]
|
|
|
|
backupdir = ${backup-dir}
|
|
|
|
savedir = ${wiki-dir}
|
|
|
|
EOF
|
2015-11-05 11:31:09 +00:00
|
|
|
|
|
|
|
chown -R ${user}:${group} "${base-dir}"
|
|
|
|
chmod 700 -R "${base-dir}"
|
|
|
|
fi
|
2015-10-28 20:31:07 +00:00
|
|
|
'';
|
|
|
|
Type = "oneshot";
|
|
|
|
RemainAfterExit = "yes";
|
|
|
|
TimeoutSec = "0";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-12-24 22:38:01 +00:00
|
|
|
services.nginx = {
|
2015-10-28 20:31:07 +00:00
|
|
|
enable = mkDefault true;
|
2019-09-25 12:06:23 +00:00
|
|
|
recommendedGzipSettings = true;
|
2016-12-24 22:38:01 +00:00
|
|
|
virtualHosts = {
|
|
|
|
"${ext-dom}" = {
|
|
|
|
#serverAliases = [
|
2018-01-09 18:10:07 +00:00
|
|
|
# "wiki.makefu.r"
|
2016-12-24 22:38:01 +00:00
|
|
|
# "wiki.makefu"
|
|
|
|
#];
|
|
|
|
forceSSL = true;
|
|
|
|
enableACME = true;
|
|
|
|
locations = {
|
|
|
|
"/" = {
|
|
|
|
root = wiki-dir;
|
2018-03-23 09:28:33 +00:00
|
|
|
index = "makefu.html";
|
2016-12-24 22:38:01 +00:00
|
|
|
extraConfig = ''
|
|
|
|
expires -1;
|
|
|
|
autoindex on;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
"/store.php" = {
|
|
|
|
root = tw-upload;
|
|
|
|
extraConfig = ''
|
|
|
|
client_max_body_size 200M;
|
|
|
|
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
|
|
|
fastcgi_pass unix:${fpm-socket};
|
|
|
|
include ${pkgs.nginx}/conf/fastcgi_params;
|
|
|
|
include ${pkgs.nginx}/conf/fastcgi.conf;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2015-10-28 20:31:07 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|