Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 100 lines 2.1 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 6 replaceVars, 7 8 # nativeBuildInputs 9 cmake, 10 pkg-config, 11 12 # buildInputs 13 glfw3, 14 imgui, 15 libGLU, 16 libX11, 17 libXcursor, 18 libXi, 19 libXinerama, 20 libXrandr, 21 libglut, 22 xorgproto, 23 24 nix-update-script, 25}: 26 27let 28 inherit (lib) cmakeBool; 29 30in 31stdenv.mkDerivation (finalAttrs: { 32 pname = "box2d"; 33 version = "3.1.1"; 34 35 src = fetchFromGitHub { 36 owner = "erincatto"; 37 repo = "box2d"; 38 tag = "v${finalAttrs.version}"; 39 hash = "sha256-IqQy9A8fWLG9H8ZPmOXeFZDaaks84miRuzXaFlNwm0g="; 40 }; 41 42 patches = [ 43 # prevent CMake from trying to download some libraries from the internet 44 (replaceVars ./cmake_dont_fetch_enkits.patch { 45 enkits_src = fetchFromGitHub { 46 owner = "dougbinks"; 47 repo = "enkiTS"; 48 rev = "686d0ec31829e0d9e5edf9ceb68c40f9b9b20ea9"; 49 hash = "sha256-CerLj/WY+J3mrMvv7dGmZltjAM9v5C/IY4X+Ph78HVs="; 50 }; 51 }) 52 ./cmake_use_system_glfw_and_imgui.patch 53 ]; 54 55 env.NIX_CFLAGS_COMPILE = toString ( 56 lib.optionals stdenv.cc.isGNU [ 57 # error: '*(float *)((char *)&localPointA + offsetof(b2Vec2, y))' may be used uninitialized 58 "-Wno-error=maybe-uninitialized" 59 ] 60 ); 61 62 nativeBuildInputs = [ 63 cmake 64 pkg-config 65 ]; 66 67 buildInputs = [ 68 glfw3 69 (imgui.override { 70 # GLFW backend is disabled by default on darwin but box2d imports it unconditionally 71 # https://github.com/erincatto/box2d/blob/v3.1.0/samples/main.cpp#L28 72 IMGUI_BUILD_GLFW_BINDING = true; 73 }) 74 libGLU 75 libX11 76 libXcursor 77 libXi 78 libXinerama 79 libXrandr 80 libglut 81 xorgproto 82 ]; 83 84 cmakeFlags = [ 85 (cmakeBool "BOX2D_BUILD_UNIT_TESTS" finalAttrs.finalPackage.doCheck) 86 ]; 87 88 passthru = { 89 updateScript = nix-update-script { }; 90 }; 91 92 meta = { 93 description = "2D physics engine"; 94 homepage = "https://box2d.org/"; 95 changelog = "https://github.com/erincatto/box2d/releases/tag/v${finalAttrs.version}"; 96 maintainers = with lib.maintainers; [ raskin ]; 97 platforms = lib.platforms.unix; 98 license = lib.licenses.zlib; 99 }; 100})