1{ lib, stdenv, fetchFromGitiles, pkg-config, libuuid, openssl, libyaml, xz }:
2
3stdenv.mkDerivation rec {
4 version = "111.15329";
5
6 pname = "vboot_reference";
7
8 src = fetchFromGitiles {
9 url = "https://chromium.googlesource.com/chromiumos/platform/vboot_reference";
10 rev = "1a1cb5c9a38030a5868e2aaad295c68432c680fd"; # refs/heads/release-R111-15329.B
11 sha256 = "sha256-56/hqqFiKHw0/ah0D20U1ueIU2iq8I4Wn5DiEWxB9qA=";
12 };
13
14 nativeBuildInputs = [ pkg-config ];
15 buildInputs = [ libuuid libyaml openssl xz ];
16
17 enableParallelBuilding = true;
18
19 env.NIX_CFLAGS_COMPILE = toString [
20 # This apparently doesn't work as expected:
21 # - https://chromium.googlesource.com/chromiumos/platform/vboot_reference/+/refs/heads/release-R111-15329.B/Makefile#439
22 # Let's apply the same flag manually.
23 "-Wno-error=deprecated-declarations"
24 ];
25
26 postPatch = ''
27 substituteInPlace Makefile \
28 --replace "ar qc" '${stdenv.cc.bintools.targetPrefix}ar qc'
29 # Drop flag unrecognized by GCC 9 (for e.g. aarch64-linux)
30 substituteInPlace Makefile \
31 --replace "-Wno-unknown-warning" ""
32 '';
33
34 preBuild = ''
35 patchShebangs scripts
36 '';
37
38 makeFlags = [
39 "DESTDIR=$(out)"
40 "HOST_ARCH=${stdenv.hostPlatform.parsed.cpu.name}"
41 "USE_FLASHROM=0"
42 # Upstream has weird opinions about DESTDIR
43 # https://chromium.googlesource.com/chromiumos/platform/vboot_reference/+/refs/heads/release-R111-15329.B/Makefile#51
44 "UB_DIR=${placeholder "out"}/bin"
45 "UL_DIR=${placeholder "out"}/lib"
46 "UI_DIR=${placeholder "out"}/include/vboot"
47 "US_DIR=${placeholder "out"}/share/vboot"
48 ];
49
50 postInstall = ''
51 mkdir -p $out/share/vboot
52 cp -r tests/devkeys* $out/share/vboot/
53 '';
54
55 meta = with lib; {
56 description = "Chrome OS partitioning and kernel signing tools";
57 license = licenses.bsd3;
58 platforms = platforms.linux;
59 maintainers = with maintainers; [ lheckemann samueldr ];
60 };
61}