1{ lib, stdenv, fetchFromGitHub, openmp ? null }:
2
3stdenv.mkDerivation (finalAttrs: {
4 pname = "b2sum";
5 version = "20190724";
6
7 src = fetchFromGitHub {
8 owner = "BLAKE2";
9 repo = "BLAKE2";
10 rev = finalAttrs.version;
11 sha256 = "sha256-6BVl3Rh+CRPQq3QxcUlk5ArvjIj/IcPCA2/Ok0Zu7UI=";
12 };
13
14 # Use the generic C implementation rather than the SSE optimised version on non-x86 platforms
15 postPatch = lib.optionalString (!stdenv.hostPlatform.isx86) ''
16 substituteInPlace makefile \
17 --replace "#FILES=b2sum.c ../ref/" "FILES=b2sum.c ../ref/" \
18 --replace "FILES=b2sum.c ../sse/" "#FILES=b2sum.c ../sse/"
19 '';
20
21 sourceRoot = "${finalAttrs.src.name}/b2sum";
22
23 buildInputs = [ openmp ];
24
25 buildFlags = [ (lib.optional (openmp == null) "NO_OPENMP=1") ];
26 installFlags = [ "PREFIX=$(out)" ];
27
28 meta = with lib; {
29 description = "The b2sum utility is similar to the md5sum or shasum utilities but for BLAKE2";
30 homepage = "https://blake2.net";
31 license = with licenses; [ asl20 cc0 openssl ];
32 maintainers = with maintainers; [ kirelagin ];
33 platforms = platforms.unix;
34 };
35})