mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-02 03:43:06 +00:00
e0464e4788
In preparation for the deprecation of `stdenv.isX`. These shorthands are not conducive to cross-compilation because they hide the platforms. Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way One example of why this is bad and especially affects compiler packages https://www.github.com/NixOS/nixpkgs/pull/343059 There are too many files to go through manually but a treewide should get users thinking when they see a `hostPlatform.isX` in a place where it doesn't make sense. ``` fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is" fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is" ```
73 lines
1.4 KiB
Nix
73 lines
1.4 KiB
Nix
{ lib
|
|
, stdenv
|
|
, fetchFromGitHub
|
|
, cmake
|
|
, libGLU
|
|
, libGL
|
|
, libglut
|
|
, libX11
|
|
, libXcursor
|
|
, libXinerama
|
|
, libXrandr
|
|
, xorgproto
|
|
, libXi
|
|
, pkg-config
|
|
, Carbon
|
|
, Cocoa
|
|
, Kernel
|
|
, OpenGL
|
|
, settingsFile ? "include/box2d/b2_settings.h"
|
|
}:
|
|
|
|
let
|
|
inherit (lib) cmakeBool optionals;
|
|
|
|
in
|
|
stdenv.mkDerivation (finalAttrs: {
|
|
pname = "box2d";
|
|
version = "2.4.2";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "erincatto";
|
|
repo = "box2d";
|
|
rev = "v${finalAttrs.version}";
|
|
hash = "sha256-yvhpgiZpjTPeSY7Ma1bh4LwIokUUKB10v2WHlamL9D8=";
|
|
};
|
|
|
|
nativeBuildInputs = [ cmake pkg-config ];
|
|
|
|
buildInputs = [
|
|
libGLU
|
|
libGL
|
|
libglut
|
|
libX11
|
|
libXcursor
|
|
libXinerama
|
|
libXrandr
|
|
xorgproto
|
|
libXi
|
|
] ++ optionals stdenv.hostPlatform.isDarwin [
|
|
Carbon Cocoa Kernel OpenGL
|
|
];
|
|
|
|
cmakeFlags = [
|
|
(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; {
|
|
description = "2D physics engine";
|
|
homepage = "https://box2d.org/";
|
|
maintainers = with maintainers; [ raskin ];
|
|
platforms = platforms.unix;
|
|
license = licenses.zlib;
|
|
};
|
|
})
|