2019-04-24 04:54:57 +01:00
|
|
|
{ stdenv, fetchFromGitHub, libtool, autoreconfHook, pkgconfig
|
2018-10-22 22:48:25 +01:00
|
|
|
, sysfsutils
|
|
|
|
# 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
|
2018-10-23 22:36:57 +01:00
|
|
|
# Not sure if jitterentropy is safe to use for cryptography
|
|
|
|
# and thus a default entropy source
|
|
|
|
, jitterentropy ? null, withJitterEntropy ? false
|
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";
|
|
|
|
version = "6.7";
|
2018-10-22 22:48:25 +01:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "nhorman";
|
|
|
|
repo = "rng-tools";
|
|
|
|
rev = "v${version}";
|
2019-04-24 04:54:57 +01:00
|
|
|
sha256 = "19f75m6mzg8h7b4snzg7d6ypvkz6nq32lrpi9ja95gqz4wsd18a5";
|
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 = ''
|
|
|
|
cp README.md README
|
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
|
|
|
|
|
|
|
buildInputs = [ sysfsutils ]
|
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 ];
|
|
|
|
|
|
|
|
# This shouldn't be necessary but is as of 6.7
|
|
|
|
NIX_LDFLAGS = optionalString withPkcs11 "-lcrypto";
|
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)" ];
|
|
|
|
|
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;
|
|
|
|
maintainers = with maintainers; [ johnazoidberg ];
|
2012-11-22 06:05:45 +00:00
|
|
|
};
|
|
|
|
}
|