SDL2_image: refactor

- internalize `darwin`
- reorder input set
  - new input: enableSdltest
- reorder buildInputs
- rewrite configureFlags
- get rid of nested with
- SDL team

Caution: can cause mass rebuilds.
This commit is contained in:
Anderson Torres 2024-06-07 11:34:40 -03:00
parent c3fa9d6d0b
commit 093e3b60d3
2 changed files with 47 additions and 20 deletions

View File

@ -1,8 +1,25 @@
{ lib, stdenv, fetchurl
, pkg-config
, SDL2, libpng, libjpeg, libtiff, giflib, libwebp, libXpm, zlib, Foundation
{
lib,
SDL2,
darwin,
fetchurl,
giflib,
libXpm,
libjpeg,
libpng,
libtiff,
libwebp,
pkg-config,
stdenv,
zlib,
# Boolean flags
## Darwin headless will hang when trying to run the SDL test program
enableSdltest ? (!stdenv.isDarwin),
}:
let
inherit (darwin.apple_sdk.frameworks) Foundation;
in
stdenv.mkDerivation (finalAttrs: {
pname = "SDL2_image";
version = "2.8.2";
@ -14,29 +31,42 @@ stdenv.mkDerivation (finalAttrs: {
nativeBuildInputs = [ pkg-config ];
buildInputs = [ SDL2 libpng libjpeg libtiff giflib libwebp libXpm zlib ]
++ lib.optional stdenv.isDarwin Foundation;
buildInputs = [
SDL2
giflib
libXpm
libjpeg
libpng
libtiff
libwebp
zlib
]
++ lib.optionals stdenv.isDarwin [
Foundation
];
configureFlags = [
# Disable dynamically loaded dependencies
"--disable-jpg-shared"
"--disable-png-shared"
"--disable-tif-shared"
"--disable-webp-shared"
(lib.enableFeature false "jpg-shared")
(lib.enableFeature false "png-shared")
(lib.enableFeature false "tif-shared")
(lib.enableFeature false "webp-shared")
(lib.enableFeature enableSdltest "sdltest")
] ++ lib.optionals stdenv.isDarwin [
# Darwin headless will hang when trying to run the SDL test program
"--disable-sdltest"
# Don't use native macOS frameworks
"--disable-imageio"
# Caution: do not set this as (!stdenv.isDarwin) since it would be true
# outside Darwin - and ImageIO does not exist outisde Darwin
(lib.enableFeature false "imageio")
];
enableParallelBuilding = true;
meta = with lib; {
meta = {
description = "SDL image library";
homepage = "http://www.libsdl.org/projects/SDL_image/";
platforms = platforms.unix;
license = licenses.zlib;
maintainers = with maintainers; [ cpages ];
homepage = "https://github.com/libsdl-org/SDL_image";
license = lib.licenses.zlib;
maintainers = lib.teams.sdl.members
++ (with lib.maintainers; [ cpages ]);
platforms = lib.platforms.unix;
};
})

View File

@ -23980,9 +23980,6 @@ with pkgs;
inherit (darwin.apple_sdk.frameworks) AudioUnit Cocoa CoreAudio CoreServices ForceFeedback OpenGL;
};
SDL2_image = callPackage ../by-name/sd/SDL2_image/package.nix {
inherit (darwin.apple_sdk.frameworks) Foundation;
};
# Pinned for pygame, toppler
SDL2_image_2_0 = SDL2_image.overrideAttrs (oldAttrs: {
version = "2.0.5";