* Use Grub 2 on the installation CD. No graphics yet.

svn path=/nixos/branches/upstart-0.6/; revision=18325
This commit is contained in:
Eelco Dolstra 2009-11-10 21:42:38 +00:00
parent d1bbe706a2
commit 091631b433
4 changed files with 45 additions and 26 deletions

View File

@ -1,20 +1,22 @@
# This module contains the basic configuration for building a NixOS # This module contains the basic configuration for building a NixOS
# installation CD. # installation CD.
{config, pkgs, ...}: { config, pkgs, ... }:
with pkgs.lib;
let let
options = { options = {
system.nixosVersion = pkgs.lib.mkOption { system.nixosVersion = mkOption {
default = "${builtins.readFile ../../../VERSION}"; default = "${builtins.readFile ../../../VERSION}";
description = '' description = ''
NixOS version number. NixOS version number.
''; '';
}; };
installer.configModule = pkgs.lib.mkOption { installer.configModule = mkOption {
example = "./nixos/modules/installer/cd-dvd/installation-cd.nix"; example = "./nixos/modules/installer/cd-dvd/installation-cd.nix";
description = '' description = ''
Filename of the configuration module that builds the CD Filename of the configuration module that builds the CD
@ -38,10 +40,12 @@ let
''; '';
# Put the current directory in a tarball. # Put the current directory in a tarball.
nixosTarball = makeTarball "nixos.tar.bz2" (pkgs.lib.cleanSource ../../..); nixosTarball = makeTarball "nixos.tar.bz2" (cleanSource ../../..);
# Put Nixpkgs in a tarball. # Put Nixpkgs in a tarball.
nixpkgsTarball = makeTarball "nixpkgs.tar.bz2" (pkgs.lib.cleanSource pkgs.path); nixpkgsTarball = makeTarball "nixpkgs.tar.bz2" (cleanSource pkgs.path);
includeSources = true;
# A dummy /etc/nixos/configuration.nix in the booted CD that # A dummy /etc/nixos/configuration.nix in the booted CD that
@ -169,12 +173,14 @@ in
# Provide the NixOS/Nixpkgs sources in /etc/nixos. This is required # Provide the NixOS/Nixpkgs sources in /etc/nixos. This is required
# for nixos-install. # for nixos-install.
echo "unpacking the NixOS/Nixpkgs sources..." ${optionalString includeSources ''
mkdir -p /etc/nixos/nixos echo "unpacking the NixOS/Nixpkgs sources..."
tar xjf ${nixosTarball}/nixos.tar.bz2 -C /etc/nixos/nixos mkdir -p /etc/nixos/nixos
mkdir -p /etc/nixos/nixpkgs tar xjf ${nixosTarball}/nixos.tar.bz2 -C /etc/nixos/nixos
tar xjf ${nixpkgsTarball}/nixpkgs.tar.bz2 -C /etc/nixos/nixpkgs mkdir -p /etc/nixos/nixpkgs
chown -R root.root /etc/nixos tar xjf ${nixpkgsTarball}/nixpkgs.tar.bz2 -C /etc/nixos/nixpkgs
chown -R root.root /etc/nixos
''}
# Provide a configuration for the CD/DVD itself, to allow users # Provide a configuration for the CD/DVD itself, to allow users
# to run nixos-rebuild to change the configuration of the # to run nixos-rebuild to change the configuration of the

View File

@ -55,12 +55,21 @@ let
}; };
# The Grub image.
grubImage = pkgs.runCommand "grub_eltorito" {}
''
${pkgs.grub2}/bin/grub-mkimage -o tmp biosdisk iso9660 help linux linux16 sh chain
cat ${pkgs.grub2}/lib/grub/*/cdboot.img tmp > $out
''; # */
# The configuration file for Grub. # The configuration file for Grub.
grubCfg = grubCfg =
'' ''
default 0 set default = 0
timeout 10 set timeout = 10
splashimage /boot/background.xpm.gz
#splashimage /boot/background.xpm.gz
${config.boot.extraGrubEntries} ${config.boot.extraGrubEntries}
''; '';
@ -112,11 +121,11 @@ in
# Individual files to be included on the CD, outside of the Nix # Individual files to be included on the CD, outside of the Nix
# store on the CD. # store on the CD.
isoImage.contents = isoImage.contents =
[ { source = "${pkgs.grub}/lib/grub/${if pkgs.stdenv.system == "i686-linux" then "i386-pc" else "x86_64-unknown"}/stage2_eltorito"; [ { source = grubImage;
target = "/boot/grub/stage2_eltorito"; target = "/boot/grub/grub_eltorito";
} }
{ source = pkgs.writeText "menu.lst" grubCfg; { source = pkgs.writeText "grub.cfg" grubCfg;
target = "/boot/grub/menu.lst"; target = "/boot/grub/grub.cfg";
} }
{ source = config.boot.kernelPackages.kernel + "/vmlinuz"; { source = config.boot.kernelPackages.kernel + "/vmlinuz";
target = "/boot/vmlinuz"; target = "/boot/vmlinuz";
@ -152,13 +161,15 @@ in
# The Grub menu. # The Grub menu.
boot.extraGrubEntries = boot.extraGrubEntries =
'' ''
title Boot from hard disk menuentry "Boot from hard disk" {
root (hd0) set root=(hd0)
chainloader +1 chainloader +1
}
title NixOS Installer / Rescue menuentry "NixOS Installer / Rescue" {
kernel /boot/vmlinuz init=/init systemConfig=/system ${toString config.boot.kernelParams} linux /boot/vmlinuz init=/init systemConfig=/system ${toString config.boot.kernelParams}
initrd /boot/initrd initrd /boot/initrd
}
''; '';
# Create the ISO image. # Create the ISO image.
@ -168,7 +179,7 @@ in
inherit (config.isoImage) isoName compressImage volumeID contents; inherit (config.isoImage) isoName compressImage volumeID contents;
bootable = true; bootable = true;
bootImage = "/boot/grub/stage2_eltorito"; bootImage = "/boot/grub/grub_eltorito";
}; };
boot.postBootCommands = boot.postBootCommands =

View File

@ -12,8 +12,9 @@ in
{ {
boot.extraGrubEntries = boot.extraGrubEntries =
'' ''
title Memtest86+ menuentry "Memtest86+" {
kernel ${memtestPath} linux16 ${memtestPath}
}
''; '';
isoImage.contents = isoImage.contents =

View File

@ -30,10 +30,11 @@ let
description = "NixOS installation CD (${description}) - ISO image for ${system}"; description = "NixOS installation CD (${description}) - ISO image for ${system}";
maintainers = map (x: lib.getAttr x lib.maintainers) maintainers; maintainers = map (x: lib.getAttr x lib.maintainers) maintainers;
}; };
inherit iso;
} }
'' ''
ensureDir $out/nix-support ensureDir $out/nix-support
echo "file iso" ${iso}/iso/*.iso* >> $out/nix-support/hydra-build-products echo "file iso" $iso/iso/*.iso* >> $out/nix-support/hydra-build-products
''; # */ ''; # */