Live location tracking and playback for the game "manhunt"

Fix nix building, sync types

bwc9876.dev 4d771113 dfd5c71a

verified
+55 -55
+7
TODO.md
··· 23 23 - [x] Transport : Handle transport cancellation better 24 24 - [x] Backend : Add checks for when the `powerup_locations` field is an empty array in settings 25 25 - [ ] Backend : More tests 26 + - [ ] Lobby tests 27 + - [ ] Game end test for actual return from loop 28 + - [ ] Testing crate for integration testing from a DSL 29 + - [ ] NixOS VM tests wrapping the testing crate 30 + - [ ] Nix : Cheat the dependency nightmare and use crane 31 + - [x] Nix : Fix manhunt.nix to actually build 32 + - [ ] Frontend : Rework state management, better hooks
+12 -12
flake.lock
··· 5 5 "nixpkgs": "nixpkgs" 6 6 }, 7 7 "locked": { 8 - "lastModified": 1750078272, 9 - "narHash": "sha256-Mbu2+ipXe1tAW3UjWXzlDE3wzyVDMOcW1z/PgGmq5T4=", 8 + "lastModified": 1750683087, 9 + "narHash": "sha256-CkmobghX9K9soC4DoorFo/vlWXxpf8xuZyoCsOnWzqM=", 10 10 "owner": "nix-community", 11 11 "repo": "flakelight", 12 - "rev": "38be6514d41071863d2a9a2f38f6f3b3433c69fb", 12 + "rev": "aa93e0e1ecdccc70c7a185f60c562effbfe3c8d9", 13 13 "type": "github" 14 14 }, 15 15 "original": { ··· 20 20 }, 21 21 "nixpkgs": { 22 22 "locked": { 23 - "lastModified": 1749794982, 24 - "narHash": "sha256-Kh9K4taXbVuaLC0IL+9HcfvxsSUx8dPB5s5weJcc9pc=", 23 + "lastModified": 1750506804, 24 + "narHash": "sha256-VLFNc4egNjovYVxDGyBYTrvVCgDYgENp5bVi9fPTDYc=", 25 25 "owner": "NixOS", 26 26 "repo": "nixpkgs", 27 - "rev": "ee930f9755f58096ac6e8ca94a1887e0534e2d81", 27 + "rev": "4206c4cb56751df534751b058295ea61357bbbaa", 28 28 "type": "github" 29 29 }, 30 30 "original": { ··· 36 36 }, 37 37 "nixpkgs_2": { 38 38 "locked": { 39 - "lastModified": 1749903597, 40 - "narHash": "sha256-jp0D4vzBcRKwNZwfY4BcWHemLGUs4JrS3X9w5k/JYDA=", 39 + "lastModified": 1750731501, 40 + "narHash": "sha256-Ah4qq+SbwMaGkuXCibyg+Fwn00el4KmI3XFX6htfDuk=", 41 41 "owner": "NixOS", 42 42 "repo": "nixpkgs", 43 - "rev": "41da1e3ea8e23e094e5e3eeb1e6b830468a7399e", 43 + "rev": "69dfebb3d175bde602f612915c5576a41b18486b", 44 44 "type": "github" 45 45 }, 46 46 "original": { ··· 62 62 "nixpkgs": ["nixpkgs"] 63 63 }, 64 64 "locked": { 65 - "lastModified": 1750041667, 66 - "narHash": "sha256-/8F9L6T9w/Fx1D6L+BtWIXg5m9F6jwOFg6uhZpKnM/0=", 65 + "lastModified": 1750732748, 66 + "narHash": "sha256-HR2b3RHsPeJm+Fb+1ui8nXibgniVj7hBNvUbXEyz0DU=", 67 67 "owner": "oxalica", 68 68 "repo": "rust-overlay", 69 - "rev": "d72bd8c9fda03c9834ea89d7a5a21c7880b79277", 69 + "rev": "4b4494b2ba7e8a8041b2e28320b2ee02c115c75f", 70 70 "type": "github" 71 71 }, 72 72 "original": {
+1
flake.nix
··· 71 71 alejandra 72 72 harfbuzz 73 73 librsvg 74 + gradle 74 75 libsoup_3 75 76 just 76 77 pango
+4 -20
frontend/src/bindings.ts
··· 187 187 * Contains location history of the given player, used after the game to sync location 188 188 * histories 189 189 */ 190 - | { PostGameSync: [string, [string, Location][]] } 191 - /** 192 - * A player has been disconnected and removed from the game (because of error or otherwise). 193 - * The player should be removed from all state 194 - */ 195 - | { DroppedPlayer: string } 196 - /** 197 - * The underlying transport has disconnected 198 - */ 199 - | "TransportDisconnect" 200 - /** 201 - * The underlying transport encountered an error 202 - */ 203 - | { TransportError: string }; 190 + | { PostGameSync: [string, [string, Location][]] }; 204 191 export type GameHistory = { 205 192 my_id: string; 206 193 game_started: string; ··· 247 234 powerup_locations: Location[]; 248 235 }; 249 236 /** 250 - * The state of the game has updated in some way, you're expected to call [get_game_state] when 251 - * receiving this 237 + * The state of the game has changed 252 238 */ 253 239 export type GameStateUpdate = null; 254 240 /** ··· 303 289 * True represents seeker, false hider 304 290 */ 305 291 teams: Partial<{ [key in string]: boolean }>; 306 - self_id: string | null; 307 - self_seeker: boolean; 292 + self_id: string; 308 293 is_host: boolean; 309 294 settings: GameSettings; 310 295 }; 311 296 /** 312 - * The lobby state has updated in some way, you're expected to call [get_lobby_state] after 313 - * receiving this 297 + * The state of the lobby has changed 314 298 */ 315 299 export type LobbyStateUpdate = null; 316 300 /**
+13 -8
nix/packages/manhunt-signaling.nix
··· 1 1 { 2 2 lib, 3 - clippy, 4 3 rustPlatform, 5 4 }: 6 5 rustPlatform.buildRustPackage { 7 6 pname = "manhunt-signaling"; 8 7 version = "0.1.0"; 9 - src = ../../manhunt-signaling; 8 + src = with lib.fileset; 9 + toSource { 10 + root = ../../.; 11 + fileset = unions [ 12 + ../../backend 13 + ../../manhunt-logic 14 + ../../manhunt-transport 15 + ../../manhunt-signaling 16 + ../../Cargo.toml 17 + ../../Cargo.lock 18 + ]; 19 + }; 10 20 cargoLock.lockFile = ../../Cargo.lock; 21 + buildAndTestSubdir = "manhunt-signaling"; 11 22 12 23 postPatch = '' 13 24 cp ${../../Cargo.lock} Cargo.lock 14 25 chmod +w Cargo.lock 15 26 ''; 16 - 17 - postCheck = '' 18 - cargo clippy --no-deps -- -D warnings 19 - ''; 20 - 21 - nativeBuildInputs = [clippy]; 22 27 23 28 meta = with lib; { 24 29 description = "Signaling server for Manhunt app";
+18 -15
nix/packages/manhunt.nix
··· 3 3 libsoup_3, 4 4 dbus, 5 5 glib, 6 - clippy, 7 6 glib-networking, 8 7 librsvg, 9 8 webkitgtk_4_1, ··· 16 15 rustPlatform.buildRustPackage { 17 16 pname = "manhunt"; 18 17 version = "0.1.0"; 19 - src = ../../backend; 18 + src = with lib.fileset; 19 + toSource { 20 + root = ../../.; 21 + fileset = unions [ 22 + ../../backend 23 + ../../manhunt-logic 24 + ../../manhunt-transport 25 + ../../manhunt-signaling 26 + ../../Cargo.toml 27 + ../../Cargo.lock 28 + ]; 29 + }; 20 30 cargoLock.lockFile = ../../Cargo.lock; 31 + buildAndTestSubdir = "backend"; 21 32 buildFeatures = [ 22 33 "tauri/custom-protocol" 23 34 ]; 24 35 25 - postCheck = '' 26 - cargo clippy --no-deps -- -D warnings 27 - ''; 28 - 29 36 nativeBuildInputs = [ 30 37 pkg-config 31 38 copyDesktopItems 32 39 wrapGAppsHook 33 - clippy 34 40 ]; 35 41 36 42 buildInputs = [ ··· 43 49 ]; 44 50 45 51 postPatch = '' 46 - cp ${../../Cargo.lock} Cargo.lock 47 - chmod +w Cargo.lock 48 - 49 - substituteInPlace tauri.conf.json \ 50 - --replace '"frontendDist": "../frontend/dist"' '"frontendDist": "${manhunt-frontend}"' 52 + substituteInPlace backend/tauri.conf.json \ 53 + --replace-fail '"frontendDist": "../frontend/dist"' '"frontendDist": "${manhunt-frontend}"' 51 54 ''; 52 55 53 56 postInstall = '' 54 - install -DT icons/128x128@2x.png $out/share/icons/hicolor/256x256@2/apps/manhunt.png 55 - install -DT icons/128x128.png $out/share/icons/hicolor/128x128/apps/manhunt.png 56 - install -DT icons/32x32.png $out/share/icons/hicolor/32x32/apps/manhunt.png 57 + install -DT backend/icons/128x128@2x.png $out/share/icons/hicolor/256x256@2/apps/manhunt.png 58 + install -DT backend/icons/128x128.png $out/share/icons/hicolor/128x128/apps/manhunt.png 59 + install -DT backend/icons/32x32.png $out/share/icons/hicolor/32x32/apps/manhunt.png 57 60 ''; 58 61 59 62 meta = with lib; {