diff --git a/modules/installer/cd-dvd/iso-image.nix b/modules/installer/cd-dvd/iso-image.nix index 15ac3449207..8117d8631f5 100644 --- a/modules/installer/cd-dvd/iso-image.nix +++ b/modules/installer/cd-dvd/iso-image.nix @@ -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 } diff --git a/modules/installer/cd-dvd/system-tarball.nix b/modules/installer/cd-dvd/system-tarball.nix index 70bb12eac00..5ca6b0e9fef 100644 --- a/modules/installer/cd-dvd/system-tarball.nix +++ b/modules/installer/cd-dvd/system-tarball.nix @@ -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"; } ]; diff --git a/modules/system/activation/top-level.nix b/modules/system/activation/top-level.nix index 36f8b05c9d2..92615c78f32 100644 --- a/modules/system/activation/top-level.nix +++ b/modules/system/activation/top-level.nix @@ -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 diff --git a/modules/system/boot/stage-2-init.sh b/modules/system/boot/stage-2-init.sh index 9a1d49c981c..b00baf8a075 100644 --- a/modules/system/boot/stage-2-init.sh +++ b/modules/system/boot/stage-2-init.sh @@ -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. diff --git a/modules/virtualisation/qemu-vm.nix b/modules/virtualisation/qemu-vm.nix index cac221d8c22..005e4ebfb54 100644 --- a/modules/virtualisation/qemu-vm.nix +++ b/modules/virtualisation/qemu-vm.nix @@ -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 \