makeInitrd: Support prepending other initrds

This commit is contained in:
William A. Kennington III 2015-03-25 12:03:03 -07:00
parent 8baaff95e6
commit f2655e4fa0
4 changed files with 17 additions and 6 deletions

View file

@ -205,7 +205,7 @@ let
# The closure of the init script of boot stage 1 is what we put in
# the initial RAM disk.
initialRamdisk = pkgs.makeInitrd {
inherit (config.boot.initrd) compressor;
inherit (config.boot.initrd) compressor prepend;
contents =
[ { object = bootStage1;
@ -247,6 +247,14 @@ in
'';
};
boot.initrd.prepend = mkOption {
default = [ ];
type = types.listOf types.str;
description = ''
Other initrd files to prepend to the final initrd we are building.
'';
};
boot.initrd.checkJournalingFS = mkOption {
default = true;
type = types.bool;

View file

@ -12,7 +12,7 @@
# `contents = {object = ...; symlink = /init;}' is a typical
# argument.
{stdenv, perl, perlArchiveCpio, cpio, contents, ubootChooser, compressor}:
{ stdenv, perl, perlArchiveCpio, cpio, contents, ubootChooser, compressor, prepend }:
let
inputsFun = ubootName : [perl cpio perlArchiveCpio ]
@ -41,5 +41,5 @@ stdenv.mkDerivation {
nativeBuildInputs = inputsFun stdenv.cross.platform.uboot;
makeUInitrd = makeUInitrdFun stdenv.cross.platform.uboot;
};
inherit compressor;
inherit compressor prepend;
}

View file

@ -36,7 +36,10 @@ storePaths=$(perl $pathsFromGraph closure-*)
# Put the closure in a gzipped cpio archive.
mkdir -p $out
(cd root && find * -print0 | cpio -o -H newc --null | perl $cpioClean | $compressor > $out/initrd)
for PREP in $prepend; do
cat $PREP >> $out/initrd
done
(cd root && find * -print0 | cpio -o -H newc --null | perl $cpioClean | $compressor >> $out/initrd)
if [ -n "$makeUInitrd" ]; then
mv $out/initrd $out/initrd.gz

View file

@ -396,9 +396,9 @@ let
inherit lib;
};
makeInitrd = {contents, compressor ? "gzip -9n"}:
makeInitrd = { contents, compressor ? "gzip -9n", prepend }:
import ../build-support/kernel/make-initrd.nix {
inherit stdenv perl perlArchiveCpio cpio contents ubootChooser compressor;
inherit stdenv perl perlArchiveCpio cpio contents ubootChooser compressor prepend;
};
makeWrapper = makeSetupHook { } ../build-support/setup-hooks/make-wrapper.sh;