* Substitute the path of the system derivation directly in the stage 2

init script.  This removes the need for the `systemConfig' boot
  parameter; `init=<stage-2-init>' is enough.  However, the GRUB menu
  builder still needs to add `systemConfig' to the kernel command line
  for compatibility with old configurations.

svn path=/nixos/trunk/; revision=23775
This commit is contained in:
Eelco Dolstra 2010-09-13 22:10:25 +00:00
parent 4046056cdc
commit c4f910f550
5 changed files with 17 additions and 37 deletions

View file

@ -174,11 +174,9 @@ in
# Closures to be copied to the Nix store on the CD, namely the init
# script and the top-level system configuration directory.
isoImage.storeContents =
[ config.system.build.bootStage2
config.system.build.toplevel
] ++
(optional config.isoImage.includeSystemBuildDependencies
config.system.build.toplevel.drvPath);
[ config.system.build.toplevel ] ++
optional config.isoImage.includeSystemBuildDependencies
config.system.build.toplevel.drvPath;
# Create the squashfs image that contains the Nix store.
system.build.squashfsStore = import ../../../lib/make-squashfs.nix {
@ -220,7 +218,7 @@ in
boot.loader.grub.extraEntries =
''
menuentry "NixOS Installer / Rescue" {
linux /boot/bzImage init=${config.system.build.bootStage2} systemConfig=${config.system.build.toplevel} ${toString config.boot.kernelParams}
linux /boot/bzImage init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams}
initrd /boot/initrd
}

View file

@ -34,8 +34,7 @@ let
# A clue for the uboot loading
ubootKernelParams = pkgs.writeText "uboot-kernel-params.txt" ''
Kernel Parameters:
init=${config.system.build.bootStage2}
systemConfig=${config.system.build.toplevel}
init=${config.system.build.toplevel}/init
${toString config.boot.kernelParams}
'';
@ -70,12 +69,7 @@ in
# Closures to be copied to the Nix store on the CD, namely the init
# script and the top-level system configuration directory.
tarball.storeContents =
[ {
object = config.system.build.bootStage2;
symlink = "none";
}
{
object = config.system.build.toplevel;
[ { object = config.system.build.toplevel;
symlink = "/var/run/current-system";
}
];

View file

@ -103,13 +103,15 @@ let
ln -s $grub $out/grub
fi
ln -s ${config.system.build.bootStage2} $out/init
ln -s ${config.system.build.initialRamdisk}/initrd $out/initrd
echo "$activationScript" > $out/activate
substituteInPlace $out/activate --subst-var out
chmod u+x $out/activate
unset activationScript
cp ${config.system.build.bootStage2} $out/init
substituteInPlace $out/init --subst-var-by systemConfig $out
ln -s ${config.system.build.etc}/etc $out/etc
ln -s ${config.system.path} $out/sw

View file

@ -1,6 +1,6 @@
#! @shell@
# !!! copied from stage 1; remove duplication
systemConfig=@systemConfig@
# Print a greeting.
@ -56,11 +56,6 @@ rm -f /etc/mtab* # not that we care about stale locks
cat /proc/mounts > /etc/mtab
# If no `systemConfig' parameter is specified on the kernel command
# line, use a fallback.
systemConfig=/nix/var/nix/profiles/system
# Process the kernel command line.
for o in $(cat /proc/cmdline); do
case $o in
@ -79,10 +74,6 @@ for o in $(cat /proc/cmdline); do
safemode)
safeMode=1
;;
systemConfig=*)
set -- $(IFS==; echo $o)
systemConfig=$2
;;
resume=*)
set -- $(IFS==; echo $o)
resumeDevice=$2
@ -90,8 +81,6 @@ for o in $(cat /proc/cmdline); do
esac
done
systemConfig="$(readlink -f "$systemConfig")"
# More special file systems, initialise required directories.
mkdir -m 0777 /dev/shm
@ -153,19 +142,16 @@ fi
# Run the script that performs all configuration activation that does
# not have to be done at boot time.
echo "running activation script..."
"$systemConfig"/activate
$systemConfig/activate
# Record the boot configuration.
if test -n "$systemConfig"; then
ln -sfn "$systemConfig" /var/run/booted-system
ln -sfn "$systemConfig" /var/run/booted-system
# Prevent the booted system form being garbage-collected
# If it weren't a gcroot, if we were running a different kernel,
# switched system, and garbage collected all, we could not load
# kernel modules anymore.
ln -sfn /var/run/booted-system /nix/var/nix/gcroots/booted-system
fi
# Prevent the booted system form being garbage-collected If it weren't
# a gcroot, if we were running a different kernel, switched system,
# and garbage collected all, we could not load kernel modules anymore.
ln -sfn /var/run/booted-system /nix/var/nix/gcroots/booted-system
# Ensure that the module tools can find the kernel modules.

View file

@ -167,7 +167,7 @@ let
-drive file=$NIX_DISK_IMAGE,if=virtio,boot=on,cache=writeback,werror=report \
-kernel ${config.system.build.toplevel}/kernel \
-initrd ${config.system.build.toplevel}/initrd \
-append "$(cat ${config.system.build.toplevel}/kernel-params) init=${config.system.build.bootStage2} systemConfig=${config.system.build.toplevel} regInfo=${regInfo} ${kernelConsole} $QEMU_KERNEL_PARAMS" \
-append "$(cat ${config.system.build.toplevel}/kernel-params) init=${config.system.build.toplevel}/init regInfo=${regInfo} ${kernelConsole} $QEMU_KERNEL_PARAMS" \
''} \
${qemuGraphics} \
$QEMU_OPTS \