diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/grub-menu-builder.sh | 50 | ||||
-rw-r--r-- | test/installer.sh | 2 | ||||
-rw-r--r-- | test/system-configuration.nix | 8 | ||||
-rw-r--r-- | test/system-configuration.sh | 5 |
4 files changed, 60 insertions, 5 deletions
diff --git a/test/grub-menu-builder.sh b/test/grub-menu-builder.sh new file mode 100644 index 00000000000..83760d975cf --- /dev/null +++ b/test/grub-menu-builder.sh @@ -0,0 +1,50 @@ +#! @bash@/bin/sh -e + +default=$1 +if test -z "$1"; then + echo "Syntax: grub-menu-builder.sh <DEFAULT-CONFIG>" + exit 1 +fi + + +target=/boot/grub/menu.lst +tmp=$target.tmp + +cat > $tmp << GRUBEND +# Automatically generated. DO NOT EDIT THIS FILE! +default=0 +timeout=5 +GRUBEND + +addEntry() { + name="$1" + path="$2" + + cat >> $tmp << GRUBEND +title $name +GRUBEND + + #cat $path/menu.lst >> $tmp + + grep -v "title \|default=\|timeout=" < $path/menu.lst >> $tmp +} + + +if test -n "$tmp"; then + addEntry "NixOS - Default" $default +fi + + +# Add all generations of the system profile to the menu, in reverse +# (most recent to least recent) order. +for generation in $( + (cd /nix/var/nix/profiles && ls -d system-*-link) \ + | sed 's/system-\([0-9]\+\)-link/\1/' \ + | sort -n -r); do + echo $generation + addEntry "NixOS - Configuration $generation" \ + /nix/var/nix/profiles/system-$generation-link +done + + +cp $tmp $target diff --git a/test/installer.sh b/test/installer.sh index 8e438f5388c..d3f747c8310 100644 --- a/test/installer.sh +++ b/test/installer.sh @@ -19,7 +19,7 @@ targetDevice="$1" nixExpr="$2" if test -z "$targetDevice" -o -z "$nixExpr"; then - echo "syntax: installer.sh <targetDevice> <nixExpr>" + echo "Syntax: installer.sh <targetDevice> <nixExpr>" exit 1 fi diff --git a/test/system-configuration.nix b/test/system-configuration.nix index a1c90813e6b..8675cf5d71b 100644 --- a/test/system-configuration.nix +++ b/test/system-configuration.nix @@ -28,9 +28,17 @@ rec { inherit (pkgs) grub coreutils gnused gnugrep diffutils; inherit grubDevice; inherit bootStage2; + inherit grubMenuBuilder; kernel = pkgs.kernel + "/vmlinuz"; initrd = initialRamdisk + "/initrd"; }; + grubMenuBuilder = pkgs.genericSubstituter { + src = ./grub-menu-builder.sh; + isExecutable = true; + inherit (pkgs) bash; + }; + + } diff --git a/test/system-configuration.sh b/test/system-configuration.sh index d35811a84da..653774cc5cc 100644 --- a/test/system-configuration.sh +++ b/test/system-configuration.sh @@ -6,9 +6,6 @@ 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 @@ -21,8 +18,8 @@ cat > $out/bin/switch-to-configuration <<EOF set -e export PATH=$coreutils/bin:$gnused/bin:$gnugrep/bin:$diffutils/bin if test -n "$grubDevice"; then + $grubMenuBuilder $out $grub/sbin/grub-install "$grubDevice" --no-floppy --recheck - cp -f $out/menu.lst /boot/grub/menu.lst ln -sf $bootStage2 /init # !!! fix? fi EOF |