at 23.11-pre 2.1 kB view raw
1{ system ? builtins.currentSystem, 2 config ? {}, 3 pkgs ? import ../.. { inherit system config; } 4}: 5 6let 7 inherit (import ../lib/testing-python.nix { inherit system pkgs; }) makeTest; 8 testCombinations = pkgs.lib.cartesianProductOfSets { 9 predictable = [true false]; 10 withNetworkd = [true false]; 11 systemdStage1 = [true false]; 12 }; 13in pkgs.lib.listToAttrs (builtins.map ({ predictable, withNetworkd, systemdStage1 }: { 14 name = pkgs.lib.optionalString (!predictable) "un" + "predictable" 15 + pkgs.lib.optionalString withNetworkd "Networkd" 16 + pkgs.lib.optionalString systemdStage1 "SystemdStage1"; 17 value = makeTest { 18 name = pkgs.lib.optionalString (!predictable) "un" + "predictableInterfaceNames" 19 + pkgs.lib.optionalString withNetworkd "-with-networkd" 20 + pkgs.lib.optionalString systemdStage1 "-systemd-stage-1"; 21 meta = {}; 22 23 nodes.machine = { lib, ... }: let 24 script = '' 25 ip link 26 if ${lib.optionalString predictable "!"} ip link show eth0; then 27 echo Success 28 else 29 exit 1 30 fi 31 ''; 32 in { 33 networking.usePredictableInterfaceNames = lib.mkForce predictable; 34 networking.useNetworkd = withNetworkd; 35 networking.dhcpcd.enable = !withNetworkd; 36 networking.useDHCP = !withNetworkd; 37 38 # Check if predictable interface names are working in stage-1 39 boot.initrd.postDeviceCommands = script; 40 41 boot.initrd.systemd = lib.mkIf systemdStage1 { 42 enable = true; 43 initrdBin = [ pkgs.iproute2 ]; 44 services.systemd-udev-settle.wantedBy = ["initrd.target"]; 45 services.check-interfaces = { 46 requiredBy = ["initrd.target"]; 47 after = ["systemd-udev-settle.service"]; 48 serviceConfig.Type = "oneshot"; 49 path = [ pkgs.iproute2 ]; 50 inherit script; 51 }; 52 }; 53 }; 54 55 testScript = '' 56 print(machine.succeed("ip link")) 57 machine.${if predictable then "fail" else "succeed"}("ip link show eth0") 58 ''; 59 }; 60}) testCombinations)