-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathexample-server.nix
118 lines (105 loc) · 2.7 KB
/
example-server.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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
{ instance }:
{ config, lib, pkgs, ... }:
{
microvm = {
vcpu = 2;
mem = 4096;
shares = [ {
tag = "ro-store";
source = "/nix/store";
mountPoint = "/nix/.ro-store";
} ];
volumes = [ {
image = "example${toString instance}-persist.img";
mountPoint = "/";
size = 20 * 1024;
} {
image = "example${toString instance}-ceph.img";
mountPoint = null;
size = 20 * 1024;
} ];
writableStoreOverlay = "/nix/.rw-store";
interfaces = [ {
id = "eth0";
type = "bridge";
mac = "02:00:00:00:00:0${toString instance}";
bridge = "virbr0";
} ];
};
networking.hostName = "example${toString instance}";
users.users.root.password = "";
# TODO:
networking.firewall.enable = false;
networking.useDHCP = false;
networking.useNetworkd = true;
systemd.network = {
netdevs = {
# a bridge to connect microvms
"br0" = {
netdevConfig = {
Kind = "bridge";
Name = "br0";
};
};
};
networks = {
# uplink
"00-eth" = {
matchConfig.MACAddress = (builtins.head config.microvm.interfaces).mac;
networkConfig.Bridge = "br0";
};
# bridge is a dumb switch without addresses on the host
"01-br0" = {
matchConfig.Name = "br0";
networkConfig = {
DHCP = "ipv4";
IPv6AcceptRA = true;
};
addresses = [ {
addressConfig.Address = "fec0::${toString instance}/64";
} ];
};
};
};
skyflake = {
nodes = builtins.listToAttrs (
map (instance: {
name = "example${toString instance}";
value.address = "fec0::${toString instance}";
}) [ 1 2 3 ]
);
storage.ceph = rec {
fsid = "8364da79-5e03-49ae-82ea-7d936278cb0f";
monKeyring = example/ceph.mon.keyring;
adminKeyring = example/ceph.client.admin.keyring;
osds = [ {
id = instance;
fsid = "8e4ae689-5c15-4381-bd75-19de743378e${toString instance}";
path = "/dev/vdb";
deviceClass = "ssd";
keyfile = toString (./example + "/osd.${toString instance}.keyring");
} ];
rbdPools.microvms = {
params = { size = 2; class = "ssd"; };
};
cephfs.skyflake.metaParams = { size = 2; class = "ssd"; };
};
nomad = {
servers = [ "example1" "example2" "example3" ];
client.meta = {
example-deployment = "yes";
};
};
users = {
test = {
uid = 1000;
sshKeys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGJJTSJdpDh82486uPiMhhyhnci4tScp5uUe7156MBC8 astro"
];
};
};
};
environment.systemPackages = with pkgs; [
tcpdump
];
}