From b9bf28fd70ae179f703b6bd99f7b0620473b183f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janne=20He=C3=9F?= Date: Fri, 15 Apr 2022 16:37:10 +0100 Subject: [PATCH] nixos/stage-1-init: Pass all parameters to the builder This is for compatiblity with the old builder to get compat with uboot support and to prepend microcode updates to the initrd --- nixos/modules/system/boot/systemd/initrd.nix | 3 +++ pkgs/build-support/kernel/make-initrd-ng.nix | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/nixos/modules/system/boot/systemd/initrd.nix b/nixos/modules/system/boot/systemd/initrd.nix index 7f5d3ae092a..6c1b42da1c4 100644 --- a/nixos/modules/system/boot/systemd/initrd.nix +++ b/nixos/modules/system/boot/systemd/initrd.nix @@ -125,6 +125,9 @@ let }; initialRamdisk = pkgs.makeInitrdNG { + name = "initrd-${kernel-name}"; + inherit (config.boot.initrd) compressor compressorArgs prepend; + contents = map (path: { object = path; symlink = ""; }) (subtractLists cfg.suppressedStorePaths cfg.storePaths) ++ mapAttrsToList (_: v: { object = v.source; symlink = v.target; }) (filterAttrs (_: v: v.enable) cfg.contents); }; diff --git a/pkgs/build-support/kernel/make-initrd-ng.nix b/pkgs/build-support/kernel/make-initrd-ng.nix index 9fd202c4484..1890bbcd173 100644 --- a/pkgs/build-support/kernel/make-initrd-ng.nix +++ b/pkgs/build-support/kernel/make-initrd-ng.nix @@ -66,14 +66,28 @@ in compressorArgs = _compressorArgsReal; }; + inherit extension makeUInitrd uInitrdArch prepend; + ${if makeUInitrd then "uInitrdCompression" else null} = uInitrdCompression; + passAsFile = ["contents"]; contents = lib.concatMapStringsSep "\n" ({ object, symlink, ... }: "${object}\n${if symlink == null then "" else symlink}") contents + "\n"; - nativeBuildInputs = [makeInitrdNGTool patchelf glibc cpio]; + nativeBuildInputs = [makeInitrdNGTool patchelf glibc cpio] ++ lib.optional makeUInitrd ubootTools; } '' mkdir ./root make-initrd-ng "$contentsPath" ./root mkdir "$out" (cd root && find * .[^.*] -exec touch -h -d '@1' '{}' +) + for PREP in $prepend; do + cat $PREP >> $out/initrd + done (cd root && find * .[^.*] -print0 | sort -z | cpio -o -H newc -R +0:+0 --reproducible --null | eval -- $compress >> "$out/initrd") + + if [ -n "$makeUInitrd" ]; then + mkimage -A "$uInitrdArch" -O linux -T ramdisk -C "$uInitrdCompression" -d "$out/initrd" $out/initrd.img + # Compatibility symlink + ln -sf "initrd.img" "$out/initrd" + else + ln -s "initrd" "$out/initrd$extension" + fi ''