nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 123 lines 2.5 kB view raw
1{ 2 cmake, 3 lib, 4 fetchFromGitHub, 5 ninja, 6 sdl3, 7 stdenv, 8 testers, 9 libX11, 10 libGL, 11 nix-update-script, 12 13 # passthru tests 14 SDL2_ttf, 15 SDL2_net, 16 SDL2_gfx, 17 SDL2_sound, 18 SDL2_mixer, 19 SDL2_image, 20 SDL_compat, 21 ffmpeg, 22 qemu, 23}: 24let 25 # tray support on sdl3 pulls in gtk3, which is quite an expensive dependency. 26 # sdl2 does not support the tray, so we can just disable that requirement. 27 sdl3' = sdl3.override { traySupport = false; }; 28in 29stdenv.mkDerivation (finalAttrs: { 30 pname = "sdl2-compat"; 31 version = "2.32.56"; 32 33 src = fetchFromGitHub { 34 owner = "libsdl-org"; 35 repo = "sdl2-compat"; 36 tag = "release-${finalAttrs.version}"; 37 hash = "sha256-Xg886KX54vwGANIhTAFslzPw/sZs2SvpXzXUXcOKgMs="; 38 }; 39 40 nativeBuildInputs = [ 41 cmake 42 ninja 43 ]; 44 45 buildInputs = [ 46 sdl3' 47 libX11 48 ]; 49 50 checkInputs = [ libGL ]; 51 52 outputs = [ 53 "out" 54 "dev" 55 ]; 56 57 outputBin = "dev"; 58 59 # SDL3 is dlopened at runtime, leave it in runpath 60 dontPatchELF = true; 61 62 cmakeFlags = [ 63 (lib.cmakeBool "SDL2COMPAT_TESTS" finalAttrs.finalPackage.doCheck) 64 (lib.cmakeFeature "CMAKE_INSTALL_RPATH" (lib.makeLibraryPath [ sdl3' ])) 65 ]; 66 67 # skip timing-based tests as those are flaky 68 env.SDL_TESTS_QUICK = 1; 69 70 doCheck = true; 71 72 patches = [ ./find-headers.patch ]; 73 setupHook = ./setup-hook.sh; 74 75 postFixup = '' 76 # allow as a drop in replacement for SDL2 77 # Can be removed after treewide switch from pkg-config to pkgconf 78 ln -s $dev/lib/pkgconfig/sdl2-compat.pc $dev/lib/pkgconfig/sdl2.pc 79 ''; 80 81 passthru = { 82 tests = { 83 pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; 84 85 inherit 86 SDL_compat 87 SDL2_ttf 88 SDL2_net 89 SDL2_gfx 90 SDL2_sound 91 SDL2_mixer 92 SDL2_image 93 ffmpeg 94 ; 95 } 96 // lib.optionalAttrs stdenv.hostPlatform.isLinux { 97 inherit qemu; 98 }; 99 100 updateScript = nix-update-script { 101 extraArgs = [ 102 "--version-regex" 103 "release-(.*)" 104 ]; 105 }; 106 }; 107 108 meta = { 109 description = "SDL2 compatibility layer that uses SDL3 behind the scenes"; 110 homepage = "https://libsdl.org"; 111 changelog = "https://github.com/libsdl-org/sdl2-compat/releases/tag/${finalAttrs.src.tag}"; 112 license = lib.licenses.zlib; 113 maintainers = with lib.maintainers; [ 114 nadiaholmquist 115 ]; 116 teams = [ lib.teams.sdl ]; 117 platforms = lib.platforms.all; 118 pkgConfigModules = [ 119 "sdl2-compat" 120 "sdl2" 121 ]; 122 }; 123})