mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-10-03 21:40:12 +00:00
wipeout-rewrite: Housekeeping, fix gamecontrollerdb loading (#553379)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user