nixpkgs/pkgs/development/libraries/libepoxy/default.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
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"
```
2024-09-25 00:04:37 +03:00

85 lines
2.2 KiB
Nix

{ lib
, stdenv
, fetchFromGitHub
, meson
, ninja
, pkg-config
, utilmacros
, python3
, libGL
, libX11
, Carbon
, OpenGL
, x11Support ? !stdenv.hostPlatform.isDarwin
, testers
}:
stdenv.mkDerivation (finalAttrs: {
pname = "libepoxy";
version = "1.5.10";
src = with finalAttrs; fetchFromGitHub {
owner = "anholt";
repo = pname;
rev = version;
sha256 = "sha256-gZiyPOW2PeTMILcPiUTqPUGRNlMM5mI1z9563v4SgEs=";
};
patches = [ ./libgl-path.patch ];
postPatch = ''
patchShebangs src/*.py
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace src/dispatch_common.h --replace "PLATFORM_HAS_GLX 0" "PLATFORM_HAS_GLX 1"
''
# cgl_core and cgl_epoxy_api fail in darwin sandbox and on Hydra (because it's headless?)
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace test/meson.build \
--replace "[ 'cgl_epoxy_api', [ 'cgl_epoxy_api.c' ] ]," ""
''
+ lib.optionalString (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) ''
substituteInPlace test/meson.build \
--replace "[ 'cgl_core', [ 'cgl_core.c' ] ]," ""
'';
outputs = [ "out" "dev" ];
nativeBuildInputs = [ meson ninja pkg-config utilmacros python3 ];
buildInputs = lib.optionals (x11Support && !stdenv.hostPlatform.isDarwin) [
libGL
] ++ lib.optionals x11Support [
libX11
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
Carbon
OpenGL
];
mesonFlags = [
"-Degl=${if (x11Support && !stdenv.hostPlatform.isDarwin) then "yes" else "no"}"
"-Dglx=${if x11Support then "yes" else "no"}"
"-Dtests=${lib.boolToString finalAttrs.finalPackage.doCheck}"
"-Dx11=${lib.boolToString x11Support}"
];
env.NIX_CFLAGS_COMPILE = lib.optionalString (x11Support && !stdenv.hostPlatform.isDarwin) ''-DLIBGL_PATH="${lib.getLib libGL}/lib"'';
doCheck = true;
passthru.tests = {
pkg-config = testers.hasPkgConfigModules {
package = finalAttrs.finalPackage;
};
};
meta = with lib; {
description = "Library for handling OpenGL function pointer management";
homepage = "https://github.com/anholt/libepoxy";
license = licenses.mit;
maintainers = [ ];
platforms = platforms.unix;
pkgConfigModules = [ "epoxy" ];
};
})