summary refs log tree commit diff
path: root/nixos/modules/installer/cd-dvd/iso-image.nix
diff options
context:
space:
mode:
authorLuca Bruno <lucabru@src.gnome.org>2014-11-08 13:09:08 +0100
committerLuca Bruno <lucabru@src.gnome.org>2014-11-08 14:33:27 +0100
commit7885c2ed12a353aa92da2087b2ba1e6adac7c069 (patch)
tree52e11d4dad0e2b19002fcf84f42db18d44799a9a /nixos/modules/installer/cd-dvd/iso-image.nix
parente3611709d6ab459be0ed16fe0fdeb7e4c4acc05d (diff)
downloadnixpkgs-7885c2ed12a353aa92da2087b2ba1e6adac7c069.tar
nixpkgs-7885c2ed12a353aa92da2087b2ba1e6adac7c069.tar.gz
nixpkgs-7885c2ed12a353aa92da2087b2ba1e6adac7c069.tar.bz2
nixpkgs-7885c2ed12a353aa92da2087b2ba1e6adac7c069.tar.lz
nixpkgs-7885c2ed12a353aa92da2087b2ba1e6adac7c069.tar.xz
nixpkgs-7885c2ed12a353aa92da2087b2ba1e6adac7c069.tar.zst
nixpkgs-7885c2ed12a353aa92da2087b2ba1e6adac7c069.zip
Revert "nixos: iso-image: use syslinux bootloader for USB booting support"
This reverts commit 455db168b30d53c903c96be80ef843b79e0744ae.
Diffstat (limited to 'nixos/modules/installer/cd-dvd/iso-image.nix')
-rw-r--r--nixos/modules/installer/cd-dvd/iso-image.nix132
1 files changed, 70 insertions, 62 deletions
diff --git a/nixos/modules/installer/cd-dvd/iso-image.nix b/nixos/modules/installer/cd-dvd/iso-image.nix
index f387c64cb9c..22f31c46080 100644
--- a/nixos/modules/installer/cd-dvd/iso-image.nix
+++ b/nixos/modules/installer/cd-dvd/iso-image.nix
@@ -8,37 +8,45 @@ with lib;
 
 let
 
-  # The configuration file for syslinux.
-  isolinuxCfg =
+  # The Grub image.
+  grubImage = pkgs.runCommand "grub_eltorito" {}
     ''
-    SERIAL 0 38400
-    UI vesamenu.c32
-    MENU TITLE NixOS
-    MENU BACKGROUND /isolinux/background.png
-
-    LABEL boot
-    MENU LABEL Boot NixOS
-    LINUX /boot/bzImage init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams}
-    INITRD /boot/initrd
-
-    LABEL chain
-    MENU LABEL Boot existing OS
-    COM32 chain.c32
-    APPEND hd0 0
-
-    LABEL reboot
-    MENU LABEL Reboot
-    COM32 reboot.c32
-
-    LABEL poweroff
-    MENU LABEL Power Off
-    COM32 poweroff.c32
+      ${pkgs.grub2}/bin/grub-mkimage -p /boot/grub -O i386-pc -o tmp biosdisk iso9660 help linux linux16 chain png jpeg echo gfxmenu reboot
+      cat ${pkgs.grub2}/lib/grub/*/cdboot.img tmp > $out
+    ''; # */
+
+
+  # The configuration file for Grub.
+  grubCfg =
+    ''
+      set default=${builtins.toString config.boot.loader.grub.default}
+      set timeout=${builtins.toString config.boot.loader.grub.timeout}
+
+      if loadfont /boot/grub/unicode.pf2; then
+        set gfxmode=640x480
+        insmod gfxterm
+        insmod vbe
+        terminal_output gfxterm
+
+        insmod png
+        if background_image /boot/grub/splash.png; then
+          set color_normal=white/black
+          set color_highlight=black/white
+        else
+          set menu_color_normal=cyan/blue
+          set menu_color_highlight=white/blue
+        fi
+
+      fi
+
+      ${config.boot.loader.grub.extraEntries}
     '';
 
+
   # The efi boot image
   efiDir = pkgs.runCommand "efi-directory" {} ''
-    mkdir -p $out/EFI/boot
-    cp -v ${pkgs.gummiboot}/lib/gummiboot/gummiboot${targetArch}.efi $out/EFI/boot/boot${targetArch}.efi
+    mkdir -p $out/efi/boot
+    cp -v ${pkgs.gummiboot}/lib/gummiboot/gummiboot${targetArch}.efi $out/efi/boot/boot${targetArch}.efi
     mkdir -p $out/loader/entries
     echo "title NixOS LiveCD" > $out/loader/entries/nixos-livecd.conf
     echo "linux /boot/bzImage" >> $out/loader/entries/nixos-livecd.conf
@@ -144,22 +152,6 @@ in
       '';
     };
 
-    isoImage.makeUsbBootable = mkOption {
-      default = false;
-      description = ''
-        Whether the ISO image should be bootable from CD as well as USB.
-      '';
-    };
-
-    isoImage.splashImage = mkOption {
-      default = pkgs.fetchurl {
-          url = https://raw.githubusercontent.com/NixOS/nixos-artwork/5729ab16c6a5793c10a2913b5a1b3f59b91c36ee/ideas/grub-splash/grub-nixos-1.png;
-          sha256 = "43fd8ad5decf6c23c87e9026170a13588c2eba249d9013cb9f888da5e2002217";
-        };
-      description = ''
-        The splash image to use in the bootloader.
-      '';
-    };
 
   };
 
@@ -174,7 +166,7 @@ in
 
     # !!! Hack - attributes expected by other modules.
     system.boot.loader.kernelFile = "bzImage";
-    environment.systemPackages = [ pkgs.grub2 pkgs.syslinux ];
+    environment.systemPackages = [ pkgs.grub2 ];
 
     # In stage 1 of the boot, mount the CD as the root FS by label so
     # that we don't need to know its device.  We pass the label of the
@@ -221,7 +213,7 @@ in
         options = "allow_other,cow,nonempty,chroot=/mnt-root,max_files=32768,hide_meta_files,dirs=/nix/.rw-store=rw:/nix/.ro-store=ro";
       };
 
-    boot.initrd.availableKernelModules = [ "squashfs" "iso9660" "usb-storage" ];
+    boot.initrd.availableKernelModules = [ "squashfs" "iso9660" ];
 
     boot.initrd.kernelModules = [ "loop" ];
 
@@ -241,12 +233,15 @@ in
     # Individual files to be included on the CD, outside of the Nix
     # store on the CD.
     isoImage.contents =
-      [ { source = pkgs.substituteAll  {
-            name = "isolinux.cfg";
-            src = pkgs.writeText "isolinux.cfg-in" isolinuxCfg;
+      [ { source = grubImage;
+          target = "/boot/grub/grub_eltorito";
+        }
+        { source = pkgs.substituteAll  {
+            name = "grub.cfg";
+            src = pkgs.writeText "grub.cfg-in" grubCfg;
             bootRoot = "/boot";
           };
-          target = "/isolinux/isolinux.cfg";
+          target = "/boot/grub/grub.cfg";
         }
         { source = config.boot.kernelPackages.kernel + "/bzImage";
           target = "/boot/bzImage";
@@ -254,38 +249,51 @@ in
         { source = config.system.build.initialRamdisk + "/initrd";
           target = "/boot/initrd";
         }
-        { source = config.system.build.squashfsStore;
-          target = "/nix-store.squashfs";
+        { source = "${pkgs.grub2}/share/grub/unicode.pf2";
+          target = "/boot/grub/unicode.pf2";
         }
-        { source = "${pkgs.syslinux}/share/syslinux";
-          target = "/isolinux";
+        { source = config.boot.loader.grub.splashImage;
+          target = "/boot/grub/splash.png";
         }
-        { source = config.isoImage.splashImage;
-          target = "/isolinux/background.png";
+        { source = config.system.build.squashfsStore;
+          target = "/nix-store.squashfs";
         }
       ] ++ optionals config.isoImage.makeEfiBootable [
         { source = efiImg;
           target = "/boot/efi.img";
         }
-        { source = "${efiDir}/EFI";
-          target = "/EFI";
+        { source = "${efiDir}/efi";
+          target = "/efi";
         }
         { source = "${efiDir}/loader";
           target = "/loader";
         }
-      ];
+      ] ++ mapAttrsToList (n: v: { source = v; target = "/boot/${n}"; }) config.boot.loader.grub.extraFiles;
+
+    # The Grub menu.
+    boot.loader.grub.extraEntries =
+      ''
+        menuentry "NixOS ${config.system.nixosVersion} Installer" {
+          linux /boot/bzImage init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams}
+          initrd /boot/initrd
+        }
+
+        menuentry "Boot from hard disk" {
+          set root=(hd0)
+          chainloader +1
+        }
+      '';
+
+    boot.loader.grub.timeout = 10;
 
     # Create the ISO image.
     system.build.isoImage = import ../../../lib/make-iso9660-image.nix ({
-      inherit (pkgs) stdenv perl pathsFromGraph xorriso syslinux;
+      inherit (pkgs) stdenv perl cdrkit pathsFromGraph;
 
       inherit (config.isoImage) isoName compressImage volumeID contents;
 
       bootable = true;
-      bootImage = "/isolinux/isolinux.bin";
-    } // optionalAttrs config.isoImage.makeUsbBootable {
-      usbBootable = true;
-      isohybridMbrImage = "${pkgs.syslinux}/share/syslinux/isohdpfx.bin";
+      bootImage = "/boot/grub/grub_eltorito";
     } // optionalAttrs config.isoImage.makeEfiBootable {
       efiBootable = true;
       efiBootImage = "boot/efi.img";