Improve foundry config
This commit is contained in:
parent
ff33a40816
commit
9bf0fea6f5
|
@ -2,41 +2,65 @@
|
||||||
let
|
let
|
||||||
name = "foundryvtt";
|
name = "foundryvtt";
|
||||||
stateDir = "/var/lib/${name}";
|
stateDir = "/var/lib/${name}";
|
||||||
port = "3333";
|
dataDir = "${stateDir}/data";
|
||||||
|
configFile = "${dataDir}/Config/options.json";
|
||||||
|
config = {
|
||||||
|
port = 3333;
|
||||||
|
upnp = false;
|
||||||
|
hostname = "rpg.maralorn.de";
|
||||||
|
routePrefix = null;
|
||||||
|
proxySSL = true;
|
||||||
|
proxyPort = null;
|
||||||
|
minifyStaticFiles = true;
|
||||||
|
updateChannel = "release";
|
||||||
|
};
|
||||||
|
declarativeConfigFile = builtins.toFile "foundry-options.json" (builtins.toJSON config);
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
config = {
|
config = {
|
||||||
users = {
|
|
||||||
groups.${name} = { };
|
|
||||||
users.${name} = {
|
|
||||||
group = name;
|
|
||||||
home = stateDir;
|
|
||||||
isSystemUser = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
systemd.services.${name} = {
|
systemd.services.${name} = {
|
||||||
enable = true;
|
enable = true;
|
||||||
description = "Foundryvtt server";
|
description = "Foundryvtt server";
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
|
StateDirectory = "${name}";
|
||||||
WorkingDirectory = stateDir;
|
WorkingDirectory = stateDir;
|
||||||
|
DynamicUser = true;
|
||||||
Restart = "always";
|
Restart = "always";
|
||||||
# Ensure ./app and ./data exist and extract the game zip to ./app
|
ExecStartPre = pkgs.writeShellScript "setup-foundry-vtt" ''
|
||||||
ExecStart = "${pkgs.nodejs}/bin/node ${stateDir}/app/resources/app/main.js --port=${port} --dataPath=${stateDir}/data";
|
uid
|
||||||
User = name;
|
mkdir -p ${stateDir}/app
|
||||||
|
if [[ -f "${configFile}" ]]; then
|
||||||
|
tempfile=$(mktemp)
|
||||||
|
cp "${configFile}" "$tempfile"
|
||||||
|
${pkgs.jq}/bin/jq ".[0] * .[1]" -s "$tempfile" "${declarativeConfigFile}" > "${configFile}"
|
||||||
|
else
|
||||||
|
cp "${declarativeConfigFile}" "${configFile}"
|
||||||
|
fi
|
||||||
|
if [[ ! -f "${stateDir}/app/resources/app/main.js" ]]; then
|
||||||
|
echo "No ${name} app found. Please download zip from foundryvtt.com and extract to ${stateDir}/app"
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
ExecStart = "${pkgs.nodejs}/bin/node ${stateDir}/app/resources/app/main.js --dataPath=${stateDir}/data";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
services = {
|
services = {
|
||||||
nginx = {
|
nginx = {
|
||||||
virtualHosts = {
|
virtualHosts = {
|
||||||
"rpg.maralorn.de" = {
|
${config.hostname} = {
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
client_max_body_size 300M;
|
client_max_body_size 300M;
|
||||||
|
proxy_set_header Host $host;
|
||||||
'';
|
'';
|
||||||
forceSSL = true;
|
forceSSL = true;
|
||||||
enableACME = true;
|
enableACME = true;
|
||||||
locations."/" = {
|
locations."/" = {
|
||||||
proxyPass = "http://[::1]:${port}";
|
proxyPass = "http://[::1]:${toString config.port}";
|
||||||
proxyWebsockets = true;
|
proxyWebsockets = true;
|
||||||
|
extraConfig = ''
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue