1{
2 lib,
3 stdenv,
4 fetchurl,
5 cmake,
6 libglut,
7 libGLU,
8 libGL,
9 glfw2,
10 glew,
11 libX11,
12 xorgproto,
13 libXi,
14 libXmu,
15 fetchpatch,
16 libXrandr,
17}:
18
19stdenv.mkDerivation rec {
20 pname = "chipmunk";
21 majorVersion = "7";
22 version = "${majorVersion}.0.3";
23
24 src = fetchurl {
25 url = "https://chipmunk-physics.net/release/Chipmunk-${majorVersion}.x/Chipmunk-${version}.tgz";
26 sha256 = "06j9cfxsyrrnyvl7hsf55ac5mgff939mmijliampphlizyg0r2q4";
27 };
28
29 patches = [
30 (fetchpatch {
31 url = "https://github.com/slembcke/Chipmunk2D/commit/9a051e6fb970c7afe09ce2d564c163b81df050a8.patch";
32 sha256 = "0ps8bjba1k544vcdx5w0qk7gcjq94yfigxf67j50s63yf70k2n70";
33 })
34 ];
35
36 nativeBuildInputs = [ cmake ];
37 buildInputs = [
38 libglut
39 libGLU
40 libGL
41 glfw2
42 glew
43 libX11
44 xorgproto
45 libXi
46 libXmu
47 libXrandr
48 ];
49
50 postInstall = ''
51 mkdir -p $out/bin
52 cp demo/chipmunk_demos $out/bin
53 '';
54
55 meta = with lib; {
56 description = "Fast and lightweight 2D game physics library";
57 mainProgram = "chipmunk_demos";
58 homepage = "http://chipmunk2d.net/";
59 license = licenses.mit;
60 platforms = platforms.unix; # supports Windows and MacOS as well, but those require more work
61 };
62}