git.iko.soy/typeable/nixpkgs
on master help sign in
nixos: Make nesting.children work in NixOS tests

We differentiate between modules and baseModules in the VM builder for NixOS tests. This way, nesting.children, eventhough it doesn't inherit from parent, still has enough config to actually complete the test. Otherwise, the qemu modules would not be loaded, for example, and a nesting.children statement would not evaluate.

commitcbc45b5981f26c80e7d78e9525373b1388b7e516 authorArian van Putten <aeroboy94@gmail.com> dateSun 26 May 2019, 00:52 (7 years ago) parenta48047a
2 files changed+36−16
nixos/lib/build-vms.nix+3−3 nixos/tests/nesting.nix+33−13
nixos/lib/build-vms.nix+3−3
@@ -32,14 +32,14 @@ rec {
3232
3333 import ./eval-config.nix {
3434 inherit system;
35− modules = configurations ++
35+ modules = configurations ++ extraConfigurations;
36+ baseModules = (import ../modules/module-list.nix) ++
3637 [ ../modules/virtualisation/qemu-vm.nix
3738 ../modules/testing/test-instrumentation.nix # !!! should only get added for automated test runs
3839 { key = "no-manual"; documentation.nixos.enable = false; }
3940 { key = "qemu"; system.build.qemu = qemu; }
4041 { key = "nodes"; _module.args.nodes = nodes; }
41− ] ++ optional minimal ../modules/testing/minimal-kernel.nix
42− ++ extraConfigurations;
42+ ] ++ optional minimal ../modules/testing/minimal-kernel.nix;
4343 };
4444
4545
nixos/tests/nesting.nix+33−13
@@ -1,22 +1,42 @@
11import ./make-test.nix {
22 name = "nesting";
3− machine = { pkgs, ... }: {
4− environment.systemPackages = [ pkgs.cowsay ];
5− nesting.clone = [
6− ({ pkgs, ... }: {
7− environment.systemPackages = [ pkgs.hello ];
8− })
9− ];
3+ nodes = {
4+ clone = { pkgs, ... }: {
5+ environment.systemPackages = [ pkgs.cowsay ];
6+ nesting.clone = [
7+ ({ pkgs, ... }: {
8+ environment.systemPackages = [ pkgs.hello ];
9+ })
10+ ];
11+ };
12+ children = { pkgs, ... }: {
13+ environment.systemPackages = [ pkgs.cowsay ];
14+ nesting.children = [
15+ ({ pkgs, ... }: {
16+ environment.systemPackages = [ pkgs.hello ];
17+ })
18+ ];
19+ };
1020 };
1121 testScript = ''
12− $machine->waitForUnit("default.target");
13− $machine->succeed("cowsay hey");
14− $machine->fail("hello");
22+ $clone->waitForUnit("default.target");
23+ $clone->succeed("cowsay hey");
24+ $clone->fail("hello");
1525
1626 # Nested clones do inherit from parent
17− $machine->succeed("/run/current-system/fine-tune/child-1/bin/switch-to-configuration test");
18− $machine->succeed("cowsay hey");
19− $machine->succeed("hello");
27+ $clone->succeed("/run/current-system/fine-tune/child-1/bin/switch-to-configuration test");
28+ $clone->succeed("cowsay hey");
29+ $clone->succeed("hello");
30+
31+
32+ $children->waitForUnit("default.target");
33+ $children->succeed("cowsay hey");
34+ $children->fail("hello");
35+
36+ # Nested children do not inherit from parent
37+ $children->succeed("/run/current-system/fine-tune/child-1/bin/switch-to-configuration test");
38+ $children->fail("cowsay hey");
39+ $children->succeed("hello");
2040
2141 '';
2242}