nixpkgs/pkgs/development/libraries/blst/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

78 lines
2.0 KiB
Nix

{ stdenv, lib, fetchFromGitHub }:
stdenv.mkDerivation ( finalAttrs: {
pname = "blst";
version = "0.3.13";
src = fetchFromGitHub {
owner = "supranational";
repo = "blst";
rev = "v${finalAttrs.version}";
hash = "sha256-+Ae2cCVVEXnV/ftVOApxDcXM3COf/4DXXd1AOuGS5uc=";
};
buildPhase = ''
runHook preBuild
./build.sh ${lib.optionalString stdenv.hostPlatform.isWindows "flavour=mingw64"}
./build.sh -shared ${lib.optionalString stdenv.hostPlatform.isWindows "flavour=mingw64"}
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out/{lib,include}
for lib in libblst.{a,so,dylib}; do
if [ -f $lib ]; then
cp $lib $out/lib/
fi
done
cp bindings/{blst.h,blst_aux.h} $out/include
for lib in blst.dll; do
if [ -f $lib ]; then
mkdir -p $out/bin
cp $lib $out/bin/
fi
done
mkdir -p $out/lib/pkgconfig
cat <<EOF > $out/lib/pkgconfig/libblst.pc
prefix=$out
exec_prefix=''\\''${prefix}
libdir=''\\''${exec_prefix}/lib
includedir=''\\''${prefix}/include
Name: libblst
Description: ${finalAttrs.meta.description}
URL: ${finalAttrs.meta.homepage}
Version: ${finalAttrs.version}
Cflags: -I''\\''${includedir}
Libs: -L''\\''${libdir} -lblst
Libs.private:
EOF
runHook postInstall
'';
# ensure we have the right install id set. Otherwise the library
# wouldn't be found during install. The alternative would be to work
# lib.optional stdenv.hostPlatform.isDarwin "LDFLAGS=-Wl,-install_name,$(out)/lib/libblst.dylib";
# into the setup.sh
postFixup = lib.optionalString stdenv.hostPlatform.isDarwin ''
install_name_tool -id $out/lib/libblst.dylib $out/lib/libblst.dylib
'';
doCheck = true;
meta = with lib; {
description = "Multilingual BLS12-381 signature library";
homepage = "https://github.com/supranational/blst";
license = licenses.isc;
maintainers = with maintainers; [ iquerejeta yvan-sraka ];
platforms = platforms.all;
};
})