Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib, stdenv, fetchFromGitHub, fetchpatch, libftdi
2, infnoise, testers }:
3
4stdenv.mkDerivation rec {
5 pname = "infnoise";
6 version = "0.3.2";
7
8 src = fetchFromGitHub {
9 owner = "leetronics";
10 repo = "infnoise";
11 rev = "e80ddd78085abf3d06df2e0d8c08fd33dade78eb";
12 sha256 = "sha256-9MKG1InkV+yrQPBTgi2gZJ3y9Fokb6WbxuAnM7n7FyA=";
13 };
14
15 patches = [
16 # Patch makefile so we can set defines from the command line instead of it depending on .git
17 ./makefile.patch
18
19 # Fix getc return type
20 (fetchpatch {
21 url = "https://github.com/leetronics/infnoise/commit/7ed7014e14253311c07e530c8f89f1c8f4705c2b.patch";
22 sha256 = "sha256-seB/fJaxQ/rXJp5iPtnobXXOccQ2KUAk6HFx31dhOhs=";
23 })
24 ];
25
26 GIT_COMMIT = src.rev;
27 GIT_VERSION = version;
28 GIT_DATE = "2019-08-12";
29
30 buildInputs = [ libftdi ];
31
32 makefile = "Makefile.linux";
33 makeFlags = [ "PREFIX=$(out)" ];
34 postPatch = ''
35 cd software
36 substituteInPlace init_scripts/infnoise.service --replace "/usr/local" "$out"
37 '';
38
39 postInstall = ''
40 make -C tools
41 find ./tools/ -executable -type f -exec \
42 sh -c "install -Dm755 {} $out/bin/infnoise-\$(basename {})" \;
43 '';
44
45 passthru = {
46 tests.version = testers.testVersion { package = infnoise; };
47 };
48
49 meta = with lib; {
50 homepage = "https://github.com/leetronics/infnoise";
51 description = "Driver for the Infinite Noise TRNG";
52 longDescription = ''
53 The Infinite Noise TRNG is a USB key hardware true random number generator.
54 It can either provide rng for userland applications, or provide rng for the OS entropy.
55 '';
56 license = licenses.cc0;
57 maintainers = with maintainers; [ StijnDW zhaofengli ];
58 platforms = platforms.linux;
59 };
60}