1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 openmp ? null,
6}:
7
8stdenv.mkDerivation (finalAttrs: {
9 pname = "b2sum";
10 version = "20190724";
11
12 src = fetchFromGitHub {
13 owner = "BLAKE2";
14 repo = "BLAKE2";
15 rev = finalAttrs.version;
16 sha256 = "sha256-6BVl3Rh+CRPQq3QxcUlk5ArvjIj/IcPCA2/Ok0Zu7UI=";
17 };
18
19 # Use the generic C implementation rather than the SSE optimised version on non-x86 platforms
20 postPatch = lib.optionalString (!stdenv.hostPlatform.isx86) ''
21 substituteInPlace makefile \
22 --replace "#FILES=b2sum.c ../ref/" "FILES=b2sum.c ../ref/" \
23 --replace "FILES=b2sum.c ../sse/" "#FILES=b2sum.c ../sse/"
24 '';
25
26 sourceRoot = "${finalAttrs.src.name}/b2sum";
27
28 buildInputs = [ openmp ];
29
30 buildFlags = [ (lib.optional (openmp == null) "NO_OPENMP=1") ];
31
32 # clang builds require at least C99 or the build fails with:
33 # error: unknown type name 'inline'
34 env.NIX_CFLAGS_COMPILE = "-std=c99";
35
36 installFlags = [ "PREFIX=$(out)" ];
37
38 meta = with lib; {
39 description = "B2sum utility is similar to the md5sum or shasum utilities but for BLAKE2";
40 mainProgram = "b2sum";
41 homepage = "https://blake2.net";
42 license = with licenses; [
43 asl20
44 cc0
45 openssl
46 ];
47 maintainers = with maintainers; [ kirelagin ];
48 platforms = platforms.unix;
49 };
50})