mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-05 13:23:17 +00:00
e0464e4788
In preparation for the deprecation of `stdenv.isX`. These shorthands are not conducive to cross-compilation because they hide the platforms. Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way One example of why this is bad and especially affects compiler packages https://www.github.com/NixOS/nixpkgs/pull/343059 There are too many files to go through manually but a treewide should get users thinking when they see a `hostPlatform.isX` in a place where it doesn't make sense. ``` fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is" fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is" ```
74 lines
1.7 KiB
Nix
74 lines
1.7 KiB
Nix
{
|
|
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.hostPlatform.isDarwin),
|
|
}:
|
|
|
|
let
|
|
inherit (darwin.apple_sdk.frameworks) Foundation;
|
|
in
|
|
stdenv.mkDerivation (finalAttrs: {
|
|
pname = "SDL2_image";
|
|
version = "2.8.2";
|
|
|
|
src = fetchurl {
|
|
url = "https://www.libsdl.org/projects/SDL_image/release/SDL2_image-${finalAttrs.version}.tar.gz";
|
|
hash = "sha256-j0hrv7z4Rk3VjJ5dkzlKsCVc5otRxalmqRgkSCCnbdw=";
|
|
};
|
|
|
|
nativeBuildInputs = [
|
|
SDL2
|
|
pkg-config
|
|
];
|
|
|
|
buildInputs = [
|
|
SDL2
|
|
giflib
|
|
libXpm
|
|
libjpeg
|
|
libpng
|
|
libtiff
|
|
libwebp
|
|
zlib
|
|
] ++ lib.optionals stdenv.hostPlatform.isDarwin [ Foundation ];
|
|
|
|
configureFlags = [
|
|
# Disable dynamically loaded dependencies
|
|
(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.hostPlatform.isDarwin [
|
|
# Don't use native macOS frameworks
|
|
# Caution: do not set this as (!stdenv.hostPlatform.isDarwin) since it would be true
|
|
# outside Darwin - and ImageIO does not exist outisde Darwin
|
|
(lib.enableFeature false "imageio")
|
|
];
|
|
|
|
strictDeps = true;
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
meta = {
|
|
description = "SDL image library";
|
|
homepage = "https://github.com/libsdl-org/SDL_image";
|
|
license = lib.licenses.zlib;
|
|
maintainers = lib.teams.sdl.members ++ (with lib.maintainers; [ ]);
|
|
platforms = lib.platforms.unix;
|
|
};
|
|
})
|