* Probe for the NixOS installation CD.
svn path=/nixu/trunk/; revision=6985
This commit is contained in:
parent
4b333e0f67
commit
67f3ee3b64
@ -1,5 +1,11 @@
|
|||||||
#! @shell@
|
#! @shell@
|
||||||
|
|
||||||
|
fail() {
|
||||||
|
# If starting stage 2 failed, start an interactive shell.
|
||||||
|
echo "Stage 2 failed, starting emergency shell..."
|
||||||
|
exec @shell@
|
||||||
|
}
|
||||||
|
|
||||||
# Print a greeting.
|
# Print a greeting.
|
||||||
echo
|
echo
|
||||||
echo "<<< NixOS Stage 1 >>>"
|
echo "<<< NixOS Stage 1 >>>"
|
||||||
@ -31,10 +37,37 @@ modprobe ide-generic
|
|||||||
modprobe ide-disk
|
modprobe ide-disk
|
||||||
modprobe ide-cd
|
modprobe ide-cd
|
||||||
|
|
||||||
|
# Try to find and mount the installation CD.
|
||||||
|
|
||||||
# Mount the installation CD.
|
# Mount the installation CD.
|
||||||
mkdir /mnt
|
mkdir /mnt
|
||||||
mkdir /mnt/cdrom
|
mkdir /mnt/cdrom
|
||||||
mount -o ro /dev/hdc /mnt/cdrom
|
|
||||||
|
echo "probing for the NixOS installation CD..."
|
||||||
|
|
||||||
|
for i in /sys/devices/*/*/media; do
|
||||||
|
if test "$(cat $i)" = "cdrom"; then
|
||||||
|
|
||||||
|
# Hopefully `drivename' matches the device created in /dev.
|
||||||
|
devName=/dev/$(cat $(dirname $i)/drivename)
|
||||||
|
|
||||||
|
echo " in $devName..."
|
||||||
|
|
||||||
|
if mount -o ro -t iso9660 $devName /mnt/cdrom; then
|
||||||
|
if test -e "/mnt/cdrom/@cdromLabel@"; then
|
||||||
|
found=1
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
umount /mnt/cdrom
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if test -z "$found"; then
|
||||||
|
echo "CD not found!"
|
||||||
|
fail
|
||||||
|
fi
|
||||||
|
|
||||||
# Start stage 2.
|
# Start stage 2.
|
||||||
# !!! Note: we can't use pivot_root here (the kernel gods have
|
# !!! Note: we can't use pivot_root here (the kernel gods have
|
||||||
@ -46,6 +79,4 @@ umount /proc # cleanup
|
|||||||
umount /sys
|
umount /sys
|
||||||
exec chroot . /init
|
exec chroot . /init
|
||||||
|
|
||||||
# If starting stage 2 failed, start an interactive shell.
|
fail
|
||||||
echo "Stage 2 failed, starting emergency shell..."
|
|
||||||
exec @shell@
|
|
||||||
|
@ -6,12 +6,13 @@
|
|||||||
|
|
||||||
{ genericSubstituter, shell, staticTools
|
{ genericSubstituter, shell, staticTools
|
||||||
, module_init_tools, extraUtils, modules
|
, module_init_tools, extraUtils, modules
|
||||||
|
, cdromLabel ? ""
|
||||||
}:
|
}:
|
||||||
|
|
||||||
genericSubstituter {
|
genericSubstituter {
|
||||||
src = ./boot-stage-1-init.sh;
|
src = ./boot-stage-1-init.sh;
|
||||||
isExecutable = true;
|
isExecutable = true;
|
||||||
inherit shell modules;
|
inherit shell modules cdromLabel;
|
||||||
path = [
|
path = [
|
||||||
staticTools
|
staticTools
|
||||||
module_init_tools
|
module_init_tools
|
||||||
|
@ -106,6 +106,9 @@ export PATH=$PATH
|
|||||||
export MODULE_DIR=$MODULE_DIR
|
export MODULE_DIR=$MODULE_DIR
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
# Set the host name.
|
||||||
|
hostname nixos
|
||||||
|
|
||||||
# Start an interactive shell.
|
# Start an interactive shell.
|
||||||
#exec @shell@
|
#exec @shell@
|
||||||
|
|
||||||
|
@ -20,6 +20,10 @@ rec {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
# The label used to identify the installation CD.
|
||||||
|
cdromLabel = "NIXOS";
|
||||||
|
|
||||||
|
|
||||||
# Determine the set of modules that we need to mount the root FS.
|
# Determine the set of modules that we need to mount the root FS.
|
||||||
modulesClosure = import ./modules-closure.nix {
|
modulesClosure = import ./modules-closure.nix {
|
||||||
inherit (pkgs) stdenv kernel module_init_tools;
|
inherit (pkgs) stdenv kernel module_init_tools;
|
||||||
@ -45,6 +49,7 @@ rec {
|
|||||||
inherit (pkgs) genericSubstituter;
|
inherit (pkgs) genericSubstituter;
|
||||||
inherit (pkgsDiet) module_init_tools;
|
inherit (pkgsDiet) module_init_tools;
|
||||||
inherit extraUtils;
|
inherit extraUtils;
|
||||||
|
inherit cdromLabel;
|
||||||
modules = modulesClosure;
|
modules = modulesClosure;
|
||||||
shell = stdenvLinuxStuff.bootstrapTools.bash;
|
shell = stdenvLinuxStuff.bootstrapTools.bash;
|
||||||
staticTools = stdenvLinuxStuff.staticTools;
|
staticTools = stdenvLinuxStuff.staticTools;
|
||||||
@ -110,8 +115,13 @@ rec {
|
|||||||
# Since the CD is read-only, the mount points must be on disk.
|
# Since the CD is read-only, the mount points must be on disk.
|
||||||
cdMountPoints = pkgs.stdenv.mkDerivation {
|
cdMountPoints = pkgs.stdenv.mkDerivation {
|
||||||
name = "mount-points";
|
name = "mount-points";
|
||||||
builder = builtins.toFile "builder.sh"
|
builder = builtins.toFile "builder.sh" "
|
||||||
"source $stdenv/setup; mkdir $out; cd $out; mkdir proc sys tmp etc dev var mnt nix nix/var";
|
source $stdenv/setup
|
||||||
|
mkdir $out
|
||||||
|
cd $out
|
||||||
|
mkdir proc sys tmp etc dev var mnt nix nix/var
|
||||||
|
touch $out/${cdromLabel}
|
||||||
|
";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user