git.delta.rocks / jrsonnet / refs/commits / 62fbb3d07cd6

difftreelog

source

lib/fleetLib.nix704 Bsourcehistory
1# Shared functions for fleet configuration, available as `fleet` module argument2{ nixpkgs, hosts }: with nixpkgs.lib; rec {3  # Modules can't register hosts because of infinite recursion4  hostNames = attrNames hosts;5  hostsToAttrs = f: listToAttrs (6    map (name: { inherit name; value = f name; }) hostNames7  );8  hostsCartesian = remove null (9    unique (10      crossLists11        (12          a: b:13            if a == b then14              null15            else16              hostsPair a b17        ) [ hostNames hostNames ]18    )19  );20  hostsPair = this: other:21    let22      sorted = sort (a: b: a < b) [ this other ];23    in24    {25      a = elemAt sorted 0;26      b = elemAt sorted 1;27    };28}