about summary refs log tree commit diff
path: root/nixos/tests/specialisation.nix
blob: b8d4b8279f4da2c1ab1637360cadd8b546e34cac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import ./make-test-python.nix {
  name = "specialisation";
  nodes =  {
    inheritconf = { pkgs, ... }: {
      environment.systemPackages = [ pkgs.cowsay ];
      specialisation.inheritconf.configuration = { pkgs, ... }: {
        environment.systemPackages = [ pkgs.hello ];
      };
    };
    noinheritconf = { pkgs, ... }: {
      environment.systemPackages = [ pkgs.cowsay ];
      specialisation.noinheritconf = {
        inheritParentConfig = false;
        configuration = { pkgs, ... }: {
          environment.systemPackages = [ pkgs.hello ];
        };
      };
    };
  };
  testScript = ''
    inheritconf.wait_for_unit("default.target")
    inheritconf.succeed("cowsay hey")
    inheritconf.fail("hello")

    with subtest("Nested clones do inherit from parent"):
        inheritconf.succeed(
            "/run/current-system/specialisation/inheritconf/bin/switch-to-configuration test"
        )
        inheritconf.succeed("cowsay hey")
        inheritconf.succeed("hello")

        noinheritconf.wait_for_unit("default.target")
        noinheritconf.succeed("cowsay hey")
        noinheritconf.fail("hello")

    with subtest("Nested children do not inherit from parent"):
        noinheritconf.succeed(
            "/run/current-system/specialisation/noinheritconf/bin/switch-to-configuration test"
        )
        noinheritconf.fail("cowsay hey")
        noinheritconf.succeed("hello")
  '';
}