···
1
+
# !!! Merge into normal install tests once all livecds are EFIable
2
+
{ pkgs, system, ... }:
5
+
with import ../lib/qemu-flags.nix;
9
+
# Build the ISO. This is the regular installation CD but with test
12
+
(import ../lib/eval-config.nix {
15
+
[ ../modules/installer/cd-dvd/installation-cd-efi.nix
16
+
../modules/testing/test-instrumentation.nix
19
+
# The test cannot access the network, so any sources we
20
+
# need must be included in the ISO.
21
+
isoImage.storeContents =
27
+
pkgs.perlPackages.XMLLibXML
34
+
}).config.system.build.isoImage;
37
+
# The config to install
38
+
config = builtins.toFile "configuration.nix" ''
40
+
imports = [ ./hardware.nix <nixos/modules/testing/test-instrumentation.nix> ];
41
+
boot.kernelPackages = pkgs.linuxPackages_3_10;
42
+
boot.loader.grub.enable = false;
43
+
boot.loader.efi.canTouchEfiVariables = true;
44
+
boot.loader.gummiboot.enable = true;
45
+
fonts.enableFontConfig = false;
46
+
fileSystems."/".label = "nixos";
50
+
biosDir = pkgs.runCommand "ovmf-bios" {} ''
52
+
ln -s ${pkgs.OVMF}/FV/OVMF.fd $out/bios.bin
60
+
createDisk("harddisk", 4 * 1024);
62
+
my $machine = createMachine({ hda => "harddisk",
63
+
hdaInterface => "virtio",
64
+
cdrom => glob("${iso}/iso/*.iso"),
65
+
qemuFlags => '-L ${biosDir} ${optionalString (pkgs.stdenv.system == "x86_64-linux") "-cpu kvm64"}'});
68
+
# Make sure that we get a login prompt etc.
69
+
$machine->succeed("echo hello");
70
+
$machine->waitForUnit("rogue");
71
+
$machine->waitForUnit("nixos-manual");
72
+
$machine->waitForUnit("dhcpcd");
74
+
# Partition the disk.
76
+
"sgdisk -Z /dev/vda",
77
+
"sgdisk -n 1:0:+256M -N 2 -t 1:ef00 -t 2:8300 -c 1:boot -c 2:root /dev/vda",
78
+
"mkfs.vfat -n BOOT /dev/vda1",
79
+
"mkfs.ext3 -L nixos /dev/vda2",
80
+
"mount LABEL=nixos /mnt",
82
+
"mount LABEL=BOOT /mnt/boot",
85
+
# Create the NixOS configuration.
87
+
"mkdir -p /mnt/etc/nixos",
88
+
"nixos-hardware-scan > /mnt/etc/nixos/hardware.nix",
91
+
my $cfg = $machine->succeed("cat /mnt/etc/nixos/hardware.nix");
92
+
print STDERR "Result of the hardware scan:\n$cfg\n";
94
+
$machine->copyFileFromHost(
96
+
"/mnt/etc/nixos/configuration.nix");
98
+
# Perform the installation.
99
+
$machine->succeed("nixos-install >&2");
101
+
# Do it again to make sure it's idempotent.
102
+
$machine->succeed("nixos-install >&2");
104
+
$machine->shutdown;
106
+
# Now see if we can boot the installation.
107
+
my $machine = createMachine({ #hda => "harddisk",
108
+
# hdaInterface => "virtio",
109
+
# !!! OVMF doesn't boot from virtio http://www.mail-archive.com/edk2-devel@lists.sourceforge.net/msg01501.html
110
+
qemuFlags => '-L ${biosDir} ${optionalString (pkgs.stdenv.system == "x86_64-linux") "-cpu kvm64"} -m 512 -hda ' . Cwd::abs_path('harddisk')});
112
+
# Did /boot get mounted, if appropriate?
113
+
$machine->waitForUnit("local-fs.target");
114
+
$machine->succeed("test -e /boot/efi");
116
+
$machine->succeed("nix-env -i coreutils >&2");
117
+
$machine->succeed("type -tP ls | tee /dev/stderr") =~ /.nix-profile/
118
+
or die "nix-env failed";
120
+
$machine->succeed("nixos-rebuild switch >&2");
122
+
$machine->shutdown;
124
+
my $machine = createMachine({ #hda => "harddisk",
125
+
# hdaInterface => "virtio",
126
+
qemuFlags => '-L ${biosDir} ${optionalString (pkgs.stdenv.system == "x86_64-linux") "-cpu kvm64"} -hda ' . Cwd::abs_path('harddisk')});
127
+
$machine->waitForUnit("network.target");
128
+
$machine->shutdown;