btrbk: add mainProgram (#356350)
[NixPkgs.git] / pkgs / by-name / li / lib25519 / package.nix
blob68d35a796a03aceaf08b02d1f59b4caf31217f13
2   stdenv,
3   lib,
4   python3,
5   fetchzip,
6   librandombytes,
7   libcpucycles,
8 }:
9 stdenv.mkDerivation (finalAttrs: {
10   pname = "lib25519";
11   version = "20240321";
13   src = fetchzip {
14     url = "https://lib25519.cr.yp.to/lib25519-${finalAttrs.version}.tar.gz";
15     hash = "sha256-R10Q803vCjIZCS4Z/uErsx547RaXfAELGQm9NuNhw+I=";
16   };
18   patches = [ ./environment-variable-tools.patch ];
20   postPatch = ''
21     patchShebangs configure
22     patchShebangs scripts-build
23   '';
25   # NOTE: lib25519 uses a custom Python `./configure`: it does not expect standard
26   # autoconfig --build --host etc. arguments: disable
27   # Pass the hostPlatform string
28   configurePhase = ''
29     runHook preConfigure
30     ./configure --host=${stdenv.buildPlatform.system} --prefix=$out
31     runHook postConfigure
32   '';
34   nativeBuildInputs = [ python3 ];
35   buildInputs = [
36     librandombytes
37     libcpucycles
38   ];
40   preFixup = lib.optionalString stdenv.hostPlatform.isDarwin ''
41     install_name_tool -id "$out/lib/lib25519.1.dylib" "$out/lib/lib25519.1.dylib"
42     for f in $out/bin/*; do
43       install_name_tool -change "lib25519.1.dylib" "$out/lib/lib25519.1.dylib" "$f"
44     done
45   '';
47   # failure: crypto_pow does not handle p=q overlap
48   doInstallCheck = !stdenv.hostPlatform.isDarwin;
49   installCheckPhase = ''
50     runHook preInstallCheck
51     $out/bin/lib25519-test
52     runHook postInstallCheck
53   '';
55   meta = {
56     homepage = "https://randombytes.cr.yp.to/";
57     description = "A simple API for applications generating fresh randomness";
58     changelog = "https://randombytes.cr.yp.to/download.html";
59     license = with lib.licenses; [
60       # Upstream specifies the public domain licenses with the terms here https://cr.yp.to/spdx.html
61       publicDomain
62       cc0
63       bsd0
64       mit
65       mit0
66     ];
67     maintainers = with lib.maintainers; [
68       kiike
69       imadnyc
70       jleightcap
71     ];
72     # This supports whatever platforms libcpucycles supports
73     inherit (libcpucycles.meta) platforms;
74   };