coreboot: separate compilation from payload installation
This commit causes the coreboot payload (i.e. the Linux kernel, initramfs, and any necessary DTBs) to be inserted into the coreboot image as part of a separate derivation from the one which compiles coreboot. As a result, changing the contents of the initramfs is extremely fast -- it can now be done without any recompilation. As a result of this, the attribute name for the final image to be flashed has changed from `coreboot` to `image`. The `coreboot` attribute now builds a payloadless `coreboot.rom`.master
parent
8efee177f2
commit
2c30620ed2
@ -0,0 +1,63 @@
|
||||
{ lib
|
||||
, nixpkgsOnBuildForBuild
|
||||
, nixpkgsOnBuildForHost
|
||||
, coreboot-toolchain ? throw "missing"
|
||||
, coreboot ? throw "missing"
|
||||
, payload ? throw "you must provide a coreboot payload (Linux kernel image or FIT)"
|
||||
, payload-compression-type ? "none"
|
||||
, payload-prefix ? "prefix"
|
||||
, payload-name ? "payload"
|
||||
, initramfs_image # path to the initramfs `cpio` archive
|
||||
, linux-command-line ? null
|
||||
}:
|
||||
|
||||
nixpkgsOnBuildForHost.stdenv.mkDerivation {
|
||||
pname = "ownerboot";
|
||||
inherit (coreboot) version;
|
||||
|
||||
passthru = { inherit (coreboot) src fmap; };
|
||||
|
||||
nativeBuildInputs = [
|
||||
nixpkgsOnBuildForBuild.coreboot-utils
|
||||
];
|
||||
|
||||
dontUnpack = true;
|
||||
|
||||
buildPhase = let
|
||||
update-cbfs = region: lib.concatStringsSep " " ([
|
||||
"cbfstool"
|
||||
"coreboot.rom"
|
||||
"add-payload"
|
||||
"-r${region}"
|
||||
"-f${payload}"
|
||||
"-n${payload-prefix}/${payload-name}"
|
||||
"-c${payload-compression-type}"
|
||||
] ++ lib.optionals (linux-command-line != null) [
|
||||
"-C'${linux-command-line}'"
|
||||
] ++ lib.optionals (initramfs_image != null) [
|
||||
"-I'${initramfs_image}'"
|
||||
] ++ [
|
||||
"\n"
|
||||
]);
|
||||
in ''
|
||||
runHook preBuild
|
||||
cp ${coreboot}/coreboot.rom .
|
||||
chmod +w coreboot.rom
|
||||
cbfstool coreboot.rom print -rNORMAL
|
||||
${lib.concatMapStrings (region: update-cbfs region) [ "NORMAL" "FALLBACK" ]}
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preBuild
|
||||
mkdir -p $out
|
||||
cp -a ${coreboot}/* $out/
|
||||
chmod +w $out/coreboot.rom
|
||||
rm $out/coreboot.rom
|
||||
mv coreboot.rom $out/
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
dontFixup = true;
|
||||
|
||||
}
|
Loading…
Reference in New Issue