2014-04-14 12:02:44 +00:00
|
|
|
{ system ? builtins.currentSystem }:
|
2010-01-06 13:36:21 +00:00
|
|
|
|
2014-04-14 12:02:44 +00:00
|
|
|
with import ../lib/testing.nix { inherit system; };
|
2010-05-27 12:20:37 +00:00
|
|
|
with import ../lib/qemu-flags.nix;
|
2014-04-14 12:02:44 +00:00
|
|
|
with pkgs.lib;
|
2010-01-10 01:26:01 +00:00
|
|
|
|
2010-01-07 13:19:38 +00:00
|
|
|
let
|
2010-01-06 13:36:21 +00:00
|
|
|
|
2014-09-24 22:03:54 +00:00
|
|
|
# Build the ISO. This is the regular minimal installation CD but
|
|
|
|
# with test instrumentation.
|
2010-01-06 13:36:21 +00:00
|
|
|
iso =
|
|
|
|
(import ../lib/eval-config.nix {
|
2012-03-04 21:08:21 +00:00
|
|
|
inherit system;
|
2010-01-06 13:36:21 +00:00
|
|
|
modules =
|
2014-09-24 22:03:54 +00:00
|
|
|
[ ../modules/installer/cd-dvd/installation-cd-minimal.nix
|
2010-01-06 13:36:21 +00:00
|
|
|
../modules/testing/test-instrumentation.nix
|
2011-09-14 18:20:50 +00:00
|
|
|
{ key = "serial";
|
2013-10-28 19:08:28 +00:00
|
|
|
boot.loader.grub.timeout = mkOverride 0 0;
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2010-01-06 16:46:21 +00:00
|
|
|
# The test cannot access the network, so any sources we
|
|
|
|
# need must be included in the ISO.
|
2010-01-06 20:52:05 +00:00
|
|
|
isoImage.storeContents =
|
2010-01-10 01:26:01 +00:00
|
|
|
[ pkgs.glibcLocales
|
2010-01-06 20:52:05 +00:00
|
|
|
pkgs.sudo
|
|
|
|
pkgs.docbook5
|
2012-07-25 22:38:20 +00:00
|
|
|
pkgs.docbook5_xsl
|
2012-04-11 09:42:53 +00:00
|
|
|
pkgs.grub
|
2012-07-26 13:42:05 +00:00
|
|
|
pkgs.perlPackages.XMLLibXML
|
2013-07-09 13:29:29 +00:00
|
|
|
pkgs.unionfs-fuse
|
2014-04-30 09:24:46 +00:00
|
|
|
pkgs.gummiboot
|
2010-01-06 20:52:05 +00:00
|
|
|
];
|
2010-01-06 13:36:21 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
}).config.system.build.isoImage;
|
|
|
|
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2010-01-06 20:52:05 +00:00
|
|
|
# The configuration to install.
|
2014-10-07 16:20:50 +00:00
|
|
|
makeConfig = { testChannel, grubVersion, grubDevice, grubIdentifier
|
2014-09-04 17:30:25 +00:00
|
|
|
, readOnly ? true, forceGrubReinstallCount ? 0 }:
|
2014-08-31 16:18:13 +00:00
|
|
|
pkgs.writeText "configuration.nix" ''
|
2010-01-06 20:52:05 +00:00
|
|
|
{ config, pkgs, modulesPath, ... }:
|
|
|
|
|
2013-09-04 11:05:09 +00:00
|
|
|
{ imports =
|
2013-10-13 15:24:11 +00:00
|
|
|
[ ./hardware-configuration.nix
|
2014-03-30 14:52:56 +00:00
|
|
|
<nixpkgs/nixos/modules/testing/test-instrumentation.nix>
|
2014-09-24 22:03:54 +00:00
|
|
|
<nixpkgs/nixos/modules/profiles/minimal.nix>
|
2010-01-06 20:52:05 +00:00
|
|
|
];
|
|
|
|
|
2014-10-07 16:20:50 +00:00
|
|
|
boot.loader.grub.version = ${toString grubVersion};
|
|
|
|
${optionalString (grubVersion == 1) ''
|
|
|
|
boot.loader.grub.splashImage = null;
|
2012-04-11 09:42:53 +00:00
|
|
|
''}
|
2014-10-07 16:20:50 +00:00
|
|
|
boot.loader.grub.device = "${grubDevice}";
|
|
|
|
boot.loader.grub.extraConfig = "serial; terminal_output.serial";
|
|
|
|
boot.loader.grub.fsIdentifier = "${grubIdentifier}";
|
2010-01-10 01:26:01 +00:00
|
|
|
|
2014-09-04 17:30:25 +00:00
|
|
|
boot.loader.grub.configurationLimit = 100 + ${toString forceGrubReinstallCount};
|
|
|
|
|
|
|
|
${optionalString (!readOnly) "nix.readOnlyStore = false;"}
|
|
|
|
|
2010-01-10 01:26:01 +00:00
|
|
|
environment.systemPackages = [ ${optionalString testChannel "pkgs.rlwrap"} ];
|
2010-01-06 20:52:05 +00:00
|
|
|
}
|
|
|
|
'';
|
|
|
|
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2010-01-10 01:26:01 +00:00
|
|
|
# Configuration of a web server that simulates the Nixpkgs channel
|
|
|
|
# distribution server.
|
2011-09-14 18:20:50 +00:00
|
|
|
webserver =
|
2010-01-10 01:26:01 +00:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
{ services.httpd.enable = true;
|
|
|
|
services.httpd.adminAddr = "foo@example.org";
|
|
|
|
services.httpd.servedDirs = singleton
|
2013-06-14 12:04:17 +00:00
|
|
|
{ urlPath = "/";
|
2010-01-10 01:26:01 +00:00
|
|
|
dir = "/tmp/channel";
|
|
|
|
};
|
|
|
|
|
2010-08-24 12:59:16 +00:00
|
|
|
virtualisation.writableStore = true;
|
2013-09-16 11:24:49 +00:00
|
|
|
virtualisation.pathsInNixDB = channelContents ++ [ pkgs.hello.src ];
|
2013-07-12 13:17:35 +00:00
|
|
|
virtualisation.memorySize = 768;
|
2014-04-11 15:15:56 +00:00
|
|
|
|
|
|
|
networking.firewall.allowedTCPPorts = [ 80 ];
|
2010-01-10 01:26:01 +00:00
|
|
|
};
|
|
|
|
|
2013-09-16 11:24:49 +00:00
|
|
|
channelContents = [ pkgs.rlwrap ];
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2010-01-10 01:26:01 +00:00
|
|
|
|
2014-04-30 09:24:46 +00:00
|
|
|
efiBios = pkgs.runCommand "ovmf-bios" {} ''
|
|
|
|
mkdir $out
|
|
|
|
ln -s ${pkgs.OVMF}/FV/OVMF.fd $out/bios.bin
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
2010-01-06 16:46:21 +00:00
|
|
|
# The test script boots the CD, installs NixOS on an empty hard
|
2010-01-07 14:19:19 +00:00
|
|
|
# disk, and then reboot from the hard disk. It's parameterized with
|
|
|
|
# a test script fragment `createPartitions', which must create
|
2014-04-30 07:40:18 +00:00
|
|
|
# partitions and filesystems.
|
2014-10-07 16:20:50 +00:00
|
|
|
testScriptFun = { createPartitions, testChannel, grubVersion, grubDevice, grubIdentifier }:
|
2014-04-30 09:24:46 +00:00
|
|
|
let
|
|
|
|
# FIXME: OVMF doesn't boot from virtio http://www.mail-archive.com/edk2-devel@lists.sourceforge.net/msg01501.html
|
2014-10-07 16:20:50 +00:00
|
|
|
iface = if grubVersion == 1 then "scsi" else "virtio";
|
2014-04-30 09:24:46 +00:00
|
|
|
qemuFlags =
|
2014-08-25 08:53:09 +00:00
|
|
|
(if iso.system == "x86_64-linux" then "-m 768 " else "-m 512 ") +
|
2014-10-07 19:02:18 +00:00
|
|
|
(optionalString (iso.system == "x86_64-linux") "-cpu kvm64 ");
|
2014-10-07 16:20:50 +00:00
|
|
|
hdFlags =''hda => "harddisk", hdaInterface => "${iface}", '';
|
2014-04-30 09:24:46 +00:00
|
|
|
in
|
2010-01-06 13:36:21 +00:00
|
|
|
''
|
2010-01-06 14:37:23 +00:00
|
|
|
createDisk("harddisk", 4 * 1024);
|
2010-01-06 13:36:21 +00:00
|
|
|
|
2014-04-30 09:24:46 +00:00
|
|
|
my $machine = createMachine({ ${hdFlags}
|
2012-07-26 19:09:01 +00:00
|
|
|
cdrom => glob("${iso}/iso/*.iso"),
|
2014-04-30 12:59:46 +00:00
|
|
|
qemuFlags => "${qemuFlags} " . '${optionalString testChannel (toString (qemuNICFlags 1 1 2))}' });
|
2010-01-10 01:26:01 +00:00
|
|
|
$machine->start;
|
2010-01-06 13:36:21 +00:00
|
|
|
|
2010-01-10 01:26:01 +00:00
|
|
|
${optionalString testChannel ''
|
|
|
|
# Create a channel on the web server containing a few packages
|
|
|
|
# to simulate the Nixpkgs channel.
|
|
|
|
$webserver->start;
|
2012-10-24 16:22:53 +00:00
|
|
|
$webserver->waitForUnit("httpd");
|
|
|
|
$webserver->succeed(
|
2012-11-16 15:34:22 +00:00
|
|
|
"nix-push --bzip2 --dest /tmp/channel --manifest --url-prefix http://nixos.org/channels/nixos-unstable " .
|
|
|
|
"${toString channelContents} >&2");
|
2013-09-16 11:24:49 +00:00
|
|
|
$webserver->succeed("mkdir /tmp/channel/sha256");
|
|
|
|
$webserver->succeed("cp ${pkgs.hello.src} /tmp/channel/sha256/${pkgs.hello.src.outputHash}");
|
2010-01-10 01:26:01 +00:00
|
|
|
''}
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2010-01-06 14:37:23 +00:00
|
|
|
# Make sure that we get a login prompt etc.
|
2012-10-24 16:22:53 +00:00
|
|
|
$machine->succeed("echo hello");
|
2012-11-09 10:45:57 +00:00
|
|
|
#$machine->waitForUnit('getty@tty2');
|
2012-10-24 16:22:53 +00:00
|
|
|
$machine->waitForUnit("rogue");
|
|
|
|
$machine->waitForUnit("nixos-manual");
|
2010-01-06 20:52:05 +00:00
|
|
|
|
2010-01-10 01:26:01 +00:00
|
|
|
${optionalString testChannel ''
|
2014-05-21 13:42:02 +00:00
|
|
|
$machine->waitForUnit("dhcpcd");
|
|
|
|
|
2010-01-10 01:26:01 +00:00
|
|
|
# Allow the machine to talk to the fake nixos.org.
|
2012-10-24 16:22:53 +00:00
|
|
|
$machine->succeed(
|
2010-02-10 14:31:46 +00:00
|
|
|
"rm /etc/hosts",
|
2013-09-16 11:24:49 +00:00
|
|
|
"echo 192.168.1.1 nixos.org cache.nixos.org tarballs.nixos.org > /etc/hosts",
|
2010-01-10 01:26:01 +00:00
|
|
|
"ifconfig eth1 up 192.168.1.2",
|
|
|
|
);
|
|
|
|
|
|
|
|
# Test nix-env.
|
2012-10-24 16:22:53 +00:00
|
|
|
$machine->fail("hello");
|
|
|
|
$machine->succeed("nix-env -i hello");
|
|
|
|
$machine->succeed("hello") =~ /Hello, world/
|
2010-01-10 01:26:01 +00:00
|
|
|
or die "bad `hello' output";
|
|
|
|
''}
|
2010-01-06 16:46:21 +00:00
|
|
|
|
2014-05-30 19:22:25 +00:00
|
|
|
# Wait for hard disks to appear in /dev
|
|
|
|
$machine->succeed("udevadm settle");
|
|
|
|
|
2010-01-06 14:37:23 +00:00
|
|
|
# Partition the disk.
|
2010-01-07 13:19:38 +00:00
|
|
|
${createPartitions}
|
2010-01-06 14:37:23 +00:00
|
|
|
|
2010-01-06 20:52:05 +00:00
|
|
|
# Create the NixOS configuration.
|
2012-10-24 16:22:53 +00:00
|
|
|
$machine->succeed(
|
2013-10-13 15:24:11 +00:00
|
|
|
"nixos-generate-config --root /mnt",
|
2010-01-06 16:46:21 +00:00
|
|
|
);
|
|
|
|
|
2013-10-13 15:24:11 +00:00
|
|
|
$machine->succeed("cat /mnt/etc/nixos/hardware-configuration.nix >&2");
|
2010-01-06 20:52:05 +00:00
|
|
|
|
2010-01-07 13:19:38 +00:00
|
|
|
$machine->copyFileFromHost(
|
2014-10-07 16:20:50 +00:00
|
|
|
"${ makeConfig { inherit testChannel grubVersion grubDevice grubIdentifier; } }",
|
2010-01-07 13:19:38 +00:00
|
|
|
"/mnt/etc/nixos/configuration.nix");
|
2010-01-06 16:46:21 +00:00
|
|
|
|
2010-01-06 20:52:05 +00:00
|
|
|
# Perform the installation.
|
2014-05-21 09:04:45 +00:00
|
|
|
$machine->succeed("nixos-install < /dev/null >&2");
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2012-05-24 23:39:03 +00:00
|
|
|
# Do it again to make sure it's idempotent.
|
2014-05-21 09:04:45 +00:00
|
|
|
$machine->succeed("nixos-install < /dev/null >&2");
|
2012-05-24 23:39:03 +00:00
|
|
|
|
2014-04-30 12:51:27 +00:00
|
|
|
$machine->succeed("umount /mnt/boot || true");
|
|
|
|
$machine->succeed("umount /mnt");
|
|
|
|
$machine->succeed("sync");
|
|
|
|
|
2010-01-06 14:37:23 +00:00
|
|
|
$machine->shutdown;
|
2010-01-06 15:14:26 +00:00
|
|
|
|
|
|
|
# Now see if we can boot the installation.
|
2014-05-21 13:20:37 +00:00
|
|
|
$machine = createMachine({ ${hdFlags} qemuFlags => "${qemuFlags}" });
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2014-04-30 09:24:46 +00:00
|
|
|
# Did /boot get mounted?
|
2012-10-24 10:58:58 +00:00
|
|
|
$machine->waitForUnit("local-fs.target");
|
2014-04-30 09:24:46 +00:00
|
|
|
|
2014-10-07 16:20:50 +00:00
|
|
|
$machine->succeed("test -e /boot/grub");
|
2010-01-07 14:59:43 +00:00
|
|
|
|
|
|
|
# Did the swap device get activated?
|
2012-10-24 10:58:58 +00:00
|
|
|
$machine->waitForUnit("swap.target");
|
|
|
|
$machine->succeed("cat /proc/swaps | grep -q /dev");
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2014-04-30 09:24:46 +00:00
|
|
|
# Check whether the channel works.
|
2012-10-24 16:22:53 +00:00
|
|
|
$machine->succeed("nix-env -i coreutils >&2");
|
|
|
|
$machine->succeed("type -tP ls | tee /dev/stderr") =~ /.nix-profile/
|
2010-01-06 20:52:05 +00:00
|
|
|
or die "nix-env failed";
|
|
|
|
|
2014-09-04 17:30:25 +00:00
|
|
|
# We need to a writable nix-store on next boot
|
|
|
|
$machine->copyFileFromHost(
|
2014-10-07 16:20:50 +00:00
|
|
|
"${ makeConfig { inherit testChannel grubVersion grubDevice grubIdentifier; readOnly = false; forceGrubReinstallCount = 1; } }",
|
2014-09-04 17:30:25 +00:00
|
|
|
"/etc/nixos/configuration.nix");
|
|
|
|
|
2014-04-30 09:24:46 +00:00
|
|
|
# Check whether nixos-rebuild works.
|
2012-10-24 16:22:53 +00:00
|
|
|
$machine->succeed("nixos-rebuild switch >&2");
|
2010-01-06 20:52:05 +00:00
|
|
|
|
2013-10-13 20:36:04 +00:00
|
|
|
# Test nixos-option.
|
|
|
|
$machine->succeed("nixos-option boot.initrd.kernelModules | grep virtio_console");
|
2014-09-05 16:49:05 +00:00
|
|
|
$machine->succeed("nixos-option boot.initrd.kernelModules | grep 'List of modules'");
|
|
|
|
$machine->succeed("nixos-option boot.initrd.kernelModules | grep qemu-guest.nix");
|
2013-10-13 20:36:04 +00:00
|
|
|
|
2010-01-06 15:14:26 +00:00
|
|
|
$machine->shutdown;
|
2010-01-06 22:53:27 +00:00
|
|
|
|
2014-09-04 17:30:25 +00:00
|
|
|
# Check whether a writable store build works
|
|
|
|
$machine = createMachine({ ${hdFlags} qemuFlags => "${qemuFlags}" });
|
|
|
|
$machine->waitForUnit("multi-user.target");
|
|
|
|
$machine->copyFileFromHost(
|
2014-10-07 16:20:50 +00:00
|
|
|
"${ makeConfig { inherit testChannel grubVersion grubDevice grubIdentifier; readOnly = false; forceGrubReinstallCount = 2; } }",
|
2014-09-04 17:30:25 +00:00
|
|
|
"/etc/nixos/configuration.nix");
|
|
|
|
$machine->succeed("nixos-rebuild boot >&2");
|
|
|
|
$machine->shutdown;
|
|
|
|
|
2010-01-06 22:53:27 +00:00
|
|
|
# And just to be sure, check that the machine still boots after
|
|
|
|
# "nixos-rebuild switch".
|
2014-05-21 13:20:37 +00:00
|
|
|
$machine = createMachine({ ${hdFlags} qemuFlags => "${qemuFlags}" });
|
2012-10-24 16:22:53 +00:00
|
|
|
$machine->waitForUnit("network.target");
|
2010-01-06 22:53:27 +00:00
|
|
|
$machine->shutdown;
|
2010-01-06 15:14:26 +00:00
|
|
|
'';
|
2010-01-06 16:46:21 +00:00
|
|
|
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2014-06-28 14:04:49 +00:00
|
|
|
makeInstallerTest = name:
|
2014-10-07 16:20:50 +00:00
|
|
|
{ createPartitions, testChannel ? false, grubVersion ? 2, grubDevice ? "/dev/vda", grubIdentifier ? "uuid" }:
|
2014-04-14 14:24:08 +00:00
|
|
|
makeTest {
|
2014-04-14 12:02:44 +00:00
|
|
|
inherit iso;
|
2014-06-28 14:04:49 +00:00
|
|
|
name = "installer-" + name;
|
2010-01-10 01:26:01 +00:00
|
|
|
nodes = if testChannel then { inherit webserver; } else { };
|
|
|
|
testScript = testScriptFun {
|
2014-10-07 16:20:50 +00:00
|
|
|
inherit createPartitions testChannel grubVersion grubDevice grubIdentifier;
|
2010-01-10 01:26:01 +00:00
|
|
|
};
|
2014-04-14 14:24:08 +00:00
|
|
|
};
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2010-01-07 13:19:38 +00:00
|
|
|
|
|
|
|
in {
|
|
|
|
|
2010-05-16 20:44:45 +00:00
|
|
|
# !!! `parted mkpart' seems to silently create overlapping partitions.
|
|
|
|
|
|
|
|
|
2010-01-07 13:19:38 +00:00
|
|
|
# The (almost) simplest partitioning scheme: a swap partition and
|
|
|
|
# one big filesystem partition.
|
2014-06-28 14:04:49 +00:00
|
|
|
simple = makeInstallerTest "simple"
|
2011-09-14 18:20:50 +00:00
|
|
|
{ createPartitions =
|
2010-01-07 13:19:38 +00:00
|
|
|
''
|
2012-10-24 16:22:53 +00:00
|
|
|
$machine->succeed(
|
2010-01-07 13:19:38 +00:00
|
|
|
"parted /dev/vda mklabel msdos",
|
|
|
|
"parted /dev/vda -- mkpart primary linux-swap 1M 1024M",
|
|
|
|
"parted /dev/vda -- mkpart primary ext2 1024M -1s",
|
|
|
|
"udevadm settle",
|
|
|
|
"mkswap /dev/vda1 -L swap",
|
|
|
|
"swapon -L swap",
|
|
|
|
"mkfs.ext3 -L nixos /dev/vda2",
|
|
|
|
"mount LABEL=nixos /mnt",
|
|
|
|
);
|
|
|
|
'';
|
2010-01-10 01:26:01 +00:00
|
|
|
testChannel = true;
|
2010-01-07 13:19:38 +00:00
|
|
|
};
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2010-01-07 13:19:38 +00:00
|
|
|
# Same as the previous, but now with a separate /boot partition.
|
2014-06-28 14:04:49 +00:00
|
|
|
separateBoot = makeInstallerTest "separateBoot"
|
2010-01-07 13:19:38 +00:00
|
|
|
{ createPartitions =
|
|
|
|
''
|
2012-10-24 16:22:53 +00:00
|
|
|
$machine->succeed(
|
2010-01-07 13:19:38 +00:00
|
|
|
"parted /dev/vda mklabel msdos",
|
|
|
|
"parted /dev/vda -- mkpart primary ext2 1M 50MB", # /boot
|
|
|
|
"parted /dev/vda -- mkpart primary linux-swap 50MB 1024M",
|
|
|
|
"parted /dev/vda -- mkpart primary ext2 1024M -1s", # /
|
|
|
|
"udevadm settle",
|
|
|
|
"mkswap /dev/vda2 -L swap",
|
|
|
|
"swapon -L swap",
|
|
|
|
"mkfs.ext3 -L nixos /dev/vda3",
|
|
|
|
"mount LABEL=nixos /mnt",
|
|
|
|
"mkfs.ext3 -L boot /dev/vda1",
|
2014-02-04 13:43:45 +00:00
|
|
|
"mkdir -p /mnt/boot",
|
2010-01-07 13:19:38 +00:00
|
|
|
"mount LABEL=boot /mnt/boot",
|
|
|
|
);
|
|
|
|
'';
|
|
|
|
};
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2010-01-07 14:19:19 +00:00
|
|
|
# Create two physical LVM partitions combined into one volume group
|
2012-08-01 19:40:58 +00:00
|
|
|
# that contains the logical swap and root partitions.
|
2014-06-28 14:04:49 +00:00
|
|
|
lvm = makeInstallerTest "lvm"
|
2010-01-07 14:19:19 +00:00
|
|
|
{ createPartitions =
|
|
|
|
''
|
2012-10-24 16:22:53 +00:00
|
|
|
$machine->succeed(
|
2010-01-07 14:19:19 +00:00
|
|
|
"parted /dev/vda mklabel msdos",
|
2014-02-09 16:59:02 +00:00
|
|
|
"parted /dev/vda -- mkpart primary 1M 2048M", # PV1
|
2010-01-07 14:59:43 +00:00
|
|
|
"parted /dev/vda -- set 1 lvm on",
|
2014-02-09 16:59:02 +00:00
|
|
|
"parted /dev/vda -- mkpart primary 2048M -1s", # PV2
|
2010-01-10 15:22:09 +00:00
|
|
|
"parted /dev/vda -- set 2 lvm on",
|
2010-01-10 19:19:52 +00:00
|
|
|
"udevadm settle",
|
2012-08-01 19:40:58 +00:00
|
|
|
"pvcreate /dev/vda1 /dev/vda2",
|
|
|
|
"vgcreate MyVolGroup /dev/vda1 /dev/vda2",
|
2010-01-07 14:19:19 +00:00
|
|
|
"lvcreate --size 1G --name swap MyVolGroup",
|
|
|
|
"lvcreate --size 2G --name nixos MyVolGroup",
|
|
|
|
"mkswap -f /dev/MyVolGroup/swap -L swap",
|
|
|
|
"swapon -L swap",
|
2012-07-26 19:52:05 +00:00
|
|
|
"mkfs.xfs -L nixos /dev/MyVolGroup/nixos",
|
2010-01-07 14:19:19 +00:00
|
|
|
"mount LABEL=nixos /mnt",
|
|
|
|
);
|
|
|
|
'';
|
|
|
|
};
|
2010-05-16 20:44:45 +00:00
|
|
|
|
2014-06-28 14:04:49 +00:00
|
|
|
swraid = makeInstallerTest "swraid"
|
2010-05-16 20:44:45 +00:00
|
|
|
{ createPartitions =
|
|
|
|
''
|
2012-10-24 16:22:53 +00:00
|
|
|
$machine->succeed(
|
2010-07-13 11:57:12 +00:00
|
|
|
"parted /dev/vda --"
|
|
|
|
. " mklabel msdos"
|
|
|
|
. " mkpart primary ext2 1M 30MB" # /boot
|
|
|
|
. " mkpart extended 30M -1s"
|
2010-07-21 21:20:42 +00:00
|
|
|
. " mkpart logical 31M 1531M" # md0 (root), first device
|
|
|
|
. " mkpart logical 1540M 3040M" # md0 (root), second device
|
|
|
|
. " mkpart logical 3050M 3306M" # md1 (swap), first device
|
|
|
|
. " mkpart logical 3320M 3576M", # md1 (swap), second device
|
2010-05-16 20:44:45 +00:00
|
|
|
"udevadm settle",
|
2010-07-13 11:57:12 +00:00
|
|
|
"ls -l /dev/vda* >&2",
|
|
|
|
"cat /proc/partitions >&2",
|
2010-06-20 16:05:15 +00:00
|
|
|
"mdadm --create --force /dev/md0 --metadata 1.2 --level=raid1 --raid-devices=2 /dev/vda5 /dev/vda6",
|
|
|
|
"mdadm --create --force /dev/md1 --metadata 1.2 --level=raid1 --raid-devices=2 /dev/vda7 /dev/vda8",
|
2012-03-20 21:45:24 +00:00
|
|
|
"udevadm settle",
|
2010-05-16 20:44:45 +00:00
|
|
|
"mkswap -f /dev/md1 -L swap",
|
|
|
|
"swapon -L swap",
|
|
|
|
"mkfs.ext3 -L nixos /dev/md0",
|
|
|
|
"mount LABEL=nixos /mnt",
|
2010-06-20 16:05:15 +00:00
|
|
|
"mkfs.ext3 -L boot /dev/vda1",
|
|
|
|
"mkdir /mnt/boot",
|
|
|
|
"mount LABEL=boot /mnt/boot",
|
2012-03-20 21:45:24 +00:00
|
|
|
"udevadm settle",
|
|
|
|
"mdadm -W /dev/md0", # wait for sync to finish; booting off an unsynced device tends to fail
|
|
|
|
"mdadm -W /dev/md1",
|
2010-05-16 20:44:45 +00:00
|
|
|
);
|
|
|
|
'';
|
|
|
|
};
|
2010-09-25 09:32:22 +00:00
|
|
|
|
2012-04-11 09:42:53 +00:00
|
|
|
# Test a basic install using GRUB 1.
|
2014-06-28 14:04:49 +00:00
|
|
|
grub1 = makeInstallerTest "grub1"
|
2012-04-11 09:42:53 +00:00
|
|
|
{ createPartitions =
|
|
|
|
''
|
2012-10-24 16:22:53 +00:00
|
|
|
$machine->succeed(
|
2012-07-26 19:09:01 +00:00
|
|
|
"parted /dev/sda mklabel msdos",
|
|
|
|
"parted /dev/sda -- mkpart primary linux-swap 1M 1024M",
|
|
|
|
"parted /dev/sda -- mkpart primary ext2 1024M -1s",
|
2012-04-11 09:42:53 +00:00
|
|
|
"udevadm settle",
|
2012-07-26 19:09:01 +00:00
|
|
|
"mkswap /dev/sda1 -L swap",
|
2012-04-11 09:42:53 +00:00
|
|
|
"swapon -L swap",
|
2012-07-26 19:09:01 +00:00
|
|
|
"mkfs.ext3 -L nixos /dev/sda2",
|
2012-04-11 09:42:53 +00:00
|
|
|
"mount LABEL=nixos /mnt",
|
|
|
|
);
|
2014-01-19 20:07:35 +00:00
|
|
|
|
2012-04-11 09:42:53 +00:00
|
|
|
'';
|
|
|
|
grubVersion = 1;
|
2012-07-26 19:09:01 +00:00
|
|
|
grubDevice = "/dev/sda";
|
2012-04-11 09:42:53 +00:00
|
|
|
};
|
|
|
|
|
2010-09-25 09:32:22 +00:00
|
|
|
# Rebuild the CD configuration with a little modification.
|
2014-04-14 14:24:08 +00:00
|
|
|
rebuildCD = makeTest
|
2010-09-25 09:32:22 +00:00
|
|
|
{ inherit iso;
|
2014-07-01 14:28:23 +00:00
|
|
|
name = "rebuild-cd";
|
2010-09-25 09:32:22 +00:00
|
|
|
nodes = { };
|
|
|
|
testScript =
|
2010-10-12 22:03:50 +00:00
|
|
|
''
|
2013-07-09 14:12:34 +00:00
|
|
|
my $machine = createMachine({ cdrom => glob("${iso}/iso/*.iso"), qemuFlags => '-m 768' });
|
2010-10-12 22:03:50 +00:00
|
|
|
$machine->start;
|
2010-09-25 09:32:22 +00:00
|
|
|
|
2010-10-12 22:03:50 +00:00
|
|
|
# Enable sshd service.
|
2012-10-24 16:22:53 +00:00
|
|
|
$machine->succeed(
|
2013-07-09 14:12:34 +00:00
|
|
|
"sed -i 's,^}\$,systemd.services.sshd.wantedBy = pkgs.lib.mkOverride 0 [\"multi-user.target\"]; },' /etc/nixos/configuration.nix"
|
2010-10-12 22:03:50 +00:00
|
|
|
);
|
2010-09-25 09:32:22 +00:00
|
|
|
|
2013-07-09 13:29:29 +00:00
|
|
|
$machine->succeed("cat /etc/nixos/configuration.nix >&2");
|
2010-09-25 09:32:22 +00:00
|
|
|
|
2010-10-12 22:03:50 +00:00
|
|
|
# Apply the new CD configuration.
|
2012-10-24 16:22:53 +00:00
|
|
|
$machine->succeed("nixos-rebuild test");
|
2010-09-25 09:32:22 +00:00
|
|
|
|
2010-10-12 22:03:50 +00:00
|
|
|
# Connect to it-self.
|
2013-07-09 14:12:34 +00:00
|
|
|
$machine->waitForUnit("sshd");
|
|
|
|
$machine->waitForOpenPort(22);
|
2010-09-25 09:32:22 +00:00
|
|
|
|
2010-10-12 22:03:50 +00:00
|
|
|
$machine->shutdown;
|
|
|
|
'';
|
2014-04-14 14:24:08 +00:00
|
|
|
};
|
2014-05-01 11:21:30 +00:00
|
|
|
|
2014-05-02 04:11:49 +00:00
|
|
|
# Test using labels to identify volumes in grub
|
2014-08-29 09:48:00 +00:00
|
|
|
simpleLabels = makeInstallerTest "simpleLabels" {
|
2014-05-02 04:11:49 +00:00
|
|
|
createPartitions = ''
|
|
|
|
$machine->succeed(
|
|
|
|
"sgdisk -Z /dev/vda",
|
2014-05-02 06:05:10 +00:00
|
|
|
"sgdisk -n 1:0:+1M -n 2:0:+1G -N 3 -t 1:ef02 -t 2:8200 -t 3:8300 -c 3:root /dev/vda",
|
2014-05-02 05:01:32 +00:00
|
|
|
"mkswap /dev/vda2 -L swap",
|
|
|
|
"swapon -L swap",
|
2014-05-02 05:25:38 +00:00
|
|
|
"mkfs.ext4 -L root /dev/vda3",
|
2014-05-02 04:11:49 +00:00
|
|
|
"mount LABEL=root /mnt",
|
|
|
|
);
|
|
|
|
'';
|
|
|
|
grubIdentifier = "label";
|
|
|
|
};
|
|
|
|
|
|
|
|
# Test using the provided disk name within grub
|
2014-05-02 07:03:25 +00:00
|
|
|
# TODO: Fix udev so the symlinks are unneeded in /dev/disks
|
2014-08-29 09:48:00 +00:00
|
|
|
simpleProvided = makeInstallerTest "simpleProvided" {
|
2014-05-02 04:11:49 +00:00
|
|
|
createPartitions = ''
|
2014-05-02 07:03:25 +00:00
|
|
|
my $UUID = "\$(blkid -s UUID -o value /dev/vda2)";
|
2014-05-02 04:11:49 +00:00
|
|
|
$machine->succeed(
|
|
|
|
"sgdisk -Z /dev/vda",
|
2014-05-02 07:53:32 +00:00
|
|
|
"sgdisk -n 1:0:+1M -n 2:0:+100M -n 3:0:+1G -N 4 -t 1:ef02 -t 2:8300 -t 3:8200 -t 4:8300 -c 2:boot -c 4:root /dev/vda",
|
2014-05-02 05:01:32 +00:00
|
|
|
"mkswap /dev/vda3 -L swap",
|
|
|
|
"swapon -L swap",
|
2014-05-02 04:11:49 +00:00
|
|
|
"mkfs.ext4 -L boot /dev/vda2",
|
2014-05-02 05:01:32 +00:00
|
|
|
"mkfs.ext4 -L root /dev/vda4",
|
2014-05-02 07:03:25 +00:00
|
|
|
);
|
|
|
|
$machine->execute("ln -s ../../vda2 /dev/disk/by-uuid/$UUID");
|
|
|
|
$machine->execute("ln -s ../../vda4 /dev/disk/by-label/root");
|
|
|
|
$machine->succeed(
|
2014-05-02 06:07:12 +00:00
|
|
|
"mount /dev/disk/by-label/root /mnt",
|
2014-05-02 04:11:49 +00:00
|
|
|
"mkdir /mnt/boot",
|
2014-05-02 07:03:25 +00:00
|
|
|
"mount /dev/disk/by-uuid/$UUID /mnt/boot"
|
2014-05-02 04:11:49 +00:00
|
|
|
);
|
|
|
|
'';
|
|
|
|
grubIdentifier = "provided";
|
|
|
|
};
|
|
|
|
|
2014-05-01 11:21:30 +00:00
|
|
|
# Simple btrfs grub testing
|
2014-08-29 09:48:00 +00:00
|
|
|
btrfsSimple = makeInstallerTest "btrfsSimple" {
|
2014-05-01 11:21:30 +00:00
|
|
|
createPartitions = ''
|
|
|
|
$machine->succeed(
|
|
|
|
"sgdisk -Z /dev/vda",
|
2014-05-02 06:05:10 +00:00
|
|
|
"sgdisk -n 1:0:+1M -n 2:0:+1G -N 3 -t 1:ef02 -t 2:8200 -t 3:8300 -c 3:root /dev/vda",
|
2014-05-02 05:01:32 +00:00
|
|
|
"mkswap /dev/vda2 -L swap",
|
|
|
|
"swapon -L swap",
|
|
|
|
"mkfs.btrfs -L root /dev/vda3",
|
2014-05-01 11:21:30 +00:00
|
|
|
"mount LABEL=root /mnt",
|
|
|
|
);
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
# Test to see if we can detect /boot and /nix on subvolumes
|
2014-08-29 09:48:00 +00:00
|
|
|
btrfsSubvols = makeInstallerTest "btrfsSubvols" {
|
2014-05-01 11:21:30 +00:00
|
|
|
createPartitions = ''
|
|
|
|
$machine->succeed(
|
|
|
|
"sgdisk -Z /dev/vda",
|
2014-05-02 06:05:10 +00:00
|
|
|
"sgdisk -n 1:0:+1M -n 2:0:+1G -N 3 -t 1:ef02 -t 2:8200 -t 3:8300 -c 3:root /dev/vda",
|
2014-05-02 05:01:32 +00:00
|
|
|
"mkswap /dev/vda2 -L swap",
|
|
|
|
"swapon -L swap",
|
|
|
|
"mkfs.btrfs -L root /dev/vda3",
|
2014-05-01 11:21:30 +00:00
|
|
|
"btrfs device scan",
|
|
|
|
"mount LABEL=root /mnt",
|
|
|
|
"btrfs subvol create /mnt/boot",
|
|
|
|
"btrfs subvol create /mnt/nixos",
|
2014-08-30 22:48:54 +00:00
|
|
|
"btrfs subvol create /mnt/nixos/default",
|
2014-05-01 11:21:30 +00:00
|
|
|
"umount /mnt",
|
2014-08-30 22:48:54 +00:00
|
|
|
"mount -o defaults,subvol=nixos/default LABEL=root /mnt",
|
2014-05-01 11:21:30 +00:00
|
|
|
"mkdir /mnt/boot",
|
|
|
|
"mount -o defaults,subvol=boot LABEL=root /mnt/boot",
|
|
|
|
);
|
|
|
|
'';
|
|
|
|
};
|
2014-08-29 23:37:28 +00:00
|
|
|
|
|
|
|
# Test to see if we can detect default and aux subvolumes correctly
|
|
|
|
btrfsSubvolDefault = makeInstallerTest "btrfsSubvolDefault" {
|
|
|
|
createPartitions = ''
|
|
|
|
$machine->succeed(
|
|
|
|
"sgdisk -Z /dev/vda",
|
|
|
|
"sgdisk -n 1:0:+1M -n 2:0:+1G -N 3 -t 1:ef02 -t 2:8200 -t 3:8300 -c 3:root /dev/vda",
|
|
|
|
"mkswap /dev/vda2 -L swap",
|
|
|
|
"swapon -L swap",
|
|
|
|
"mkfs.btrfs -L root /dev/vda3",
|
|
|
|
"btrfs device scan",
|
|
|
|
"mount LABEL=root /mnt",
|
|
|
|
"btrfs subvol create /mnt/badpath",
|
|
|
|
"btrfs subvol create /mnt/badpath/boot",
|
|
|
|
"btrfs subvol create /mnt/nixos",
|
|
|
|
"btrfs subvol set-default \$(btrfs subvol list /mnt | grep 'nixos' | awk '{print \$2}') /mnt",
|
|
|
|
"umount /mnt",
|
|
|
|
"mount -o defaults LABEL=root /mnt",
|
|
|
|
"mkdir -p /mnt/badpath/boot", # Help ensure the detection mechanism is actually looking up subvolumes
|
|
|
|
"mkdir /mnt/boot",
|
|
|
|
"mount -o defaults,subvol=badpath/boot LABEL=root /mnt/boot",
|
|
|
|
);
|
|
|
|
'';
|
|
|
|
};
|
2010-01-06 13:36:21 +00:00
|
|
|
}
|