From 2d4449f7387fa9b8edbce0673ced027178232f89 Mon Sep 17 00:00:00 2001 From: Rhys-T <108157737+Rhys-T@users.noreply.github.com> Date: Tue, 24 Jun 2025 12:57:32 -0400 Subject: [PATCH 1/3] icbm3d: fix darwin and cross-compiled builds Forces `$CC` back to the correct value so it doesn't just assume `gcc`. Patches `randnum.c` and `text.c` to use the correct `#include`s instead of just ignoring the implicit declaration warnings. --- pkgs/by-name/ic/icbm3d/package.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/ic/icbm3d/package.nix b/pkgs/by-name/ic/icbm3d/package.nix index 22a2fc0cc044..1973d0de4f37 100644 --- a/pkgs/by-name/ic/icbm3d/package.nix +++ b/pkgs/by-name/ic/icbm3d/package.nix @@ -16,11 +16,17 @@ 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 ' text.c + ''; installPhase = '' runHook preInstall @@ -35,6 +41,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; }; }) From 2476727700f6e02c9a95f0f0ff1d22769b044ec0 Mon Sep 17 00:00:00 2001 From: Rhys-T <108157737+Rhys-T@users.noreply.github.com> Date: Tue, 24 Jun 2025 13:23:34 -0400 Subject: [PATCH 2/3] icbm3d: remove install commands from makefile 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. --- pkgs/by-name/ic/icbm3d/package.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/by-name/ic/icbm3d/package.nix b/pkgs/by-name/ic/icbm3d/package.nix index 1973d0de4f37..270e57c3045d 100644 --- a/pkgs/by-name/ic/icbm3d/package.nix +++ b/pkgs/by-name/ic/icbm3d/package.nix @@ -26,6 +26,11 @@ stdenv.mkDerivation (finalAttrs: { substituteInPlace randnum.c --replace-fail 'stdio.h' 'stdlib.h' sed -i '1i\ #include ' 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 = '' From 30fa220f2edfd9389afe398c7cedf6fd8d3390cd Mon Sep 17 00:00:00 2001 From: Rhys-T <108157737+Rhys-T@users.noreply.github.com> Date: Tue, 24 Jun 2025 13:39:49 -0400 Subject: [PATCH 3/3] xgalagapp: fix darwin and cross-compiled builds Forces `$CXX` back to the correct value so it doesn't just assume `g++`. Also rewrites the derivation to use the standard `buildPhase`, and properly call the `preInstall` and `postInstall` hooks. --- pkgs/by-name/xg/xgalagapp/package.nix | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pkgs/by-name/xg/xgalagapp/package.nix b/pkgs/by-name/xg/xgalagapp/package.nix index 8afd7f29f069..0611ba0ae8fc 100644 --- a/pkgs/by-name/xg/xgalagapp/package.nix +++ b/pkgs/by-name/xg/xgalagapp/package.nix @@ -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; }; }