@@ -1,4 +1,4 @@
1−{ stdenv, fetchFromGitHub, libtool, autoconf, automake, pkgconfig
1+{ stdenv, fetchFromGitHub, libtool, autoreconfHook, pkgconfig
22, sysfsutils
33 # WARNING: DO NOT USE BEACON GENERATED VALUES AS SECRET CRYPTOGRAPHIC KEYS
44 # https://www.nist.gov/programs-projects/nist-randomness-beacon
@@ -8,32 +8,43 @@
88 # Not sure if jitterentropy is safe to use for cryptography
99 # and thus a default entropy source
1010, jitterentropy ? null, withJitterEntropy ? false
11+, libp11 ? null, withPkcs11 ? true
1112}:
13+
1214with stdenv.lib;
15+
1316stdenv.mkDerivation rec {
14− name = "rng-tools-${version}";
15− version = "6.6";
17+ pname = "rng-tools";
18+ version = "6.7";
1619
1720 src = fetchFromGitHub {
1821 owner = "nhorman";
1922 repo = "rng-tools";
2023 rev = "v${version}";
21− sha256 = "0c32sxfvngdjzfmxn5ngc5yxwi8ij3yl216nhzyz9r31qi3m14v7";
24+ sha256 = "19f75m6mzg8h7b4snzg7d6ypvkz6nq32lrpi9ja95gqz4wsd18a5";
2225 };
2326
24− nativeBuildInputs = [ libtool autoconf automake pkgconfig ];
27+ postPatch = ''
28+ cp README.md README
29+ '';
2530
26− preConfigure = "./autogen.sh";
31+ nativeBuildInputs = [ autoreconfHook libtool pkgconfig ];
2732
28− configureFlags =
29− optional (!withJitterEntropy) "--disable-jitterentropy"
30− ++ optional (!withNistBeacon) "--without-nistbeacon"
31− ++ optional (!withGcrypt) "--without-libgcrypt";
33+ configureFlags = [
34+ (withFeature withGcrypt "libgcrypt")
35+ (enableFeature withJitterEntropy "jitterentropy")
36+ (withFeature withNistBeacon "nistbeacon")
37+ (withFeature withPkcs11 "pkcs11")
38+ ];
3239
3340 buildInputs = [ sysfsutils ]
34− ++ optional withJitterEntropy [ jitterentropy ]
35− ++ optional withGcrypt [ libgcrypt.dev ]
36− ++ optional withNistBeacon [ openssl.dev curl.dev libxml2.dev ];
41+ ++ optionals withGcrypt [ libgcrypt ]
42+ ++ optionals withJitterEntropy [ jitterentropy ]
43+ ++ optionals withNistBeacon [ openssl curl libxml2 ]
44+ ++ optionals withPkcs11 [ libp11 openssl ];
45+
46+ # This shouldn't be necessary but is as of 6.7
47+ NIX_LDFLAGS = optionalString withPkcs11 "-lcrypto";
3748
3849 enableParallelBuilding = true;
3950
@@ -43,8 +54,8 @@ stdenv.mkDerivation rec {
4354 meta = {
4455 description = "A random number generator daemon";
4556 homepage = https://github.com/nhorman/rng-tools;
46− license = stdenv.lib.licenses.gpl2Plus;
47− platforms = stdenv.lib.platforms.linux;
48− maintainers = with stdenv.lib.maintainers; [ johnazoidberg ];
57+ license = licenses.gpl2Plus;
58+ platforms = platforms.linux;
59+ maintainers = with maintainers; [ johnazoidberg ];
4960 };
5061}