Remove zipTwoLists
This function is redundant (we also have zipLists).
This commit is contained in:
parent
67b1a20f12
commit
7c30ce9562
@ -209,20 +209,6 @@ rec {
|
|||||||
init = list: assert list != []; take (length list - 1) list;
|
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;
|
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];
|
crossLists = f: foldl (fs: args: concatMap (f: map f args) fs) [f];
|
||||||
|
@ -41,22 +41,22 @@ rec {
|
|||||||
|
|
||||||
machines = attrNames nodes;
|
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, ... }:
|
[ ( { config, pkgs, nodes, ... }:
|
||||||
let
|
let
|
||||||
interfacesNumbered = zipTwoLists config.virtualisation.vlans (range 1 255);
|
interfacesNumbered = zipLists config.virtualisation.vlans (range 1 255);
|
||||||
interfaces = flip map interfacesNumbered ({ first, second }:
|
interfaces = flip map interfacesNumbered ({ fst, snd }:
|
||||||
nameValuePair "eth${toString second}" { ip4 =
|
nameValuePair "eth${toString snd}" { ip4 =
|
||||||
[ { address = "192.168.${toString first}.${toString m.second}";
|
[ { address = "192.168.${toString fst}.${toString m.snd}";
|
||||||
prefixLength = 24;
|
prefixLength = 24;
|
||||||
} ];
|
} ];
|
||||||
});
|
});
|
||||||
in
|
in
|
||||||
{ key = "ip-address";
|
{ key = "ip-address";
|
||||||
config =
|
config =
|
||||||
{ networking.hostName = m.first;
|
{ networking.hostName = m.fst;
|
||||||
|
|
||||||
networking.interfaces = listToAttrs interfaces;
|
networking.interfaces = listToAttrs interfaces;
|
||||||
|
|
||||||
@ -76,11 +76,11 @@ rec {
|
|||||||
|
|
||||||
virtualisation.qemu.options =
|
virtualisation.qemu.options =
|
||||||
flip map interfacesNumbered
|
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_;
|
in listToAttrs nodes_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user