1{ lib, stdenv, fetchFromGitiles, pkg-config, libuuid, openssl, libyaml, xz }:
2
3stdenv.mkDerivation rec {
4 version = "20180311";
5 checkout = "4c84e077858c809ee80a9a6f9b38185cf7dcded7";
6
7 pname = "vboot_reference";
8
9 src = fetchFromGitiles {
10 url = "https://chromium.googlesource.com/chromiumos/platform/vboot_reference";
11 rev = checkout;
12 sha256 = "1zja4ma6flch08h5j2l1hqnxmw2xwylidnddxxd5y2x05dai9ddj";
13 };
14
15 nativeBuildInputs = [ pkg-config ];
16 buildInputs = [ openssl libuuid libyaml xz ];
17
18 enableParallelBuilding = true;
19
20 patches = [ ./dont_static_link.patch ];
21
22 NIX_CFLAGS_COMPILE = [
23 # fix build with gcc9
24 "-Wno-error"
25 # workaround build failure on -fno-common toolchains:
26 # ld: /build/source/build/futility/vb2_helper.o:(.bss+0x0): multiple definition of
27 # `vboot_version'; /build/source/build/futility/futility.o:(.bss+0x0): first defined here
28 # TODO: remove it when next release contains:
29 # https://chromium.googlesource.com/chromiumos/platform/vboot_reference/+/df4d2000a22db673a788b8e57e8e7c0cc3cee777
30 "-fcommon"
31 ];
32
33 postPatch = ''
34 substituteInPlace Makefile \
35 --replace "ar qc" '${stdenv.cc.bintools.targetPrefix}ar qc'
36 '';
37
38 preBuild = ''
39 patchShebangs scripts
40 '';
41
42 makeFlags = [
43 "DESTDIR=$(out)"
44 "HOST_ARCH=${stdenv.hostPlatform.parsed.cpu.name}"
45 ];
46
47 postInstall = ''
48 mkdir -p $out/share/vboot
49 cp -r tests/devkeys* $out/share/vboot/
50 '';
51
52 meta = with lib; {
53 description = "Chrome OS partitioning and kernel signing tools";
54 license = licenses.bsd3;
55 platforms = platforms.linux;
56 maintainers = with maintainers; [ lheckemann ];
57 };
58}