This repository has no description
0

Configure Feed

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

mazegame: let nginx serve the client from the store

+26 -5
+3 -3
flake.lock
··· 559 559 ] 560 560 }, 561 561 "locked": { 562 - "lastModified": 1789920601, 563 - "narHash": "sha256-4TNAueQrBZVXdd5Xng2762caj03rY4knT++CRdLCSdk=", 562 + "lastModified": 1789937985, 563 + "narHash": "sha256-1UbLKrLuA72rO1BQn4t6TGR5hD33lRqFkVX20itMlxE=", 564 564 "owner": "lassulus", 565 565 "repo": "mazegame", 566 - "rev": "144886275b4fcde442e71aaf5a7827b2e70e81f2", 566 + "rev": "6d5574b752bdb1647daa1dc4739c91f76721b077", 567 567 "type": "github" 568 568 }, 569 569 "original": {
+23 -2
2configs/mazegame.nix
··· 2 2 domain = "maze.lassul.us"; 3 3 port = 8772; 4 4 in 5 - { self, ... }: 5 + { self, config, ... }: 6 6 { 7 7 # mazegame: Windows 95 "Maze" screensaver you can play in a browser tab. The 8 8 # exit is the NixOS snowflake. /watch is a spectator camera that follows a ··· 18 18 services.nginx.virtualHosts.${domain} = { 19 19 enableACME = true; 20 20 forceSSL = true; 21 + # nginx hands out the client straight from the store. The game server is a 22 + # single event loop: every .js it serves during a join burst is time it is 23 + # not spending on the world tick, and a crowd arriving costs six files 24 + # each. 25 + # …the very package the service runs, so the client never lags the server. 26 + root = config.services.mazegame.package.static; 27 + locations."/" = { 28 + index = "index.html"; 29 + tryFiles = "$uri $uri/ =404"; 30 + extraConfig = '' 31 + # Versions ride in the store path, but the URLs never change, so let 32 + # the browser revalidate rather than cache a stale client. 33 + add_header Cache-Control "no-cache"; 34 + ''; 35 + }; 36 + locations."= /play".tryFiles = "/index.html =404"; 37 + locations."= /watch".tryFiles = "/watch.html =404"; 38 + 21 39 # Player and watcher sockets stay open for as long as someone is in the 22 40 # maze; players heartbeat every 3s, watchers every 3s, so the default 23 41 # 60s read timeout would only bite on a wedged client, but a long window 24 42 # keeps idle spectators connected. 25 - locations."/" = { 43 + locations."/ws/" = { 26 44 proxyPass = "http://127.0.0.1:${toString port}"; 27 45 proxyWebsockets = true; 28 46 extraConfig = '' 29 47 proxy_read_timeout 1h; 30 48 proxy_send_timeout 1h; 31 49 ''; 50 + }; 51 + locations."/api/" = { 52 + proxyPass = "http://127.0.0.1:${toString port}"; 32 53 }; 33 54 }; 34 55 }