aboutsummaryrefslogtreecommitdiff
path: root/nixos/modules/hosts.nix
blob: 19f877e63bbb7aaf3c5fab0cd74da56472fa6cef (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
{ config, lib, pkgs, ... }:

with lib;

let

  cnf = config.cynerd.hosts;

  staticZoneOption = mkOption {
    type = types.attrsOf types.str;
    readOnly = true;
  };

in {

  options = {
    cynerd.hosts = {
      enable = mkOption {
        type = types.bool;
        default = false;
        description = "Use my personal static hosts";
      };
      vpn = staticZoneOption;
      spt = staticZoneOption;
      adm = staticZoneOption;
    };
  };

  config = {
    cynerd.hosts = {
      vpn = {
        "lipwig" = "10.8.0.1";
        # Portable
        "android" = "10.8.0.2";
        "albert" = "10.8.0.3";
        "dean" = "10.8.0.4";
        "susan" = "10.8.0.5";
        "binky" = "10.8.0.6";
        # Endpoints
        "spt-omnia" = "10.8.0.50";
        "adm-omnia" = "10.8.0.51";
      };
      spt = {
        # Network
        "omnia" = "10.8.2.1";
        "mox" = "10.8.2.2";
        "mox2" = "10.8.2.3";
        # Local
        "mpd" = "10.8.2.51";
        "errol" = "10.8.2.60";
        # Portable
        "albert" = "10.8.2.61";
        "susan" = "10.8.2.62";
        "binky" = "10.8.2.63";
      };
      adm = {
        # Network
        "omnia" = "10.8.3.1";
        "omnia2" = "10.8.3.3";
        # Local
        "ridcully" = "10.8.3.60";
        "3dprint" = "10.8.3.80";
        "mpd" = "192.168.0.51";
        # Portable
        "albert" ="10.8.3.61";
        "susan" = "10.8.3.62";
        "binky" = "10.8.3.63";
      };
    };

    networking.hosts = mkIf cnf.enable {
      # VPN
      "${cnf.vpn.lipwig}" = ["lipwig.vpn"];
      "${cnf.vpn.android}" = ["android.vpn"];
      "${cnf.vpn.albert}" = ["albert.vpn"];
      "${cnf.vpn.dean}" = ["dean.vpn"];
      "${cnf.vpn.susan}" = ["susan.vpn"];
      "${cnf.vpn.binky}" = ["binky.vpn"];
      "${cnf.vpn.spt-omnia}" = ["spt.vpn"];
      "${cnf.vpn.adm-omnia}" = ["adm.vpn"];
      # Spt
      "${cnf.spt.omnia}" = ["omnia.spt"];
      "${cnf.spt.mox}" = ["mox.spt"];
      "${cnf.spt.mox2}" = ["mox2.spt"];
      "10.8.2.4" = ["mi3g.spt"];
      "${cnf.spt.mpd}" = ["mpd.spt"];
      "${cnf.spt.errol}" = ["errol" "desktop.spt"];
      "${cnf.spt.albert}" = ["albert.spt"];
      "${cnf.spt.susan}" = ["susan.spt"];
      "${cnf.spt.binky}" = ["binky.spt"];
      # Adm
      "${cnf.adm.omnia}" = ["omnia.adm"];
      "10.8.3.2" = ["redmi.adm"];
      "${cnf.adm.omnia2}" = ["omnia2.adm"];
      "${cnf.adm.ridcully}" = ["ridcully" "desktop.adm"];
      "${cnf.adm.albert}" = ["albert.adm"];
      "${cnf.adm.susan}" = ["susan.adm"];
      "${cnf.adm.binky}" = ["binky.adm"];
      "${cnf.adm."3dprint"}" = ["3dprint"];
      "${cnf.adm.mpd}" = ["mpd.adm"];
    };
  };

}