nixos/tests/installer: Allow to pass extra config.
We're going to need it for installer tests where nixos-generate-config isn't yet able to fully detect the filesystems/hardware. for example for device mapper configurations other than LVM. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
parent
478e1d6f14
commit
5d2c6f0353
@ -45,7 +45,8 @@ let
|
|||||||
|
|
||||||
# The configuration to install.
|
# The configuration to install.
|
||||||
makeConfig = { testChannel, grubVersion, grubDevice, grubIdentifier
|
makeConfig = { testChannel, grubVersion, grubDevice, grubIdentifier
|
||||||
, readOnly ? true, forceGrubReinstallCount ? 0 }:
|
, extraConfig, readOnly ? true, forceGrubReinstallCount ? 0
|
||||||
|
}:
|
||||||
pkgs.writeText "configuration.nix" ''
|
pkgs.writeText "configuration.nix" ''
|
||||||
{ config, lib, pkgs, modulesPath, ... }:
|
{ config, lib, pkgs, modulesPath, ... }:
|
||||||
|
|
||||||
@ -70,6 +71,7 @@ let
|
|||||||
environment.systemPackages = [ ${optionalString testChannel "pkgs.rlwrap"} ];
|
environment.systemPackages = [ ${optionalString testChannel "pkgs.rlwrap"} ];
|
||||||
|
|
||||||
nix.binaryCaches = [ http://cache.nixos.org/ ];
|
nix.binaryCaches = [ http://cache.nixos.org/ ];
|
||||||
|
${replaceChars ["\n"] ["\n "] extraConfig}
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
@ -106,7 +108,9 @@ let
|
|||||||
# disk, and then reboot from the hard disk. It's parameterized with
|
# disk, and then reboot from the hard disk. It's parameterized with
|
||||||
# a test script fragment `createPartitions', which must create
|
# a test script fragment `createPartitions', which must create
|
||||||
# partitions and filesystems.
|
# partitions and filesystems.
|
||||||
testScriptFun = { createPartitions, testChannel, grubVersion, grubDevice, grubIdentifier }:
|
testScriptFun = { createPartitions, testChannel, grubVersion, grubDevice
|
||||||
|
, grubIdentifier, extraConfig
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
# FIXME: OVMF doesn't boot from virtio http://www.mail-archive.com/edk2-devel@lists.sourceforge.net/msg01501.html
|
# FIXME: OVMF doesn't boot from virtio http://www.mail-archive.com/edk2-devel@lists.sourceforge.net/msg01501.html
|
||||||
iface = if grubVersion == 1 then "scsi" else "virtio";
|
iface = if grubVersion == 1 then "scsi" else "virtio";
|
||||||
@ -172,7 +176,7 @@ let
|
|||||||
$machine->succeed("cat /mnt/etc/nixos/hardware-configuration.nix >&2");
|
$machine->succeed("cat /mnt/etc/nixos/hardware-configuration.nix >&2");
|
||||||
|
|
||||||
$machine->copyFileFromHost(
|
$machine->copyFileFromHost(
|
||||||
"${ makeConfig { inherit testChannel grubVersion grubDevice grubIdentifier; } }",
|
"${ makeConfig { inherit testChannel grubVersion grubDevice grubIdentifier extraConfig; } }",
|
||||||
"/mnt/etc/nixos/configuration.nix");
|
"/mnt/etc/nixos/configuration.nix");
|
||||||
|
|
||||||
# Perform the installation.
|
# Perform the installation.
|
||||||
@ -210,7 +214,7 @@ let
|
|||||||
|
|
||||||
# We need to a writable nix-store on next boot
|
# We need to a writable nix-store on next boot
|
||||||
$machine->copyFileFromHost(
|
$machine->copyFileFromHost(
|
||||||
"${ makeConfig { inherit testChannel grubVersion grubDevice grubIdentifier; readOnly = false; forceGrubReinstallCount = 1; } }",
|
"${ makeConfig { inherit testChannel grubVersion grubDevice grubIdentifier extraConfig; readOnly = false; forceGrubReinstallCount = 1; } }",
|
||||||
"/etc/nixos/configuration.nix");
|
"/etc/nixos/configuration.nix");
|
||||||
|
|
||||||
# Check whether nixos-rebuild works.
|
# Check whether nixos-rebuild works.
|
||||||
@ -227,7 +231,7 @@ let
|
|||||||
$machine = createMachine({ ${hdFlags} qemuFlags => "${qemuFlags}" });
|
$machine = createMachine({ ${hdFlags} qemuFlags => "${qemuFlags}" });
|
||||||
$machine->waitForUnit("multi-user.target");
|
$machine->waitForUnit("multi-user.target");
|
||||||
$machine->copyFileFromHost(
|
$machine->copyFileFromHost(
|
||||||
"${ makeConfig { inherit testChannel grubVersion grubDevice grubIdentifier; readOnly = false; forceGrubReinstallCount = 2; } }",
|
"${ makeConfig { inherit testChannel grubVersion grubDevice grubIdentifier extraConfig; readOnly = false; forceGrubReinstallCount = 2; } }",
|
||||||
"/etc/nixos/configuration.nix");
|
"/etc/nixos/configuration.nix");
|
||||||
$machine->succeed("nixos-rebuild boot >&2");
|
$machine->succeed("nixos-rebuild boot >&2");
|
||||||
$machine->shutdown;
|
$machine->shutdown;
|
||||||
@ -241,13 +245,16 @@ let
|
|||||||
|
|
||||||
|
|
||||||
makeInstallerTest = name:
|
makeInstallerTest = name:
|
||||||
{ createPartitions, testChannel ? false, grubVersion ? 2, grubDevice ? "/dev/vda", grubIdentifier ? "uuid" }:
|
{ createPartitions, testChannel ? false, grubVersion ? 2
|
||||||
|
, grubDevice ? "/dev/vda", grubIdentifier ? "uuid", extraConfig ? ""
|
||||||
|
}:
|
||||||
makeTest {
|
makeTest {
|
||||||
inherit iso;
|
inherit iso;
|
||||||
name = "installer-" + name;
|
name = "installer-" + name;
|
||||||
nodes = if testChannel then { inherit webserver; } else { };
|
nodes = if testChannel then { inherit webserver; } else { };
|
||||||
testScript = testScriptFun {
|
testScript = testScriptFun {
|
||||||
inherit createPartitions testChannel grubVersion grubDevice grubIdentifier;
|
inherit createPartitions testChannel grubVersion grubDevice
|
||||||
|
grubIdentifier extraConfig;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user