2022-02-10 20:34:41 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, autoreconfHook
|
|
|
|
, libtool
|
|
|
|
, pkg-config
|
2022-02-20 05:27:41 +00:00
|
|
|
, psmisc
|
2022-09-22 12:36:57 +00:00
|
|
|
, argp-standalone
|
2022-02-10 20:34:41 +00:00
|
|
|
, openssl
|
2022-09-22 12:36:57 +00:00
|
|
|
, jitterentropy, withJitterEntropy ? true
|
2020-04-24 23:36:52 +00:00
|
|
|
# WARNING: DO NOT USE BEACON GENERATED VALUES AS SECRET CRYPTOGRAPHIC KEYS
|
|
|
|
# https://www.nist.gov/programs-projects/nist-randomness-beacon
|
2022-09-22 12:36:57 +00:00
|
|
|
, curl, jansson, libxml2, withNistBeacon ? false
|
|
|
|
, libp11, opensc, withPkcs11 ? true
|
|
|
|
, librtlsdr, withRtlsdr ? true
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "rng-tools";
|
2022-02-20 05:27:41 +00:00
|
|
|
version = "6.15";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "nhorman";
|
2022-02-10 20:34:41 +00:00
|
|
|
repo = pname;
|
2020-04-24 23:36:52 +00:00
|
|
|
rev = "v${version}";
|
2022-02-20 05:27:41 +00:00
|
|
|
hash = "sha256-km+MEng3VWZF07sdvGLbAG/vf8/A1DxhA/Xa2Y+LAEQ=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
nativeBuildInputs = [ autoreconfHook libtool pkg-config ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
configureFlags = [
|
2022-09-22 12:36:57 +00:00
|
|
|
(lib.enableFeature (withJitterEntropy) "jitterentropy")
|
|
|
|
(lib.withFeature (withNistBeacon) "nistbeacon")
|
|
|
|
(lib.withFeature (withPkcs11) "pkcs11")
|
|
|
|
(lib.withFeature (withRtlsdr) "rtlsdr")
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2022-02-10 20:34:41 +00:00
|
|
|
buildInputs = [ openssl ]
|
2022-09-22 12:36:57 +00:00
|
|
|
++ lib.optionals stdenv.hostPlatform.isMusl [ argp-standalone ]
|
|
|
|
++ lib.optionals withJitterEntropy [ jitterentropy ]
|
|
|
|
++ lib.optionals withNistBeacon [ curl jansson libxml2 ]
|
2022-11-27 09:42:12 +00:00
|
|
|
++ lib.optionals withPkcs11 [ libp11 libp11.passthru.openssl ]
|
2022-09-22 12:36:57 +00:00
|
|
|
++ lib.optionals withRtlsdr [ librtlsdr ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2022-01-27 00:19:43 +00:00
|
|
|
makeFlags = [
|
|
|
|
"AR:=$(AR)" # For cross-compilation
|
2022-09-22 12:36:57 +00:00
|
|
|
] ++ lib.optionals withPkcs11 [
|
2022-01-27 00:19:43 +00:00
|
|
|
"PKCS11_ENGINE=${opensc}/lib/opensc-pkcs11.so" # Overrides configure script paths
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
preCheck = "patchShebangs tests/*.sh";
|
2022-02-20 05:27:41 +00:00
|
|
|
checkInputs = [ psmisc ]; # rngtestjitter.sh needs killall
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-02-10 20:34:41 +00:00
|
|
|
doInstallCheck = true;
|
|
|
|
installCheckPhase = ''
|
|
|
|
runHook preInstallCheck
|
|
|
|
set -o pipefail
|
|
|
|
$out/bin/rngtest --version | grep $version
|
|
|
|
runHook postInstallCheck
|
|
|
|
'';
|
|
|
|
|
2022-09-22 12:36:57 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "A random number generator daemon";
|
|
|
|
homepage = "https://github.com/nhorman/rng-tools";
|
2022-02-10 20:34:41 +00:00
|
|
|
changelog = "https://github.com/nhorman/rng-tools/releases/tag/v${version}";
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.gpl2Plus;
|
|
|
|
platforms = platforms.linux;
|
|
|
|
maintainers = with maintainers; [ johnazoidberg c0bw3b ];
|
|
|
|
};
|
|
|
|
}
|