This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

superconfig / 2configs / mazegame.nix
2.1 kB 59 lines
1let 2 domain = "maze.lassul.us"; 3 port = 8772; 4in 5{ self, config, ... }: 6{ 7 # mazegame: Windows 95 "Maze" screensaver you can play in a browser tab. The 8 # exit is the NixOS snowflake. /watch is a spectator camera that follows a 9 # random player and cuts to the next one after 2s without movement. 10 imports = [ self.inputs.mazegame.nixosModules.default ]; 11 12 services.mazegame = { 13 enable = true; 14 host = "127.0.0.1"; 15 port = port; 16 }; 17 18 services.nginx.virtualHosts.${domain} = { 19 enableACME = true; 20 forceSSL = true; 21 # nginx hands out the client straight from the store — the very package 22 # the service runs, so the page never lags the server. The game is a 23 # single event loop: every .js it serves during a join burst is a tick it 24 # is not spending on the world, and a crowd arriving costs six files each. 25 root = config.services.mazegame.package.static; 26 locations."/" = { 27 index = "index.html"; 28 tryFiles = "$uri $uri/ =404"; 29 # Versions ride in the store path but the URLs never change, so let the 30 # browser revalidate against the ETag rather than cache a stale client. 31 # add_header does not inherit into the exact-match locations below. 32 extraConfig = ''add_header Cache-Control "no-cache";''; 33 }; 34 locations."= /play" = { 35 tryFiles = "/index.html =404"; 36 extraConfig = ''add_header Cache-Control "no-cache";''; 37 }; 38 locations."= /watch" = { 39 tryFiles = "/watch.html =404"; 40 extraConfig = ''add_header Cache-Control "no-cache";''; 41 }; 42 43 # Player and watcher sockets stay open for as long as someone is in the 44 # maze; players heartbeat every 3s, watchers every 3s, so the default 45 # 60s read timeout would only bite on a wedged client, but a long window 46 # keeps idle spectators connected. 47 locations."/ws/" = { 48 proxyPass = "http://127.0.0.1:${toString port}"; 49 proxyWebsockets = true; 50 extraConfig = '' 51 proxy_read_timeout 1h; 52 proxy_send_timeout 1h; 53 ''; 54 }; 55 locations."/api/" = { 56 proxyPass = "http://127.0.0.1:${toString port}"; 57 }; 58 }; 59}