Merge pull request #209964 from Majiir/fix-initrd-systemd-closure

nixos/systemd/initrd: follow init param symlinks
This commit is contained in:
Will Fancher 2024-03-18 14:39:37 -04:00 committed by GitHub
commit 99587a3411
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -518,7 +518,7 @@ in {
case $o in
init=*)
IFS== read -r -a initParam <<< "$o"
closure="$(dirname "''${initParam[1]}")"
closure="''${initParam[1]}"
;;
esac
done
@ -529,6 +529,13 @@ in {
exit 1
fi
# Resolve symlinks in the init parameter. We need this for some boot loaders
# (e.g. boot.loader.generationsDir).
closure="$(chroot /sysroot ${pkgs.coreutils}/bin/realpath "$closure")"
# Assume the directory containing the init script is the closure.
closure="$(dirname "$closure")"
# If we are not booting a NixOS closure (e.g. init=/bin/sh),
# we don't know what root to prepare so we don't do anything
if ! [ -x "/sysroot$(readlink "/sysroot$closure/prepare-root" || echo "$closure/prepare-root")" ]; then