Files
nixpkgs/pkgs/by-name/sd/sdl2-compat/package.nix
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

126 lines
2.5 KiB
Nix

{
cmake,
lib,
fetchFromGitHub,
ninja,
sdl3,
stdenv,
testers,
libX11,
libGL,
nix-update-script,
# passthru tests
SDL2_ttf,
SDL2_net,
SDL2_gfx,
SDL2_sound,
SDL2_mixer,
SDL2_image,
SDL_compat,
ffmpeg,
qemu,
x11Support ? !stdenv.hostPlatform.isAndroid && !stdenv.hostPlatform.isWindows,
}:
let
# tray support on sdl3 pulls in gtk3, which is quite an expensive dependency.
# sdl2 does not support the tray, so we can just disable that requirement.
sdl3' = sdl3.override { traySupport = false; };
in
stdenv.mkDerivation (finalAttrs: {
pname = "sdl2-compat";
version = "2.32.56";
src = fetchFromGitHub {
owner = "libsdl-org";
repo = "sdl2-compat";
tag = "release-${finalAttrs.version}";
hash = "sha256-Xg886KX54vwGANIhTAFslzPw/sZs2SvpXzXUXcOKgMs=";
};
nativeBuildInputs = [
cmake
ninja
];
buildInputs = [
sdl3'
]
++ lib.optional x11Support libX11;
checkInputs = [ libGL ];
outputs = [
"out"
"dev"
];
outputBin = "dev";
# SDL3 is dlopened at runtime, leave it in runpath
dontPatchELF = true;
cmakeFlags = [
(lib.cmakeBool "SDL2COMPAT_TESTS" finalAttrs.finalPackage.doCheck)
(lib.cmakeFeature "CMAKE_INSTALL_RPATH" (lib.makeLibraryPath [ sdl3' ]))
];
# skip timing-based tests as those are flaky
env.SDL_TESTS_QUICK = 1;
doCheck = true;
patches = [ ./find-headers.patch ];
setupHook = ./setup-hook.sh;
postFixup = ''
# allow as a drop in replacement for SDL2
# Can be removed after treewide switch from pkg-config to pkgconf
ln -s $dev/lib/pkgconfig/sdl2-compat.pc $dev/lib/pkgconfig/sdl2.pc
'';
passthru = {
tests = {
pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
inherit
SDL_compat
SDL2_ttf
SDL2_net
SDL2_gfx
SDL2_sound
SDL2_mixer
SDL2_image
ffmpeg
;
}
// lib.optionalAttrs stdenv.hostPlatform.isLinux {
inherit qemu;
};
updateScript = nix-update-script {
extraArgs = [
"--version-regex"
"release-(.*)"
];
};
};
meta = {
description = "SDL2 compatibility layer that uses SDL3 behind the scenes";
homepage = "https://libsdl.org";
changelog = "https://github.com/libsdl-org/sdl2-compat/releases/tag/${finalAttrs.src.tag}";
license = lib.licenses.zlib;
maintainers = with lib.maintainers; [
nadiaholmquist
];
teams = [ lib.teams.sdl ];
platforms = lib.platforms.all;
pkgConfigModules = [
"sdl2-compat"
"sdl2"
];
};
})