8 stdenv.mkDerivation (finalAttrs: {
9 pname = "librandombytes";
13 url = "https://randombytes.cr.yp.to/librandombytes-${finalAttrs.version}.tar.gz";
14 hash = "sha256-LE8iWw7FxckPREyqefgKtslD6CPDsL7VsfHScQ6JmLs=";
17 patches = [ ./environment-variable-tools.patch ];
20 patchShebangs configure
21 patchShebangs scripts-build
24 __structuredAttrs = true;
26 # NOTE: librandombytes uses a custom Python `./configure`: it does not expect standard
27 # autoconfig --build --host etc. arguments: disable
28 configurePlatforms = [ ];
30 # NOTE: the librandombytes library has required specific CFLAGS defined:
31 # https://randombytes.cr.yp.to/librandombytes-20240318/compilers/default.html
32 # - `-O` (alias `-O1`) safe optimization
33 # - `-Qunused-arguments` suppress clang warning
34 # the default "fortify" hardening sets -O2, -D_FORTIFY_SOURCE=2:
35 # since librandombytes uses -O1, we disable the fortify hardening, and then manually re-enable -D_FORTIFY_SOURCE.
36 hardeningDisable = [ "fortify" ];
37 env.NIX_CFLAGS_COMPILE = toString (
38 lib.optionals stdenv.cc.isClang [ "-Qunused-arguments" ]
45 nativeBuildInputs = [ python3 ];
47 buildInputs = [ openssl ];
49 preFixup = lib.optionalString stdenv.hostPlatform.isDarwin ''
50 install_name_tool -id "$out/lib/librandombytes-kernel.1.dylib" "$out/lib/librandombytes-kernel.1.dylib"
51 install_name_tool -change "librandombytes-kernel.1.dylib" "$out/lib/librandombytes-kernel.1.dylib" "$out/bin/randombytes-info"
54 passthru.updateScript = ./update.sh;
57 homepage = "https://randombytes.cr.yp.to/";
58 description = "A simple API for applications generating fresh randomness";
59 changelog = "https://randombytes.cr.yp.to/download.html";
60 license = with lib.licenses; [
61 # Upstream specifies the public domain licenses with the terms here https://cr.yp.to/spdx.html
68 maintainers = with lib.maintainers; [
78 # Cannot support 32 bit MIPS because options in libcpucycles only supports mips64: https://cpucycles.cr.yp.to/libcpucycles-20240318/cpucycles/options.html
81 # powerpc-linux (32 bits) is supported by upstream project but not by nix
87 # Upstream package supports sparc, but nix does not
88 ] ++ lib.platforms.darwin; # Work on MacOS X mentioned: https://randombytes.cr.yp.to/download.html