biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / applications / science / robotics / mujoco / default.nix
blob3013ce74a334be979909a03dc11cb6b05fee04b2
1 { cereal_1_3_2
2 , cmake
3 , fetchFromGitHub
4 , fetchFromGitLab
5 , glfw
6 , glm
7 , lib
8 , spdlog
9 , stdenv
12 let
13   pin = {
15     # See https://github.com/google-deepmind/mujoco/blob/3.0.0/cmake/MujocoDependencies.cmake#L17-L64
16     abseil-cpp = fetchFromGitHub {
17       owner = "abseil";
18       repo = "abseil-cpp";
19       rev = "2f9e432cce407ce0ae50676696666f33a77d42ac";
20       hash = "sha256-D4E11bICKr3Z5RRah7QkfXVsXtuUg32FMmKpiOGjZDM=";
21     };
22     benchmark = fetchFromGitHub {
23       owner = "google";
24       repo = "benchmark";
25       rev = "e45585a4b8e75c28479fa4107182c28172799640";
26       hash = "sha256-pgHvmRpPd99ePUVRsi7WXLVSZngZ5q6r1vWW4mdGvxY=";
27     };
28     ccd = fetchFromGitHub {
29       owner = "danfis";
30       repo = "libccd";
31       rev = "7931e764a19ef6b21b443376c699bbc9c6d4fba8";
32       hash = "sha256-TIZkmqQXa0+bSWpqffIgaBela0/INNsX9LPM026x1Wk=";
33     };
34     eigen3 = fetchFromGitLab {
35       owner = "libeigen";
36       repo = "eigen";
37       rev = "2a9055b50ed22101da7d77e999b90ed50956fe0b";
38       hash = "sha256-tx/XR7xJ7IMh5RMvL8wRo/g+dfD3xcjZkLPSY4D9HaY=";
39     };
40     googletest = fetchFromGitHub {
41       owner = "google";
42       repo = "googletest";
43       rev = "f8d7d77c06936315286eb55f8de22cd23c188571";
44       hash = "sha256-t0RchAHTJbuI5YW4uyBPykTvcjy90JW9AOPNjIhwh6U=";
45     };
46     lodepng = fetchFromGitHub {
47       owner = "lvandeve";
48       repo = "lodepng";
49       rev = "b4ed2cd7ecf61d29076169b49199371456d4f90b";
50       hash = "sha256-5cCkdj/izP4e99BKfs/Mnwu9aatYXjlyxzzYiMD/y1M=";
51     };
52     qhull = fetchFromGitHub {
53       owner = "qhull";
54       repo = "qhull";
55       rev = "0c8fc90d2037588024d9964515c1e684f6007ecc";
56       hash = "sha256-Ptzxad3ewmKJbbcmrBT+os4b4SR976zlCG9F0nq0x94=";
57     };
58     tinyobjloader = fetchFromGitHub {
59       owner = "tinyobjloader";
60       repo = "tinyobjloader";
61       rev = "1421a10d6ed9742f5b2c1766d22faa6cfbc56248";
62       hash = "sha256-9z2Ne/WPCiXkQpT8Cun/pSGUwgClYH+kQ6Dx1JvW6w0=";
63     };
64     tinyxml2 = fetchFromGitHub {
65       owner = "leethomason";
66       repo = "tinyxml2";
67       rev = "9a89766acc42ddfa9e7133c7d81a5bda108a0ade";
68       hash = "sha256-YGAe4+Ttv/xeou+9FoJjmQCKgzupTYdDhd+gzvtz/88=";
69     };
70     marchingcubecpp = fetchFromGitHub {
71       owner = "aparis69";
72       repo = "MarchingCubeCpp";
73       rev = "5b79e5d6bded086a0abe276a4b5a69fc17ae9bf1";
74       hash = "sha256-L0DH1GJZ/3vatQAU/KZj/2xTKE6Fwcw9eQYzLdqX2N4=";
75     };
77     tmd = stdenv.mkDerivation rec {
78       name = "TriangleMeshDistance";
80       src = fetchFromGitHub {
81         owner = "InteractiveComputerGraphics";
82         repo = name;
83         rev = "e55a15c20551f36242fd6368df099a99de71d43a";
84         hash = "sha256-vj6TMMT8mp7ciLa5nzVAhMWPcAHXq+ZwHlWsRA3uCmg=";
85       };
87       installPhase = ''
88         mkdir -p $out/include/tmd
89         cp ${name}/include/tmd/${name}.h $out/include/tmd/
90       '';
91     };
93     sdflib = stdenv.mkDerivation rec {
94       name = "SdfLib";
96       src = fetchFromGitHub {
97         owner = "UPC-ViRVIG";
98         repo = name;
99         rev = "1927bee6bb8225258a39c8cbf14e18a4d50409ae";
100         hash = "sha256-+SFUOdZ6pGZvnQa0mT+yfbTMHWe2CTOlroXcuVBHdOE=";
101       };
103       patches = [ ./sdflib-system-deps.patch ];
105       cmakeFlags = [
106         "-DSDFLIB_USE_ASSIMP=OFF"
107         "-DSDFLIB_USE_OPENMP=OFF"
108         "-DSDFLIB_USE_ENOKI=OFF"
109         "-DSDFLIB_USE_SYSTEM_GLM=ON"
110         "-DSDFLIB_USE_SYSTEM_SPDLOG=ON"
111         "-DSDFLIB_USE_SYSTEM_CEREAL=ON"
112         "-DSDFLIB_USE_SYSTEM_TRIANGLEMESHDISTANCE=ON"
113       ];
115       nativeBuildInputs = [ cmake ];
116       buildInputs = [
117         pin.tmd
119         # Mainline. The otherwise pinned glm realease from 2018 does
120         # not build due to test failures and missing files.
121         glm
123         spdlog
124         cereal_1_3_2
125       ];
126     };
128   };
130 in stdenv.mkDerivation rec {
131   pname = "mujoco";
132   version = "3.1.4";
134   # Bumping version? Make sure to look though the MuJoCo's commit
135   # history for bumped dependency pins!
136   src = fetchFromGitHub {
137     owner = "google-deepmind";
138     repo = "mujoco";
139     rev = "refs/tags/${version}";
140     hash = "sha256-VgD6ditMDpHki7l23Gjip2roA8Oi4MGpxl+4gSLTEFs=";
141   };
143   patches = [ ./mujoco-system-deps-dont-fetch.patch ];
145   nativeBuildInputs = [ cmake ];
147   buildInputs = [
148     pin.sdflib
149     glm
151     # non-numerical
152     spdlog
153     cereal_1_3_2
154     glfw
155   ];
157   cmakeFlags = [
158     "-DMUJOCO_USE_SYSTEM_sdflib=ON"
159     "-DMUJOCO_SIMULATE_USE_SYSTEM_GLFW=ON"
160     "-DMUJOCO_SAMPLES_USE_SYSTEM_GLFW=ON"
161   ];
163   # Move things into place so that cmake doesn't try downloading dependencies.
164   preConfigure = ''
165     mkdir -p build/_deps
166     ln -s ${pin.abseil-cpp} build/_deps/abseil-cpp-src
167     ln -s ${pin.benchmark} build/_deps/benchmark-src
168     ln -s ${pin.ccd} build/_deps/ccd-src
169     ln -s ${pin.eigen3} build/_deps/eigen3-src
170     ln -s ${pin.googletest} build/_deps/googletest-src
171     ln -s ${pin.lodepng} build/_deps/lodepng-src
172     ln -s ${pin.qhull} build/_deps/qhull-src
173     ln -s ${pin.tinyobjloader} build/_deps/tinyobjloader-src
174     ln -s ${pin.tinyxml2} build/_deps/tinyxml2-src
175     ln -s ${pin.marchingcubecpp} build/_deps/marchingcubecpp-src
176   '';
178   passthru.pin = { inherit (pin) lodepng eigen3 abseil-cpp; };
180   meta = with lib; {
181     description = "Multi-Joint dynamics with Contact. A general purpose physics simulator.";
182     homepage = "https://mujoco.org/";
183     changelog = "https://github.com/google-deepmind/mujoco/releases/tag/${version}";
184     license = licenses.asl20;
185     maintainers = with maintainers; [ samuela tmplt ];
186     broken = stdenv.isDarwin;
187   };