From 2a1631daac08ec5bc793883231298967061041c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cyryl=20P=C5=82otnicki?= Date: Sat, 18 Jun 2022 12:19:35 +0100 Subject: [PATCH] another foundry instance --- nixos/boxes/vpsfree1/foundryvtt.nix | 70 ++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 21 deletions(-) diff --git a/nixos/boxes/vpsfree1/foundryvtt.nix b/nixos/boxes/vpsfree1/foundryvtt.nix index 4238a6f3..5a7f42e2 100644 --- a/nixos/boxes/vpsfree1/foundryvtt.nix +++ b/nixos/boxes/vpsfree1/foundryvtt.nix @@ -1,4 +1,13 @@ -{ config, pkgs, inputs, lib, ... }: { +{ config, pkgs, inputs, lib, ... }: +let + foundryvtt = pkgs.fetchzip { + name = "foundryvtt"; + url = "file:///" + ./FoundryVTT-9.269.zip; + postFetch = ""; + sha256 = "sha256-7YlF3tQ0XsN8CJO7WrjAhz8rHdl/pgqGUpjIJJnB0Eg="; + stripRoot = false; + }; +in { imports = [ ../nginx.nix ]; services.nginx = { @@ -13,6 +22,35 @@ }; }; }; + virtualHosts = { + "foundryvtt1.peninsula.industries" = { + forceSSL = true; + enableACME = true; + locations."/" = { + proxyPass = "http://localhost:30001"; + proxyWebsockets = true; + }; + }; + }; + }; + + containers.foundryvtt1 = { + autoStart = true; + forwardPorts = [{ + containerPort = 30001; + hostPort = 30001; + }]; + config = { config, pkgs, ... }: { + systemd.services."foundryvtt" = { + requires = [ "network-online.target" ]; + wantedBy = [ "multi-user.target" ]; + script = '' + mkdir -p /var/lib/foundryvtt + ${pkgs.nodejs-18_x}/bin/node ${foundryvtt}/resources/app/main.js --dataPath=/var/lib/foundryvtt --port=30001 + ''; + serviceConfig.Restart = "always"; + }; + }; }; containers.foundryvtt = { @@ -21,26 +59,16 @@ containerPort = 30000; hostPort = 30000; }]; - config = { config, pkgs, ... }: - let - foundryvtt = pkgs.fetchzip { - name = "foundryvtt"; - url = "file:///" + ./FoundryVTT-9.269.zip; - postFetch = ""; - sha256 = "sha256-7YlF3tQ0XsN8CJO7WrjAhz8rHdl/pgqGUpjIJJnB0Eg="; - stripRoot = false; - }; - in { - systemd.services."foundryvtt" = { - requires = [ "network-online.target" ]; - wantedBy = [ "multi-user.target" ]; - script = '' - mkdir -p /var/lib/foundryvtt - ${pkgs.nodejs-18_x}/bin/node ${foundryvtt}/resources/app/main.js --dataPath=/var/lib/foundryvtt - ''; - serviceConfig.Restart = "always"; - }; + config = { config, pkgs, ... }: { + systemd.services."foundryvtt" = { + requires = [ "network-online.target" ]; + wantedBy = [ "multi-user.target" ]; + script = '' + mkdir -p /var/lib/foundryvtt + ${pkgs.nodejs-18_x}/bin/node ${foundryvtt}/resources/app/main.js --dataPath=/var/lib/foundryvtt + ''; + serviceConfig.Restart = "always"; }; - + }; }; }