Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 90 lines 2.3 kB view raw
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 23 pname = "raylib"; 24in 25 26lib.checkListOfEnum "${pname}: platform" 27 [ 28 "Desktop" 29 "Web" 30 "Android" 31 "Raspberry Pi" 32 "SDL" 33 ] 34 [ platform ] 35 ( 36 stdenv.mkDerivation (finalAttrs: { 37 __structuredAttrs = true; 38 39 inherit pname; 40 version = "5.5"; 41 42 src = fetchFromGitHub { 43 owner = "raysan5"; 44 repo = "raylib"; 45 rev = finalAttrs.version; 46 hash = "sha256-J99i4z4JF7d6mJNuJIB0rHNDhXJ5AEkG0eBvvuBLHrY="; 47 }; 48 49 # autoPatchelfHook is needed for appendRunpaths 50 nativeBuildInputs = [ 51 cmake 52 ] 53 ++ optional (builtins.length finalAttrs.appendRunpaths > 0) autoPatchelfHook; 54 55 buildInputs = optional (platform == "Desktop") glfw ++ optional (platform == "SDL") SDL2; 56 57 propagatedBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [ 58 libGLU 59 libX11 60 ]; 61 62 # https://github.com/raysan5/raylib/wiki/CMake-Build-Options 63 cmakeFlags = [ 64 "-DCUSTOMIZE_BUILD=ON" 65 "-DPLATFORM=${platform}" 66 ] 67 ++ optional (platform == "Desktop") "-DUSE_EXTERNAL_GLFW=ON" 68 ++ optional includeEverything "-DINCLUDE_EVERYTHING=ON" 69 ++ optional sharedLib "-DBUILD_SHARED_LIBS=ON"; 70 71 appendRunpaths = optional stdenv.hostPlatform.isLinux ( 72 lib.makeLibraryPath (optional alsaSupport alsa-lib ++ optional pulseSupport libpulseaudio) 73 ); 74 75 passthru.tests = { 76 inherit raylib-games; 77 }; 78 79 meta = { 80 description = "Simple and easy-to-use library to enjoy videogames programming"; 81 homepage = "https://www.raylib.com/"; 82 downloadPage = "https://github.com/raysan5/raylib"; 83 license = lib.licenses.zlib; 84 maintainers = [ lib.maintainers.diniamo ]; 85 teams = [ lib.teams.ngi ]; 86 platforms = lib.platforms.all; 87 changelog = "https://github.com/raysan5/raylib/blob/${finalAttrs.version}/CHANGELOG"; 88 }; 89 }) 90 )