From fb4b83f9b7b7a5d1e1b472951d000f51f6ce5ed3 Mon Sep 17 00:00:00 2001 From: Marcin Serwin Date: Thu, 8 May 2025 18:23:08 +0200 Subject: [PATCH 1/3] SDL_compat: set rpath during installation --- pkgs/by-name/sd/SDL_compat/package.nix | 30 ++++++++++---------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/pkgs/by-name/sd/SDL_compat/package.nix b/pkgs/by-name/sd/SDL_compat/package.nix index 59788c98bbcf1..197b0b16598a2 100644 --- a/pkgs/by-name/sd/SDL_compat/package.nix +++ b/pkgs/by-name/sd/SDL_compat/package.nix @@ -52,6 +52,17 @@ stdenv.mkDerivation (finalAttrs: { ] ++ lib.optionals openglSupport [ libGLU ]; + postPatch = '' + substituteInPlace CMakeLists.txt \ + --replace-fail 'set(CMAKE_SKIP_RPATH TRUE)' 'set(CMAKE_SKIP_RPATH FALSE)' + ''; + + dontPatchELF = true; # don't strip rpath + + cmakeFlags = [ + (lib.cmakeFeature "CMAKE_INSTALL_RPATH" (lib.makeLibraryPath [ sdl2-compat ])) + ]; + enableParallelBuilding = true; postInstall = '' @@ -66,25 +77,6 @@ stdenv.mkDerivation (finalAttrs: { patches = [ ./find-headers.patch ]; setupHook = ./setup-hook.sh; - postFixup = '' - for lib in $out/lib/*${stdenv.hostPlatform.extensions.sharedLibrary}* ; do - if [[ -L "$lib" ]]; then - ${ - if stdenv.hostPlatform.isDarwin then - '' - install_name_tool ${ - lib.strings.concatMapStrings (x: " -add_rpath ${lib.makeLibraryPath [ x ]} ") finalAttrs.buildInputs - } "$lib" - '' - else - '' - patchelf --set-rpath "$(patchelf --print-rpath $lib):${lib.makeLibraryPath finalAttrs.buildInputs}" "$lib" - '' - } - fi - done - ''; - meta = { homepage = "https://www.libsdl.org/"; description = "Cross-platform multimedia library - build SDL 1.2 applications against 2.0"; From bf1a329f7080dc43f9d162b1efd0635867583ee2 Mon Sep 17 00:00:00 2001 From: Marcin Serwin Date: Thu, 8 May 2025 19:20:13 +0200 Subject: [PATCH 2/3] SDL_compat: add basic checkPhase --- pkgs/by-name/sd/SDL_compat/package.nix | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/pkgs/by-name/sd/SDL_compat/package.nix b/pkgs/by-name/sd/SDL_compat/package.nix index 197b0b16598a2..cddc638d715d7 100644 --- a/pkgs/by-name/sd/SDL_compat/package.nix +++ b/pkgs/by-name/sd/SDL_compat/package.nix @@ -59,12 +59,26 @@ stdenv.mkDerivation (finalAttrs: { dontPatchELF = true; # don't strip rpath - cmakeFlags = [ - (lib.cmakeFeature "CMAKE_INSTALL_RPATH" (lib.makeLibraryPath [ sdl2-compat ])) - ]; + cmakeFlags = + let + rpath = lib.makeLibraryPath [ sdl2-compat ]; + in + [ + (lib.cmakeFeature "CMAKE_INSTALL_RPATH" rpath) + (lib.cmakeFeature "CMAKE_BUILD_RPATH" rpath) + (lib.cmakeBool "SDL12TESTS" finalAttrs.finalPackage.doCheck) + ]; enableParallelBuilding = true; + # Darwin fails with "Critical error: required built-in appearance SystemAppearance not found" + doCheck = !stdenv.hostPlatform.isDarwin; + checkPhase = '' + runHook preCheck + ./testver + runHook postCheck + ''; + postInstall = '' # allow as a drop in replacement for SDL # Can be removed after treewide switch from pkg-config to pkgconf From 69948e3608e3c84860771d554c1d1fb6c8620571 Mon Sep 17 00:00:00 2001 From: Marcin Serwin Date: Thu, 8 May 2025 18:58:04 +0200 Subject: [PATCH 3/3] SDL_compat: add passthru.tests --- pkgs/by-name/sd/SDL_compat/package.nix | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pkgs/by-name/sd/SDL_compat/package.nix b/pkgs/by-name/sd/SDL_compat/package.nix index cddc638d715d7..683d6eb38c984 100644 --- a/pkgs/by-name/sd/SDL_compat/package.nix +++ b/pkgs/by-name/sd/SDL_compat/package.nix @@ -11,6 +11,12 @@ pkg-config, pkg-config-unwrapped, stdenv, + testers, + dosbox, + SDL_image, + SDL_ttf, + SDL_mixer, + SDL_sound, # Boolean flags libGLSupported ? lib.elem stdenv.hostPlatform.system mesa.meta.platforms, openglSupport ? libGLSupported, @@ -91,6 +97,18 @@ stdenv.mkDerivation (finalAttrs: { patches = [ ./find-headers.patch ]; setupHook = ./setup-hook.sh; + passthru.tests = { + pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; + + inherit + SDL_image + SDL_ttf + SDL_mixer + SDL_sound + dosbox + ; + }; + meta = { homepage = "https://www.libsdl.org/"; description = "Cross-platform multimedia library - build SDL 1.2 applications against 2.0"; @@ -99,5 +117,9 @@ stdenv.mkDerivation (finalAttrs: { maintainers = with lib.maintainers; [ peterhoeg ]; teams = [ lib.teams.sdl ]; platforms = lib.platforms.all; + pkgConfigModules = [ + "sdl" + "sdl12_compat" + ]; }; })