From 576e50fc85a4cecada30c977718492ace6ce37a0 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sat, 31 Dec 2022 13:55:33 -0800 Subject: [PATCH] flashrom: add option for google chromebook fork --- src/flashrom/default.nix | 43 +++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/src/flashrom/default.nix b/src/flashrom/default.nix index 71ce23c..04b3aa4 100644 --- a/src/flashrom/default.nix +++ b/src/flashrom/default.nix @@ -1,34 +1,53 @@ { stdenv , lib +, fetchgit , fetchFromGitHub , installShellFiles , libftdi1 , libusb1 , pciutils , pkg-config + +# use google's out-of-tree flashrom which can manipulate the +# write-protection registers of the chromebooks' on-board flash +# chips +, forChromebook ? false }: stdenv.mkDerivation { pname = "flashrom"; - version = "1.2+wp"; + version = if !forChromebook then "1.2+wp" else "0.9.9+d2da98-google"; - src = fetchFromGitHub { - owner = "flashrom"; - repo = "flashrom"; - rev = "cd9b7b427d19e591c1091cb783a51951ef3aeffc"; - sha256 = "sha256-gK/z+WkEHFmT/dYnNLMn4Cb2ESBfqipc19ZVxmaZabQ="; - }; + src = + if !forChromebook + then fetchFromGitHub { + owner = "flashrom"; + repo = "flashrom"; + rev = "cd9b7b427d19e591c1091cb783a51951ef3aeffc"; + sha256 = "sha256-gK/z+WkEHFmT/dYnNLMn4Cb2ESBfqipc19ZVxmaZabQ="; + } else fetchgit { + url = "https://chromium.googlesource.com/chromiumos/third_party/flashrom"; + rev = "d2da987986cf2b7f048174ba339907cc760b1c3d"; + hash = "sha256-nB8B0MXjVpAsg4+0VvO5jqRBsmEHdllgIMkTmaBJ6gE="; + }; nativeBuildInputs = [ pkg-config installShellFiles ]; buildInputs = lib.optional (!stdenv.hostPlatform.isStatic) libftdi1 ++ [ libusb1 pciutils ]; - patches = [ - ./0001-implement-wp-enable-disable-for-gigadevice-flash-chi.patch - ./0002-layout.c-allow-nested-regions.patch - ]; + patches = + if !forChromebook then [ + ./0001-implement-wp-enable-disable-for-gigadevice-flash-chi.patch + ./0002-layout.c-allow-nested-regions.patch + ] else [ + ../platform/kevin/chromebook-flashrom-kludges.patch + ]; - makeFlags = [ "PREFIX=$(out)" "libinstall" ]; + makeFlags = if !forChromebook then [ + "PREFIX=$(out)" "libinstall" + ] else [ + "PREFIX=$(out)" "install" + ]; meta = with lib; { homepage = "https://www.flashrom.org";