Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions pkgs/by-name/sd/sdl2-compat/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
ffmpeg,
qemu,
}:

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";
Expand All @@ -39,7 +43,7 @@ stdenv.mkDerivation (finalAttrs: {
];

buildInputs = [
sdl3
sdl3'
libX11
];

Expand All @@ -57,7 +61,7 @@ stdenv.mkDerivation (finalAttrs: {

cmakeFlags = [
(lib.cmakeBool "SDL2COMPAT_TESTS" finalAttrs.finalPackage.doCheck)
(lib.cmakeFeature "CMAKE_INSTALL_RPATH" (lib.makeLibraryPath [ sdl3 ]))
(lib.cmakeFeature "CMAKE_INSTALL_RPATH" (lib.makeLibraryPath [ sdl3' ]))
];

# skip timing-based tests as those are flaky
Expand Down
32 changes: 26 additions & 6 deletions pkgs/by-name/sd/sdl3/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,29 @@
libudevSupport ? stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isAndroid,
sndioSupport ? false,
testSupport ? true,
traySupport ? true,
waylandSupport ? stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isAndroid,
x11Support ? !stdenv.hostPlatform.isAndroid && !stdenv.hostPlatform.isWindows,
}:

assert lib.assertMsg (
waylandSupport -> openglSupport
) "SDL3 requires OpenGL support to enable Wayland";
assert lib.assertMsg (ibusSupport -> dbusSupport) "SDL3 requires dbus support to enable ibus";

stdenv.mkDerivation (finalAttrs: {
pname = "sdl3";
version = "3.2.12";

outputs = [
"lib"
"dev"
"out"
];
outputs =
[
"lib"
"dev"
"out"
]
++ lib.optionals testSupport [
"installedTests"
];

src = fetchFromGitHub {
owner = "libsdl-org";
Expand All @@ -78,13 +84,19 @@ stdenv.mkDerivation (finalAttrs: {

postPatch =
# Tests timeout on Darwin
# `testtray` loads assets from a relative path, which we are patching to be absolute
lib.optionalString testSupport ''
substituteInPlace test/CMakeLists.txt \
--replace-fail 'set(noninteractive_timeout 10)' 'set(noninteractive_timeout 30)'

substituteInPlace test/testtray.c \
--replace-warn '../test/' '${placeholder "installedTests"}/share/assets/'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for using --replace-warn instead of --replace-fail here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because its a test output. I believe the package shouldn't hard-fail if a test binary might not have built successfully, that is my reasoning. It should be loud enough to find if something goes wrong, but not be annoying when it breaks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testtray is not part of our CI, so that one failing to replace doesn't actually affect anything.

''
+ lib.optionalString waylandSupport ''
substituteInPlace src/video/wayland/SDL_waylandmessagebox.c \
--replace-fail '"zenity"' '"${lib.getExe zenity}"'
substituteInPlace src/dialog/unix/SDL_zenitydialog.c \
--replace-fail '"zenity"' '"${lib.getExe zenity}"'
'';

strictDeps = true;
Expand Down Expand Up @@ -113,7 +125,7 @@ stdenv.mkDerivation (finalAttrs: {
libusb1
]
++ lib.optional (
stdenv.hostPlatform.isUnix && !stdenv.hostPlatform.isDarwin
stdenv.hostPlatform.isUnix && !stdenv.hostPlatform.isDarwin && traySupport
) libayatana-appindicator
++ lib.optional alsaSupport alsa-lib
++ lib.optional dbusSupport dbus
Expand Down Expand Up @@ -160,11 +172,13 @@ stdenv.mkDerivation (finalAttrs: {
(lib.cmakeBool "SDL_PULSEAUDIO" pulseaudioSupport)
(lib.cmakeBool "SDL_SNDIO" sndioSupport)
(lib.cmakeBool "SDL_TEST_LIBRARY" testSupport)
(lib.cmakeBool "SDL_TRAY_DUMMY" (!traySupport))
(lib.cmakeBool "SDL_WAYLAND" waylandSupport)
(lib.cmakeBool "SDL_WAYLAND_LIBDECOR" libdecorSupport)
(lib.cmakeBool "SDL_X11" x11Support)

(lib.cmakeBool "SDL_TESTS" finalAttrs.finalPackage.doCheck)
(lib.cmakeBool "SDL_INSTALL_TESTS" testSupport)
];

doCheck = testSupport && stdenv.buildPlatform.canExecute stdenv.hostPlatform;
Expand All @@ -180,6 +194,12 @@ stdenv.mkDerivation (finalAttrs: {
) "-rpath ${lib.makeLibraryPath (finalAttrs.dlopenBuildInputs)}";
};

postInstall = lib.optionalString testSupport ''
moveToOutput "share/installed-tests" "$installedTests"
moveToOutput "libexec/installed-tests" "$installedTests"
install -Dm 444 -t $installedTests/share/assets test/*.bmp
'';

passthru = {
# Building this in its own derivation to make sure the rpath hack above propagate to users
debug-text-example = stdenv.mkDerivation (finalAttrs': {
Expand Down
Loading