1let
2 mkIfStateConfig = id: {
3 enable = true;
4 settings.interfaces.eth1 = {
5 addresses = [ "2001:0db8::${builtins.toString id}/64" ];
6 link = {
7 state = "up";
8 kind = "physical";
9 };
10 };
11 };
12in
13{
14 name = "ifstate-initrd";
15
16 nodes = {
17 server = {
18 imports = [ ../../modules/profiles/minimal.nix ];
19
20 virtualisation.interfaces.eth1.vlan = 1;
21
22 # Initrd IfState enforces stage 2 ifstate using assertion.
23 networking.ifstate = {
24 enable = true;
25 settings.interfaces = { };
26 };
27
28 boot.initrd = {
29 network = {
30 enable = true;
31 ifstate = mkIfStateConfig 1 // {
32 allowIfstateToDrasticlyIncreaseInitrdSize = true;
33 };
34 };
35 systemd = {
36 enable = true;
37 network.enable = false;
38 services.boot-blocker = {
39 before = [ "initrd.target" ];
40 wantedBy = [ "initrd.target" ];
41 script = "sleep infinity";
42 serviceConfig.Type = "oneshot";
43 };
44 };
45 };
46 };
47
48 client = {
49 imports = [ ../../modules/profiles/minimal.nix ];
50
51 virtualisation.interfaces.eth1.vlan = 1;
52
53 networking.ifstate = mkIfStateConfig 2;
54 };
55 };
56
57 testScript = # python
58 ''
59 start_all()
60 client.wait_for_unit("network.target")
61
62 # try to ping the server from the client
63 client.wait_until_succeeds("ping -c 1 2001:0db8::1")
64 '';
65}