about summary refs log tree commit diff
path: root/nixos/tests
diff options
context:
space:
mode:
authoraszlig <aszlig@redmoonstudios.org>2015-05-21 12:37:14 +0200
committeraszlig <aszlig@redmoonstudios.org>2015-05-21 13:21:40 +0200
commit5d2c6f0353a2c85a755299c28d78cd2de493856f (patch)
tree7facff59703287a092bf59d96fa1022e84ad64a5 /nixos/tests
parent478e1d6f14123cdddc3132dba7bb662fe1d8cd40 (diff)
downloadnixlib-5d2c6f0353a2c85a755299c28d78cd2de493856f.tar
nixlib-5d2c6f0353a2c85a755299c28d78cd2de493856f.tar.gz
nixlib-5d2c6f0353a2c85a755299c28d78cd2de493856f.tar.bz2
nixlib-5d2c6f0353a2c85a755299c28d78cd2de493856f.tar.lz
nixlib-5d2c6f0353a2c85a755299c28d78cd2de493856f.tar.xz
nixlib-5d2c6f0353a2c85a755299c28d78cd2de493856f.tar.zst
nixlib-5d2c6f0353a2c85a755299c28d78cd2de493856f.zip
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>
Diffstat (limited to 'nixos/tests')
-rw-r--r--nixos/tests/installer.nix21
1 files changed, 14 insertions, 7 deletions
diff --git a/nixos/tests/installer.nix b/nixos/tests/installer.nix
index af87705b9279..db029a5cc845 100644
--- a/nixos/tests/installer.nix
+++ b/nixos/tests/installer.nix
@@ -45,7 +45,8 @@ let
 
   # The configuration to install.
   makeConfig = { testChannel, grubVersion, grubDevice, grubIdentifier
-    , readOnly ? true, forceGrubReinstallCount ? 0 }:
+               , extraConfig, readOnly ? true, forceGrubReinstallCount ? 0
+               }:
     pkgs.writeText "configuration.nix" ''
       { config, lib, pkgs, modulesPath, ... }:
 
@@ -70,6 +71,7 @@ let
         environment.systemPackages = [ ${optionalString testChannel "pkgs.rlwrap"} ];
 
         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
   # a test script fragment `createPartitions', which must create
   # partitions and filesystems.
-  testScriptFun = { createPartitions, testChannel, grubVersion, grubDevice, grubIdentifier }:
+  testScriptFun = { createPartitions, testChannel, grubVersion, grubDevice
+                  , grubIdentifier, extraConfig
+                  }:
     let
       # 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";
@@ -172,7 +176,7 @@ let
       $machine->succeed("cat /mnt/etc/nixos/hardware-configuration.nix >&2");
 
       $machine->copyFileFromHost(
-          "${ makeConfig { inherit testChannel grubVersion grubDevice grubIdentifier; } }",
+          "${ makeConfig { inherit testChannel grubVersion grubDevice grubIdentifier extraConfig; } }",
           "/mnt/etc/nixos/configuration.nix");
 
       # Perform the installation.
@@ -210,7 +214,7 @@ let
 
       # We need to a writable nix-store on next boot
       $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");
 
       # Check whether nixos-rebuild works.
@@ -227,7 +231,7 @@ let
       $machine = createMachine({ ${hdFlags} qemuFlags => "${qemuFlags}" });
       $machine->waitForUnit("multi-user.target");
       $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");
       $machine->succeed("nixos-rebuild boot >&2");
       $machine->shutdown;
@@ -241,13 +245,16 @@ let
 
 
   makeInstallerTest = name:
-    { createPartitions, testChannel ? false, grubVersion ? 2, grubDevice ? "/dev/vda", grubIdentifier ? "uuid" }:
+    { createPartitions, testChannel ? false, grubVersion ? 2
+    , grubDevice ? "/dev/vda", grubIdentifier ? "uuid", extraConfig ? ""
+    }:
     makeTest {
       inherit iso;
       name = "installer-" + name;
       nodes = if testChannel then { inherit webserver; } else { };
       testScript = testScriptFun {
-        inherit createPartitions testChannel grubVersion grubDevice grubIdentifier;
+        inherit createPartitions testChannel grubVersion grubDevice
+                grubIdentifier extraConfig;
       };
     };