git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/install-grub: Fix symlink installation for boot filesystems which don't support symlinking

Some filesystems like fat32 don't support symlinking and need to be supported on /boot as an efi system partition. Instead of creating the symlink directly in boot, create the symlink in a temporary directory which has to support symlinking.

commitcb343e7be6445a643a22992871a76e4911af2c49 authorWilliam A. Kennington III <william@wkennington.com> dateSun 5 Jul 2015, 18:34 (11 years ago) parentc61d048
1 file changed+6−10
nixos/modules/system/boot/loader/grub/install-grub.pl+6−10
nixos/modules/system/boot/loader/grub/install-grub.pl+6−10
@@ -7,6 +7,7 @@ use File::Path;
77use File::stat;
88use File::Copy;
99use File::Slurp;
10+use File::Temp;
1011require List::Compare;
1112use POSIX;
1213use Cwd;
@@ -506,14 +507,9 @@ my $efiDiffer = $efiTarget ne $prevGrubState->efi;
506507my $efiMountPointDiffer = $efiSysMountPoint ne $prevGrubState->efiMountPoint;
507508my $requireNewInstall = $devicesDiffer || $nameDiffer || $versionDiffer || $efiDiffer || $efiMountPointDiffer || (($ENV{'NIXOS_INSTALL_GRUB'} // "") eq "1");
508509
509−# install a symlink so that grub can detect the boot drive when set
510−# as the root directory
511−if (! -l "$bootPath/boot") {
512− if (-e "$bootPath/boot") {
513− unlink "$bootPath/boot";
514− }
515− symlink ".", "$bootPath/boot";
516−}
510+# install a symlink so that grub can detect the boot drive
511+my $tmpDir = File::Temp::tempdir(CLEANUP => 1) or die "Failed to create temporary space";
512+symlink "$bootPath", "$tmpDir/boot" or die "Failed to symlink $tmpDir/boot";
517513
518514# install non-EFI GRUB
519515if (($requireNewInstall != 0) && ($efiTarget eq "no" || $efiTarget eq "both")) {
@@ -521,10 +517,10 @@ if (($requireNewInstall != 0) && ($efiTarget eq "no" || $efiTarget eq "both")) {
521517 next if $dev eq "nodev";
522518 print STDERR "installing the GRUB $grubVersion boot loader on $dev...\n";
523519 if ($grubTarget eq "") {
524− system("$grub/sbin/grub-install", "--recheck", "--root-directory=$bootPath", Cwd::abs_path($dev)) == 0
520+ system("$grub/sbin/grub-install", "--recheck", "--root-directory=$tmpDir", Cwd::abs_path($dev)) == 0
525521 or die "$0: installation of GRUB on $dev failed\n";
526522 } else {
527− system("$grub/sbin/grub-install", "--recheck", "--root-directory=$bootPath", "--target=$grubTarget", Cwd::abs_path($dev)) == 0
523+ system("$grub/sbin/grub-install", "--recheck", "--root-directory=$tmpDir", "--target=$grubTarget", Cwd::abs_path($dev)) == 0
528524 or die "$0: installation of GRUB on $dev failed\n";
529525 }
530526 }