nixpkgs/pkgs/applications/graphics/foxotron/default.nix
Manuel Frischknecht 5ff0ef514f foxotron: fetch assimp patches to fix build
Foxotron vendors a lot of dependencies (see the `external` directory and
the various submodules it contains). One of them (`FBX`) fails to build
with current versions of GCC because the compiler cannot resolve the
type `std::uint32_t`. The affected file still imports the type via
`#include <stdint.h>`, which has been superseded by `#include <cstdint>`
in C++11.

The upstream patch applied here fixes this build issue by introducing
the missing include line of `<cstdint>`.

The new addition to `postPatch` disables a `-Werror` setting that
(currently) seemingly only causes assimp builds failures on darwin.

Co-authored-by: Cosima Neidahl <opna2608@protonmail.com>
2024-01-22 21:24:20 +01:00

102 lines
2.7 KiB
Nix

{ stdenv
, lib
, fetchFromGitHub
, fetchpatch
, nix-update-script
, cmake
, pkg-config
, makeWrapper
, zlib
, libX11
, libXrandr
, libXinerama
, libXcursor
, libXi
, libXext
, libGLU
, alsa-lib
, fontconfig
, AVFoundation
, Carbon
, Cocoa
, CoreAudio
, Kernel
, OpenGL
}:
stdenv.mkDerivation rec {
pname = "foxotron";
version = "2023-07-16";
src = fetchFromGitHub {
owner = "Gargaj";
repo = "Foxotron";
rev = version;
fetchSubmodules = true;
sha256 = "sha256-s1eWZMVitVSP7nJJ5wXvnV8uI6yto7LmvlvocOwVAxw=";
};
patches = [
(fetchpatch {
name = "0001-assimp-Include-cstdint-for-std-uint32_t.patch";
url = "https://github.com/assimp/assimp/commit/108e3192a201635e49e99a91ff2044e1851a2953.patch";
stripLen = 1;
extraPrefix = "externals/assimp/";
hash = "sha256-rk0EFmgeZVwvx3NJOOob5Jwj9/J+eOtuAzfwp88o+J4=";
})
];
postPatch = ''
substituteInPlace CMakeLists.txt \
--replace "set(CMAKE_OSX_ARCHITECTURES x86_64)" ""
# Outdated vendored assimp, many warnings with newer compilers, too old for CMake option to control this
# Note that this -Werror caused issues on darwin, so make sure to re-check builds there before removing this
substituteInPlace externals/assimp/code/CMakeLists.txt \
--replace 'TARGET_COMPILE_OPTIONS(assimp PRIVATE -Werror)' ""
'';
nativeBuildInputs = [ cmake pkg-config makeWrapper ];
buildInputs = [ zlib ]
++ lib.optionals stdenv.hostPlatform.isLinux [ libX11 libXrandr libXinerama libXcursor libXi libXext alsa-lib fontconfig libGLU ]
++ lib.optionals stdenv.hostPlatform.isDarwin [ AVFoundation Carbon Cocoa CoreAudio Kernel OpenGL ];
env.NIX_CFLAGS_COMPILE = toString [
# Needed with GCC 12
"-Wno-error=array-bounds"
];
# error: writing 1 byte into a region of size 0
hardeningDisable = [ "fortify3" ];
installPhase = ''
runHook preInstall
mkdir -p $out/{bin,lib/foxotron}
cp -R ${lib.optionalString stdenv.hostPlatform.isDarwin "Foxotron.app/Contents/MacOS/"}Foxotron \
../{config.json,Shaders,Skyboxes} $out/lib/foxotron/
wrapProgram $out/lib/foxotron/Foxotron \
--chdir "$out/lib/foxotron"
ln -s $out/{lib/foxotron,bin}/Foxotron
runHook postInstall
'';
passthru = {
updateScript = nix-update-script { };
};
meta = with lib; {
description = "General purpose model viewer";
longDescription = ''
ASSIMP based general purpose model viewer ("turntable") created for the
Revision 2021 3D Graphics Competition.
'';
homepage = "https://github.com/Gargaj/Foxotron";
license = licenses.unlicense;
maintainers = with maintainers; [ OPNA2608 ];
platforms = platforms.all;
};
}