summaryrefslogtreecommitdiff
path: root/hosts/chaski/services/exneuland.nix
blob: a0c765a6edd763236b52fc950c8ea1a77daef62f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{ config, lib, pkgs, ... }:

let
  workadventure-nix = builtins.fetchGit {
    url = "https://stuebinm.eu/git/workadventure-nix";
    ref = "master";
  };
  wapkgs = import "${workadventure-nix.outPath}/wapkgs.nix" {
    inherit pkgs;
    lib = pkgs.lib;
  };
  frontdrv = wapkgs.workadventure-tcm.front.override {
    environment = {
      PUSHER_URL = "https://exneuland.stuebinm.eu/pusher";
      START_ROOM_URL = "/_/global/world.di.c3voc.de/maps/main.json";
    };
  };
  exneuland = import ../../../pkgs/exneuland.nix;
in
{
  services.nginx = {
    enable = true;
    recommendedProxySettings = true;
    virtualHosts."exneuland.stuebinm.eu" = {
      root = "${frontdrv}/dist";
      locations."/_/".tryFiles = "/index.html =404";

      locations."/pusher" = {
        proxyPass = "http://localhost:4000";
        proxyWebsockets = true;
        extraConfig = ''
          add_header Access-Control-Allow-Origin https://exneuland.stuebinm.eu;
        '';
      };

      enableACME = true;
      forceSSL = true;
    };
  };

  systemd.services.exneuland = {
    wantedBy = [ "multi-user.target" ];
    after = [ "network.target" ];
    description = "exneuland backend for workadventure";
    serviceConfig = {
      ExecStart = "${exneuland}/bin/exneuland start";
      Restart = "always";
    };
  };
}