about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/box2d/default.nix
blob: c2611a8b8dffb6c37a0baa8ec5d5baf2dcf3f1b8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
{ lib
, stdenv
, fetchFromGitHub
, cmake
, libGLU
, libGL
, freeglut
, libX11
, libXcursor
, libXinerama
, libXrandr
, xorgproto
, libXi
, pkg-config
, Carbon
, Cocoa
, Kernel
, OpenGL
, settingsFile ? "include/box2d/b2_settings.h"
}:

let
  inherit (lib) cmakeBool optionals;

in
stdenv.mkDerivation (finalAttrs: {
  pname = "box2d";
  version = "2.4.1";

  src = fetchFromGitHub {
    owner = "erincatto";
    repo = "box2d";
    rev = "v${finalAttrs.version}";
    hash = "sha256-cL8L+WSTcswj+Bwy8kSOwuEqLyWEM6xa/j/94aBiSck=";
  };

  nativeBuildInputs = [ cmake pkg-config ];

  buildInputs = [
    libGLU
    libGL
    freeglut
    libX11
    libXcursor
    libXinerama
    libXrandr
    xorgproto
    libXi
  ] ++ optionals stdenv.isDarwin [
    Carbon Cocoa Kernel OpenGL
  ];

  cmakeFlags = [
    (cmakeBool "BOX2D_BUILD_UNIT_TESTS" finalAttrs.doCheck)
  ];

  prePatch = ''
    substituteInPlace ${settingsFile}  \
      --replace-fail 'b2_maxPolygonVertices	8' 'b2_maxPolygonVertices	15'
  '';

  # 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";

  meta = with lib; {
    description = "2D physics engine";
    homepage = "https://box2d.org/";
    maintainers = with maintainers; [ raskin ];
    platforms = platforms.unix;
    license = licenses.zlib;
  };
})