diff --git a/nixos/modules/system/boot/stage-1.nix b/nixos/modules/system/boot/stage-1.nix index 16bebe03740a..2c3dfd2f460f 100644 --- a/nixos/modules/system/boot/stage-1.nix +++ b/nixos/modules/system/boot/stage-1.nix @@ -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; diff --git a/pkgs/build-support/kernel/make-initrd.nix b/pkgs/build-support/kernel/make-initrd.nix index 0582ca553012..895160616b79 100644 --- a/pkgs/build-support/kernel/make-initrd.nix +++ b/pkgs/build-support/kernel/make-initrd.nix @@ -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; } diff --git a/pkgs/build-support/kernel/make-initrd.sh b/pkgs/build-support/kernel/make-initrd.sh index 17b261f98407..08961a1b49c2 100644 --- a/pkgs/build-support/kernel/make-initrd.sh +++ b/pkgs/build-support/kernel/make-initrd.sh @@ -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 diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index dce09bf29a17..89b23c8de4e9 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -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;