summary refs log tree commit diff
diff options
context:
space:
mode:
authorWilliam A. Kennington III <william@wkennington.com>2015-06-17 11:47:36 -0700
committerWilliam A. Kennington III <william@wkennington.com>2015-06-17 11:47:36 -0700
commitd4fc2b4d99122ba6592835aa84f659b22aeea433 (patch)
tree983ca10c8a39b9dbb3f68e77a329d5eb55445f17
parent911403c9e5833f52d04777bb9eaf66e727cca554 (diff)
downloadnixpkgs-d4fc2b4d99122ba6592835aa84f659b22aeea433.tar
nixpkgs-d4fc2b4d99122ba6592835aa84f659b22aeea433.tar.gz
nixpkgs-d4fc2b4d99122ba6592835aa84f659b22aeea433.tar.bz2
nixpkgs-d4fc2b4d99122ba6592835aa84f659b22aeea433.tar.lz
nixpkgs-d4fc2b4d99122ba6592835aa84f659b22aeea433.tar.xz
nixpkgs-d4fc2b4d99122ba6592835aa84f659b22aeea433.tar.zst
nixpkgs-d4fc2b4d99122ba6592835aa84f659b22aeea433.zip
nixos/install-grub: Fix grub1 installation
-rw-r--r--nixos/modules/system/boot/loader/grub/install-grub.pl12
1 files changed, 10 insertions, 2 deletions
diff --git a/nixos/modules/system/boot/loader/grub/install-grub.pl b/nixos/modules/system/boot/loader/grub/install-grub.pl
index 9db4c4003c9..cad9013bf5a 100644
--- a/nixos/modules/system/boot/loader/grub/install-grub.pl
+++ b/nixos/modules/system/boot/loader/grub/install-grub.pl
@@ -502,6 +502,14 @@ my $efiDiffer = ($efiTarget eq \$prevGrubState->efi);
 my $efiMountPointDiffer = ($efiSysMountPoint eq \$prevGrubState->efiMountPoint);
 my $requireNewInstall = $devicesDiffer || $versionDiffer || $efiDiffer || $efiMountPointDiffer || (($ENV{'NIXOS_INSTALL_GRUB'} // "") eq "1");
 
+# install a symlink so that grub can detect the boot drive when set
+# as the root directory
+if (! -l "$bootPath/boot") {
+    if (-e "$bootPath/boot") {
+        unlink "$bootPath/boot";
+    }
+    symlink ".", "$bootPath/boot";
+}
 
 # install non-EFI GRUB
 if (($requireNewInstall != 0) && ($efiTarget eq "no" || $efiTarget eq "both")) {
@@ -509,10 +517,10 @@ if (($requireNewInstall != 0) && ($efiTarget eq "no" || $efiTarget eq "both")) {
         next if $dev eq "nodev";
         print STDERR "installing the GRUB $grubVersion boot loader on $dev...\n";
         if ($grubTarget eq "") {
-            system("$grub/sbin/grub-install", "--recheck", "--boot-directory=$bootPath", Cwd::abs_path($dev)) == 0
+            system("$grub/sbin/grub-install", "--recheck", "--root-directory=$bootPath", Cwd::abs_path($dev)) == 0
                 or die "$0: installation of GRUB on $dev failed\n";
         } else {
-            system("$grub/sbin/grub-install", "--recheck", "--boot-directory=$bootPath", "--target=$grubTarget", Cwd::abs_path($dev)) == 0
+            system("$grub/sbin/grub-install", "--recheck", "--root-directory=$bootPath", "--target=$grubTarget", Cwd::abs_path($dev)) == 0
                 or die "$0: installation of GRUB on $dev failed\n";
         }
     }