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] 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; }; })