summaryrefslogtreecommitdiff
path: root/lib/machine.nix
blob: 10e766fe2445bee3faa80a7ee099194a13df4df9 (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
lib: systemOptions: with lib; let
  modules = [
    {
      options.machines = mkOption {
          description = "Machine options";
          default = {};
          type = with types; attrsOf (submodule ({ name, config, ... }: {
            freeformType = attrs;
            options = {
                modules = mkOption {
                    description = "Final list of modules to import";
                    type = listOf str;
                    default = [];
                };
                profiles = mkOption {
                    description = "List of profiles to use";
                    type = listOf str;
                    default = [];
                };
                hostname = mkOption {
                    description = "The machine's hostname";
                    type = str;
                    readOnly = true;
                    default = name;
                };
                ipv4 = mkOption {
                    description = "The machines public IPv4 addresses";
                    type = listOf str;
                    default = [];
                };
                ipv6 = mkOption {
                    description = "The machines public IPv6 addresses";
                    type = listOf str;
                    default = [];
                };
                isStation = mkOption {
                    description = "The machine is a desktop station";
                    type = bool;
                    default = false;
                };
                isServer = mkOption {
                    description = "The machine is a server";
                    type = bool;
                    default = false;
                };
                isFake = mkOption {
                    description = "The machine is a fake machine";
                    type = bool;
                    default = false;
                };
                isDarwin = mkOption {
                    description = "The machine is a fake machine";
                    type = bool;
                    default = false;
                };
                tailnet = mkOption {
                  default = {};
                  type = with types; attrsOf (submodule ({ name, config, ... }: {
                    options = {
                      ipv4 = mkOption {
                          description = "The machine's tailnet IPv4 address";
                          type = str;
                          default = null;
                      };
                      ipv6 = mkOption {
                          description = "The machine's tailnet IPv6 address";
                          type = str;
                          default = null;
                      };
                      nodeKey = mkOption {
                          description = "The machine's tailnet public key";
                          type = str;
                          default = null;
                      };
                    };
                  }));
                };
                syncthing = mkOption {
                  default = {};
                  type = with types; submodule {
                    freeformType = attrs;
                    options = {
                      id = mkOption {
                          description = "The machine's syncting public id";
                          type = str;
                          default = "";
                      };
                      enable = mkEnableOption "Add to syncthing cluster";
                    };
                  };
                };
            };
          }));
      };
      config.machines = systemOptions;
    }
  ];
in (evalModules { inherit modules; }).config.machines