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