summary refs log tree commit diff
path: root/nixos/tests/predictable-interface-names.nix
blob: 0d73436c1c3f5544816b4e3a8a502c789f2d4acb (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
{ system ? builtins.currentSystem }:

let
  inherit (import ../lib/testing.nix { inherit system; }) makeTest pkgs;
in pkgs.lib.listToAttrs (pkgs.lib.crossLists (predictable: withNetworkd: {
  name = pkgs.lib.optionalString (!predictable) "un" + "predictable"
       + pkgs.lib.optionalString withNetworkd "Networkd";
  value = makeTest {
    name = "${if predictable then "" else "un"}predictableInterfaceNames${if withNetworkd then "-with-networkd" else ""}";
    meta = {};

    machine = { lib, ... }: {
      networking.usePredictableInterfaceNames = lib.mkForce predictable;
      networking.useNetworkd = withNetworkd;
      networking.dhcpcd.enable = !withNetworkd;
    };

    testScript = ''
      print $machine->succeed("ip link");
      $machine->succeed("ip link show ${if predictable then "ens3" else "eth0"}");
      $machine->fail("ip link show ${if predictable then "eth0" else "ens3"}");
    '';
  };
}) [[true false] [true false]])