Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2fdedf0
nixos: iso-image: use syslinux bootloader for USB booting support
bobvanderlinden Oct 26, 2014
c9164f5
nixos: iso-image: escape '=' in all filenames passed to xorriso
bobvanderlinden Oct 26, 2014
3e51348
nixos: installation: make installation ISOs USB bootable
bobvanderlinden Oct 30, 2014
deb7b8d
nixos: iso-image: removed sketchy escaping of '=' for xorriso
bobvanderlinden Nov 2, 2014
7104d3a
nixos: iso-image: make use of grub timeout for gummiboot and syslinux
bobvanderlinden Nov 16, 2014
f3ca492
nixos: iso-image: solved UNetbootin compatiblity
bobvanderlinden Nov 16, 2014
b45acd3
nixos: iso-image: removed com32 entries from syslinux menu
bobvanderlinden Nov 16, 2014
29f3742
nixos: iso-image: added notes for UNetbootin compatiblity
bobvanderlinden Nov 16, 2014
76c8879
nixos: iso-image: escape filenames passed to xorriso better
bobvanderlinden Nov 16, 2014
0dc1420
nixos: iso-image: use correct timeout values for syslinux
bobvanderlinden Nov 19, 2014
f06f7f9
nixos: test: added usb and bios options for machine creation
bobvanderlinden Nov 19, 2014
a278383
nixos: test: added tests for booting installation iso in various ways
bobvanderlinden Nov 19, 2014
89e14f9
nixos: iso-image: use timeout from gummiboot config for gummiboot
bobvanderlinden Jan 14, 2015
a7a0cf0
nixos: iso-image: add Memtest86+ boot entry if enabled in grub
bobvanderlinden Jan 21, 2015
cbe8cdd
nixos: iso-image: refactor if to use optionalString
bobvanderlinden Jan 21, 2015
723c1c1
nixos: iso-image: use generic boot-loader timeout
bobvanderlinden Jan 31, 2015
e478354
nixos: iso-image: use label "EFIBOOT" for efi.img
bobvanderlinden Feb 3, 2015
2cbb4ad
nixos: iso-image: use memtest86 instead of memtest86+
bobvanderlinden Feb 3, 2015
dfa2b74
Revert "nixos: iso-image: use memtest86 instead of memtest86+"
bobvanderlinden Mar 1, 2015
dbf7436
nixos: iso-image: use memtest86 params in syslinux
bobvanderlinden Mar 2, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions nixos/lib/make-iso9660-image.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ stdenv, perl, cdrkit, pathsFromGraph
{ stdenv, perl, pathsFromGraph, xorriso, syslinux

, # The file name of the resulting ISO image.
isoName ? "cd.iso"
Expand All @@ -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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make it true by default?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured it should be false since efiBootable was also false by default. Maybe they should both be true?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only @edolstra can say, I think there's no reason to have them set to false by default.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might even be a good option to just remove those, but I don't know whether this needs to stay compatible with other nix configurations. I can't think of any good use-case where you'd want to disable EFI or USB support.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lethalman these cannot be true by default, since bootImage, efiBootImage, isohybridMbrImage need to be filled as well for the assertions to pass. I still think it might be a good idea to just remove all of these options and maybe rename the file to make-iso9660-syslinux-image.nix to make clear this is not just any regular ISO.


, # 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

Expand All @@ -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;
Expand Down
70 changes: 55 additions & 15 deletions nixos/lib/make-iso9660-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ stripSlash() {
if test "${res:0:1}" = /; then res=${res:1}; fi
}

# Escape potential equal signs (=) with backslash (\=)
escapeEquals() {
echo "$1" | sed -e 's/\\/\\\\/g' -e 's/=/\\=/g'
}

# Queues an file/directory to be placed on the ISO.
# An entry consists of a local source path (2) and
# a destination path on the ISO (1).
addPath() {
target="$1"
source="$2"
echo "$(escapeEquals "$target")=$(escapeEquals "$source")" >> pathlist
}

stripSlash "$bootImage"; bootImage="$res"


Expand All @@ -31,11 +45,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
Expand All @@ -44,22 +67,22 @@ touch pathlist
# Add the individual files.
for ((i = 0; i < ${#targets_[@]}; i++)); do
stripSlash "${targets_[$i]}"
echo "$res=${sources_[$i]}" >> pathlist
addPath "$res" "${sources_[$i]}"
done


# Add the closures of the top-level store objects.
storePaths=$(perl $pathsFromGraph closure-*)
for i in $storePaths; do
echo "${i:1}=$i" >> pathlist
addPath "${i:1}" "$i"
done


# Also include a manifest of the closures in a format suitable for
# nix-store --load-db.
if [ -n "$object" ]; then
printRegistration=1 perl $pathsFromGraph closure-* > nix-path-registration
echo "nix-path-registration=nix-path-registration" >> pathlist
addPath "nix-path-registration" "nix-path-registration"
fi


Expand All @@ -70,22 +93,39 @@ for ((n = 0; n < ${#objects[*]}; n++)); do
if test "$symlink" != "none"; then
mkdir -p $(dirname ./$symlink)
ln -s $object ./$symlink
echo "$symlink=./$symlink" >> pathlist
addPath "$symlink" "./$symlink"
fi
done

# !!! what does this do?
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
--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
4 changes: 4 additions & 0 deletions nixos/lib/test-driver/Machine.pm
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ sub new {
if defined $args->{hda};
$startCommand .= "-cdrom $args->{cdrom} "
if defined $args->{cdrom};
$startCommand .= "-device piix3-usb-uhci -drive id=usbdisk,file=$args->{usb},if=none,readonly -device usb-storage,drive=usbdisk "
if defined $args->{usb};
$startCommand .= "-bios $args->{bios} "
if defined $args->{bios};
$startCommand .= $args->{qemuFlags} || "";
} else {
$startCommand = Cwd::abs_path $startCommand;
Expand Down
3 changes: 3 additions & 0 deletions nixos/modules/installer/cd-dvd/installation-cd-base.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ with lib;
# EFI booting
isoImage.makeEfiBootable = true;

# USB booting
isoImage.makeUsbBootable = true;

# Add Memtest86+ to the CD.
boot.loader.grub.memtest86.enable = true;

Expand Down
Loading