git.iko.soy/typeable/nixpkgs
on master help sign in
nixos: Add test that demonstrates how to use nesting.clone

This is actually very useful. Allows you to test switch-to-configuration nesting.children is still currently still broken as it will throw away 'too much' of the config, including the modules that make nixos tests work in the first place. But that's something for another time.

commita48047a755047b34471a740dffa07744221d63c2 authorArian van Putten <aeroboy94@gmail.com> dateSun 26 May 2019, 00:35 (7 years ago) parentd50b434
2 files changed+23
nixos/tests/all-tests.nix+1 nixos/tests/nesting.nix+22
nixos/tests/all-tests.nix+1
@@ -161,6 +161,7 @@ in
161161 nat.standalone = handleTest ./nat.nix { withFirewall = false; };
162162 ndppd = handleTest ./ndppd.nix {};
163163 neo4j = handleTest ./neo4j.nix {};
164+ nesting = handleTest ./nesting.nix {};
164165 netdata = handleTest ./netdata.nix {};
165166 networking.networkd = handleTest ./networking.nix { networkd = true; };
166167 networking.scripted = handleTest ./networking.nix { networkd = false; };
nixos/tests/nesting.nixnew file+22
@@ -0,0 +1,22 @@
1+import ./make-test.nix {
2+ name = "nesting";
3+ machine = { pkgs, ... }: {
4+ environment.systemPackages = [ pkgs.cowsay ];
5+ nesting.clone = [
6+ ({ pkgs, ... }: {
7+ environment.systemPackages = [ pkgs.hello ];
8+ })
9+ ];
10+ };
11+ testScript = ''
12+ $machine->waitForUnit("default.target");
13+ $machine->succeed("cowsay hey");
14+ $machine->fail("hello");
15+
16+ # 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");
20+
21+ '';
22+}