summaryrefslogtreecommitdiffstats
path: root/common/tinc.nix
blob: 1016f42747904709e753514d1f6f85014654773e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{ config, lib, ... }:

with lib;
with builtins;
let
  networks = attrNames (readDir ./tinc/private);
in {
  imports = map (network: (./tinc/private + "/${network}")) networks;

  services.tinc.networks = genAttrs networks (network: {
    name = config.networking.hostName;

    hosts = let
      hosts = attrNames (readDir (./tinc/private + "/${network}/hosts"));
      config = hostname: readFile (./tinc/private + "/${network}/hosts/${hostname}");
    in genAttrs hosts config;
  });
}