blob: 0df5363ae42fba9f2470ebb5561c853c3b290c3a (
plain) (
tree)
|
|
{ config, lib, pkgs, ... }:
let
cfg = config.myServices.websites.games.terraforming-mars;
terraforming-mars = pkgs.callPackage ./terraforming-mars.nix {};
in
{
options.myServices.websites.games.terraforming-mars.enable = lib.mkEnableOption "Enable Terraforming mars game";
config = lib.mkIf cfg.enable {
systemd.services.terraforming-mars = {
path = [ pkgs.nodejs pkgs.bashInteractive ];
description = "Terraforming mars game";
wantedBy = [ "multi-user.target" ];
script = ''
export PORT=/run/terraforming-mars/socket.sock
export NODE_ENV=production
mkdir -p /var/lib/terraforming-mars/db
npm run start
'';
postStart = ''
sleep 5;
chown :wwwrun /run/terraforming-mars/socket.sock
chmod g+w /run/terraforming-mars/socket.sock
'';
serviceConfig = {
User = "terraformingmars";
DynamicUser = true;
SupplementaryGroups = [ "wwwrun" ];
Type = "simple";
WorkingDirectory = terraforming-mars;
RuntimeDirectory = "terraforming-mars";
StateDirectory = "terraforming-mars";
};
};
services.websites.env.tools.vhostConfs.games_terraforming-mars = {
certName = "games";
certMainHost = "games.immae.eu";
hosts = [ "terraforming-mars.games.immae.eu" ];
root = null;
extraConfig = [
''
ProxyPass / unix:///run/terraforming-mars/socket.sock|http://terraforming-mars.games.immae.eu/
ProxyPassReverse / unix:///run/terraforming-mars/socket.sock|http://terraforming-mars.games.immae.eu/
''
];
};
};
}
|