mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-01 19:33:03 +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" ```
63 lines
1.8 KiB
Nix
63 lines
1.8 KiB
Nix
{ lib
|
|
, SDL2
|
|
, cmake
|
|
, darwin
|
|
, fetchFromGitHub
|
|
, libGLU
|
|
, libiconv
|
|
, mesa
|
|
, pkg-config
|
|
, stdenv
|
|
# Boolean flags
|
|
, libGLSupported ? lib.elem stdenv.hostPlatform.system mesa.meta.platforms
|
|
, openglSupport ? libGLSupported
|
|
}:
|
|
|
|
let
|
|
inherit (darwin.apple_sdk.frameworks) Cocoa;
|
|
inherit (darwin) autoSignDarwinBinariesHook;
|
|
in
|
|
stdenv.mkDerivation (finalAttrs: {
|
|
pname = "SDL_compat";
|
|
version = "1.2.68";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "libsdl-org";
|
|
repo = "sdl12-compat";
|
|
rev = "release-" + finalAttrs.version;
|
|
hash = "sha256-f2dl3L7/qoYNl4sjik1npcW/W09zsEumiV9jHuKnUmM=";
|
|
};
|
|
|
|
nativeBuildInputs = [ cmake pkg-config ]
|
|
++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [ autoSignDarwinBinariesHook ];
|
|
|
|
propagatedBuildInputs = [ SDL2 ]
|
|
++ lib.optionals stdenv.hostPlatform.isDarwin [ libiconv Cocoa ]
|
|
++ lib.optionals openglSupport [ libGLU ];
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
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.propagatedBuildInputs} "$lib"
|
|
'' else ''
|
|
patchelf --set-rpath "$(patchelf --print-rpath $lib):${lib.makeLibraryPath finalAttrs.propagatedBuildInputs}" "$lib"
|
|
''}
|
|
fi
|
|
done
|
|
'';
|
|
|
|
meta = {
|
|
homepage = "https://www.libsdl.org/";
|
|
description = "Cross-platform multimedia library - build SDL 1.2 applications against 2.0";
|
|
license = lib.licenses.zlib;
|
|
mainProgram = "sdl-config";
|
|
maintainers = lib.teams.sdl.members ++ (with lib.maintainers; [ peterhoeg ]);
|
|
platforms = lib.platforms.all;
|
|
};
|
|
})
|