nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ stdenv, lib, fetchFromGitHub, cmake, fetchpatch
2, mesa, libGLU, glfw
3, libX11, libXi, libXcursor, libXrandr, libXinerama
4, alsaSupport ? stdenv.hostPlatform.isLinux, alsa-lib
5, pulseSupport ? stdenv.hostPlatform.isLinux, libpulseaudio
6, sharedLib ? true
7, includeEverything ? true
8, raylib-games
9}:
10
11stdenv.mkDerivation rec {
12 pname = "raylib";
13 version = "4.2.0";
14
15 src = fetchFromGitHub {
16 owner = "raysan5";
17 repo = pname;
18 rev = version;
19 sha256 = "sha256-aMIjywcQxki0cKlNznPAMfvrtGj3qcR95D4/BDuPZZM=";
20 };
21
22 nativeBuildInputs = [ cmake ];
23
24 buildInputs = [
25 mesa glfw libXi libXcursor libXrandr libXinerama
26 ] ++ lib.optional alsaSupport alsa-lib
27 ++ lib.optional pulseSupport libpulseaudio;
28 propagatedBuildInputs = [ libGLU libX11 ];
29
30 patches = [
31 # fixes glfw compile error;
32 # remove with next raylib version > 4.2.0 or when glfw 3.4.0 is released.
33 (fetchpatch {
34 url = "https://github.com/raysan5/raylib/commit/2ad7967db80644a25ca123536cf2f6efcb869684.patch";
35 sha256 = "sha256-/xgzox1ITeoZ91QWdwnJJ+jJ5nJsMHcEgbIEdNYh4NY=";
36 name = "raylib-glfw-fix.patch";
37 })
38 ];
39
40 # https://github.com/raysan5/raylib/wiki/CMake-Build-Options
41 cmakeFlags = [
42 "-DUSE_EXTERNAL_GLFW=ON"
43 "-DBUILD_EXAMPLES=OFF"
44 "-DCUSTOMIZE_BUILD=1"
45 ] ++ lib.optional includeEverything "-DINCLUDE_EVERYTHING=ON"
46 ++ lib.optional sharedLib "-DBUILD_SHARED_LIBS=ON";
47
48 # fix libasound.so/libpulse.so not being found
49 preFixup = ''
50 ${lib.optionalString alsaSupport "patchelf --add-needed ${alsa-lib}/lib/libasound.so $out/lib/libraylib.so.${version}"}
51 ${lib.optionalString pulseSupport "patchelf --add-needed ${libpulseaudio}/lib/libpulse.so $out/lib/libraylib.so.${version}"}
52 '';
53
54 passthru.tests = [ raylib-games ];
55
56 meta = with lib; {
57 description = "A simple and easy-to-use library to enjoy videogames programming";
58 homepage = "https://www.raylib.com/";
59 license = licenses.zlib;
60 maintainers = with maintainers; [ adamlwgriffiths ];
61 platforms = platforms.linux;
62 changelog = "https://github.com/raysan5/raylib/blob/${version}/CHANGELOG";
63 };
64}