2021-10-28 20:10:47 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
2021-10-28 20:07:49 +00:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
hosts = import ./hosts;
|
|
|
|
|
|
|
|
cfg = config.services.my-tinc;
|
|
|
|
|
|
|
|
mapAttrs = f: attrs: builtins.listToAttrs (
|
|
|
|
map (name: { inherit name; value = f name (builtins.getAttr name attrs); }) (builtins.attrNames attrs)
|
|
|
|
);
|
|
|
|
in
|
|
|
|
{
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
# All hosts we know of
|
|
|
|
services.tinc.networks.my-tinc.hostSettings = mapAttrs (name: host: {
|
2021-10-28 21:05:35 +00:00
|
|
|
addresses = if (host ? address) then [ { address = host.address; } ] else [];
|
2021-10-28 20:07:49 +00:00
|
|
|
subnets = [ { address = host.subnetAddr; } ];
|
2021-10-28 20:47:07 +00:00
|
|
|
rsaPublicKey = mkIf (host ? "rsaPublicKey") host.rsaPublicKey;
|
|
|
|
settings.Ed25519PublicKey = mkIf (host ? "ed25519PublicKey") host.ed25519PublicKey;
|
2021-10-28 20:07:49 +00:00
|
|
|
}) hosts;
|
|
|
|
};
|
|
|
|
}
|