Compare commits
2 commits
b541b78145
...
b9ef9ac91d
Author | SHA1 | Date | |
---|---|---|---|
b9ef9ac91d | |||
1b68df7229 |
2 changed files with 16 additions and 16 deletions
|
@ -10,8 +10,8 @@ rec {
|
|||
|
||||
inRange = i: range: i >= range.start && i < range.end;
|
||||
|
||||
# Build a selector function that will filters point-by-point any index in xs.
|
||||
# e.g. if you want to select specific indexes you can just use that.
|
||||
# Build a selector function that will filters point-by-point any index in xs.
|
||||
# e.g. if you want to select specific indexes you can just use that.
|
||||
# If you want to select contiguous interval of indexes, you are better served by
|
||||
# `mkIntervalFilter`.
|
||||
mkPointwiseFilter = xs: index: any (allowedIndex: index == allowedIndex) xs;
|
||||
|
@ -21,26 +21,26 @@ rec {
|
|||
# to `inRange`.
|
||||
mkIntervalFilter = intervals: index: any (allowedRange: inRange index allowedRange) intervals;
|
||||
|
||||
# Build an attribute set map from values to indexes.
|
||||
# Build an attribute set map from values to indexes.
|
||||
# e.g. reversedEnumerate [ "a" "b" ] == { "a" = 0; "b" = 1; }.
|
||||
reversedEnumerate = list: listToAttrs
|
||||
(zipListsWith
|
||||
reversedEnumerate = list: listToAttrs
|
||||
(zipListsWith
|
||||
(index: value: nameValuePair value index)
|
||||
(range 0 (length list - 1))
|
||||
list);
|
||||
|
||||
# Collect a list of attribute sets into an attribute set.
|
||||
# Merge order depends on attrValues iteration order and foldl.
|
||||
chainAttrs = attrs: foldl (a: b: a // b) (builtins.attrValues attrs);
|
||||
chainAttrs = attrs: foldl (a: b: a // b) { } (builtins.attrValues attrs);
|
||||
|
||||
# Given an attribute set of an attribute set of items, does it describe a valid partition of some global set?
|
||||
# This does not check for completeness.
|
||||
# idFunction :: Attrs K V → List Identifier
|
||||
isValidPartition = attrs:
|
||||
isValidPartition = attrs:
|
||||
let
|
||||
values = builtins.attrValues attrs;
|
||||
in
|
||||
# TODO(performance?): this is the simple dumb idea.
|
||||
in
|
||||
# TODO(performance?): this is the simple dumb idea.
|
||||
# A better idea would use n(n - 1)/2 iterations over values to exploit symmetry of item equality.
|
||||
# To do so, a strategy could be to consider all shifted toplevel identifiers lists and zip them.
|
||||
# There's sum_k(n - k) such lists, and therefore: n(n - 1)/2 lists.
|
||||
|
@ -48,16 +48,16 @@ rec {
|
|||
# So, if we have N subsets in the partition and each subset has at most K items, we end up doing something like (K log K) * N(N - 1)/2
|
||||
# In practice, K should be the biggest and N is quite small.
|
||||
lib.all (subset:
|
||||
lib.all (anotherSubset:
|
||||
lib.all (anotherSubset:
|
||||
subset != anotherSubset -> lib.intersectAttrs subset anotherSubset == {}
|
||||
) values
|
||||
) values;
|
||||
|
||||
# Renumber an attribute set of items.
|
||||
# Renumber an attribute set of items.
|
||||
# For each item in the attribute set, we replace its value by a call to the renumbering function
|
||||
# where we pass renumberedIndex and value.
|
||||
# It's a form of imap for attribute sets.
|
||||
renumber = indexFn: renumberingFn: attrs:
|
||||
# where we pass renumberedIndex and value.
|
||||
# It's a form of imap for attribute sets.
|
||||
renumber = indexFn: renumberingFn: attrs:
|
||||
let
|
||||
indexes = reversedEnumerate (map (n: toString (indexFn n)) (builtins.attrValues attrs));
|
||||
in
|
||||
|
|
|
@ -131,8 +131,8 @@ in
|
|||
# TODO: do not hardcode, just reuse the Colmena hive module outputs to generate all the required details.
|
||||
]
|
||||
++ (map (index: record "bm-${toString index}.wob01.infra" 300 "AAAA" "2a01:584:11::1:${toString index}") (genList lib.id 11))
|
||||
++ (map (node: record "builder-${toString node.config.bagel.baremetal.builders.num}.wob01.infra" 300 "CNAME" "bm-${toString node.config.bagel.baremetal.num}") builderNodes)
|
||||
++ (map (node: record "storage-${toString node.config.bagel.baremetal.storage.num}.wob01.infra" 300 "CNAME" "bm-${toString node.config.bagel.baremetal.num}") storageNodes)
|
||||
++ (map (node: record "builder-${toString node.config.bagel.baremetal.builders.num}.wob01.infra" 300 "CNAME" "bm-${toString node.config.bagel.baremetal.num}.wob01.infra.forkos.org") builderNodes)
|
||||
++ (map (node: record "storage-${toString node.config.bagel.baremetal.storage.num}.wob01.infra" 300 "CNAME" "bm-${toString node.config.bagel.baremetal.num}.wob01.infra.forkos.org") storageNodes)
|
||||
++ (
|
||||
let
|
||||
# FIXME: figure out a way to poke `config.services.s3-revproxy` and
|
||||
|
|
Loading…
Reference in a new issue