Files
nixpkgs/pkgs/by-name/bo/box2d/package.nix
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

101 lines
2.0 KiB
Nix

{
lib,
stdenv,
fetchFromGitHub,
replaceVars,
# nativeBuildInputs
cmake,
pkg-config,
# buildInputs
glfw3,
imgui,
libGLU,
libX11,
libXcursor,
libXi,
libXinerama,
libXrandr,
libglut,
xorgproto,
nix-update-script,
}:
let
inherit (lib) cmakeBool;
in
stdenv.mkDerivation (finalAttrs: {
pname = "box2d";
version = "3.1.1";
src = fetchFromGitHub {
owner = "erincatto";
repo = "box2d";
tag = "v${finalAttrs.version}";
hash = "sha256-IqQy9A8fWLG9H8ZPmOXeFZDaaks84miRuzXaFlNwm0g=";
};
patches = [
# prevent CMake from trying to download some libraries from the internet
(replaceVars ./cmake_dont_fetch_enkits.patch {
enkits_src = fetchFromGitHub {
owner = "dougbinks";
repo = "enkiTS";
rev = "686d0ec31829e0d9e5edf9ceb68c40f9b9b20ea9";
hash = "sha256-CerLj/WY+J3mrMvv7dGmZltjAM9v5C/IY4X+Ph78HVs=";
};
})
./cmake_use_system_glfw_and_imgui.patch
];
env.NIX_CFLAGS_COMPILE = toString (
lib.optionals stdenv.cc.isGNU [
# error: '*(float *)((char *)&localPointA + offsetof(b2Vec2, y))' may be used uninitialized
"-Wno-error=maybe-uninitialized"
]
);
nativeBuildInputs = [
cmake
pkg-config
];
buildInputs = [
glfw3
(imgui.override {
# GLFW backend is disabled by default on darwin but box2d imports it unconditionally
# https://github.com/erincatto/box2d/blob/v3.1.0/samples/main.cpp#L28
IMGUI_BUILD_GLFW_BINDING = true;
})
libGLU
libX11
libXcursor
libXi
libXinerama
libXrandr
libglut
xorgproto
];
cmakeFlags = [
(cmakeBool "BOX2D_BUILD_UNIT_TESTS" finalAttrs.finalPackage.doCheck)
];
passthru = {
updateScript = nix-update-script { };
};
meta = {
description = "2D physics engine";
homepage = "https://box2d.org/";
changelog = "https://github.com/erincatto/box2d/releases/tag/v${finalAttrs.version}";
maintainers = with lib.maintainers; [ raskin ];
platforms = lib.platforms.unix;
license = lib.licenses.zlib;
};
})