2022-09-09 14:08:57 +00:00
|
|
|
{ stdenv, lib, fetchFromGitHub, cmake, fetchpatch
|
|
|
|
, mesa, libGLU, glfw
|
|
|
|
, libX11, libXi, libXcursor, libXrandr, libXinerama
|
|
|
|
, alsaSupport ? stdenv.hostPlatform.isLinux, alsa-lib
|
|
|
|
, pulseSupport ? stdenv.hostPlatform.isLinux, libpulseaudio
|
|
|
|
, sharedLib ? true
|
|
|
|
, includeEverything ? true
|
2022-11-02 22:02:43 +00:00
|
|
|
, raylib-games
|
2021-03-09 03:18:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "raylib";
|
2022-09-09 14:08:57 +00:00
|
|
|
version = "4.2.0";
|
2021-03-09 03:18:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "raysan5";
|
|
|
|
repo = pname;
|
|
|
|
rev = version;
|
2022-09-09 14:08:57 +00:00
|
|
|
sha256 = "sha256-aMIjywcQxki0cKlNznPAMfvrtGj3qcR95D4/BDuPZZM=";
|
2021-03-09 03:18:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ cmake ];
|
2022-11-02 22:02:43 +00:00
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
buildInputs = [
|
2022-11-02 22:02:43 +00:00
|
|
|
mesa glfw libXi libXcursor libXrandr libXinerama
|
2021-06-28 23:13:55 +00:00
|
|
|
] ++ lib.optional alsaSupport alsa-lib
|
2021-03-09 03:18:52 +00:00
|
|
|
++ lib.optional pulseSupport libpulseaudio;
|
2022-11-02 22:02:43 +00:00
|
|
|
propagatedBuildInputs = [ libGLU libX11 ];
|
2021-03-09 03:18:52 +00:00
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
patches = [
|
|
|
|
# fixes glfw compile error;
|
|
|
|
# remove with next raylib version > 4.2.0 or when glfw 3.4.0 is released.
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/raysan5/raylib/commit/2ad7967db80644a25ca123536cf2f6efcb869684.patch";
|
|
|
|
sha256 = "sha256-/xgzox1ITeoZ91QWdwnJJ+jJ5nJsMHcEgbIEdNYh4NY=";
|
|
|
|
name = "raylib-glfw-fix.patch";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
# https://github.com/raysan5/raylib/wiki/CMake-Build-Options
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DUSE_EXTERNAL_GLFW=ON"
|
|
|
|
"-DBUILD_EXAMPLES=OFF"
|
2022-09-09 14:08:57 +00:00
|
|
|
"-DCUSTOMIZE_BUILD=1"
|
2021-06-04 09:07:49 +00:00
|
|
|
] ++ lib.optional includeEverything "-DINCLUDE_EVERYTHING=ON"
|
|
|
|
++ lib.optional sharedLib "-DBUILD_SHARED_LIBS=ON";
|
2021-03-09 03:18:52 +00:00
|
|
|
|
|
|
|
# fix libasound.so/libpulse.so not being found
|
|
|
|
preFixup = ''
|
2021-06-28 23:13:55 +00:00
|
|
|
${lib.optionalString alsaSupport "patchelf --add-needed ${alsa-lib}/lib/libasound.so $out/lib/libraylib.so.${version}"}
|
2021-03-09 03:18:52 +00:00
|
|
|
${lib.optionalString pulseSupport "patchelf --add-needed ${libpulseaudio}/lib/libpulse.so $out/lib/libraylib.so.${version}"}
|
|
|
|
'';
|
|
|
|
|
2022-11-02 22:02:43 +00:00
|
|
|
passthru.tests = [ raylib-games ];
|
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "A simple and easy-to-use library to enjoy videogames programming";
|
2021-08-05 21:33:18 +00:00
|
|
|
homepage = "https://www.raylib.com/";
|
2021-03-09 03:18:52 +00:00
|
|
|
license = licenses.zlib;
|
|
|
|
maintainers = with maintainers; [ adamlwgriffiths ];
|
|
|
|
platforms = platforms.linux;
|
2021-10-06 13:57:05 +00:00
|
|
|
changelog = "https://github.com/raysan5/raylib/blob/${version}/CHANGELOG";
|
2021-03-09 03:18:52 +00:00
|
|
|
};
|
|
|
|
}
|