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 closure of the init script of boot stage 1 is what we put in
# the initial RAM disk. # the initial RAM disk.
initialRamdisk = pkgs.makeInitrd { initialRamdisk = pkgs.makeInitrd {
inherit (config.boot.initrd) compressor; inherit (config.boot.initrd) compressor prepend;
contents = contents =
[ { object = bootStage1; [ { 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 { boot.initrd.checkJournalingFS = mkOption {
default = true; default = true;
type = types.bool; type = types.bool;

View File

@ -12,7 +12,7 @@
# `contents = {object = ...; symlink = /init;}' is a typical # `contents = {object = ...; symlink = /init;}' is a typical
# argument. # argument.
{stdenv, perl, perlArchiveCpio, cpio, contents, ubootChooser, compressor}: { stdenv, perl, perlArchiveCpio, cpio, contents, ubootChooser, compressor, prepend }:
let let
inputsFun = ubootName : [perl cpio perlArchiveCpio ] inputsFun = ubootName : [perl cpio perlArchiveCpio ]
@ -41,5 +41,5 @@ stdenv.mkDerivation {
nativeBuildInputs = inputsFun stdenv.cross.platform.uboot; nativeBuildInputs = inputsFun stdenv.cross.platform.uboot;
makeUInitrd = makeUInitrdFun 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. # Put the closure in a gzipped cpio archive.
mkdir -p $out 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 if [ -n "$makeUInitrd" ]; then
mv $out/initrd $out/initrd.gz mv $out/initrd $out/initrd.gz

View File

@ -396,9 +396,9 @@ let
inherit lib; inherit lib;
}; };
makeInitrd = {contents, compressor ? "gzip -9n"}: makeInitrd = { contents, compressor ? "gzip -9n", prepend }:
import ../build-support/kernel/make-initrd.nix { 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; makeWrapper = makeSetupHook { } ../build-support/setup-hooks/make-wrapper.sh;