nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 cmake,
6 autoPatchelfHook,
7 glfw,
8 SDL2,
9 alsa-lib,
10 libpulseaudio,
11 raylib-games,
12 libGLU,
13 libX11,
14 platform ? "Desktop", # Note that "Web", "Android" and "Raspberry Pi" do not currently work
15 pulseSupport ? stdenv.hostPlatform.isLinux,
16 alsaSupport ? false,
17 sharedLib ? true,
18 includeEverything ? true,
19}:
20let
21 inherit (lib) optional;
22
23in
24
25lib.checkListOfEnum "raylib: platform"
26 [
27 "Desktop"
28 "Web"
29 "Android"
30 "Raspberry Pi"
31 "SDL"
32 ]
33 [ platform ]
34 (
35 stdenv.mkDerivation (finalAttrs: {
36 __structuredAttrs = true;
37
38 pname = "raylib";
39 version = "5.5-unstable-2026-01-20";
40
41 src = fetchFromGitHub {
42 owner = "raysan5";
43 repo = "raylib";
44 rev = "c610d228a244f930ad53492604640f39584c66da";
45 hash = "sha256-7Lhgqb7QJwz94M1ZxWgueTwIgSVclGCvHklZXGzoJgQ=";
46 };
47
48 # autoPatchelfHook is needed for appendRunpaths
49 nativeBuildInputs = [
50 cmake
51 ]
52 ++ optional (builtins.length finalAttrs.appendRunpaths > 0) autoPatchelfHook;
53
54 buildInputs = optional (platform == "Desktop") glfw ++ optional (platform == "SDL") SDL2;
55
56 propagatedBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [
57 libGLU
58 libX11
59 ];
60
61 # https://github.com/raysan5/raylib/wiki/CMake-Build-Options
62 cmakeFlags = [
63 "-DCUSTOMIZE_BUILD=ON"
64 "-DPLATFORM=${platform}"
65 ]
66 ++ optional (platform == "Desktop") "-DUSE_EXTERNAL_GLFW=ON"
67 ++ optional includeEverything "-DINCLUDE_EVERYTHING=ON"
68 ++ optional sharedLib "-DBUILD_SHARED_LIBS=ON";
69
70 appendRunpaths = optional stdenv.hostPlatform.isLinux (
71 lib.makeLibraryPath (optional alsaSupport alsa-lib ++ optional pulseSupport libpulseaudio)
72 );
73
74 passthru.tests = {
75 inherit raylib-games;
76 };
77
78 meta = {
79 description = "Simple and easy-to-use library to enjoy videogames programming";
80 homepage = "https://www.raylib.com/";
81 downloadPage = "https://github.com/raysan5/raylib";
82 license = lib.licenses.zlib;
83 maintainers = [ lib.maintainers.diniamo ];
84 teams = [ lib.teams.ngi ];
85 platforms = lib.platforms.all;
86 changelog = "https://github.com/raysan5/raylib/blob/${finalAttrs.src.rev}/CHANGELOG";
87 };
88 })
89 )