icbm3d, xgalagapp: fix darwin and cross-compiled builds (#419640)

This commit is contained in:
Aleksana
2025-06-25 15:29:58 +08:00
committed by GitHub
2 changed files with 23 additions and 6 deletions
+13 -2
View File
@@ -16,11 +16,22 @@ stdenv.mkDerivation (finalAttrs: {
buildInputs = [ libX11 ];
buildFlags = [ "CC=${stdenv.cc.targetPrefix}cc" ]; # fix darwin and cross-compiled builds
# Function are declared after they are used in the file, this is error since gcc-14.
# randnum.c:25:3: warning: implicit declaration of function 'srand' [-Wimplicit-function-declaration]
# randnum.c:33:7: warning: implicit declaration of function 'rand'; did you mean 'randnum'? [-Wimplicit-function-declaration]
# text.c:34:50: warning: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
env.NIX_CFLAGS_COMPILE = "-Wno-error=implicit-function-declaration";
postPatch = ''
substituteInPlace randnum.c --replace-fail 'stdio.h' 'stdlib.h'
sed -i '1i\
#include <string.h>' text.c
# The Makefile tries to install icbm3d immediately after building it, and
# ends up trying to copy it to /icbm3d. Normally this just gets an error
# and moves on, but it's probably better to not try it in the first place.
sed -i '/INSTALLROOT/d' makefile
'';
installPhase = ''
runHook preInstall
@@ -35,6 +46,6 @@ stdenv.mkDerivation (finalAttrs: {
description = "3D vector-based clone of the atari game Missile Command";
mainProgram = "icbm3d";
license = lib.licenses.gpl2Plus;
platforms = lib.platforms.linux;
platforms = lib.platforms.unix;
};
})
+10 -4
View File
@@ -19,14 +19,20 @@ stdenv.mkDerivation rec {
libXpm
];
buildPhase = ''
make all HIGH_SCORES_FILE=.xgalaga++.scores
'';
buildFlags = [
"all"
"HIGH_SCORES_FILE=.xgalaga++.scores"
"CXX=${stdenv.cc.targetPrefix}c++" # fix darwin and cross-compiled builds
];
installPhase = ''
runHook preInstall
mkdir -p $out/bin $out/share/man
mv xgalaga++ $out/bin
mv xgalaga++.6x $out/share/man
runHook postInstall
'';
meta = with lib; {
@@ -34,6 +40,6 @@ stdenv.mkDerivation rec {
description = "XGalaga++ is a classic single screen vertical shoot em up. It is inspired by XGalaga and reuses most of its sprites";
mainProgram = "xgalaga++";
license = licenses.gpl2Plus;
platforms = platforms.linux;
platforms = platforms.unix;
};
}