diff --git a/nixos/machines/hera/configuration.nix b/nixos/machines/hera/configuration.nix index 87d85584..3f613c1a 100644 --- a/nixos/machines/hera/configuration.nix +++ b/nixos/machines/hera/configuration.nix @@ -20,6 +20,7 @@ in { ../../roles/go-neb.nix ../../roles/laminar ../../roles/kassandra-server.nix + ../../roles/foundryvtt.nix ./web.nix ./mail.nix ./boot.nix diff --git a/nixos/roles/foundryvtt.nix b/nixos/roles/foundryvtt.nix new file mode 100644 index 00000000..cf01a3f9 --- /dev/null +++ b/nixos/roles/foundryvtt.nix @@ -0,0 +1,57 @@ +{ pkgs, lib, config, ... }: +let + name = "foundryvtt"; + stateDir = "/var/lib/${name}"; + port = "3333"; +in { + config = { + users = { + groups.${name} = { }; + users.${name} = { + group = name; + home = stateDir; + }; + }; + systemd.services.${name} = { + enable = true; + description = "Foundryvtt server"; + serviceConfig = { + WorkingDirectory = stateDir; + #ExecStartPre = pkgs.writeShellScript "setup-foundry-vtt" '' + #mkdir -p ${stateDir}/app ${stateDir}/data + #if [[ -f "${stateDir}/${name}.zip" ]]; then + #${pkgs.coreutils}/bin/rm -rf app + #mkdir -p app + #cd app + #${pkgs.unzip}/bin/unzip ${stateDir}/${name}.zip + #${pkgs.coreutils}/bin/mv ${stateDir}/${name}.zip ${stateDir}/${name}.zip + #else + #if [[ ! -f "${stateDir}/app/resources/app/main.js" ]]; then + #echo "No ${name} app found. Please download zip from foundryvtt.com and place at ${stateDir}/${name}.zip" + #fi + #fi + #''; + ExecStart = + "${pkgs.nodejs}/bin/node ${stateDir}/app/resources/app/main.js --port=${port} --dataPath=${stateDir}/data"; + User = name; + }; + }; + services = { + nginx = { + virtualHosts = { + "rpg.maralorn.de" = { + extraConfig = '' + client_max_body_size 300M; + ''; + forceSSL = true; + enableACME = true; + locations."/" = { + proxyPass = "http://[::1]:${port}"; + proxyWebsockets = true; + }; + }; + }; + }; + }; + }; +}