From a48047a755047b34471a740dffa07744221d63c2 Mon Sep 17 00:00:00 2001 From: Arian van Putten Date: Sun, 26 May 2019 00:35:29 +0200 Subject: [PATCH] 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. --- nixos/tests/all-tests.nix | 1 + nixos/tests/nesting.nix | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 nixos/tests/nesting.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 9bce49c9e30..10a381c2c8f 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -161,6 +161,7 @@ in nat.standalone = handleTest ./nat.nix { withFirewall = false; }; ndppd = handleTest ./ndppd.nix {}; neo4j = handleTest ./neo4j.nix {}; + nesting = handleTest ./nesting.nix {}; netdata = handleTest ./netdata.nix {}; networking.networkd = handleTest ./networking.nix { networkd = true; }; networking.scripted = handleTest ./networking.nix { networkd = false; }; diff --git a/nixos/tests/nesting.nix b/nixos/tests/nesting.nix new file mode 100644 index 00000000000..3be64d7a9b5 --- /dev/null +++ b/nixos/tests/nesting.nix @@ -0,0 +1,22 @@ +import ./make-test.nix { + name = "nesting"; + machine = { pkgs, ... }: { + environment.systemPackages = [ pkgs.cowsay ]; + nesting.clone = [ + ({ pkgs, ... }: { + environment.systemPackages = [ pkgs.hello ]; + }) + ]; + }; + testScript = '' + $machine->waitForUnit("default.target"); + $machine->succeed("cowsay hey"); + $machine->fail("hello"); + + # Nested clones do inherit from parent + $machine->succeed("/run/current-system/fine-tune/child-1/bin/switch-to-configuration test"); + $machine->succeed("cowsay hey"); + $machine->succeed("hello"); + + ''; +}