2024-04-21 15:54:59 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, cmake
|
|
|
|
, libGLU
|
|
|
|
, libGL
|
2024-07-27 06:49:29 +00:00
|
|
|
, libglut
|
2024-04-21 15:54:59 +00:00
|
|
|
, libX11
|
|
|
|
, libXcursor
|
|
|
|
, libXinerama
|
|
|
|
, libXrandr
|
|
|
|
, xorgproto
|
|
|
|
, libXi
|
|
|
|
, pkg-config
|
|
|
|
, Carbon
|
|
|
|
, Cocoa
|
|
|
|
, Kernel
|
|
|
|
, OpenGL
|
|
|
|
, settingsFile ? "include/box2d/b2_settings.h"
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
let
|
|
|
|
inherit (lib) cmakeBool optionals;
|
|
|
|
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "box2d";
|
2024-04-21 15:54:59 +00:00
|
|
|
version = "2.4.1";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-01-03 16:56:52 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "erincatto";
|
|
|
|
repo = "box2d";
|
2024-04-21 15:54:59 +00:00
|
|
|
rev = "v${finalAttrs.version}";
|
|
|
|
hash = "sha256-cL8L+WSTcswj+Bwy8kSOwuEqLyWEM6xa/j/94aBiSck=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-01-03 16:56:52 +00:00
|
|
|
nativeBuildInputs = [ cmake pkg-config ];
|
2024-04-21 15:54:59 +00:00
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
libGLU
|
|
|
|
libGL
|
2024-07-27 06:49:29 +00:00
|
|
|
libglut
|
2024-04-21 15:54:59 +00:00
|
|
|
libX11
|
|
|
|
libXcursor
|
|
|
|
libXinerama
|
|
|
|
libXrandr
|
|
|
|
xorgproto
|
|
|
|
libXi
|
|
|
|
] ++ optionals stdenv.isDarwin [
|
|
|
|
Carbon Cocoa Kernel OpenGL
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
cmakeFlags = [
|
2024-04-21 15:54:59 +00:00
|
|
|
(cmakeBool "BOX2D_BUILD_UNIT_TESTS" finalAttrs.doCheck)
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
prePatch = ''
|
2024-04-21 15:54:59 +00:00
|
|
|
substituteInPlace ${settingsFile} \
|
|
|
|
--replace-fail 'b2_maxPolygonVertices 8' 'b2_maxPolygonVertices 15'
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
# tests are broken on 2.4.1 and 2.3.x doesn't have tests: https://github.com/erincatto/box2d/issues/677
|
|
|
|
doCheck = lib.versionAtLeast finalAttrs.version "2.4.2";
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "2D physics engine";
|
|
|
|
homepage = "https://box2d.org/";
|
2024-04-21 15:54:59 +00:00
|
|
|
maintainers = with maintainers; [ raskin ];
|
2021-06-28 23:13:55 +00:00
|
|
|
platforms = platforms.unix;
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.zlib;
|
|
|
|
};
|
2024-04-21 15:54:59 +00:00
|
|
|
})
|