-
Notifications
You must be signed in to change notification settings - Fork 9
/
hive.nix
51 lines (43 loc) · 1.5 KB
/
hive.nix
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
let
pkgs = import (import ./nixpkgs.nix) { };
lib = pkgs.lib;
inherit (pkgs.callPackage ./resources.nix { }) resources resourcesByRole;
inherit (import ./utils.nix) nodeIP;
etcdHosts = map (r: r.values.name) (resourcesByRole "etcd");
controlPlaneHosts = map (r: r.values.name) (resourcesByRole "controlplane");
workerHosts = map (r: r.values.name) (resourcesByRole "worker");
loadBalancerHosts = map (r: r.values.name) (resourcesByRole "loadbalancer");
etcdConf = { ... }: {
imports = [ ./modules/etcd.nix ];
deployment.tags = [ "etcd" ];
};
controlPlaneConf = { ... }: {
imports = [ ./modules/controlplane ];
deployment.tags = [ "controlplane" ];
};
workerConf = { ... }: {
imports = [ ./modules/worker ];
deployment.tags = [ "worker" ];
};
loadBalancerConf = { ... }: {
imports = [ ./modules/loadbalancer ];
deployment.tags = [ "loadbalancer" ];
};
in
{
meta = {
nixpkgs = import (import ./nixpkgs.nix);
};
defaults = { name, self, ... }: {
imports = [
./modules/autoresources.nix
./modules/base.nix
];
deployment.targetHost = nodeIP self;
networking.hostName = name;
};
}
// builtins.listToAttrs (map (h: { name = h; value = etcdConf; }) etcdHosts)
// builtins.listToAttrs (map (h: { name = h; value = controlPlaneConf; }) controlPlaneHosts)
// builtins.listToAttrs (map (h: { name = h; value = loadBalancerConf; }) loadBalancerHosts)
// builtins.listToAttrs (map (h: { name = h; value = workerConf; }) workerHosts)