* 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
# installation CD.
{config, pkgs, ...}:
{ config, pkgs, ... }:
with pkgs.lib;
let
options = {
system.nixosVersion = pkgs.lib.mkOption {
system.nixosVersion = mkOption {
default = "${builtins.readFile ../../../VERSION}";
description = ''
NixOS version number.
'';
};
installer.configModule = pkgs.lib.mkOption {
installer.configModule = mkOption {
example = "./nixos/modules/installer/cd-dvd/installation-cd.nix";
description = ''
Filename of the configuration module that builds the CD
@ -38,10 +40,12 @@ let
'';
# 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.
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
@ -169,12 +173,14 @@ in
# Provide the NixOS/Nixpkgs sources in /etc/nixos. This is required
# for nixos-install.
echo "unpacking the NixOS/Nixpkgs sources..."
mkdir -p /etc/nixos/nixos
tar xjf ${nixosTarball}/nixos.tar.bz2 -C /etc/nixos/nixos
mkdir -p /etc/nixos/nixpkgs
tar xjf ${nixpkgsTarball}/nixpkgs.tar.bz2 -C /etc/nixos/nixpkgs
chown -R root.root /etc/nixos
${optionalString includeSources ''
echo "unpacking the NixOS/Nixpkgs sources..."
mkdir -p /etc/nixos/nixos
tar xjf ${nixosTarball}/nixos.tar.bz2 -C /etc/nixos/nixos
mkdir -p /etc/nixos/nixpkgs
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
# 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.
grubCfg =
''
default 0
timeout 10
splashimage /boot/background.xpm.gz
set default = 0
set timeout = 10
#splashimage /boot/background.xpm.gz
${config.boot.extraGrubEntries}
'';
@ -112,11 +121,11 @@ in
# Individual files to be included on the CD, outside of the Nix
# store on the CD.
isoImage.contents =
[ { source = "${pkgs.grub}/lib/grub/${if pkgs.stdenv.system == "i686-linux" then "i386-pc" else "x86_64-unknown"}/stage2_eltorito";
target = "/boot/grub/stage2_eltorito";
[ { source = grubImage;
target = "/boot/grub/grub_eltorito";
}
{ source = pkgs.writeText "menu.lst" grubCfg;
target = "/boot/grub/menu.lst";
{ source = pkgs.writeText "grub.cfg" grubCfg;
target = "/boot/grub/grub.cfg";
}
{ source = config.boot.kernelPackages.kernel + "/vmlinuz";
target = "/boot/vmlinuz";
@ -152,13 +161,15 @@ in
# The Grub menu.
boot.extraGrubEntries =
''
title Boot from hard disk
root (hd0)
menuentry "Boot from hard disk" {
set root=(hd0)
chainloader +1
}
title NixOS Installer / Rescue
kernel /boot/vmlinuz init=/init systemConfig=/system ${toString config.boot.kernelParams}
menuentry "NixOS Installer / Rescue" {
linux /boot/vmlinuz init=/init systemConfig=/system ${toString config.boot.kernelParams}
initrd /boot/initrd
}
'';
# Create the ISO image.
@ -168,7 +179,7 @@ in
inherit (config.isoImage) isoName compressImage volumeID contents;
bootable = true;
bootImage = "/boot/grub/stage2_eltorito";
bootImage = "/boot/grub/grub_eltorito";
};
boot.postBootCommands =

View File

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

View File

@ -30,10 +30,11 @@ let
description = "NixOS installation CD (${description}) - ISO image for ${system}";
maintainers = map (x: lib.getAttr x lib.maintainers) maintainers;
};
inherit iso;
}
''
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
''; # */