2012-03-05 01:08:21 +04:00
|
|
|
{ pkgs, system, ... }:
|
2010-01-06 16:36:21 +03:00
|
|
|
|
2010-01-10 04:26:01 +03:00
|
|
|
with pkgs.lib;
|
2010-05-27 16:20:37 +04:00
|
|
|
with import ../lib/qemu-flags.nix;
|
2010-01-10 04:26:01 +03:00
|
|
|
|
2010-01-07 16:19:38 +03:00
|
|
|
let
|
2010-01-06 16:36:21 +03:00
|
|
|
|
|
|
|
# Build the ISO. This is the regular installation CD but with test
|
|
|
|
# instrumentation.
|
|
|
|
iso =
|
|
|
|
(import ../lib/eval-config.nix {
|
2012-03-05 01:08:21 +04:00
|
|
|
inherit system;
|
2010-01-06 16:36:21 +03:00
|
|
|
modules =
|
2010-01-06 23:52:05 +03:00
|
|
|
[ ../modules/installer/cd-dvd/installation-cd-graphical.nix
|
2010-01-06 16:36:21 +03:00
|
|
|
../modules/testing/test-instrumentation.nix
|
2011-09-14 22:20:50 +04:00
|
|
|
{ key = "serial";
|
2013-10-28 23:08:28 +04:00
|
|
|
boot.loader.grub.timeout = mkOverride 0 0;
|
2011-09-14 22:20:50 +04:00
|
|
|
|
2010-01-06 19:46:21 +03:00
|
|
|
# The test cannot access the network, so any sources we
|
|
|
|
# need must be included in the ISO.
|
2010-01-06 23:52:05 +03:00
|
|
|
isoImage.storeContents =
|
2010-01-10 04:26:01 +03:00
|
|
|
[ pkgs.glibcLocales
|
2010-01-06 23:52:05 +03:00
|
|
|
pkgs.sudo
|
|
|
|
pkgs.docbook5
|
2012-07-26 02:38:20 +04:00
|
|
|
pkgs.docbook5_xsl
|
2012-04-11 13:42:53 +04:00
|
|
|
pkgs.grub
|
2012-07-26 17:42:05 +04:00
|
|
|
pkgs.perlPackages.XMLLibXML
|
2013-07-09 17:29:29 +04:00
|
|
|
pkgs.unionfs-fuse
|
2010-01-06 23:52:05 +03:00
|
|
|
];
|
2010-01-06 16:36:21 +03:00
|
|
|
}
|
|
|
|
];
|
|
|
|
}).config.system.build.isoImage;
|
|
|
|
|
2011-09-14 22:20:50 +04:00
|
|
|
|
2010-01-06 23:52:05 +03:00
|
|
|
# The configuration to install.
|
2012-07-26 23:09:01 +04:00
|
|
|
config = { fileSystems, testChannel, grubVersion, grubDevice }: pkgs.writeText "configuration.nix"
|
2010-01-06 23:52:05 +03:00
|
|
|
''
|
|
|
|
{ config, pkgs, modulesPath, ... }:
|
|
|
|
|
2013-09-04 15:05:09 +04:00
|
|
|
{ imports =
|
2013-10-13 19:24:11 +04:00
|
|
|
[ ./hardware-configuration.nix
|
2014-03-30 18:52:56 +04:00
|
|
|
<nixpkgs/nixos/modules/testing/test-instrumentation.nix>
|
2010-01-06 23:52:05 +03:00
|
|
|
];
|
|
|
|
|
2012-04-11 13:42:53 +04:00
|
|
|
boot.loader.grub.version = ${toString grubVersion};
|
|
|
|
${optionalString (grubVersion == 1) ''
|
|
|
|
boot.loader.grub.splashImage = null;
|
|
|
|
''}
|
2012-07-26 23:09:01 +04:00
|
|
|
boot.loader.grub.device = "${grubDevice}";
|
2010-06-17 02:18:26 +04:00
|
|
|
boot.loader.grub.extraConfig = "serial; terminal_output.serial";
|
2010-01-10 04:26:01 +03:00
|
|
|
|
|
|
|
environment.systemPackages = [ ${optionalString testChannel "pkgs.rlwrap"} ];
|
2010-01-06 23:52:05 +03:00
|
|
|
}
|
|
|
|
'';
|
|
|
|
|
2010-01-07 16:19:38 +03:00
|
|
|
rootFS =
|
|
|
|
''
|
2012-11-16 01:55:00 +04:00
|
|
|
fileSystems."/".device = "/dev/disk/by-label/nixos";
|
2010-01-07 16:19:38 +03:00
|
|
|
'';
|
2011-09-14 22:20:50 +04:00
|
|
|
|
2010-01-07 16:19:38 +03:00
|
|
|
bootFS =
|
|
|
|
''
|
2012-11-16 01:55:00 +04:00
|
|
|
fileSystems."/boot".device = "/dev/disk/by-label/boot";
|
2010-01-07 16:19:38 +03:00
|
|
|
'';
|
|
|
|
|
2011-09-14 22:20:50 +04:00
|
|
|
|
2010-01-10 04:26:01 +03:00
|
|
|
# Configuration of a web server that simulates the Nixpkgs channel
|
|
|
|
# distribution server.
|
2011-09-14 22:20:50 +04:00
|
|
|
webserver =
|
2010-01-10 04:26:01 +03:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
{ services.httpd.enable = true;
|
|
|
|
services.httpd.adminAddr = "foo@example.org";
|
|
|
|
services.httpd.servedDirs = singleton
|
2013-06-14 16:04:17 +04:00
|
|
|
{ urlPath = "/";
|
2010-01-10 04:26:01 +03:00
|
|
|
dir = "/tmp/channel";
|
|
|
|
};
|
|
|
|
|
2010-08-24 16:59:16 +04:00
|
|
|
virtualisation.writableStore = true;
|
2013-09-16 15:24:49 +04:00
|
|
|
virtualisation.pathsInNixDB = channelContents ++ [ pkgs.hello.src ];
|
2013-07-12 17:17:35 +04:00
|
|
|
virtualisation.memorySize = 768;
|
2010-01-10 04:26:01 +03:00
|
|
|
};
|
|
|
|
|
2013-09-16 15:24:49 +04:00
|
|
|
channelContents = [ pkgs.rlwrap ];
|
2011-09-14 22:20:50 +04:00
|
|
|
|
2010-01-10 04:26:01 +03:00
|
|
|
|
2010-01-06 19:46:21 +03:00
|
|
|
# The test script boots the CD, installs NixOS on an empty hard
|
2010-01-07 17:19:19 +03:00
|
|
|
# disk, and then reboot from the hard disk. It's parameterized with
|
|
|
|
# a test script fragment `createPartitions', which must create
|
|
|
|
# partitions and filesystems, and a configuration.nix fragment
|
|
|
|
# `fileSystems'.
|
2012-07-26 23:09:01 +04:00
|
|
|
testScriptFun = { createPartitions, fileSystems, testChannel, grubVersion, grubDevice }:
|
|
|
|
let iface = if grubVersion == 1 then "scsi" else "virtio"; in
|
2010-01-06 16:36:21 +03:00
|
|
|
''
|
2010-01-06 17:37:23 +03:00
|
|
|
createDisk("harddisk", 4 * 1024);
|
2010-01-06 16:36:21 +03:00
|
|
|
|
2012-07-26 23:09:01 +04:00
|
|
|
my $machine = createMachine({ hda => "harddisk",
|
|
|
|
hdaInterface => "${iface}",
|
|
|
|
cdrom => glob("${iso}/iso/*.iso"),
|
2012-04-10 16:50:20 +04:00
|
|
|
qemuFlags => '${optionalString testChannel (toString (qemuNICFlags 1 1 2))} ${optionalString (pkgs.stdenv.system == "x86_64-linux") "-cpu kvm64"}'});
|
2010-01-10 04:26:01 +03:00
|
|
|
$machine->start;
|
2010-01-06 16:36:21 +03:00
|
|
|
|
2010-01-10 04:26:01 +03:00
|
|
|
${optionalString testChannel ''
|
|
|
|
# Create a channel on the web server containing a few packages
|
|
|
|
# to simulate the Nixpkgs channel.
|
|
|
|
$webserver->start;
|
2012-10-24 20:22:53 +04:00
|
|
|
$webserver->waitForUnit("httpd");
|
|
|
|
$webserver->succeed(
|
2012-11-16 19:34:22 +04:00
|
|
|
"nix-push --bzip2 --dest /tmp/channel --manifest --url-prefix http://nixos.org/channels/nixos-unstable " .
|
|
|
|
"${toString channelContents} >&2");
|
2013-09-16 15:24:49 +04:00
|
|
|
$webserver->succeed("mkdir /tmp/channel/sha256");
|
|
|
|
$webserver->succeed("cp ${pkgs.hello.src} /tmp/channel/sha256/${pkgs.hello.src.outputHash}");
|
2010-01-10 04:26:01 +03:00
|
|
|
''}
|
2011-09-14 22:20:50 +04:00
|
|
|
|
2010-01-06 17:37:23 +03:00
|
|
|
# Make sure that we get a login prompt etc.
|
2012-10-24 20:22:53 +04:00
|
|
|
$machine->succeed("echo hello");
|
2012-11-09 14:45:57 +04:00
|
|
|
#$machine->waitForUnit('getty@tty2');
|
2012-10-24 20:22:53 +04:00
|
|
|
$machine->waitForUnit("rogue");
|
|
|
|
$machine->waitForUnit("nixos-manual");
|
|
|
|
$machine->waitForUnit("dhcpcd");
|
2010-01-06 23:52:05 +03:00
|
|
|
|
2010-01-10 04:26:01 +03:00
|
|
|
${optionalString testChannel ''
|
|
|
|
# Allow the machine to talk to the fake nixos.org.
|
2012-10-24 20:22:53 +04:00
|
|
|
$machine->succeed(
|
2010-02-10 17:31:46 +03:00
|
|
|
"rm /etc/hosts",
|
2013-09-16 15:24:49 +04:00
|
|
|
"echo 192.168.1.1 nixos.org cache.nixos.org tarballs.nixos.org > /etc/hosts",
|
2010-01-10 04:26:01 +03:00
|
|
|
"ifconfig eth1 up 192.168.1.2",
|
|
|
|
);
|
|
|
|
|
|
|
|
# Test nix-env.
|
2012-10-24 20:22:53 +04:00
|
|
|
$machine->fail("hello");
|
|
|
|
$machine->succeed("nix-env -i hello");
|
|
|
|
$machine->succeed("hello") =~ /Hello, world/
|
2010-01-10 04:26:01 +03:00
|
|
|
or die "bad `hello' output";
|
|
|
|
''}
|
2010-01-06 19:46:21 +03:00
|
|
|
|
2010-01-06 17:37:23 +03:00
|
|
|
# Partition the disk.
|
2010-01-07 16:19:38 +03:00
|
|
|
${createPartitions}
|
2010-01-06 17:37:23 +03:00
|
|
|
|
2010-01-06 23:52:05 +03:00
|
|
|
# Create the NixOS configuration.
|
2012-10-24 20:22:53 +04:00
|
|
|
$machine->succeed(
|
2013-10-13 19:24:11 +04:00
|
|
|
"nixos-generate-config --root /mnt",
|
2010-01-06 19:46:21 +03:00
|
|
|
);
|
|
|
|
|
2013-10-13 19:24:11 +04:00
|
|
|
$machine->succeed("cat /mnt/etc/nixos/hardware-configuration.nix >&2");
|
2010-01-06 23:52:05 +03:00
|
|
|
|
2010-01-07 16:19:38 +03:00
|
|
|
$machine->copyFileFromHost(
|
2012-07-26 23:09:01 +04:00
|
|
|
"${ config { inherit fileSystems testChannel grubVersion grubDevice; } }",
|
2010-01-07 16:19:38 +03:00
|
|
|
"/mnt/etc/nixos/configuration.nix");
|
2010-01-06 19:46:21 +03:00
|
|
|
|
2010-01-06 23:52:05 +03:00
|
|
|
# Perform the installation.
|
2012-10-24 20:22:53 +04:00
|
|
|
$machine->succeed("nixos-install >&2");
|
2011-09-14 22:20:50 +04:00
|
|
|
|
2012-05-25 03:39:03 +04:00
|
|
|
# Do it again to make sure it's idempotent.
|
2012-10-24 20:22:53 +04:00
|
|
|
$machine->succeed("nixos-install >&2");
|
2012-05-25 03:39:03 +04:00
|
|
|
|
2010-01-06 17:37:23 +03:00
|
|
|
$machine->shutdown;
|
2010-01-06 18:14:26 +03:00
|
|
|
|
|
|
|
# Now see if we can boot the installation.
|
2012-07-26 23:09:01 +04:00
|
|
|
my $machine = createMachine({ hda => "harddisk", hdaInterface => "${iface}" });
|
2011-09-14 22:20:50 +04:00
|
|
|
|
2010-01-07 16:19:38 +03:00
|
|
|
# Did /boot get mounted, if appropriate?
|
2012-10-24 14:58:58 +04:00
|
|
|
$machine->waitForUnit("local-fs.target");
|
|
|
|
$machine->succeed("test -e /boot/grub");
|
2010-01-07 17:59:43 +03:00
|
|
|
|
|
|
|
# Did the swap device get activated?
|
2012-10-24 14:58:58 +04:00
|
|
|
$machine->waitForUnit("swap.target");
|
|
|
|
$machine->succeed("cat /proc/swaps | grep -q /dev");
|
2011-09-14 22:20:50 +04:00
|
|
|
|
2012-10-24 20:22:53 +04:00
|
|
|
$machine->succeed("nix-env -i coreutils >&2");
|
|
|
|
$machine->succeed("type -tP ls | tee /dev/stderr") =~ /.nix-profile/
|
2010-01-06 23:52:05 +03:00
|
|
|
or die "nix-env failed";
|
|
|
|
|
2012-10-24 20:22:53 +04:00
|
|
|
$machine->succeed("nixos-rebuild switch >&2");
|
2010-01-06 23:52:05 +03:00
|
|
|
|
2013-10-14 00:36:04 +04:00
|
|
|
# Test nixos-option.
|
|
|
|
$machine->succeed("nixos-option boot.initrd.kernelModules | grep virtio_console");
|
|
|
|
$machine->succeed("nixos-option -d boot.initrd.kernelModules | grep 'List of modules'");
|
|
|
|
$machine->succeed("nixos-option -l boot.initrd.kernelModules | grep /etc/nixos/configuration.nix");
|
|
|
|
|
2010-01-06 18:14:26 +03:00
|
|
|
$machine->shutdown;
|
2010-01-07 01:53:27 +03:00
|
|
|
|
|
|
|
# And just to be sure, check that the machine still boots after
|
|
|
|
# "nixos-rebuild switch".
|
2012-07-26 23:52:05 +04:00
|
|
|
my $machine = createMachine({ hda => "harddisk", hdaInterface => "${iface}" });
|
2012-10-24 20:22:53 +04:00
|
|
|
$machine->waitForUnit("network.target");
|
2010-01-07 01:53:27 +03:00
|
|
|
$machine->shutdown;
|
2010-01-06 18:14:26 +03:00
|
|
|
'';
|
2010-01-06 19:46:21 +03:00
|
|
|
|
2011-09-14 22:20:50 +04:00
|
|
|
|
2012-07-26 23:09:01 +04:00
|
|
|
makeTest = { createPartitions, fileSystems, testChannel ? false, grubVersion ? 2, grubDevice ? "/dev/vda" }:
|
2010-01-07 16:19:38 +03:00
|
|
|
{ inherit iso;
|
2010-01-10 04:26:01 +03:00
|
|
|
nodes = if testChannel then { inherit webserver; } else { };
|
|
|
|
testScript = testScriptFun {
|
2012-07-26 23:09:01 +04:00
|
|
|
inherit createPartitions fileSystems testChannel grubVersion grubDevice;
|
2010-01-10 04:26:01 +03:00
|
|
|
};
|
2010-01-07 16:19:38 +03:00
|
|
|
};
|
2011-09-14 22:20:50 +04:00
|
|
|
|
2010-01-07 16:19:38 +03:00
|
|
|
|
|
|
|
in {
|
|
|
|
|
2010-05-17 00:44:45 +04:00
|
|
|
# !!! `parted mkpart' seems to silently create overlapping partitions.
|
|
|
|
|
|
|
|
|
2010-01-07 16:19:38 +03:00
|
|
|
# The (almost) simplest partitioning scheme: a swap partition and
|
|
|
|
# one big filesystem partition.
|
|
|
|
simple = makeTest
|
2011-09-14 22:20:50 +04:00
|
|
|
{ createPartitions =
|
2010-01-07 16:19:38 +03:00
|
|
|
''
|
2012-10-24 20:22:53 +04:00
|
|
|
$machine->succeed(
|
2010-01-07 16:19:38 +03: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",
|
|
|
|
);
|
|
|
|
'';
|
|
|
|
fileSystems = rootFS;
|
2010-01-10 04:26:01 +03:00
|
|
|
testChannel = true;
|
2010-01-07 16:19:38 +03:00
|
|
|
};
|
2011-09-14 22:20:50 +04:00
|
|
|
|
2010-01-07 16:19:38 +03:00
|
|
|
# Same as the previous, but now with a separate /boot partition.
|
|
|
|
separateBoot = makeTest
|
|
|
|
{ createPartitions =
|
|
|
|
''
|
2012-10-24 20:22:53 +04:00
|
|
|
$machine->succeed(
|
2010-01-07 16:19:38 +03: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 17:43:45 +04:00
|
|
|
"mkdir -p /mnt/boot",
|
2010-01-07 16:19:38 +03:00
|
|
|
"mount LABEL=boot /mnt/boot",
|
|
|
|
);
|
|
|
|
'';
|
|
|
|
fileSystems = rootFS + bootFS;
|
|
|
|
};
|
2011-09-14 22:20:50 +04:00
|
|
|
|
2010-01-07 17:19:19 +03:00
|
|
|
# Create two physical LVM partitions combined into one volume group
|
2012-08-01 23:40:58 +04:00
|
|
|
# that contains the logical swap and root partitions.
|
2010-01-07 17:19:19 +03:00
|
|
|
lvm = makeTest
|
|
|
|
{ createPartitions =
|
|
|
|
''
|
2012-10-24 20:22:53 +04:00
|
|
|
$machine->succeed(
|
2010-01-07 17:19:19 +03:00
|
|
|
"parted /dev/vda mklabel msdos",
|
2014-02-09 20:59:02 +04:00
|
|
|
"parted /dev/vda -- mkpart primary 1M 2048M", # PV1
|
2010-01-07 17:59:43 +03:00
|
|
|
"parted /dev/vda -- set 1 lvm on",
|
2014-02-09 20:59:02 +04:00
|
|
|
"parted /dev/vda -- mkpart primary 2048M -1s", # PV2
|
2010-01-10 18:22:09 +03:00
|
|
|
"parted /dev/vda -- set 2 lvm on",
|
2010-01-10 22:19:52 +03:00
|
|
|
"udevadm settle",
|
2012-08-01 23:40:58 +04:00
|
|
|
"pvcreate /dev/vda1 /dev/vda2",
|
|
|
|
"vgcreate MyVolGroup /dev/vda1 /dev/vda2",
|
2010-01-07 17:19:19 +03: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 23:52:05 +04:00
|
|
|
"mkfs.xfs -L nixos /dev/MyVolGroup/nixos",
|
2010-01-07 17:19:19 +03:00
|
|
|
"mount LABEL=nixos /mnt",
|
|
|
|
);
|
|
|
|
'';
|
2012-08-01 23:40:58 +04:00
|
|
|
fileSystems = rootFS;
|
2010-01-07 17:19:19 +03:00
|
|
|
};
|
2010-05-17 00:44:45 +04:00
|
|
|
|
2013-09-16 13:31:09 +04:00
|
|
|
/*
|
2010-05-17 00:44:45 +04:00
|
|
|
swraid = makeTest
|
|
|
|
{ createPartitions =
|
|
|
|
''
|
2012-10-24 20:22:53 +04:00
|
|
|
$machine->succeed(
|
2010-07-13 15:57:12 +04:00
|
|
|
"parted /dev/vda --"
|
|
|
|
. " mklabel msdos"
|
|
|
|
. " mkpart primary ext2 1M 30MB" # /boot
|
|
|
|
. " mkpart extended 30M -1s"
|
2010-07-22 01:20:42 +04: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-17 00:44:45 +04:00
|
|
|
"udevadm settle",
|
2010-07-13 15:57:12 +04:00
|
|
|
"ls -l /dev/vda* >&2",
|
|
|
|
"cat /proc/partitions >&2",
|
2010-06-20 20:05:15 +04: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-21 01:45:24 +04:00
|
|
|
"udevadm settle",
|
2010-05-17 00:44:45 +04:00
|
|
|
"mkswap -f /dev/md1 -L swap",
|
|
|
|
"swapon -L swap",
|
|
|
|
"mkfs.ext3 -L nixos /dev/md0",
|
|
|
|
"mount LABEL=nixos /mnt",
|
2010-06-20 20:05:15 +04:00
|
|
|
"mkfs.ext3 -L boot /dev/vda1",
|
|
|
|
"mkdir /mnt/boot",
|
|
|
|
"mount LABEL=boot /mnt/boot",
|
2012-03-21 01:45:24 +04: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-17 00:44:45 +04:00
|
|
|
);
|
|
|
|
'';
|
2010-06-20 20:05:15 +04:00
|
|
|
fileSystems = rootFS + bootFS;
|
2010-05-17 00:44:45 +04:00
|
|
|
};
|
2013-09-16 13:31:09 +04:00
|
|
|
*/
|
2010-09-25 13:32:22 +04:00
|
|
|
|
2012-04-11 13:42:53 +04:00
|
|
|
# Test a basic install using GRUB 1.
|
|
|
|
grub1 = makeTest
|
|
|
|
{ createPartitions =
|
|
|
|
''
|
2012-10-24 20:22:53 +04:00
|
|
|
$machine->succeed(
|
2012-07-26 23:09:01 +04: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 13:42:53 +04:00
|
|
|
"udevadm settle",
|
2012-07-26 23:09:01 +04:00
|
|
|
"mkswap /dev/sda1 -L swap",
|
2012-04-11 13:42:53 +04:00
|
|
|
"swapon -L swap",
|
2012-07-26 23:09:01 +04:00
|
|
|
"mkfs.ext3 -L nixos /dev/sda2",
|
2012-04-11 13:42:53 +04:00
|
|
|
"mount LABEL=nixos /mnt",
|
|
|
|
);
|
2014-01-20 00:07:35 +04:00
|
|
|
|
2012-04-11 13:42:53 +04:00
|
|
|
'';
|
|
|
|
fileSystems = rootFS;
|
|
|
|
grubVersion = 1;
|
2012-07-26 23:09:01 +04:00
|
|
|
grubDevice = "/dev/sda";
|
2012-04-11 13:42:53 +04:00
|
|
|
};
|
|
|
|
|
2010-09-25 13:32:22 +04:00
|
|
|
# Rebuild the CD configuration with a little modification.
|
2011-09-14 22:20:50 +04:00
|
|
|
rebuildCD =
|
2010-09-25 13:32:22 +04:00
|
|
|
{ inherit iso;
|
|
|
|
nodes = { };
|
|
|
|
testScript =
|
2010-10-13 02:03:50 +04:00
|
|
|
''
|
2013-07-09 18:12:34 +04:00
|
|
|
my $machine = createMachine({ cdrom => glob("${iso}/iso/*.iso"), qemuFlags => '-m 768' });
|
2010-10-13 02:03:50 +04:00
|
|
|
$machine->start;
|
2010-09-25 13:32:22 +04:00
|
|
|
|
2010-10-13 02:03:50 +04:00
|
|
|
# Enable sshd service.
|
2012-10-24 20:22:53 +04:00
|
|
|
$machine->succeed(
|
2013-07-09 18:12:34 +04:00
|
|
|
"sed -i 's,^}\$,systemd.services.sshd.wantedBy = pkgs.lib.mkOverride 0 [\"multi-user.target\"]; },' /etc/nixos/configuration.nix"
|
2010-10-13 02:03:50 +04:00
|
|
|
);
|
2010-09-25 13:32:22 +04:00
|
|
|
|
2013-07-09 17:29:29 +04:00
|
|
|
$machine->succeed("cat /etc/nixos/configuration.nix >&2");
|
2010-09-25 13:32:22 +04:00
|
|
|
|
2010-10-13 02:03:50 +04:00
|
|
|
# Apply the new CD configuration.
|
2012-10-24 20:22:53 +04:00
|
|
|
$machine->succeed("nixos-rebuild test");
|
2010-09-25 13:32:22 +04:00
|
|
|
|
2010-10-13 02:03:50 +04:00
|
|
|
# Connect to it-self.
|
2013-07-09 18:12:34 +04:00
|
|
|
$machine->waitForUnit("sshd");
|
|
|
|
$machine->waitForOpenPort(22);
|
2010-09-25 13:32:22 +04:00
|
|
|
|
2010-10-13 02:03:50 +04:00
|
|
|
$machine->shutdown;
|
|
|
|
'';
|
2010-09-25 13:32:22 +04:00
|
|
|
};
|
2010-01-06 16:36:21 +03:00
|
|
|
}
|