aboutsummaryrefslogtreecommitdiff
path: root/systems/eldiron/websites/games/codenames/shell.nix
blob: 053696b0d06a2b67710c6d2f9d5bb77f505255a5 (plain) (blame)
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
{ pkgs ? import <nixpkgs> {} }: with pkgs;
let
  greenapid = callPackage ./greenapid.nix {};
  frontend = callPackage ./frontend.nix {};
  nginx_conf = writeText "nginx.conf" ''
      pid ./nginx.pid;
      error_log stderr;
      daemon off;
      events {
      }
      http {
        include ${mailcap}/etc/nginx/mime.types;
        server {
          listen 0.0.0.0:8081;
          listen [::]:8081;
          location /api/ {
            proxy_set_header X-Real-IP  $remote_addr;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_pass http://127.0.0.1:8080/;
          }
          location / {
            root ${frontend};
            try_files $uri $uri/ /index.html;
          }
        }
      }
  '';
in
pkgs.mkShell {
  buildInputs = [
    greenapid
    frontend
    python2
    nginx
  ];
  shellHook = ''
    greenapid &
    pid=$!

    finish() {
      kill $pid;
    }

    trap finish EXIT

    nginx -c ${nginx_conf} -p ./nginx/
    exit
  '';
}