diff --git a/test/installer.sh b/test/installer.sh index 359086a5238..14b6e2a4aac 100644 --- a/test/installer.sh +++ b/test/installer.sh @@ -31,7 +31,7 @@ umount "$targetDevice" 2> /dev/null || true # Check it. -fsck "$targetDevice" +fsck -n "$targetDevice" # Mount the target device. @@ -107,7 +107,7 @@ cp /etc/resolv.conf $mountPoint/etc/ # Do a nix-pull to speed up building. nixpkgsURL=http://nix.cs.uu.nl/dist/nix/nixpkgs-0.11pre6984 -chroot $mountPoint @nix@/bin/nix-pull $nixpkgsURL/MANIFEST +#chroot $mountPoint @nix@/bin/nix-pull $nixpkgsURL/MANIFEST # Build the specified Nix expression in the target store and install @@ -120,4 +120,15 @@ chroot $mountPoint @nix@/bin/nix-pull $nixpkgsURL/MANIFEST chroot $mountPoint @nix@/bin/nix-env \ -p /nix/var/nix/profiles/system \ - -f "/mnt/$nixExpr" -i '*' + -f "/mnt/$nixExpr" -i system-configuration + + +# Grub needs a mtab. +echo "$targetDevice / somefs rw 0 0" > $mountPoint/etc/mtab + + +# Switch to the new system configuration. This will install Grub with +# a menu default pointing at the kernel/initrd/etc of the new +# configuration. +echo "finalising the installation..." +chroot $mountPoint /nix/var/nix/profiles/system/bin/switch-to-configuration diff --git a/test/make-initrd.nix b/test/make-initrd.nix index f850e1cf657..91722b96602 100644 --- a/test/make-initrd.nix +++ b/test/make-initrd.nix @@ -10,11 +10,11 @@ # A symlink `/init' is made to the store path passed in the `init' # argument. -{stdenv, cpio, packages, init}: +{stdenv, cpio, packages, init, nix}: stdenv.mkDerivation { name = "initrd"; builder = ./make-initrd.sh; - buildInputs = [cpio]; + buildInputs = [cpio nix]; inherit packages init; } diff --git a/test/make-initrd.sh b/test/make-initrd.sh index 2620b90eec7..5da23533feb 100644 --- a/test/make-initrd.sh +++ b/test/make-initrd.sh @@ -6,7 +6,7 @@ set -o pipefail # way to get the closure is to call Nix, which is strictly speaking # forbidden. But we do it anyway. In time, we should add a feature # to Nix to let Nix pass closures to builders. -packagesClosure=$(/nix/bin/nix-store -qR $packages $init) +packagesClosure=$(nix-store -qR $packages $init) # Paths in cpio archives *must* be relative, otherwise the kernel # won't unpack 'em. diff --git a/test/rescue-cd.nix b/test/rescue-cd.nix index defeeb48ece..002288bea87 100644 --- a/test/rescue-cd.nix +++ b/test/rescue-cd.nix @@ -14,6 +14,8 @@ in rec { + inherit nixosInstaller; # !!! debug + # Since the CD is read-only, the mount points must be on disk. cdMountPoints = pkgs.stdenv.mkDerivation { diff --git a/test/rescue-system.nix b/test/rescue-system.nix index 890e3cfdf82..40ec535c6b1 100644 --- a/test/rescue-system.nix +++ b/test/rescue-system.nix @@ -59,7 +59,7 @@ rec { # The closure of the init script of boot stage 1 is what we put in # the initial RAM disk. initialRamdisk = import ./make-initrd.nix { - inherit (pkgs) stdenv cpio; + inherit (pkgs) stdenv cpio nix; packages = []; init = bootStage1; }; diff --git a/test/system-configuration.nix b/test/system-configuration.nix new file mode 100644 index 00000000000..ef04dc1badc --- /dev/null +++ b/test/system-configuration.nix @@ -0,0 +1,32 @@ +let + + # The root device. + rootDevice = "/dev/hda1"; + + # The device on which GRUB should be installed (leave empty if you + # don't want GRUB to be installed). + grubDevice = "/dev/hda"; + +in + + # Build boot scripts for the CD that find the CD-ROM automatically. + with import ./rescue-system.nix { + autoDetectRootDevice = false; + inherit rootDevice; + }; + + +rec { + + + systemConfiguration = pkgs.stdenv.mkDerivation { + name = "system-configuration"; + builder = ./system-configuration.sh; + inherit (pkgs) grub coreutils gnused gnugrep diffutils; + inherit grubDevice; + kernel = pkgs.kernel + "/vmlinuz"; + initrd = initialRamdisk + "/initrd"; + }; + + +} diff --git a/test/system-configuration.sh b/test/system-configuration.sh new file mode 100644 index 00000000000..17d58f4d0cb --- /dev/null +++ b/test/system-configuration.sh @@ -0,0 +1,29 @@ +source $stdenv/setup + +ensureDir $out + +ln -s $kernel $out/kernel +ln -s $grub $out/grub + +cat > $out/menu.lst << GRUBEND +# Automatically generated. DO NOT EDIT THIS FILE! +default=0 +timeout=5 +title NixOS + kernel $kernel selinux=0 apm=on acpi=on + initrd $initrd +GRUBEND + +ensureDir $out/bin + +cat > $out/bin/switch-to-configuration <