summaryrefslogtreecommitdiffstats
path: root/3modules/tv/identity.nix
blob: e0cd46c06dc12bdd21675577944c64b1e87980e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
{ config, lib, ... }:

with lib;
let
  cfg = config.tv.identity;

  out = {
    options.tv.identity = api;
    config = mkIf cfg.enable imp;
  };

  api = {
    enable = mkEnableOption "tv.identity";

    self = mkOption {
      type = types.unspecified;
    };
    hosts = mkOption {
      type = with types; attrsOf unspecified;
      default = {
        cd = {
          #dc = "cac";
          dc = "tv";
          fqdn = "cd.retiolum";
          subdomains = [
          ];
          addr = "10.243.113.222";
          #addr6 = "42:4522:25f8:36bb:8ccb:0150:231a:2af3";
          #internet-addr = "162.219.5.183";
          cores = 2;
        };
        mkdir = {
          #dc = "cac";
          dc = "tv";
          fqdn = "mkdir.retiolum";
          subdomains = [
          ];
          addr = "10.243.113.223";
          cores = 1;
        };
        nomic = {
          #dc = "gg";
          dc = "tv";
          fqdn = "nomic.retiolum";
          subdomains = [
          ];
          addr = "10.243.0.110";
          cores = 2;
        };
        rmdir = {
          #dc = "cac";
          dc = "tv";
          fqdn = "rmdir.retiolum";
          subdomains = [
          ];
          addr = "10.243.113.224";
          #addr = "42:4522:25f8:36bb:8ccb:0150:231a:2af5";
          cores = 1;
        };
        wu = {
          #dc = "gg";
          dc = "tv";
          fqdn = "wu.retiolum";
          subdomains = [
          ];
          addr = "10.243.13.37";
          cores = 8;
        };
      };
    };
  };

  imp = {
    networking.extraHosts =
      let
        f = name: { addr, fqdn, subdomains, ... }: ''
          ${addr} ${toString (map (s: "${s}.${name} ${s}.${fqdn}") subdomains)}
        '';
      in
      concatStringsSep "\n" (mapAttrsToList f cfg.hosts);
  };

in
out