nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 120 lines 2.8 kB view raw
1{ 2 lib, 3 sdl2-compat, 4 cmake, 5 darwin, 6 fetchFromGitHub, 7 libGLU, 8 libiconv, 9 libX11, 10 mesa, 11 pkg-config, 12 pkg-config-unwrapped, 13 stdenv, 14 testers, 15 dosbox, 16 SDL_image, 17 SDL_ttf, 18 SDL_mixer, 19 SDL_sound, 20 # Boolean flags 21 libGLSupported ? lib.elem stdenv.hostPlatform.system mesa.meta.platforms, 22 openglSupport ? libGLSupported, 23}: 24 25let 26 inherit (darwin) autoSignDarwinBinariesHook; 27in 28stdenv.mkDerivation (finalAttrs: { 29 pname = "SDL_compat"; 30 version = "1.2.72"; 31 32 src = fetchFromGitHub { 33 owner = "libsdl-org"; 34 repo = "sdl12-compat"; 35 rev = "release-" + finalAttrs.version; 36 hash = "sha256-dTBsbLJFQSaWWhn1+CCQopq7sBONxvlaAximmo3iYVM="; 37 }; 38 39 nativeBuildInputs = [ 40 cmake 41 pkg-config 42 ] 43 ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [ 44 autoSignDarwinBinariesHook 45 ]; 46 47 # re-export PKG_CHECK_MODULES m4 macro used by sdl.m4 48 propagatedNativeBuildInputs = [ pkg-config-unwrapped ]; 49 50 buildInputs = [ 51 libX11 52 sdl2-compat 53 ] 54 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 55 libiconv 56 ] 57 ++ lib.optionals openglSupport [ libGLU ]; 58 59 dontPatchELF = true; # don't strip rpath 60 61 cmakeFlags = 62 let 63 rpath = lib.makeLibraryPath [ sdl2-compat ]; 64 in 65 [ 66 (lib.cmakeFeature "CMAKE_INSTALL_RPATH" rpath) 67 (lib.cmakeFeature "CMAKE_BUILD_RPATH" rpath) 68 (lib.cmakeBool "SDL12TESTS" finalAttrs.finalPackage.doCheck) 69 ]; 70 71 enableParallelBuilding = true; 72 73 # Darwin fails with "Critical error: required built-in appearance SystemAppearance not found" 74 doCheck = !stdenv.hostPlatform.isDarwin; 75 checkPhase = '' 76 runHook preCheck 77 ./test/testver 78 runHook postCheck 79 ''; 80 81 postInstall = '' 82 # allow as a drop in replacement for SDL 83 # Can be removed after treewide switch from pkg-config to pkgconf 84 ln -s $out/lib/pkgconfig/sdl12_compat.pc $out/lib/pkgconfig/sdl.pc 85 ''; 86 87 patches = [ 88 # The setup hook scans paths of buildInputs to find SDL related packages and 89 # adds their include and library paths to environment variables. The sdl-config 90 # is patched to use these variables to produce correct flags for compiler. 91 ./find-headers.patch 92 ]; 93 setupHook = ./setup-hook.sh; 94 95 passthru.tests = { 96 pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; 97 98 inherit 99 SDL_image 100 SDL_ttf 101 SDL_mixer 102 SDL_sound 103 dosbox 104 ; 105 }; 106 107 meta = { 108 homepage = "https://www.libsdl.org/"; 109 description = "Cross-platform multimedia library - build SDL 1.2 applications against 2.0"; 110 license = lib.licenses.zlib; 111 mainProgram = "sdl-config"; 112 maintainers = with lib.maintainers; [ peterhoeg ]; 113 teams = [ lib.teams.sdl ]; 114 platforms = lib.platforms.all; 115 pkgConfigModules = [ 116 "sdl" 117 "sdl12_compat" 118 ]; 119 }; 120})