From 203e6da7733f61f48fcb1d9dd1b1c2583c51fe34 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sun, 9 Apr 2023 19:43:34 -0700 Subject: [PATCH] flashrom: parameterize and passthru patches Sadly we need at least two different forks of flashrom, with different patches (and therefore different capabilities) applied to each. This commit parameterizes the flashrom expression and includes those parameters in the `passthru` so downstream expressions can check whether various needed features are present. --- src/util/flashrom/default.nix | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/util/flashrom/default.nix b/src/util/flashrom/default.nix index 9e44ec8..c2e437d 100644 --- a/src/util/flashrom/default.nix +++ b/src/util/flashrom/default.nix @@ -13,6 +13,9 @@ # chips and can also write to the embedded controller (EC) flash, # which is a separate chip , forChromebook ? false + +, writeProtectSupport ? true +, overlappingFmapRegionSupport ? false }: stdenv.mkDerivation { @@ -36,13 +39,14 @@ stdenv.mkDerivation { buildInputs = lib.optional (!stdenv.hostPlatform.isStatic) libftdi1 ++ [ libusb1 pciutils ]; - 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 - ]; + patches = lib.optionals (writeProtectSupport && !forChromebook) [ + # the forChromebook fork already has (Google's version of) the enableWriteProtect patches + ./0001-implement-wp-enable-disable-for-gigadevice-flash-chi.patch + ] ++ lib.optionals forChromebook [ + ../../platform/kevin/chromebook-flashrom-kludges.patch + ] ++ lib.optionals overlappingFmapRegionSupport [ + ./0002-layout.c-allow-nested-regions.patch + ]; makeFlags = if !forChromebook then [ "PREFIX=$(out)" "libinstall" @@ -54,6 +58,10 @@ stdenv.mkDerivation { mv $out/sbin/flashrom $out/sbin/flashrom-chromebook ''; + passthru = { + inherit forChromebook writeProtectSupport overlappingFmapRegionSupport; + }; + meta = with lib; { homepage = "https://www.flashrom.org"; description = "Utility for reading, writing, erasing and verifying flash ROM chips";