1 { system ? builtins.currentSystem
3 , pkgs ? import ../.. { inherit system config; }
7 with import ../lib/testing-python.nix { inherit system pkgs; };
10 inherit (lib.maintainers) elvishjerricco;
13 boot.initrd.systemd = {
15 network.wait-online.timeout = 10;
16 network.wait-online.anyInterface = true;
17 targets.network-online.requiredBy = [ "initrd.target" ];
18 services.systemd-networkd-wait-online.requiredBy =
19 [ "network-online.target" ];
20 initrdBin = [ pkgs.iproute2 pkgs.iputils pkgs.gnugrep ];
22 testing.initrdBackdoor = true;
23 boot.initrd.network.enable = true;
26 mkFlushTest = flush: script: makeTest {
27 name = "systemd-initrd-network-${lib.optionalString (!flush) "no-"}flush";
28 meta.maintainers = [ elvishjerricco ];
33 boot.initrd.network.flushBeforeStage2 = flush;
34 systemd.services.check-flush = {
35 requiredBy = ["multi-user.target"];
36 before = [ "network-pre.target" "multi-user.target" "shutdown.target" ];
37 conflicts = [ "shutdown.target" ];
38 wants = ["network-pre.target"];
39 unitConfig.DefaultDependencies = false;
40 serviceConfig.Type = "oneshot";
41 path = [ pkgs.iproute2 pkgs.iputils pkgs.gnugrep ];
47 machine.wait_for_unit("network-online.target")
49 "ip addr | grep 10.0.2.15",
54 machine.wait_for_unit("multi-user.target")
60 name = "systemd-initrd-network";
61 meta.maintainers = [ elvishjerricco ];
63 nodes.machine = common;
66 machine.wait_for_unit("network-online.target")
68 "ip addr | grep 10.0.2.15",
73 # Make sure the systemd-network user was set correctly in initrd
74 machine.wait_for_unit("multi-user.target")
75 machine.succeed("[ $(stat -c '%U,%G' /run/systemd/netif/links) = systemd-network,systemd-network ]")
76 machine.succeed("ip addr show >&2")
77 machine.succeed("ip route show >&2")
81 doFlush = mkFlushTest true ''
82 if ip addr | grep 10.0.2.15; then
83 echo "Network configuration survived switch-root; flushBeforeStage2 failed"
88 dontFlush = mkFlushTest false ''
89 if ! (ip addr | grep 10.0.2.15); then
90 echo "Network configuration didn't survive switch-root"