diff options
Diffstat (limited to 'modules/private/websites/tools/games/terraforming-mars/default.nix')
-rw-r--r-- | modules/private/websites/tools/games/terraforming-mars/default.nix | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/modules/private/websites/tools/games/terraforming-mars/default.nix b/modules/private/websites/tools/games/terraforming-mars/default.nix new file mode 100644 index 0000000..0df5363 --- /dev/null +++ b/modules/private/websites/tools/games/terraforming-mars/default.nix | |||
@@ -0,0 +1,48 @@ | |||
1 | { config, lib, pkgs, ... }: | ||
2 | let | ||
3 | cfg = config.myServices.websites.games.terraforming-mars; | ||
4 | terraforming-mars = pkgs.callPackage ./terraforming-mars.nix {}; | ||
5 | in | ||
6 | { | ||
7 | options.myServices.websites.games.terraforming-mars.enable = lib.mkEnableOption "Enable Terraforming mars game"; | ||
8 | config = lib.mkIf cfg.enable { | ||
9 | systemd.services.terraforming-mars = { | ||
10 | path = [ pkgs.nodejs pkgs.bashInteractive ]; | ||
11 | description = "Terraforming mars game"; | ||
12 | wantedBy = [ "multi-user.target" ]; | ||
13 | script = '' | ||
14 | export PORT=/run/terraforming-mars/socket.sock | ||
15 | export NODE_ENV=production | ||
16 | mkdir -p /var/lib/terraforming-mars/db | ||
17 | npm run start | ||
18 | ''; | ||
19 | postStart = '' | ||
20 | sleep 5; | ||
21 | chown :wwwrun /run/terraforming-mars/socket.sock | ||
22 | chmod g+w /run/terraforming-mars/socket.sock | ||
23 | ''; | ||
24 | serviceConfig = { | ||
25 | User = "terraformingmars"; | ||
26 | DynamicUser = true; | ||
27 | SupplementaryGroups = [ "wwwrun" ]; | ||
28 | Type = "simple"; | ||
29 | WorkingDirectory = terraforming-mars; | ||
30 | RuntimeDirectory = "terraforming-mars"; | ||
31 | StateDirectory = "terraforming-mars"; | ||
32 | }; | ||
33 | }; | ||
34 | |||
35 | services.websites.env.tools.vhostConfs.games_terraforming-mars = { | ||
36 | certName = "games"; | ||
37 | certMainHost = "games.immae.eu"; | ||
38 | hosts = [ "terraforming-mars.games.immae.eu" ]; | ||
39 | root = null; | ||
40 | extraConfig = [ | ||
41 | '' | ||
42 | ProxyPass / unix:///run/terraforming-mars/socket.sock|http://terraforming-mars.games.immae.eu/ | ||
43 | ProxyPassReverse / unix:///run/terraforming-mars/socket.sock|http://terraforming-mars.games.immae.eu/ | ||
44 | '' | ||
45 | ]; | ||
46 | }; | ||
47 | }; | ||
48 | } | ||