* Nix expression for stage 2.

* Start stage 2 from stage 1.

svn path=/nixu/trunk/; revision=6945
This commit is contained in:
Eelco Dolstra 2006-11-04 00:01:13 +00:00
parent 14cc7b8828
commit 1691c66673
4 changed files with 60 additions and 2 deletions

View file

@ -36,5 +36,10 @@ mkdir /mnt
mkdir /mnt/cdrom
mount -o ro /dev/hdc /mnt/cdrom
# Start an interactive shell.
# Start stage 2. !!! We use chroot for now, but I guess that should
# be pivot_root or so.
chroot /mnt/cdrom /init
# If starting stage 2 failed, start an interactive shell.
echo "Stage 2 failed, starting emergency shell..."
exec @shell@

31
test/boot-stage-2-init.sh Normal file
View file

@ -0,0 +1,31 @@
#! @shell@
# !!! copied from stage 1; remove duplication
# Print a greeting.
echo
echo "<<< NixOS Stage 2 >>>"
echo
# Set the PATH.
export PATH=/empty
for i in @path@; do
PATH=$PATH:$i/bin
if test -e $i/sbin; then
PATH=$PATH:$i/sbin
fi
done
# Mount special file systems.
mkdir /etc # to shut up mount
touch /etc/fstab # idem
mkdir /proc
mount -t proc proc /proc
mkdir /sys
mount -t sysfs sys /sys
# Create device nodes in /dev.
source @makeDevices@
# Start an interactive shell.
exec @shell@

14
test/boot-stage-2.nix Normal file
View file

@ -0,0 +1,14 @@
{ genericSubstituter, shell, coreutils
, utillinux
}:
genericSubstituter {
src = ./boot-stage-2-init.sh;
isExecutable = true;
inherit shell;
path = [
coreutils
utillinux
];
makeDevices = ./make-devices.sh;
}

View file

@ -56,6 +56,14 @@ rec {
};
# The init script of boot stage 2, which is supposed to do
# everything else to bring up the system.
bootStage2 = import ./boot-stage-2.nix {
inherit (pkgs) genericSubstituter coreutils utillinux;
shell = pkgs.bash + "/bin/sh";
};
# Create an ISO image containing the isolinux boot loader, the
# kernel, and initrd produced above.
rescueCD = import ./make-iso9660-image.nix {
@ -77,7 +85,7 @@ rec {
}
];
init = pkgs.bash + "/bin/sh";
init = bootStage2;
bootable = true;
bootImage = "isolinux/isolinux.bin";