about summary refs log tree commit diff
path: root/nixos/modules/system
diff options
context:
space:
mode:
authorWill Fancher <elvishjerricco@gmail.com>2024-03-18 14:39:37 -0400
committerGitHub <noreply@github.com>2024-03-18 14:39:37 -0400
commit99587a341116c9f404feb440d774a54c4ab4f7b6 (patch)
tree92f9487d01ea2c4d9cb112f43edfd43f78cdb5ed /nixos/modules/system
parent3b988c076b96e49b3fbbee90a59f6c8998d2f51e (diff)
parent58a373809a0399a64d8f5bc7ccc79d6c3c625447 (diff)
Merge pull request #209964 from Majiir/fix-initrd-systemd-closure
nixos/systemd/initrd: follow init param symlinks
Diffstat (limited to 'nixos/modules/system')
-rw-r--r--nixos/modules/system/boot/systemd/initrd.nix9
1 files changed, 8 insertions, 1 deletions
diff --git a/nixos/modules/system/boot/systemd/initrd.nix b/nixos/modules/system/boot/systemd/initrd.nix
index 7abba80fbefb7..7a4648b45612d 100644
--- a/nixos/modules/system/boot/systemd/initrd.nix
+++ b/nixos/modules/system/boot/systemd/initrd.nix
@@ -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