{ stdenv , lib , fetchFromGitHub , installShellFiles , libftdi1 , libusb1 , pciutils , pkg-config }: stdenv.mkDerivation { pname = "flashrom"; version = "1.2+wp"; src = fetchFromGitHub { owner = "flashrom"; repo = "flashrom"; rev = "cd9b7b427d19e591c1091cb783a51951ef3aeffc"; sha256 = "sha256-gK/z+WkEHFmT/dYnNLMn4Cb2ESBfqipc19ZVxmaZabQ="; }; 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 ]; makeFlags = [ "PREFIX=$(out)" "libinstall" ]; meta = with lib; { homepage = "https://www.flashrom.org"; description = "Utility for reading, writing, erasing and verifying flash ROM chips"; license = licenses.gpl2; }; }