diff options
author | Bob van der Linden <bobvanderlinden@gmail.com> | 2014-10-26 21:29:04 +0100 |
---|---|---|
committer | Vladimír Čunát <vcunat@gmail.com> | 2015-03-24 22:01:04 +0100 |
commit | 8d092270d28d82aa5623bcde55a2ee85129ac1f1 (patch) | |
tree | a4bec9fd0bb0f43c48f44f7e074ec24ade0b93bb /nixos/lib | |
parent | 9a75c1d7c8ee19046ce67f2dc725821d2d5452fa (diff) |
nixos: iso-image: use syslinux bootloader for USB booting support
This changes the bootloader for iso generation from Grub to
syslinux. In addition this adds USB booting support, so that
"dd" can be used to burn the generated ISO to USB thumbdrives
instead of needing applications like UnetBootin.
Diffstat (limited to 'nixos/lib')
-rw-r--r-- | nixos/lib/make-iso9660-image.nix | 13 | ||||
-rw-r--r-- | nixos/lib/make-iso9660-image.sh | 48 |
2 files changed, 50 insertions, 11 deletions
diff --git a/nixos/lib/make-iso9660-image.nix b/nixos/lib/make-iso9660-image.nix index 5ad546e9534d..b2409c6006bc 100644 --- a/nixos/lib/make-iso9660-image.nix +++ b/nixos/lib/make-iso9660-image.nix @@ -1,4 +1,4 @@ -{ stdenv, perl, cdrkit, pathsFromGraph +{ stdenv, perl, pathsFromGraph, xorriso, syslinux , # The file name of the resulting ISO image. isoName ? "cd.iso" @@ -22,12 +22,18 @@ , # Whether this should be an efi-bootable El-Torito CD. efiBootable ? false +, # Wheter this should be an hybrid CD (bootable from USB as well as CD). + usbBootable ? false + , # The path (in the ISO file system) of the boot image. bootImage ? "" , # The path (in the ISO file system) of the efi boot image. efiBootImage ? "" +, # The path (outside the ISO file system) of the isohybrid-mbr image. + isohybridMbrImage ? "" + , # Whether to compress the resulting ISO image with bzip2. compressImage ? false @@ -38,13 +44,14 @@ assert bootable -> bootImage != ""; assert efiBootable -> efiBootImage != ""; +assert usbBootable -> isohybridMbrImage != ""; stdenv.mkDerivation { name = "iso9660-image"; builder = ./make-iso9660-image.sh; - buildInputs = [perl cdrkit]; + buildInputs = [perl xorriso syslinux]; - inherit isoName bootable bootImage compressImage volumeID pathsFromGraph efiBootImage efiBootable; + inherit isoName bootable bootImage compressImage volumeID pathsFromGraph efiBootImage efiBootable isohybridMbrImage usbBootable; # !!! should use XML. sources = map (x: x.source) contents; diff --git a/nixos/lib/make-iso9660-image.sh b/nixos/lib/make-iso9660-image.sh index 675b5bb35148..c8522513aa23 100644 --- a/nixos/lib/make-iso9660-image.sh +++ b/nixos/lib/make-iso9660-image.sh @@ -31,11 +31,20 @@ if test -n "$bootable"; then fi done - bootFlags="-b $bootImage -c .boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table" + isoBootFlags="-eltorito-boot ${bootImage} + -eltorito-catalog .boot.cat + -no-emul-boot -boot-load-size 4 -boot-info-table" +fi + +if test -n "$usbBootable"; then + usbBootFlags="-isohybrid-mbr ${isohybridMbrImage}" fi if test -n "$efiBootable"; then - bootFlags="$bootFlags -eltorito-alt-boot -e $efiBootImage -no-emul-boot" + efiBootFlags="-eltorito-alt-boot + -e $efiBootImage + -no-emul-boot + -isohybrid-gpt-basdat" fi touch pathlist @@ -74,18 +83,41 @@ for ((n = 0; n < ${#objects[*]}; n++)); do fi done -# !!! what does this do? +# Escape filenames that contain '='. +# TODO: Handle this properly. This fails for filenames +# that contain multiple '=' symbols. cat pathlist | sed -e 's/=\(.*\)=\(.*\)=/\\=\1=\2\\=/' | tee pathlist.safer mkdir -p $out/iso -genCommand="genisoimage -iso-level 4 -r -J $bootFlags -hide-rr-moved -graft-points -path-list pathlist.safer ${volumeID:+-V $volumeID}" -if test -z "$compressImage"; then - $genCommand -o $out/iso/$isoName -else - $genCommand | bzip2 > $out/iso/$isoName.bz2 + +xorriso="xorriso + -as mkisofs + -iso-level 3 + -volid ${volumeID} + -appid nixos + -publisher nixos + -graft-points + -full-iso9660-filenames + ${isoBootFlags} + ${usbBootFlags} + ${efiBootFlags} + -r + -path-list pathlist.safer + --sort-weight 0 / + --sort-weight 1 /isolinux" # Make sure isolinux is near the beginning of the ISO + +$xorriso -output $out/iso/$isoName + +if test -n "$usbBootable"; then + echo "Making image hybrid..." + isohybrid --uefi $out/iso/$isoName fi +if test -n "$compressImage"; then + echo "Compressing image..." + bzip2 $out/iso/$isoName +fi mkdir -p $out/nix-support echo $system > $out/nix-support/system |