{ fetchgit, fetchurl, stdenv, m4, flex, bison, zlib, gnat, curl, writeText , callPackage, lib, corebootConfig ? { CONFIG_PAYLOAD_NONE = "y"; } }: let version = "4.12"; src = fetchgit { url = "https://review.coreboot.org/coreboot.git"; rev = "${version}"; fetchSubmodules = true; sha256 = "1l140zbvn6pkbrr55lymhi4lycimhpy8xgm45shl4zv6a9vjd66z"; }; toolchain = stdenv.mkDerivation rec { pname = "coreboot-toolchain"; inherit version src; nativeBuildInputs = [ curl stdenv m4 flex bison zlib gnat ]; buildPhase = '' mkdir -p util/crossgcc/tarballs ${lib.concatMapStringsSep "\n" (file: "ln -s ${file.archive} util/crossgcc/tarballs/${file.name}") (callPackage ./files.nix { })} NIX_HARDENING_ENABLE="$\{NIX_HARDENING_ENABLE/ format/\}" make crossgcc-i386 CPUS=$NIX_BUILD_CORES ''; installPhase = '' cp -r util/crossgcc $out ''; }; writeConfig = config: let filteredConfig = lib.filterAttrs (n: v: v != null) config; lines = lib.mapAttrsToList (name: value: "${name}=${value}") filteredConfig; configFile = writeText "config" (lib.concatStringsSep "\n" lines); in configFile; in stdenv.mkDerivation rec { pname = "coreboot"; inherit version src; postPatch = '' rm -rf util/crossgcc cp -r ${toolchain} util/crossgcc chmod u+rwX -R util/crossgcc patchShebangs util/xcompile/xcompile ''; configurePhase = '' runHook preConfigure cp ${writeConfig corebootConfig} .config make olddefconfig runHook postConfigure ''; installPhase = '' mkdir -p $out cp build/coreboot.rom $out ''; passthru = { inherit toolchain writeConfig corebootConfig; }; }