2019-04-24 04:54:57 +01:00
|
|
|
{ stdenv, fetchFromGitHub, libtool, autoreconfHook, pkgconfig
|
2018-10-22 22:48:25 +01:00
|
|
|
, sysfsutils
|
2019-11-12 23:05:28 +00:00
|
|
|
, argp-standalone
|
2018-10-22 22:48:25 +01:00
|
|
|
# WARNING: DO NOT USE BEACON GENERATED VALUES AS SECRET CRYPTOGRAPHIC KEYS
|
|
|
|
# https://www.nist.gov/programs-projects/nist-randomness-beacon
|
|
|
|
, curl ? null, libxml2 ? null, openssl ? null, withNistBeacon ? false
|
|
|
|
# Systems that support RDRAND but not AES-NI require libgcrypt to use RDRAND as an entropy source
|
|
|
|
, libgcrypt ? null, withGcrypt ? true
|
2019-11-12 23:05:28 +00:00
|
|
|
, jitterentropy ? null, withJitterEntropy ? true
|
2019-04-26 07:17:13 +01:00
|
|
|
, libp11 ? null, opensc ? null, withPkcs11 ? true
|
2018-10-22 22:48:25 +01:00
|
|
|
}:
|
2019-04-24 04:54:57 +01:00
|
|
|
|
2018-10-22 22:48:25 +01:00
|
|
|
with stdenv.lib;
|
2019-04-24 04:54:57 +01:00
|
|
|
|
2012-11-22 06:05:45 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2019-04-24 04:54:57 +01:00
|
|
|
pname = "rng-tools";
|
2019-11-12 23:05:28 +00:00
|
|
|
version = "6.8";
|
2018-10-22 22:48:25 +01:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "nhorman";
|
|
|
|
repo = "rng-tools";
|
|
|
|
rev = "v${version}";
|
2019-11-12 23:05:28 +00:00
|
|
|
sha256 = "1clm9i9xg3j79q0d6vinn6dx0nwh1fvzcmkqpcbay7mwsgkknvw2";
|
2018-10-22 22:48:25 +01:00
|
|
|
};
|
2012-11-22 06:05:45 +00:00
|
|
|
|
2019-04-24 04:54:57 +01:00
|
|
|
postPatch = ''
|
2019-04-26 07:17:13 +01:00
|
|
|
${optionalString withPkcs11 ''
|
|
|
|
substituteInPlace rngd.c \
|
|
|
|
--replace /usr/lib64/opensc-pkcs11.so ${opensc}/lib/opensc-pkcs11.so
|
|
|
|
''}
|
2019-04-24 04:54:57 +01:00
|
|
|
'';
|
2012-11-22 06:05:45 +00:00
|
|
|
|
2019-04-24 04:54:57 +01:00
|
|
|
nativeBuildInputs = [ autoreconfHook libtool pkgconfig ];
|
2018-10-22 22:48:25 +01:00
|
|
|
|
2019-04-24 04:54:57 +01:00
|
|
|
configureFlags = [
|
|
|
|
(withFeature withGcrypt "libgcrypt")
|
|
|
|
(enableFeature withJitterEntropy "jitterentropy")
|
|
|
|
(withFeature withNistBeacon "nistbeacon")
|
|
|
|
(withFeature withPkcs11 "pkcs11")
|
|
|
|
];
|
2018-10-22 22:48:25 +01:00
|
|
|
|
2019-11-12 23:05:28 +00:00
|
|
|
# argp-standalone is only used when libc lacks argp parsing (musl)
|
2018-10-22 22:48:25 +01:00
|
|
|
buildInputs = [ sysfsutils ]
|
2019-11-12 23:05:28 +00:00
|
|
|
++ optionals stdenv.hostPlatform.isx86_64 [ argp-standalone ]
|
2019-04-24 04:54:57 +01:00
|
|
|
++ optionals withGcrypt [ libgcrypt ]
|
|
|
|
++ optionals withJitterEntropy [ jitterentropy ]
|
2019-04-26 07:17:13 +01:00
|
|
|
++ optionals withNistBeacon [ curl libxml2 openssl ]
|
2019-04-24 04:54:57 +01:00
|
|
|
++ optionals withPkcs11 [ libp11 openssl ];
|
|
|
|
|
2018-10-22 22:48:25 +01:00
|
|
|
enableParallelBuilding = true;
|
2012-11-22 06:05:45 +00:00
|
|
|
|
2018-02-26 23:17:23 +00:00
|
|
|
# For cross-compilation
|
|
|
|
makeFlags = [ "AR:=$(AR)" ];
|
|
|
|
|
2019-11-12 23:05:28 +00:00
|
|
|
doCheck = true;
|
|
|
|
preCheck = "patchShebangs tests/*.sh";
|
|
|
|
|
2012-11-22 06:05:45 +00:00
|
|
|
meta = {
|
|
|
|
description = "A random number generator daemon";
|
2018-10-22 22:48:25 +01:00
|
|
|
homepage = https://github.com/nhorman/rng-tools;
|
2019-04-24 04:54:57 +01:00
|
|
|
license = licenses.gpl2Plus;
|
|
|
|
platforms = platforms.linux;
|
2019-11-12 23:05:28 +00:00
|
|
|
maintainers = with maintainers; [ johnazoidberg c0bw3b ];
|
2012-11-22 06:05:45 +00:00
|
|
|
};
|
|
|
|
}
|