nixpkgs/pkgs/by-name/li/lib25519/package.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

76 lines
1.9 KiB
Nix

{
stdenv,
lib,
python3,
fetchzip,
librandombytes,
libcpucycles,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "lib25519";
version = "20240321";
src = fetchzip {
url = "https://lib25519.cr.yp.to/lib25519-${finalAttrs.version}.tar.gz";
hash = "sha256-R10Q803vCjIZCS4Z/uErsx547RaXfAELGQm9NuNhw+I=";
};
patches = [ ./environment-variable-tools.patch ];
postPatch = ''
patchShebangs configure
patchShebangs scripts-build
'';
# NOTE: lib25519 uses a custom Python `./configure`: it does not expect standard
# autoconfig --build --host etc. arguments: disable
# Pass the hostPlatform string
configurePhase = ''
runHook preConfigure
./configure --host=${stdenv.buildPlatform.system} --prefix=$out
runHook postConfigure
'';
nativeBuildInputs = [ python3 ];
buildInputs = [
librandombytes
libcpucycles
];
preFixup = lib.optionalString stdenv.hostPlatform.isDarwin ''
install_name_tool -id "$out/lib/lib25519.1.dylib" "$out/lib/lib25519.1.dylib"
for f in $out/bin/*; do
install_name_tool -change "lib25519.1.dylib" "$out/lib/lib25519.1.dylib" "$f"
done
'';
# failure: crypto_pow does not handle p=q overlap
doInstallCheck = !stdenv.hostPlatform.isDarwin;
installCheckPhase = ''
runHook preInstallCheck
$out/bin/lib25519-test
runHook postInstallCheck
'';
meta = {
homepage = "https://randombytes.cr.yp.to/";
description = "A simple API for applications generating fresh randomness";
changelog = "https://randombytes.cr.yp.to/download.html";
license = with lib.licenses; [
# Upstream specifies the public domain licenses with the terms here https://cr.yp.to/spdx.html
publicDomain
cc0
bsd0
mit
mit0
];
maintainers = with lib.maintainers; [
kiike
imadnyc
jleightcap
];
# This supports whatever platforms libcpucycles supports
inherit (libcpucycles.meta) platforms;
};
})