2018-11-11 09:41:11 +01:00
|
|
|
{ system ? builtins.currentSystem,
|
|
|
|
config ? {},
|
|
|
|
pkgs ? import ../.. { inherit system config; }
|
|
|
|
}:
|
2018-02-09 19:40:39 +01:00
|
|
|
|
2018-04-29 15:28:33 +02:00
|
|
|
let
|
2019-12-01 03:16:32 +01:00
|
|
|
inherit (import ../lib/testing-python.nix { inherit system pkgs; }) makeTest;
|
2021-01-28 23:03:02 +01:00
|
|
|
testCombinations = pkgs.lib.cartesianProductOfSets {
|
|
|
|
predictable = [true false];
|
|
|
|
withNetworkd = [true false];
|
2022-06-29 07:01:59 +02:00
|
|
|
systemdStage1 = [true false];
|
2021-01-28 23:03:02 +01:00
|
|
|
};
|
2022-06-29 07:01:59 +02:00
|
|
|
in pkgs.lib.listToAttrs (builtins.map ({ predictable, withNetworkd, systemdStage1 }: {
|
2018-04-29 15:28:33 +02:00
|
|
|
name = pkgs.lib.optionalString (!predictable) "un" + "predictable"
|
2022-06-29 07:01:59 +02:00
|
|
|
+ pkgs.lib.optionalString withNetworkd "Networkd"
|
|
|
|
+ pkgs.lib.optionalString systemdStage1 "SystemdStage1";
|
2018-04-29 15:28:33 +02:00
|
|
|
value = makeTest {
|
2022-06-29 07:01:59 +02:00
|
|
|
name = pkgs.lib.optionalString (!predictable) "un" + "predictableInterfaceNames"
|
|
|
|
+ pkgs.lib.optionalString withNetworkd "-with-networkd"
|
|
|
|
+ pkgs.lib.optionalString systemdStage1 "-systemd-stage-1";
|
2018-04-29 15:28:33 +02:00
|
|
|
meta = {};
|
|
|
|
|
2022-06-29 07:01:59 +02:00
|
|
|
nodes.machine = { lib, ... }: let
|
|
|
|
script = ''
|
|
|
|
ip link
|
|
|
|
if ${lib.optionalString predictable "!"} ip link show eth0; then
|
|
|
|
echo Success
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
in {
|
2018-04-29 15:28:33 +02:00
|
|
|
networking.usePredictableInterfaceNames = lib.mkForce predictable;
|
|
|
|
networking.useNetworkd = withNetworkd;
|
|
|
|
networking.dhcpcd.enable = !withNetworkd;
|
2019-09-23 16:37:58 +02:00
|
|
|
networking.useDHCP = !withNetworkd;
|
2019-09-22 17:14:47 +02:00
|
|
|
|
|
|
|
# Check if predictable interface names are working in stage-1
|
2023-11-01 20:09:25 +01:00
|
|
|
boot.initrd.postDeviceCommands = lib.mkIf (!systemdStage1) script;
|
2022-06-29 07:01:59 +02:00
|
|
|
|
|
|
|
boot.initrd.systemd = lib.mkIf systemdStage1 {
|
|
|
|
enable = true;
|
|
|
|
initrdBin = [ pkgs.iproute2 ];
|
|
|
|
services.systemd-udev-settle.wantedBy = ["initrd.target"];
|
|
|
|
services.check-interfaces = {
|
|
|
|
requiredBy = ["initrd.target"];
|
|
|
|
after = ["systemd-udev-settle.service"];
|
|
|
|
serviceConfig.Type = "oneshot";
|
|
|
|
path = [ pkgs.iproute2 ];
|
|
|
|
inherit script;
|
|
|
|
};
|
|
|
|
};
|
2018-04-29 15:28:33 +02:00
|
|
|
};
|
2018-02-09 19:40:39 +01:00
|
|
|
|
2018-04-29 15:28:33 +02:00
|
|
|
testScript = ''
|
2019-12-01 03:16:32 +01:00
|
|
|
print(machine.succeed("ip link"))
|
|
|
|
machine.${if predictable then "fail" else "succeed"}("ip link show eth0")
|
2018-04-29 15:28:33 +02:00
|
|
|
'';
|
|
|
|
};
|
2021-01-28 23:03:02 +01:00
|
|
|
}) testCombinations)
|