blob: 68d35a796a03aceaf08b02d1f59b4caf31217f13 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
{
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;
};
})
|