diff --git a/modules/foundry.nix b/modules/foundry.nix index e245ea2..61a3528 100644 --- a/modules/foundry.nix +++ b/modules/foundry.nix @@ -1,4 +1,4 @@ -{ lib, config, ... }: +{ lib, config, pkgs, ... }: let cfg = config.permafrost.foundry; @@ -13,6 +13,32 @@ in { permafrost.nginx.enable = lib.mkDefault true; } + { + users.groups.foundry = { }; + users.users.foundry = { + group = "foundry"; + isSystemUser = true; + description = "foundryvtt user"; + }; + + systemd.services.foundry = + let + mainPath = "/home/foundry/foundryvtt/resources/app/main.js"; + dataPath = "/home/foundry/foundrydata"; + in + { + description = "foundryvtt service"; + enable = true; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + User = "foundry"; + Restart = "always"; + WorkingDirectory = "/home/foundry/foundryvtt"; + ExecStart = "${lib.getExe pkgs.nodejs_20} ${mainPath} --dataPath=${dataPath}"; + }; + }; + } { services.nginx.virtualHosts."scarlet.zynh.me" = { serverName = "scarlet.zynh.me";