2013-10-09 20:54:09 +02:00
|
|
|
# !!! Merge into normal install tests once all livecds are EFIable
|
|
|
|
{ pkgs, system, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
|
|
|
with import ../lib/qemu-flags.nix;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
# Build the ISO. This is the regular installation CD but with test
|
|
|
|
# instrumentation.
|
|
|
|
iso =
|
|
|
|
(import ../lib/eval-config.nix {
|
|
|
|
inherit system;
|
|
|
|
modules =
|
2013-11-01 16:29:36 +01:00
|
|
|
[ ../modules/installer/cd-dvd/installation-cd-minimal.nix
|
2013-10-09 20:54:09 +02:00
|
|
|
../modules/testing/test-instrumentation.nix
|
|
|
|
{ key = "serial";
|
|
|
|
|
|
|
|
# The test cannot access the network, so any sources we
|
|
|
|
# need must be included in the ISO.
|
|
|
|
isoImage.storeContents =
|
|
|
|
[ pkgs.glibcLocales
|
|
|
|
pkgs.sudo
|
|
|
|
pkgs.docbook5
|
|
|
|
pkgs.docbook5_xsl
|
|
|
|
pkgs.grub
|
|
|
|
pkgs.perlPackages.XMLLibXML
|
|
|
|
pkgs.unionfs-fuse
|
|
|
|
pkgs.gummiboot
|
|
|
|
pkgs.libxslt
|
|
|
|
];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}).config.system.build.isoImage;
|
|
|
|
|
|
|
|
|
|
|
|
# The config to install
|
|
|
|
config = builtins.toFile "configuration.nix" ''
|
|
|
|
{ pkgs, ... }: {
|
2013-10-13 17:24:11 +02:00
|
|
|
imports = [ ./hardware-configuration.nix <nixos/modules/testing/test-instrumentation.nix> ];
|
2013-10-09 20:54:09 +02:00
|
|
|
boot.loader.grub.enable = false;
|
|
|
|
boot.loader.efi.canTouchEfiVariables = true;
|
|
|
|
boot.loader.gummiboot.enable = true;
|
|
|
|
fonts.enableFontConfig = false;
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
|
|
|
|
biosDir = pkgs.runCommand "ovmf-bios" {} ''
|
|
|
|
mkdir $out
|
|
|
|
ln -s ${pkgs.OVMF}/FV/OVMF.fd $out/bios.bin
|
|
|
|
'';
|
|
|
|
|
|
|
|
in {
|
|
|
|
simple = {
|
|
|
|
inherit iso;
|
|
|
|
nodes = {};
|
|
|
|
testScript = ''
|
|
|
|
createDisk("harddisk", 4 * 1024);
|
|
|
|
|
|
|
|
my $machine = createMachine({ hda => "harddisk",
|
2013-10-14 22:02:29 +02:00
|
|
|
hdaInterface => "scsi",
|
2013-10-09 20:54:09 +02:00
|
|
|
cdrom => glob("${iso}/iso/*.iso"),
|
|
|
|
qemuFlags => '-L ${biosDir} ${optionalString (pkgs.stdenv.system == "x86_64-linux") "-cpu kvm64"}'});
|
|
|
|
$machine->start;
|
|
|
|
|
|
|
|
# Make sure that we get a login prompt etc.
|
|
|
|
$machine->succeed("echo hello");
|
|
|
|
$machine->waitForUnit("rogue");
|
|
|
|
$machine->waitForUnit("nixos-manual");
|
|
|
|
|
|
|
|
# Partition the disk.
|
|
|
|
$machine->succeed(
|
2013-10-16 12:16:34 +02:00
|
|
|
"sgdisk -Z /dev/sda",
|
|
|
|
"sgdisk -n 1:0:+256M -N 2 -t 1:ef00 -t 2:8300 -c 1:boot -c 2:root /dev/sda",
|
|
|
|
"mkfs.vfat -n BOOT /dev/sda1",
|
|
|
|
"mkfs.ext3 -L nixos /dev/sda2",
|
2013-10-09 20:54:09 +02:00
|
|
|
"mount LABEL=nixos /mnt",
|
|
|
|
"mkdir /mnt/boot",
|
|
|
|
"mount LABEL=BOOT /mnt/boot",
|
|
|
|
);
|
|
|
|
|
|
|
|
# Create the NixOS configuration.
|
|
|
|
$machine->succeed(
|
2013-10-13 17:24:11 +02:00
|
|
|
"nixos-generate-config --root /mnt",
|
2013-10-09 20:54:09 +02:00
|
|
|
);
|
|
|
|
|
2013-10-13 17:24:11 +02:00
|
|
|
$machine->succeed("cat /mnt/etc/nixos/hardware-configuration.nix >&2");
|
2013-10-09 20:54:09 +02:00
|
|
|
|
|
|
|
$machine->copyFileFromHost(
|
|
|
|
"${config}",
|
|
|
|
"/mnt/etc/nixos/configuration.nix");
|
|
|
|
|
|
|
|
# Perform the installation.
|
|
|
|
$machine->succeed("nixos-install >&2");
|
|
|
|
|
|
|
|
# Do it again to make sure it's idempotent.
|
|
|
|
$machine->succeed("nixos-install >&2");
|
|
|
|
|
|
|
|
$machine->shutdown;
|
|
|
|
|
|
|
|
# Now see if we can boot the installation.
|
|
|
|
my $machine = createMachine({ #hda => "harddisk",
|
|
|
|
# hdaInterface => "virtio",
|
|
|
|
# !!! OVMF doesn't boot from virtio http://www.mail-archive.com/edk2-devel@lists.sourceforge.net/msg01501.html
|
|
|
|
qemuFlags => '-L ${biosDir} ${optionalString (pkgs.stdenv.system == "x86_64-linux") "-cpu kvm64"} -m 512 -hda ' . Cwd::abs_path('harddisk')});
|
|
|
|
|
|
|
|
# Did /boot get mounted, if appropriate?
|
|
|
|
$machine->waitForUnit("local-fs.target");
|
|
|
|
$machine->succeed("test -e /boot/efi");
|
|
|
|
|
|
|
|
$machine->succeed("nix-env -i coreutils >&2");
|
|
|
|
$machine->succeed("type -tP ls | tee /dev/stderr") =~ /.nix-profile/
|
|
|
|
or die "nix-env failed";
|
|
|
|
|
|
|
|
$machine->succeed("nixos-rebuild switch >&2");
|
|
|
|
|
|
|
|
$machine->shutdown;
|
|
|
|
|
|
|
|
my $machine = createMachine({ #hda => "harddisk",
|
|
|
|
# hdaInterface => "virtio",
|
|
|
|
qemuFlags => '-L ${biosDir} ${optionalString (pkgs.stdenv.system == "x86_64-linux") "-cpu kvm64"} -hda ' . Cwd::abs_path('harddisk')});
|
|
|
|
$machine->waitForUnit("network.target");
|
|
|
|
$machine->shutdown;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|