From 7c30ce95627d63efeca85c4c65aaaee1856b7887 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 28 Jul 2015 14:56:27 +0200 Subject: [PATCH] Remove zipTwoLists This function is redundant (we also have zipLists). --- lib/lists.nix | 14 -------------- nixos/lib/build-vms.nix | 18 +++++++++--------- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/lib/lists.nix b/lib/lists.nix index fde6f5d42fcb..7fc1924066ba 100644 --- a/lib/lists.nix +++ b/lib/lists.nix @@ -209,20 +209,6 @@ rec { init = list: assert list != []; take (length list - 1) list; - # Zip two lists together. - zipTwoLists = xs: ys: - let - len1 = length xs; - len2 = length ys; - len = if len1 < len2 then len1 else len2; - zipTwoLists' = n: - if n != len then - [ { first = elemAt xs n; second = elemAt ys n; } ] - ++ zipTwoLists' (n + 1) - else []; - in zipTwoLists' 0; - - deepSeqList = xs: y: if any (x: deepSeq x false) xs then y else y; crossLists = f: foldl (fs: args: concatMap (f: map f args) fs) [f]; diff --git a/nixos/lib/build-vms.nix b/nixos/lib/build-vms.nix index d0c9e7c6d236..01d6b21bba90 100644 --- a/nixos/lib/build-vms.nix +++ b/nixos/lib/build-vms.nix @@ -41,22 +41,22 @@ rec { machines = attrNames nodes; - machinesNumbered = zipTwoLists machines (range 1 254); + machinesNumbered = zipLists machines (range 1 254); - nodes_ = flip map machinesNumbered (m: nameValuePair m.first + nodes_ = flip map machinesNumbered (m: nameValuePair m.fst [ ( { config, pkgs, nodes, ... }: let - interfacesNumbered = zipTwoLists config.virtualisation.vlans (range 1 255); - interfaces = flip map interfacesNumbered ({ first, second }: - nameValuePair "eth${toString second}" { ip4 = - [ { address = "192.168.${toString first}.${toString m.second}"; + interfacesNumbered = zipLists config.virtualisation.vlans (range 1 255); + interfaces = flip map interfacesNumbered ({ fst, snd }: + nameValuePair "eth${toString snd}" { ip4 = + [ { address = "192.168.${toString fst}.${toString m.snd}"; prefixLength = 24; } ]; }); in { key = "ip-address"; config = - { networking.hostName = m.first; + { networking.hostName = m.fst; networking.interfaces = listToAttrs interfaces; @@ -76,11 +76,11 @@ rec { virtualisation.qemu.options = flip map interfacesNumbered - ({ first, second }: qemuNICFlags second first m.second); + ({ fst, snd }: qemuNICFlags snd fst m.snd); }; } ) - (getAttr m.first nodes) + (getAttr m.fst nodes) ] ); in listToAttrs nodes_;