From bb3936fa00b78c7cd95302b60f3f127a2c2ac7a5 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sun, 8 Sep 2024 11:21:35 +0200 Subject: [PATCH 1/5] box2d: move to pkgs/by-name --- .../box2d/default.nix => by-name/bo/box2d/package.nix} | 10 +++++----- pkgs/top-level/all-packages.nix | 4 ---- 2 files changed, 5 insertions(+), 9 deletions(-) rename pkgs/{development/libraries/box2d/default.nix => by-name/bo/box2d/package.nix} (89%) diff --git a/pkgs/development/libraries/box2d/default.nix b/pkgs/by-name/bo/box2d/package.nix similarity index 89% rename from pkgs/development/libraries/box2d/default.nix rename to pkgs/by-name/bo/box2d/package.nix index acc2d96caf4a7..675b9802ef218 100644 --- a/pkgs/development/libraries/box2d/default.nix +++ b/pkgs/by-name/bo/box2d/package.nix @@ -12,10 +12,7 @@ , xorgproto , libXi , pkg-config -, Carbon -, Cocoa -, Kernel -, OpenGL +, darwin , settingsFile ? "include/box2d/b2_settings.h" }: @@ -47,7 +44,10 @@ stdenv.mkDerivation (finalAttrs: { xorgproto libXi ] ++ optionals stdenv.hostPlatform.isDarwin [ - Carbon Cocoa Kernel OpenGL + darwin.apple_sdk.frameworks.Carbon + darwin.apple_sdk.frameworks.Cocoa + darwin.apple_sdk.frameworks.Kernel + darwin.apple_sdk.frameworks.OpenGL ]; cmakeFlags = [ diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 3ecb984fb6678..25b1899bd5895 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -19069,10 +19069,6 @@ with pkgs; botan3 ; - box2d = callPackage ../development/libraries/box2d { - inherit (darwin.apple_sdk.frameworks) Carbon Cocoa Kernel OpenGL; - }; - boxfort = callPackage ../development/libraries/boxfort { }; brunsli = callPackage ../development/libraries/brunsli { }; From eb0a83d348bfb4aee79054cc991b1174328185f9 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sun, 8 Sep 2024 11:22:59 +0200 Subject: [PATCH 2/5] box2d: format with nixfmt --- pkgs/by-name/bo/box2d/package.nix | 72 +++++++++++++++++-------------- 1 file changed, 39 insertions(+), 33 deletions(-) diff --git a/pkgs/by-name/bo/box2d/package.nix b/pkgs/by-name/bo/box2d/package.nix index 675b9802ef218..3981235a3cd63 100644 --- a/pkgs/by-name/bo/box2d/package.nix +++ b/pkgs/by-name/bo/box2d/package.nix @@ -1,19 +1,20 @@ -{ lib -, stdenv -, fetchFromGitHub -, cmake -, libGLU -, libGL -, libglut -, libX11 -, libXcursor -, libXinerama -, libXrandr -, xorgproto -, libXi -, pkg-config -, darwin -, settingsFile ? "include/box2d/b2_settings.h" +{ + lib, + stdenv, + fetchFromGitHub, + cmake, + libGLU, + libGL, + libglut, + libX11, + libXcursor, + libXinerama, + libXrandr, + xorgproto, + libXi, + pkg-config, + darwin, + settingsFile ? "include/box2d/b2_settings.h", }: let @@ -31,25 +32,30 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-yvhpgiZpjTPeSY7Ma1bh4LwIokUUKB10v2WHlamL9D8="; }; - nativeBuildInputs = [ cmake pkg-config ]; - - buildInputs = [ - libGLU - libGL - libglut - libX11 - libXcursor - libXinerama - libXrandr - xorgproto - libXi - ] ++ optionals stdenv.hostPlatform.isDarwin [ - darwin.apple_sdk.frameworks.Carbon - darwin.apple_sdk.frameworks.Cocoa - darwin.apple_sdk.frameworks.Kernel - darwin.apple_sdk.frameworks.OpenGL + nativeBuildInputs = [ + cmake + pkg-config ]; + buildInputs = + [ + libGLU + libGL + libglut + libX11 + libXcursor + libXinerama + libXrandr + xorgproto + libXi + ] + ++ optionals stdenv.hostPlatform.isDarwin [ + darwin.apple_sdk.frameworks.Carbon + darwin.apple_sdk.frameworks.Cocoa + darwin.apple_sdk.frameworks.Kernel + darwin.apple_sdk.frameworks.OpenGL + ]; + cmakeFlags = [ (cmakeBool "BOX2D_BUILD_UNIT_TESTS" finalAttrs.finalPackage.doCheck) ]; From be31de13d1d663f2149475c59ecec2bc13e44fd2 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sun, 8 Sep 2024 11:24:27 +0200 Subject: [PATCH 3/5] box2d: 2.4.2 -> 3.0.0 Diff: https://github.com/erincatto/box2d/compare/v2.4.2...v3.0.0 Changelog: https://box2d.org/posts/2024/08/releasing-box2d-3.0/ --- .../bo/box2d/cmake_dont_fetch_enkits.patch | 16 +++++ .../cmake_use_system_glfw_and_imgui.patch | 44 +++++++++++++ pkgs/by-name/bo/box2d/package.nix | 65 +++++++++++++------ 3 files changed, 104 insertions(+), 21 deletions(-) create mode 100644 pkgs/by-name/bo/box2d/cmake_dont_fetch_enkits.patch create mode 100644 pkgs/by-name/bo/box2d/cmake_use_system_glfw_and_imgui.patch diff --git a/pkgs/by-name/bo/box2d/cmake_dont_fetch_enkits.patch b/pkgs/by-name/bo/box2d/cmake_dont_fetch_enkits.patch new file mode 100644 index 0000000000000..aa685fb71f140 --- /dev/null +++ b/pkgs/by-name/bo/box2d/cmake_dont_fetch_enkits.patch @@ -0,0 +1,16 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 8c1390e..791d3b7 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -83,10 +83,7 @@ if(PROJECT_IS_TOP_LEVEL) + # Used in tests and samples + FetchContent_Declare( + enkits +- GIT_REPOSITORY https://github.com/dougbinks/enkiTS.git +- GIT_TAG master +- GIT_SHALLOW TRUE +- GIT_PROGRESS TRUE ++ URL @enkits_src@ + ) + FetchContent_MakeAvailable(enkits) + endif() diff --git a/pkgs/by-name/bo/box2d/cmake_use_system_glfw_and_imgui.patch b/pkgs/by-name/bo/box2d/cmake_use_system_glfw_and_imgui.patch new file mode 100644 index 0000000000000..1e13c132c2b64 --- /dev/null +++ b/pkgs/by-name/bo/box2d/cmake_use_system_glfw_and_imgui.patch @@ -0,0 +1,44 @@ +diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt +index dd136f7..96c5db7 100644 +--- a/samples/CMakeLists.txt ++++ b/samples/CMakeLists.txt +@@ -17,37 +17,11 @@ set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "GLFW Examples") + set(GLFW_BUILD_TESTS OFF CACHE BOOL "GLFW Tests") + set(GLFW_INSTALL OFF CACHE BOOL "GLFW Install") + +-FetchContent_Declare( +- glfw +- GIT_REPOSITORY https://github.com/glfw/glfw.git +- GIT_TAG master +- GIT_SHALLOW TRUE +- GIT_PROGRESS TRUE +-) +-FetchContent_MakeAvailable(glfw) ++find_package(glfw) + + # imgui and glfw backend for GUI + # https://gist.github.com/jeffamstutz/992723dfabac4e3ffff265eb71a24cd9 +-FetchContent_Populate(imgui +- URL https://github.com/ocornut/imgui/archive/docking.zip +- SOURCE_DIR ${CMAKE_SOURCE_DIR}/build/imgui +-) +- +-set(IMGUI_DIR ${CMAKE_SOURCE_DIR}/build/imgui) +- +-add_library(imgui STATIC +- ${IMGUI_DIR}/imgui.cpp +- ${IMGUI_DIR}/imgui_draw.cpp +- ${IMGUI_DIR}/imgui_demo.cpp +- ${IMGUI_DIR}/imgui_tables.cpp +- ${IMGUI_DIR}/imgui_widgets.cpp +- +- ${IMGUI_DIR}/backends/imgui_impl_glfw.cpp +- ${IMGUI_DIR}/backends/imgui_impl_opengl3.cpp +-) +-target_link_libraries(imgui PUBLIC glfw glad) +-target_include_directories(imgui PUBLIC ${IMGUI_DIR} ${IMGUI_DIR}/backends) +-target_compile_definitions(imgui PUBLIC IMGUI_DISABLE_OBSOLETE_FUNCTIONS) ++find_package(imgui) + + # jsmn for json + set(JSMN_DIR ${CMAKE_SOURCE_DIR}/extern/jsmn) diff --git a/pkgs/by-name/bo/box2d/package.nix b/pkgs/by-name/bo/box2d/package.nix index 3981235a3cd63..61b5bcfbc293b 100644 --- a/pkgs/by-name/bo/box2d/package.nix +++ b/pkgs/by-name/bo/box2d/package.nix @@ -2,19 +2,26 @@ lib, stdenv, fetchFromGitHub, + + substituteAll, + + # nativeBuildInputs cmake, - libGLU, + pkg-config, + + # buildInputs + glfw3, + imgui, libGL, + libGLU, libglut, libX11, libXcursor, + libXi, libXinerama, libXrandr, xorgproto, - libXi, - pkg-config, darwin, - settingsFile ? "include/box2d/b2_settings.h", }: let @@ -23,15 +30,37 @@ let in stdenv.mkDerivation (finalAttrs: { pname = "box2d"; - version = "2.4.2"; + version = "3.0.0"; src = fetchFromGitHub { owner = "erincatto"; repo = "box2d"; - rev = "v${finalAttrs.version}"; - hash = "sha256-yvhpgiZpjTPeSY7Ma1bh4LwIokUUKB10v2WHlamL9D8="; + rev = "refs/tags/v${finalAttrs.version}"; + hash = "sha256-ZS6v+Oq7wWjUY3ZEp6h7W7fQ5nUienz9N+ntXodgAVQ="; }; + patches = [ + # prevent CMake from trying to download some libraries from the internet + (substituteAll { + src = ./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 + ]; + + # Taken from https://github.com/erincatto/box2d/pull/784 + postPatch = '' + substituteInPlace samples/settings.cpp \ + --replace-fail "fread( data, size, 1, file );" "size_t count = fread( data, size, 1, file );" + substituteInPlace samples/shader.cpp \ + --replace-fail "fread( source, size, 1, file );" "size_t count = fread( source, size, 1, file );" + ''; + nativeBuildInputs = [ cmake pkg-config @@ -39,15 +68,17 @@ stdenv.mkDerivation (finalAttrs: { buildInputs = [ - libGLU + glfw3 + imgui libGL + libGLU libglut libX11 libXcursor + libXi libXinerama libXrandr xorgproto - libXi ] ++ optionals stdenv.hostPlatform.isDarwin [ darwin.apple_sdk.frameworks.Carbon @@ -60,19 +91,11 @@ stdenv.mkDerivation (finalAttrs: { (cmakeBool "BOX2D_BUILD_UNIT_TESTS" finalAttrs.finalPackage.doCheck) ]; - prePatch = '' - substituteInPlace ${settingsFile} \ - --replace-fail 'b2_maxPolygonVertices 8' 'b2_maxPolygonVertices 15' - ''; - - # tests are broken on 2.4.2 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; { + meta = { description = "2D physics engine"; homepage = "https://box2d.org/"; - maintainers = with maintainers; [ raskin ]; - platforms = platforms.unix; - license = licenses.zlib; + maintainers = with lib.maintainers; [ raskin ]; + platforms = lib.platforms.unix; + license = lib.licenses.zlib; }; }) From fade7e31c60d9edf20e5781bdf3986f9fc421ac7 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sun, 15 Sep 2024 11:37:05 +0200 Subject: [PATCH 4/5] qt6Packages.qmlbox2d: unstable-2022-08-25 -> 0-unstable-2024-04-15 --- .../libraries/qmlbox2d/default.nix | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/pkgs/development/libraries/qmlbox2d/default.nix b/pkgs/development/libraries/qmlbox2d/default.nix index 7f7613d7f05fa..2e196887eeca7 100644 --- a/pkgs/development/libraries/qmlbox2d/default.nix +++ b/pkgs/development/libraries/qmlbox2d/default.nix @@ -4,14 +4,16 @@ let inherit (lib) cmakeBool; # 2.3.1 is the only supported version - box2d' = (box2d.override { settingsFile = "Box2D/Common/b2Settings.h"; }).overrideAttrs (old: rec { + box2d' = box2d.overrideAttrs (old: rec { version = "2.3.1"; src = fetchFromGitHub { owner = "erincatto"; repo = "box2d"; - rev = "v${version}"; + rev = "refs/tags/v${version}"; hash = "sha256-Z2J17YMzQNZqABIa5eyJDT7BWfXveymzs+DWsrklPIs="; }; + patches = []; + postPatch = ""; sourceRoot = "${src.name}/Box2D"; cmakeFlags = old.cmakeFlags or [ ] ++ [ (cmakeBool "BOX2D_INSTALL" true) @@ -23,13 +25,13 @@ let in stdenv.mkDerivation { pname = "qml-box2d"; - version = "unstable-2022-08-25"; + version = "0-unstable-2024-04-15"; src = fetchFromGitHub { owner = "qml-box2d"; repo = "qml-box2d"; - rev = "0bb88a6f871eef72b3b9ded9329c15f1da1f4fd7"; - hash = "sha256-sfSVetpHIAIujpgjvRScAkJRlQQYjQ/yQrkWvp7Yu0s="; + rev = "3a85439726d1ac4d082308feba45f23859ba71e0"; + hash = "sha256-lTgzPJWSwNfPRj5Lc63C69o4ILuyhVRLvltTo5E7yq0="; }; dontWrapQtApps = true; @@ -42,11 +44,11 @@ stdenv.mkDerivation { (cmakeBool "USE_SYSTEM_BOX2D" true) ]; - meta = with lib; { + meta = { description = "QML plugin for Box2D engine"; homepage = "https://github.com/qml-box2d/qml-box2d"; - maintainers = with maintainers; [ guibou ]; - platforms = platforms.linux; - license = licenses.zlib; + maintainers = with lib.maintainers; [ guibou ]; + platforms = lib.platforms.linux; + license = lib.licenses.zlib; }; } From 1a68e10bde46e160cb759a2e11b7db3574baabc6 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sun, 6 Oct 2024 12:06:47 +0200 Subject: [PATCH 5/5] box2d-lite: init at 1.0.1 --- pkgs/by-name/bo/box2d-lite/package.nix | 44 ++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 pkgs/by-name/bo/box2d-lite/package.nix diff --git a/pkgs/by-name/bo/box2d-lite/package.nix b/pkgs/by-name/bo/box2d-lite/package.nix new file mode 100644 index 0000000000000..3f59e88a41987 --- /dev/null +++ b/pkgs/by-name/bo/box2d-lite/package.nix @@ -0,0 +1,44 @@ +{ + lib, + stdenv, + fetchFromGitHub, + + # nativeBuildInputs + cmake, + + # buildInputs + glfw3, + libGL, + libX11, +}: + +stdenv.mkDerivation rec { + pname = "box2d-lite"; + version = "1.0.1"; + + src = fetchFromGitHub { + owner = "erincatto"; + repo = "box2d-lite"; + rev = "refs/tags/${version}"; + hash = "sha256-XilbE1HsDgpTvmz2EmcF9OZBHkabNxuBAo08al0Zixo="; + }; + + nativeBuildInputs = [ + cmake + ]; + + buildInputs = [ + glfw3 + libGL + libX11 + ]; + + meta = { + description = "A small 2D physics engine"; + homepage = "https://github.com/erincatto/box2d-lite"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ GaetanLepage ]; + mainProgram = "box2d-lite"; + platforms = lib.platforms.all; + }; +}