From 1710aeb1840c1df233db81aa46e4e76070e545ce 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 --- .../bo/box2d/package.nix} | 33 +++++++------------ pkgs/top-level/all-packages.nix | 9 ----- 2 files changed, 11 insertions(+), 31 deletions(-) rename pkgs/{development/libraries/box2d/default.nix => by-name/bo/box2d/package.nix} (79%) diff --git a/pkgs/development/libraries/box2d/default.nix b/pkgs/by-name/bo/box2d/package.nix similarity index 79% rename from pkgs/development/libraries/box2d/default.nix rename to pkgs/by-name/bo/box2d/package.nix index 197d9313de27..deb842eb92ce 100644 --- a/pkgs/development/libraries/box2d/default.nix +++ b/pkgs/by-name/bo/box2d/package.nix @@ -13,10 +13,6 @@ xorgproto, libXi, pkg-config, - Carbon, - Cocoa, - Kernel, - OpenGL, settingsFile ? "include/box2d/b2_settings.h", }: @@ -40,24 +36,17 @@ stdenv.mkDerivation (finalAttrs: { pkg-config ]; - buildInputs = - [ - libGLU - libGL - libglut - libX11 - libXcursor - libXinerama - libXrandr - xorgproto - libXi - ] - ++ optionals stdenv.hostPlatform.isDarwin [ - Carbon - Cocoa - Kernel - OpenGL - ]; + buildInputs = [ + libGL + libGLU + libX11 + libXcursor + libXi + libXinerama + libXrandr + libglut + xorgproto + ]; cmakeFlags = [ (cmakeBool "BOX2D_BUILD_UNIT_TESTS" finalAttrs.finalPackage.doCheck) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index e695a90ed900..df92e6596b8d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -9012,15 +9012,6 @@ with pkgs; botan3 ; - box2d = callPackage ../development/libraries/box2d { - inherit (darwin.apple_sdk.frameworks) - Carbon - Cocoa - Kernel - OpenGL - ; - }; - c-ares = callPackage ../development/libraries/c-ares { }; c-aresMinimal = callPackage ../development/libraries/c-ares { From ebd1be41800cb26de0b2159c3ffb64a23d760bd9 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sun, 8 Sep 2024 11:24:27 +0200 Subject: [PATCH 2/5] box2d: 2.4.2 -> 3.1.0 Diff: https://github.com/erincatto/box2d/compare/v2.4.2...v3.1.0 Changelog: https://box2d.org/documentation/md_release__notes__v310.html --- .../bo/box2d/cmake_dont_fetch_enkits.patch | 16 ++++ .../cmake_use_system_glfw_and_imgui.patch | 54 ++++++++++++++ pkgs/by-name/bo/box2d/package.nix | 73 +++++++++++++------ 3 files changed, 122 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 000000000000..aa685fb71f14 --- /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 000000000000..dd76023882df --- /dev/null +++ b/pkgs/by-name/bo/box2d/cmake_use_system_glfw_and_imgui.patch @@ -0,0 +1,54 @@ +diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt +index 5020345..97af8c6 100644 +--- a/samples/CMakeLists.txt ++++ b/samples/CMakeLists.txt +@@ -17,47 +17,12 @@ 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 3.4 +- GIT_SHALLOW TRUE +- GIT_PROGRESS TRUE +-) +-FetchContent_MakeAvailable(glfw) ++find_package(glfw) + + # imgui and glfw backend for GUI + # https://gist.github.com/jeffamstutz/992723dfabac4e3ffff265eb71a24cd9 + # Modified to pin to a specific imgui release +-FetchContent_Populate(imgui +- URL https://github.com/ocornut/imgui/archive/refs/tags/v1.91.3.zip +- SOURCE_DIR ${CMAKE_SOURCE_DIR}/build/imgui +-) +- +-set(IMGUI_DIR ${CMAKE_SOURCE_DIR}/build/imgui) +- +-add_library(imgui STATIC +- ${IMGUI_DIR}/imconfig.h +- ${IMGUI_DIR}/imgui.h +- +- ${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) +-set_target_properties(imgui PROPERTIES +- CXX_STANDARD 20 +- CXX_STANDARD_REQUIRED YES +- CXX_EXTENSIONS NO +-) ++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 deb842eb92ce..8b29fa3afa45 100644 --- a/pkgs/by-name/bo/box2d/package.nix +++ b/pkgs/by-name/bo/box2d/package.nix @@ -2,42 +2,76 @@ lib, stdenv, fetchFromGitHub, + + substituteAll, + + # nativeBuildInputs cmake, + pkg-config, + + # buildInputs + glfw3, + imgui, libGLU, - libGL, - libglut, libX11, libXcursor, + libXi, libXinerama, libXrandr, + libglut, xorgproto, - libXi, - pkg-config, - settingsFile ? "include/box2d/b2_settings.h", + + nix-update-script, }: let - inherit (lib) cmakeBool optionals; + inherit (lib) cmakeBool; in stdenv.mkDerivation (finalAttrs: { pname = "box2d"; - version = "2.4.2"; + version = "3.1.0"; src = fetchFromGitHub { owner = "erincatto"; repo = "box2d"; - rev = "v${finalAttrs.version}"; - hash = "sha256-yvhpgiZpjTPeSY7Ma1bh4LwIokUUKB10v2WHlamL9D8="; + tag = "v${finalAttrs.version}"; + hash = "sha256-QTSU1+9x8GoUK3hlTDMh43fc4vbNfFR7syt6xVHIuPs="; }; + 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 + ]; + + 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 = [ - libGL + 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 @@ -52,19 +86,16 @@ stdenv.mkDerivation (finalAttrs: { (cmakeBool "BOX2D_BUILD_UNIT_TESTS" finalAttrs.finalPackage.doCheck) ]; - prePatch = '' - substituteInPlace ${settingsFile} \ - --replace-fail 'b2_maxPolygonVertices 8' 'b2_maxPolygonVertices 15' - ''; + passthru = { + updateScript = nix-update-script { }; + }; - # 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; + changelog = "https://github.com/erincatto/box2d/releases/tag/v${finalAttrs.version}"; + maintainers = with lib.maintainers; [ raskin ]; + platforms = lib.platforms.unix; + license = lib.licenses.zlib; }; }) From 3ec60797a5c9eed73e274b9bd0c5fd057588b373 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sun, 15 Sep 2024 11:37:05 +0200 Subject: [PATCH 3/5] qt6Packages.qmlbox2d: unstable-2022-08-25 -> 0-unstable-2024-04-15 --- .../libraries/qmlbox2d/default.nix | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/pkgs/development/libraries/qmlbox2d/default.nix b/pkgs/development/libraries/qmlbox2d/default.nix index 5f6cf45351f2..3a1552d6596a 100644 --- a/pkgs/development/libraries/qmlbox2d/default.nix +++ b/pkgs/development/libraries/qmlbox2d/default.nix @@ -7,20 +7,23 @@ cmake, pkg-config, box2d, + unstableGitUpdater, }: 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}"; + tag = "v${version}"; hash = "sha256-Z2J17YMzQNZqABIa5eyJDT7BWfXveymzs+DWsrklPIs="; }; + patches = [ ]; + postPatch = ""; sourceRoot = "${src.name}/Box2D"; cmakeFlags = old.cmakeFlags or [ ] ++ [ (cmakeBool "BOX2D_INSTALL" true) @@ -32,13 +35,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; @@ -58,11 +61,17 @@ stdenv.mkDerivation { (cmakeBool "USE_SYSTEM_BOX2D" true) ]; - meta = with lib; { + passthru = { + updateScript = unstableGitUpdater { + hardcodeZeroVersion = true; + }; + }; + + 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 a19141a6d034efca78610465a28a12753b9c29c6 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sun, 20 Apr 2025 16:27:57 +0200 Subject: [PATCH 4/5] box2d_2: init at 2.4.2 --- pkgs/by-name/bo/box2d_2/package.nix | 68 +++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 pkgs/by-name/bo/box2d_2/package.nix diff --git a/pkgs/by-name/bo/box2d_2/package.nix b/pkgs/by-name/bo/box2d_2/package.nix new file mode 100644 index 000000000000..48eb6c42bfc9 --- /dev/null +++ b/pkgs/by-name/bo/box2d_2/package.nix @@ -0,0 +1,68 @@ +{ + lib, + stdenv, + fetchFromGitHub, + + # nativeBuildInputs + cmake, + pkg-config, + + # buildInputs + glfw3, + libGLU, + libX11, + libXcursor, + libXi, + libXinerama, + libXrandr, + libglut, + xorgproto, + + nix-update-script, +}: + +let + inherit (lib) cmakeBool; + +in +stdenv.mkDerivation (finalAttrs: { + pname = "box2d"; + version = "2.4.2"; + + src = fetchFromGitHub { + owner = "erincatto"; + repo = "box2d"; + tag = "v${finalAttrs.version}"; + hash = "sha256-yvhpgiZpjTPeSY7Ma1bh4LwIokUUKB10v2WHlamL9D8="; + }; + + nativeBuildInputs = [ + cmake + pkg-config + ]; + + buildInputs = [ + glfw3 + libGLU + libX11 + libXcursor + libXi + libXinerama + libXrandr + libglut + xorgproto + ]; + + cmakeFlags = [ + (cmakeBool "BOX2D_BUILD_UNIT_TESTS" finalAttrs.finalPackage.doCheck) + ]; + + 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; + }; +}) From e65a310c20e039882d2f34dd200cf98a64e1101b Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sun, 20 Apr 2025 16:33:07 +0200 Subject: [PATCH 5/5] libreoffice: use box2d_2 --- pkgs/applications/office/libreoffice/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/office/libreoffice/default.nix b/pkgs/applications/office/libreoffice/default.nix index 356a46d5ca81..dbad506b8c94 100644 --- a/pkgs/applications/office/libreoffice/default.nix +++ b/pkgs/applications/office/libreoffice/default.nix @@ -10,7 +10,7 @@ libxslt, perl, perlPackages, - box2d, + box2d_2, gettext, zlib, libjpeg, @@ -397,7 +397,7 @@ stdenv.mkDerivation (finalAttrs: { ant bluez5 boost - box2d + box2d_2 cairo clucene_core_2 cppunit