From 96a35f72f24c8f01c08c603c383c0dda89dbdc7d Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Sun, 16 Aug 2026 18:58:58 +0200 Subject: [PATCH] wipeout-rewrite: Housekeeping, fix gamecontrollerdb loading - Enable __structuredAttrs & strictDeps - Fix building under the latter - writeShellScript -> writeShellApplication For build-time syntax checking - Patch in path to gamecontrollerdb.txt from sdl_gamecontrollerdb With a build-time check for its existence, to make sure this doesn't silently bitrot --- pkgs/by-name/wi/wipeout-rewrite/package.nix | 64 +++++++++++++++------ 1 file changed, 48 insertions(+), 16 deletions(-) diff --git a/pkgs/by-name/wi/wipeout-rewrite/package.nix b/pkgs/by-name/wi/wipeout-rewrite/package.nix index 2fa5afbf3fc0..f5e8ad6f897c 100644 --- a/pkgs/by-name/wi/wipeout-rewrite/package.nix +++ b/pkgs/by-name/wi/wipeout-rewrite/package.nix @@ -3,25 +3,33 @@ lib, fetchFromGitHub, unstableGitUpdater, - makeWrapper, glew, + makeWrapper, + pkg-config, + sdl_gamecontrollerdb, SDL2, - writeShellScript, + writeShellApplication, }: let datadir = "\"\${XDG_DATA_HOME:-$HOME/.local/share}\"/wipeout-rewrite"; - datadirCheck = writeShellScript "wipeout-rewrite-check-datadir.sh" '' - datadir=${datadir} + datadirCheck = writeShellApplication { + name = "wipeout-rewrite-check-datadir"; + text = '' + datadir=${datadir} - if [ ! -d "$datadir" ]; then - echo "[Wrapper] Creating data directory $datadir" - mkdir -p "$datadir" - fi + if [ ! -d "$datadir" ]; then + echo "[Wrapper] Creating data directory $datadir" + mkdir -p "$datadir" + fi - echo "[Wrapper] Remember to put your game assets into $datadir/wipeout if you haven't done so yet!" - echo "[Wrapper] Check https://github.com/phoboslab/wipeout-rewrite#running for the required format." - ''; + echo "[Wrapper] Remember to put your game assets into $datadir/wipeout if you haven't done so yet!" + echo "[Wrapper] Check https://github.com/phoboslab/wipeout-rewrite#running for the required format." + ''; + }; + + # Would be cool if this was a passthru attribute of sdl_gamecontrollerdb? + gameControllerDbPath = "${sdl_gamecontrollerdb}/share/gamecontrollerdb.txt"; in stdenv.mkDerivation (finalAttrs: { pname = "wipeout-rewrite"; @@ -34,10 +42,31 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-X14rixCUJCQYxeLRpnSb3xWslwcwxoyLtYu1YH3O7WY="; }; - enableParallelBuilding = true; + postPatch = + # Don't rely on sdl2-config (gives issues with strictDeps & cross) + '' + substituteInPlace Makefile \ + --replace-fail 'sdl2-config' 'pkg-config sdl2' + '' + # Hardcode path to our sdl_gamecontrollerdb (with a check to make sure it actually exists) + + '' + if [ ! -f ${gameControllerDbPath} ]; then + echo "${gameControllerDbPath} does not exist!" + exit 1 + fi + + substituteInPlace src/platform_sdl.c \ + --replace-fail \ + 'char *gcdb_path = strcat(strcpy(temp_path, path_assets), "gamecontrollerdb.txt")' \ + 'char *gcdb_path = "${gameControllerDbPath}"' + ''; + + __structuredAttrs = true; + strictDeps = true; nativeBuildInputs = [ makeWrapper + pkg-config ]; buildInputs = [ @@ -45,6 +74,8 @@ stdenv.mkDerivation (finalAttrs: { SDL2 ]; + enableParallelBuilding = true; + # Force this to empty, so assets are looked up in CWD instead of $out/bin env.NIX_CFLAGS_COMPILE = "-DPATH_ASSETS="; @@ -52,11 +83,12 @@ stdenv.mkDerivation (finalAttrs: { runHook preInstall install -Dm755 wipegame $out/bin/wipegame - - # I can't get --chdir to not expand the bash variables in datadir at build time (so they point to /homeless-shelter) - # or put them inside single quotes (breaking the expansion at runtime) + '' + # I can't get --chdir to not expand the bash variables in datadir at build time (so they point to /homeless-shelter) + # or put them inside single quotes (breaking the expansion at runtime) + + '' wrapProgram $out/bin/wipegame \ - --run '${datadirCheck}' \ + --run '${lib.getExe datadirCheck}' \ --run 'cd ${datadir}' runHook postInstall