git.delta.rocks / jrsonnet / refs/commits / 97d9be65842c

difftreelog

source

lib/fleetLib.nix717 Bsourcehistory
1# Shared functions for fleet configuration, available as `fleet` module argument2{ nixpkgs, hostNames }: with nixpkgs.lib; rec {3  hostsToAttrs = f: listToAttrs (4    map (name: { inherit name; value = f name; }) hostNames5  );6  hostsCartesian = remove null (7    unique (8      crossLists9        (10          a: b:11            if a == b then12              null13            else14              hostsPair a b15        ) [ hostNames hostNames ]16    )17  );18  hostsPair = this: other:19    let20      sorted = sort (a: b: a < b) [ this other ];21    in22    {23      a = elemAt sorted 0;24      b = elemAt sorted 1;25    };26  hostPairName = this: other:27    if this < other then "${this}-${other}"28    else "${other}-${this}";29}