diff --git a/hosts/fw.cloonar.com/configuration.nix b/hosts/fw.cloonar.com/configuration.nix index a1c89df..cbe9390 100644 --- a/hosts/fw.cloonar.com/configuration.nix +++ b/hosts/fw.cloonar.com/configuration.nix @@ -46,8 +46,9 @@ ./modules/snapserver.nix # gaming - ./modules/palworld.nix + # ./modules/palworld.nix # ./modules/ark-survival-evolved.nix + ./modules/foundry-vtt.nix # setup network ./modules/setupnetwork.nix diff --git a/hosts/fw.cloonar.com/modules/foundry-vtt.nix b/hosts/fw.cloonar.com/modules/foundry-vtt.nix new file mode 100644 index 0000000..05d514c --- /dev/null +++ b/hosts/fw.cloonar.com/modules/foundry-vtt.nix @@ -0,0 +1,77 @@ +{ config, pkgs, ... }: +let + foundry-vtt = pkgs.callPackage ../pkgs/foundry-vtt {}; + cids = import ../modules/staticids.nix; +in { + users.users.foundry-vtt = { + isSystemUser = true; + uid = cids.uids.foundry-vtt; + home = "/var/lib/foundry-vtt"; + group = "foundry-vtt"; + createHome = true; + }; + + users.groups.foundry-vtt = { + gid = cids.gids.foundry-vtt; + }; + + + containers.foundry-vtt = { + autoStart = true; + ephemeral = true; + privateNetwork = true; + hostBridge = "server"; + hostAddress = "10.42.97.1"; + localAddress = "10.42.97.21/24"; + bindMounts = { + "/var/lib/foundry-vtt" = { + hostPath = "/var/lib/foundry-vtt"; + isReadOnly = false; + }; + }; + config = { lib, config, pkgs, ... }: { + networking = { + hostName = "foundry-vtt"; + useHostResolvConf = false; + defaultGateway = { + address = "10.42.97.1"; + interface = "eth0"; + }; + nameservers = [ "10.42.97.1" ]; + }; + systemd.services.foundry-vtt = { + description = "Foundry VTT Server"; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + environment = { + NODE_ENV = "production"; + }; + serviceConfig = { + ExecStart = "${pkgs.nodejs}/bin/node ${foundry-vtt}/share/foundry-vtt/resources/app/main.js --dataPath=${config.users.users.foundry-vtt.home}"; + Restart = "always"; + User = "foundry-vtt"; + WorkingDirectory = "${config.users.users.foundry-vtt.home}"; + }; + }; + + users.users.foundry-vtt = { + isSystemUser = true; + uid = cids.uids.foundry-vtt; + home = "/var/lib/foundry-vtt"; + group = "foundry-vtt"; + }; + + users.groups.foundry-vtt = { + gid = cids.gids.foundry-vtt; + }; + + networking.firewall = { + enable = true; + allowedTCPPorts = [ 30000 ]; + }; + + + system.stateVersion = "24.05"; + }; + }; +} diff --git a/hosts/fw.cloonar.com/modules/web/proxies.nix b/hosts/fw.cloonar.com/modules/web/proxies.nix index ae3dd6c..cf0f234 100644 --- a/hosts/fw.cloonar.com/modules/web/proxies.nix +++ b/hosts/fw.cloonar.com/modules/web/proxies.nix @@ -7,4 +7,13 @@ proxyPass = "https://git.cloonar.com/"; }; }; + services.nginx.virtualHosts."foundry-vtt.cloonar.com" = { + forceSSL = true; + enableACME = true; + acmeRoot = null; + locations."/" = { + proxyPass = "http://10.42.97.21:30000"; + proxyWebsockets = true; + }; + }; } diff --git a/hosts/fw.cloonar.com/pkgs/foundry-vtt/FoundryVTT-12.331.zip b/hosts/fw.cloonar.com/pkgs/foundry-vtt/FoundryVTT-12.331.zip new file mode 100644 index 0000000..dca1421 Binary files /dev/null and b/hosts/fw.cloonar.com/pkgs/foundry-vtt/FoundryVTT-12.331.zip differ diff --git a/hosts/fw.cloonar.com/pkgs/foundry-vtt/default.nix b/hosts/fw.cloonar.com/pkgs/foundry-vtt/default.nix new file mode 100644 index 0000000..69a34c5 --- /dev/null +++ b/hosts/fw.cloonar.com/pkgs/foundry-vtt/default.nix @@ -0,0 +1,25 @@ +{ stdenv, lib, unzip }: + +stdenv.mkDerivation rec { + pname = "foundry-vtt"; + version = "12.331"; + + src = ./FoundryVTT-12.331.zip; + + nativeBuildInputs = [ unzip ]; + + unpackPhase = '' + unzip $src + ''; + + installPhase = '' + mkdir -p $out/share/foundry-vtt + cp -r . $out/share/foundry-vtt + ''; + + meta = with lib; { + description = "Tabletop simulator"; + license = licenses.mit; # Adjust as needed + platforms = platforms.all; + }; +}