diff --git a/boot/boot-stage-2-init.sh b/boot/boot-stage-2-init.sh index 7b0d48c73bc2..5678c6d53d43 100644 --- a/boot/boot-stage-2-init.sh +++ b/boot/boot-stage-2-init.sh @@ -62,6 +62,10 @@ for o in $(cat /proc/cmdline); do safemode) safeMode=1 ;; + systemConfig=*) + set -- $(IFS==; echo $o) + systemConfig=$2 + ;; esac done @@ -93,7 +97,13 @@ mknod -m 0644 /dev/urandom c 1 9 # needed for passwd # Run the script that performs all configuration activation that does # not have to be done at boot time. -@activateConfiguration@ +@activateConfiguration@ "$systemConfig" + + +# Record the boot configuration. !!! Should this be a GC root? +if test -n "$systemConfig"; then + ln -sfn "$systemConfig" /var/run/booted-system +fi # Ensure that the module tools can find the kernel modules. @@ -104,10 +114,6 @@ export MODULE_DIR=@kernel@/lib/modules/ @shell@ @bootLocal@ -# Start an interactive shell. -#exec @shell@ - - # Start Upstart's init. export UPSTART_CFG_DIR=/etc/event.d setPath "@upstartPath@" diff --git a/installer/grub-menu-builder.sh b/installer/grub-menu-builder.sh index 078d2c09d074..50d8205f8ecd 100644 --- a/installer/grub-menu-builder.sh +++ b/installer/grub-menu-builder.sh @@ -48,7 +48,7 @@ addEntry() { cat >> $tmp << GRUBEND title $name - kernel $kernel init=$(readlink -f $path/init) $(cat $path/kernel-params) + kernel $kernel systemConfig=$(readlink -f $path) init=$(readlink -f $path/init) $(cat $path/kernel-params) initrd $initrd GRUBEND } diff --git a/system/activate-configuration.sh b/system/activate-configuration.sh index 766d75fa1675..553199269f90 100644 --- a/system/activate-configuration.sh +++ b/system/activate-configuration.sh @@ -1,5 +1,7 @@ #! @shell@ +systemConfig="$1" + export PATH=/empty for i in @path@; do PATH=$PATH:$i/bin:$i/sbin; done @@ -138,7 +140,9 @@ hostname @hostName@ # Make this configuration the current configuration. -ln -sfn @out@ /var/run/current-system +if test -n "$systemConfig"; then + ln -sfn "$systemConfig" /var/run/current-system +fi # Prevent the current configuration from being garbage-collected. ln -sfn /var/run/current-system /nix/var/nix/gcroots/current-system diff --git a/system/switch-to-configuration.sh b/system/switch-to-configuration.sh index f3b61ded26a9..a2bdb094d988 100644 --- a/system/switch-to-configuration.sh +++ b/system/switch-to-configuration.sh @@ -62,7 +62,7 @@ if test "$action" = "switch" -o "$action" = "test"; then # Activate the new configuration (i.e., update /etc, make # accounts, and so on). echo "Activating the configuration..." - @out@/activate + @out@/activate @out@ # Make Upstart reload its events. !!! Should wait until it has # finished processing its stop events. diff --git a/system/system.nix b/system/system.nix index bec3adb943bd..482156a7ca91 100644 --- a/system/system.nix +++ b/system/system.nix @@ -294,6 +294,7 @@ rec { inherit activateConfiguration; inherit grubMenuBuilder; inherit etc; + inherit systemPath; kernel = pkgs.kernel + "/vmlinuz"; initrd = initialRamdisk + "/initrd"; # Most of these are needed by grub-install. diff --git a/system/system.sh b/system/system.sh index c358e8705728..321260777e33 100644 --- a/system/system.sh +++ b/system/system.sh @@ -8,6 +8,7 @@ ln -s $bootStage2 $out/init ln -s $initrd $out/initrd ln -s $activateConfiguration $out/activate ln -s $etc/etc $out/etc +ln -s $systemPath $out/sw echo "$kernelParams" > $out/kernel-params