nixpkgs/pkgs/development/libraries/silgraphite/graphite2.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

70 lines
1.9 KiB
Nix

{ lib
, stdenv
, llvmPackages
, fetchurl
, pkg-config
, freetype
, cmake
, static ? stdenv.hostPlatform.isStatic
, testers
}:
stdenv.mkDerivation (finalAttrs: {
version = "1.3.14";
pname = "graphite2";
src = fetchurl {
url = with finalAttrs; "https://github.com/silnrsi/graphite/releases/download/${version}/${pname}-${version}.tgz";
sha256 = "1790ajyhk0ax8xxamnrk176gc9gvhadzy78qia4rd8jzm89ir7gr";
};
outputs = [ "out" "dev" ];
nativeBuildInputs = [ pkg-config cmake ];
buildInputs = [ freetype ]
++ lib.optional (stdenv.targetPlatform.useLLVM or false)
(llvmPackages.compiler-rt.override {
doFakeLibgcc = true;
});
patches = lib.optionals stdenv.hostPlatform.isDarwin [ ./macosx.patch ];
postPatch = ''
# disable broken 'nametabletest' test, fails on gcc-13:
# https://github.com/silnrsi/graphite/pull/74
substituteInPlace tests/CMakeLists.txt \
--replace 'add_subdirectory(nametabletest)' '#add_subdirectory(nametabletest)'
# support cross-compilation by using target readelf binary:
substituteInPlace Graphite.cmake \
--replace 'readelf' "${stdenv.cc.targetPrefix}readelf"
'';
cmakeFlags = lib.optionals static [
"-DBUILD_SHARED_LIBS=OFF"
];
# Remove a test that fails to statically link (undefined reference to png and
# freetype symbols)
postConfigure = lib.optionalString static ''
sed -e '/freetype freetype.c/d' -i ../tests/examples/CMakeLists.txt
'';
doCheck = true;
passthru.tests = {
pkg-config = testers.hasPkgConfigModules {
package = finalAttrs.finalPackage;
};
};
meta = with lib; {
description = "Advanced font engine";
homepage = "https://graphite.sil.org/";
license = licenses.lgpl21;
maintainers = [ maintainers.raskin ];
pkgConfigModules = [ "graphite2" ];
mainProgram = "gr2fonttest";
platforms = platforms.unix ++ platforms.windows;
};
})