summary refs log tree commit diff
diff options
context:
space:
mode:
authorsymphorien <symphorien@users.noreply.github.com>2018-02-09 18:40:39 +0000
committerFranz Pletz <fpletz@fnordicwalking.de>2018-02-09 18:40:39 +0000
commit01460745602c2c31f2ce6d7a22ff80602894679b (patch)
tree47a09f5c8fa604e93e29720ecbb96ecea734d753
parenta51cda85ff30876b71fee87b1eef4409af6d4277 (diff)
downloadnixpkgs-01460745602c2c31f2ce6d7a22ff80602894679b.tar
nixpkgs-01460745602c2c31f2ce6d7a22ff80602894679b.tar.gz
nixpkgs-01460745602c2c31f2ce6d7a22ff80602894679b.tar.bz2
nixpkgs-01460745602c2c31f2ce6d7a22ff80602894679b.tar.lz
nixpkgs-01460745602c2c31f2ce6d7a22ff80602894679b.tar.xz
nixpkgs-01460745602c2c31f2ce6d7a22ff80602894679b.tar.zst
nixpkgs-01460745602c2c31f2ce6d7a22ff80602894679b.zip
nixos/tests: add predictable-interface-names.nix (#34305)
-rw-r--r--lib/lists.nix8
-rw-r--r--nixos/release-small.nix1
-rw-r--r--nixos/release.nix1
-rw-r--r--nixos/tests/predictable-interface-names.nix27
4 files changed, 35 insertions, 2 deletions
diff --git a/lib/lists.nix b/lib/lists.nix
index 8f67c6bb0ca..f2e6bacdc98 100644
--- a/lib/lists.nix
+++ b/lib/lists.nix
@@ -440,8 +440,12 @@ rec {
   init = list: assert list != []; take (length list - 1) list;
 
 
-  /* FIXME(zimbatm) Not used anywhere
-   */
+  /* return the image of the cross product of some lists by a function
+
+    Example:
+      crossLists (x:y: "${toString x}${toString y}") [[1 2] [3 4]]
+      => [ "13" "14" "23" "24" ]
+  */
   crossLists = f: foldl (fs: args: concatMap (f: map f args) fs) [f];
 
 
diff --git a/nixos/release-small.nix b/nixos/release-small.nix
index 24c448449c1..2b532c70763 100644
--- a/nixos/release-small.nix
+++ b/nixos/release-small.nix
@@ -41,6 +41,7 @@ in rec {
         nfs3
         openssh
         php-pcre
+        predictable-interface-names
         proxy
         simple;
       installer = {
diff --git a/nixos/release.nix b/nixos/release.nix
index 2c605500376..16f00e78faa 100644
--- a/nixos/release.nix
+++ b/nixos/release.nix
@@ -326,6 +326,7 @@ in rec {
   tests.pgmanage = callTest tests/pgmanage.nix {};
   tests.postgis = callTest tests/postgis.nix {};
   #tests.pgjwt = callTest tests/pgjwt.nix {};
+  tests.predictable-interface-names = callSubTests tests/predictable-interface-names.nix {};
   tests.printing = callTest tests/printing.nix {};
   tests.prometheus = callTest tests/prometheus.nix {};
   tests.proxy = callTest tests/proxy.nix {};
diff --git a/nixos/tests/predictable-interface-names.nix b/nixos/tests/predictable-interface-names.nix
new file mode 100644
index 00000000000..b4c2039923c
--- /dev/null
+++ b/nixos/tests/predictable-interface-names.nix
@@ -0,0 +1,27 @@
+{ system ? builtins.currentSystem
+, pkgs ? import ../.. { inherit system; }
+}:
+with import ../lib/testing.nix { inherit system; };
+let boolToString = x: if x then "yes" else "no"; in
+let testWhenSetTo = predictable: withNetworkd:
+makeTest {
+  name = "${if predictable then "" else "un"}predictableInterfaceNames${if withNetworkd then "-with-networkd" else ""}";
+  meta = {};
+
+  machine = { config, pkgs, ... }: {
+    networking.usePredictableInterfaceNames = pkgs.stdenv.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"}");
+  '';
+}; in
+with pkgs.stdenv.lib.lists;
+with pkgs.stdenv.lib.attrsets;
+listToAttrs (map (drv: nameValuePair drv.name drv) (
+crossLists testWhenSetTo [[true false] [true false]]
+))